Base: codex-main originale (prima del fork aKode)

This commit is contained in:
Andrea
2026-11-09 10:37:42 +01:00
commit 7874033c81
10166 changed files with 2728937 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
load("//:defs.bzl", "codex_rust_crate")
codex_rust_crate(
name = "rustls-provider",
crate_name = "codex_utils_rustls_provider",
)

View File

@@ -0,0 +1,15 @@
[package]
name = "codex-utils-rustls-provider"
version.workspace = true
edition.workspace = true
license.workspace = true
[lints]
workspace = true
[dependencies]
rustls = { workspace = true }
[lib]
test = false
doctest = false

View File

@@ -0,0 +1,39 @@
use std::sync::Once;
const REQUIRED_SIGNATURE_SCHEME: rustls::SignatureScheme =
rustls::SignatureScheme::ECDSA_NISTP521_SHA512;
/// Ensures a process-wide rustls crypto provider is installed.
///
/// rustls cannot auto-select a provider when both `ring` and `aws-lc-rs`
/// features are enabled in the dependency graph.
pub fn ensure_rustls_crypto_provider() {
static RUSTLS_PROVIDER_INIT: Once = Once::new();
RUSTLS_PROVIDER_INIT.call_once(|| {
// aws-lc-rs supports a broader WebPKI signature set than ring, including
// ECDSA P-521/SHA-512 certs used by some enterprise TLS proxies.
if rustls::crypto::aws_lc_rs::default_provider()
.install_default()
.is_err()
{
// Preserve the previous best-effort behavior for embedded hosts that
// install a process-global provider before Codex can install one.
return;
}
let Some(provider) = rustls::crypto::CryptoProvider::get_default() else {
panic!("aws-lc-rs rustls crypto provider should be installed");
};
assert!(
provider_supports_required_signature_scheme(provider),
"installed rustls crypto provider must support {REQUIRED_SIGNATURE_SCHEME:?}"
);
});
}
fn provider_supports_required_signature_scheme(provider: &rustls::crypto::CryptoProvider) -> bool {
provider
.signature_verification_algorithms
.supported_schemes()
.contains(&REQUIRED_SIGNATURE_SCHEME)
}

View File

@@ -0,0 +1,26 @@
use codex_utils_rustls_provider::ensure_rustls_crypto_provider;
const EMPTY_ALGORITHMS: rustls::crypto::WebPkiSupportedAlgorithms =
rustls::crypto::WebPkiSupportedAlgorithms {
all: &[],
mapping: &[],
};
#[test]
fn ensure_provider_preserves_preinstalled_provider() {
let mut provider = rustls::crypto::aws_lc_rs::default_provider();
provider.signature_verification_algorithms = EMPTY_ALGORITHMS;
assert!(provider.install_default().is_ok());
ensure_rustls_crypto_provider();
let Some(provider) = rustls::crypto::CryptoProvider::get_default() else {
panic!("preinstalled rustls provider should still be installed");
};
assert!(
!provider
.signature_verification_algorithms
.supported_schemes()
.contains(&rustls::SignatureScheme::ECDSA_NISTP521_SHA512)
);
}

View File

@@ -0,0 +1,16 @@
use codex_utils_rustls_provider::ensure_rustls_crypto_provider;
#[test]
fn ensure_provider_installs_ecdsa_p521_sha512_support() {
ensure_rustls_crypto_provider();
let Some(provider) = rustls::crypto::CryptoProvider::get_default() else {
panic!("rustls provider should be installed");
};
assert!(
provider
.signature_verification_algorithms
.supported_schemes()
.contains(&rustls::SignatureScheme::ECDSA_NISTP521_SHA512)
);
}