Rimossi i provider integrati OpenAI, Bedrock e GCP e ogni fallback a OpenAI (B)
Parte "sicurezza" della fase 3 di aKode (e39aae00), senza le funzioni di imeAI:
- via i provider integrati openai, amazon-bedrock, amazon-bedrock-runtime e gcp
(crate model-provider: moduli amazon_bedrock, gcp, chatgpt_base_url; login Bedrock;
onboarding Bedrock/GCP; richieste app-server di setup cloud);
- nessun URL predefinito verso api.openai.com / chatgpt.com: un provider senza
base_url non viene mai contattato; senza model_provider configurato exec e TUI
mostrano come scriverne uno in config.toml (NO_MODEL_PROVIDER_CONFIGURED_ERROR);
- via la skill openai-docs, la sample skill-installer (scaricava da github.com/openai/skills),
request_plugin_install, AppsInstructions, URL predefiniti di realtime e updater;
- test di sicurezza adattati (provider "mock" al posto di quello integrato), non cancellati.
Restano fuori da questo commit (categoria F/D/E, non portate): chiave per provider nel
portachiavi, modelli da /models, unione dei messaggi di sistema, crate web-tools e
SearXNG, header @@ in apply_patch, modello ausiliario, tool function per apply_patch.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -193,7 +193,11 @@ fn packaged_daemon_launch(action: &str, initial: InitialDaemon) -> Result<()> {
|
||||
assert_eq!(standalone.join("current").canonicalize()?, cli_selection);
|
||||
}
|
||||
if action == "bootstrap" {
|
||||
assert_eq!(output["autoUpdateEnabled"], false);
|
||||
// Only stable release versions follow automatic updates; local builds versioned
|
||||
// 0.0.0 do not. aKode builds carry a release version (0.1.0).
|
||||
let stable_build =
|
||||
env!("CARGO_PKG_VERSION") != "0.0.0" && !env!("CARGO_PKG_VERSION").contains(['-', '+']);
|
||||
assert_eq!(output["autoUpdateEnabled"], stable_build);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -78,11 +78,6 @@ async fn daemon_exclusion_survives_fork_picker() -> Result<()> {
|
||||
daemon_startup("fork").await
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn daemon_auto_start_preserves_bedrock_onboarding() -> Result<()> {
|
||||
daemon_startup("bedrock").await
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[cfg(windows)]
|
||||
async fn elevated_local_tui_uses_embedded_without_starting_daemon() -> Result<()> {
|
||||
@@ -146,12 +141,6 @@ async fn restrictive_launcher_uses_embedded_if_daemon_cannot_start() -> Result<(
|
||||
daemon_startup("restrictive-job").await
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[cfg(unix)]
|
||||
async fn bedrock_onboarding_discovers_credentials_on_the_running_daemon() -> Result<()> {
|
||||
daemon_startup("bedrock-running").await
|
||||
}
|
||||
|
||||
async fn daemon_startup(command: &str) -> Result<()> {
|
||||
#[cfg(windows)]
|
||||
let elevated = codex_app_server_daemon::is_elevated()?;
|
||||
@@ -177,17 +166,24 @@ async fn daemon_startup(command: &str) -> Result<()> {
|
||||
"failed to prepare CLI test executable"
|
||||
);
|
||||
let bedrock_onboarding = matches!(command, "bedrock" | "bedrock-running");
|
||||
// aKode has no built-in catalog for providers without a catalog URL; keep the bundled one.
|
||||
let catalog = home.path().join("test-models.json");
|
||||
fs::write(&catalog, include_str!("../../models-manager/models.json"))?;
|
||||
fs::write(
|
||||
home.path().join("config.toml"),
|
||||
format!(
|
||||
"model = \"gpt-5.6-terra\"\n\
|
||||
model_provider = \"mock\"\n\
|
||||
model_catalog_json = {}\n\
|
||||
cli_auth_credentials_store = \"file\"\n\
|
||||
suppress_unstable_features_warning = true\n\
|
||||
windows.sandbox = \"unelevated\"\n\
|
||||
tui.disable_paste_burst = true\n\
|
||||
{}\n\
|
||||
notice.model_migrations.\"gpt-5.6-terra\" = \"gpt-6-sol\"\n\
|
||||
[model_providers.mock]\nname = \"mock\"\nbase_url = \"http://127.0.0.1:9/v1\"\nrequires_openai_auth = true\n\
|
||||
[projects.{}]\ntrust_level = \"{}\"\n",
|
||||
serde_json::to_string(&catalog.display().to_string())?,
|
||||
if command == "discovered" {
|
||||
"tui.status_line=[\"model\",\"thread-id\",\"thread-name\"]\nfeatures.daemon_auto_start=false"
|
||||
} else if bedrock_onboarding {
|
||||
@@ -380,7 +376,7 @@ async fn daemon_startup(command: &str) -> Result<()> {
|
||||
"session_id": thread_id, "id": thread_id,
|
||||
"timestamp": "2025-01-05T12:00:00Z", "cwd": workspace_path,
|
||||
"originator": "codex", "cli_version": "0.0.0",
|
||||
"source": "cli", "model_provider": "openai"
|
||||
"source": "cli", "model_provider": "mock"
|
||||
}
|
||||
});
|
||||
let message = serde_json::json!({
|
||||
|
||||
@@ -25,7 +25,7 @@ fn debug_models_bundled_prints_json() -> Result<()> {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn debug_models_default_prints_json_without_auth() -> Result<()> {
|
||||
fn debug_models_default_prints_empty_json_without_provider() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
let mut cmd = codex_command(codex_home.path())?;
|
||||
let output = cmd.args(["debug", "models"]).output()?;
|
||||
@@ -34,7 +34,8 @@ fn debug_models_default_prints_json_without_auth() -> Result<()> {
|
||||
let stdout = String::from_utf8(output.stdout)?;
|
||||
let value: serde_json::Value = serde_json::from_str(&stdout)?;
|
||||
assert!(value["models"].is_array());
|
||||
assert!(!value["models"].as_array().unwrap_or(&Vec::new()).is_empty());
|
||||
// aKode has no default provider and no built-in catalog: nothing to list, no network.
|
||||
assert!(value["models"].as_array().unwrap_or(&Vec::new()).is_empty());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -121,7 +121,9 @@ async fn network_only_reports_recoverable_config_warnings_and_effective_config()
|
||||
let config = std::fs::read_to_string(&config_path)?;
|
||||
std::fs::write(
|
||||
config_path,
|
||||
format!("{config}\n[otel.span_attributes]\n\"\" = \"missing-key\"\n"),
|
||||
// OTEL exporters were removed (otel settings are ignored without warnings); use another
|
||||
// recoverable, warning-only setting.
|
||||
format!("{config}\n[features.guardianv2]\nasync_classifier_mode = \"conversation\"\n"),
|
||||
)?;
|
||||
let output = local_command(&home)?
|
||||
.args(["doctor", "--network-only", "--json"])
|
||||
@@ -137,8 +139,8 @@ async fn network_only_reports_recoverable_config_warnings_and_effective_config()
|
||||
let startup_warning = std::iter::once(warnings)
|
||||
.chain(warnings.as_array().into_iter().flatten())
|
||||
.filter_map(Value::as_str)
|
||||
.find(|warning| warning.starts_with("Ignoring invalid `otel.span_attributes` config"))
|
||||
.context("missing recoverable OTEL config warning")?;
|
||||
.find(|warning| warning.starts_with("`[features.guardianv2].async_classifier_mode`"))
|
||||
.context("missing recoverable config warning")?;
|
||||
let check_statuses = report["checks"]
|
||||
.as_object()
|
||||
.unwrap()
|
||||
@@ -170,7 +172,7 @@ async fn network_only_reports_recoverable_config_warnings_and_effective_config()
|
||||
"scope": "invocation config, including managed policy",
|
||||
"provider": "local",
|
||||
"startupWarnings": baseline_warning_count + 1,
|
||||
"startupWarning": "Ignoring invalid `otel.span_attributes` config: configured span attribute key must not be empty",
|
||||
"startupWarning": "`[features.guardianv2].async_classifier_mode` is deprecated and ignored. Async classification always uses conversations; remove this setting from config.toml or profile configuration files.",
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
@@ -371,8 +371,10 @@ fn doctor_reports_only_safe_config_error_metadata() -> Result<()> {
|
||||
"model_provider = \"doctor-test-credential\"",
|
||||
),
|
||||
),
|
||||
// A type error in a known key reports its location (file/line/column) but never
|
||||
// the offending value.
|
||||
(
|
||||
"doctor_config_invalid_data",
|
||||
"doctor_config_invalid_type",
|
||||
user_config_file.clone(),
|
||||
original.replace(
|
||||
"wire_api = \"responses\"",
|
||||
|
||||
@@ -47,7 +47,7 @@ fn mcp_list_reports_invalid_keybinding_reason() -> Result<()> {
|
||||
.get_output()
|
||||
.stderr
|
||||
.clone();
|
||||
let output = String::from_utf8(output)?;
|
||||
let output = normalize_config_location(&String::from_utf8(output)?);
|
||||
insta::allow_duplicates! {
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
@@ -304,3 +304,23 @@ fn no_daemon_rejects_queue_and_explicit_remote_targets() -> Result<()> {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Replaces `<temp home>/config.toml:<line>:<column>` with a stable placeholder.
|
||||
fn normalize_config_location(output: &str) -> String {
|
||||
output
|
||||
.lines()
|
||||
.map(|line| match line.find("/config.toml:") {
|
||||
Some(index) => {
|
||||
let start = line[..index].rfind(' ').map_or(0, |space| space + 1);
|
||||
let rest = &line[index + "/config.toml:".len()..];
|
||||
let after_location = rest.splitn(3, ':').nth(2).unwrap_or_default();
|
||||
format!(
|
||||
"{}[CODEX_HOME]/config.toml:<line>:<column>:{after_location}",
|
||||
&line[..start]
|
||||
)
|
||||
}
|
||||
None => line.to_string(),
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n")
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
use std::path::Path;
|
||||
|
||||
use anyhow::Result;
|
||||
use codex_config::types::AuthCredentialsStoreMode;
|
||||
use codex_login::AuthKeyringBackendKind;
|
||||
use codex_login::login_with_bedrock_access_keys;
|
||||
use predicates::str::contains;
|
||||
use pretty_assertions::assert_eq;
|
||||
use serde_json::Value;
|
||||
@@ -169,79 +166,68 @@ fn legacy_chatgpt_auth_is_reported_as_not_logged_in_and_logout_removes_it() -> R
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn logout_clears_only_the_selected_bedrock_provider() -> Result<()> {
|
||||
for (model_provider_id, managed_bedrock_auth, model) in [
|
||||
("amazon-bedrock", true, "openai.gpt-5.6-sol"),
|
||||
("amazon-bedrock-runtime", true, "global.openai.gpt-5.6-sol"),
|
||||
("openai", true, "gpt-5.6-sol"),
|
||||
("amazon-bedrock", false, "gpt-5.6-sol"),
|
||||
("amazon-bedrock-runtime", false, "us.openai.gpt-5.6-sol"),
|
||||
("openai", false, "gpt-5.6-sol"),
|
||||
] {
|
||||
let codex_home = TempDir::new()?;
|
||||
let config_path = codex_home.path().join("config.toml");
|
||||
std::fs::write(
|
||||
&config_path,
|
||||
format!(
|
||||
"cli_auth_credentials_store = \"file\"\n\
|
||||
model_provider = \"{model_provider_id}\"\n\
|
||||
model = \"{model}\"\n\
|
||||
model_reasoning_effort = \"high\"\n\
|
||||
[model_providers.amazon-bedrock]\n\
|
||||
base_url = \"https://mantle.example.com/v1\"\n\
|
||||
[model_providers.amazon-bedrock.aws]\n\
|
||||
profile = \"mantle-profile\"\n\
|
||||
region = \"us-west-2\"\n\
|
||||
auth_refresh = {{ command = \"aws\", args = [\"sso\", \"login\"] }}\n\
|
||||
[model_providers.amazon-bedrock-runtime]\n\
|
||||
base_url = \"https://runtime.example.com/v1\"\n\
|
||||
[model_providers.amazon-bedrock-runtime.aws]\n\
|
||||
profile = \"runtime-profile\"\n\
|
||||
region = \"us-east-1\"\n\
|
||||
auth_refresh = {{ command = \"aws\", args = [\"login\"] }}\n"
|
||||
),
|
||||
)?;
|
||||
if managed_bedrock_auth {
|
||||
login_with_bedrock_access_keys(
|
||||
codex_home.path(),
|
||||
"managed-access-key-id",
|
||||
"managed-secret-access-key",
|
||||
Some("managed-session-token"),
|
||||
AuthCredentialsStoreMode::File,
|
||||
AuthKeyringBackendKind::default(),
|
||||
)?;
|
||||
}
|
||||
let mut expected_config: toml::Value =
|
||||
toml::from_str(&std::fs::read_to_string(&config_path)?)?;
|
||||
if model_provider_id != "openai" {
|
||||
let expected_root = expected_config
|
||||
.as_table_mut()
|
||||
.expect("config should be a table");
|
||||
expected_root.remove("model_provider");
|
||||
expected_root.remove("model");
|
||||
expected_root["model_providers"][model_provider_id]
|
||||
.as_table_mut()
|
||||
.expect("selected Bedrock provider should be a table")
|
||||
.remove("aws");
|
||||
}
|
||||
let expected_message = if managed_bedrock_auth || model_provider_id != "openai" {
|
||||
"Successfully logged out"
|
||||
} else {
|
||||
"Not logged in"
|
||||
};
|
||||
fn provider_api_key_login_uses_private_file_store_and_never_prints_the_key() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
std::fs::write(
|
||||
codex_home.path().join("config.toml"),
|
||||
"provider_api_key_store = \"file\"\n\
|
||||
model_provider = \"imeai\"\n\
|
||||
[model_providers.imeai]\n\
|
||||
name = \"imeAI\"\n\
|
||||
base_url = \"http://127.0.0.1:9/v1\"\n\
|
||||
api_key = \"keyring\"\n",
|
||||
)?;
|
||||
let secret = "sk-provider-secret-0123456789";
|
||||
|
||||
codex_command(codex_home.path())?
|
||||
.env("AWS_ACCESS_KEY_ID", "environment-access-key-id")
|
||||
.env("AWS_SECRET_ACCESS_KEY", "environment-secret-access-key")
|
||||
.args(["logout"])
|
||||
.assert()
|
||||
.success()
|
||||
.stderr(contains(expected_message));
|
||||
let login = codex_command(codex_home.path())?
|
||||
.args(["login", "--provider", "imeai", "--with-api-key"])
|
||||
.write_stdin(format!("{secret}\n"))
|
||||
.assert()
|
||||
.success();
|
||||
let stderr = String::from_utf8_lossy(&login.get_output().stderr).to_string();
|
||||
assert!(
|
||||
stderr.contains("API key for `imeai` saved in file"),
|
||||
"{stderr}"
|
||||
);
|
||||
assert!(!stderr.contains(secret), "{stderr}");
|
||||
|
||||
assert!(!codex_home.path().join("auth.json").exists());
|
||||
let actual_config: toml::Value = toml::from_str(&std::fs::read_to_string(&config_path)?)?;
|
||||
assert_eq!(actual_config, expected_config);
|
||||
let path = codex_home.path().join("provider_api_keys.json");
|
||||
let stored: Value = serde_json::from_str(&std::fs::read_to_string(&path)?)?;
|
||||
assert_eq!(stored, json!({ "imeai": secret }));
|
||||
#[cfg(unix)]
|
||||
{
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
assert_eq!(
|
||||
std::fs::metadata(&path)?.permissions().mode() & 0o777,
|
||||
0o600
|
||||
);
|
||||
}
|
||||
// The shared stored key is untouched.
|
||||
assert!(!codex_home.path().join("auth.json").exists());
|
||||
|
||||
let status = codex_command(codex_home.path())?
|
||||
.args(["login", "status"])
|
||||
.assert()
|
||||
.success();
|
||||
let stderr = String::from_utf8_lossy(&status.get_output().stderr).to_string();
|
||||
assert!(
|
||||
stderr.contains("Provider `imeai`: API key stored in file"),
|
||||
"{stderr}"
|
||||
);
|
||||
assert!(!stderr.contains(secret), "{stderr}");
|
||||
|
||||
codex_command(codex_home.path())?
|
||||
.args(["logout", "--provider", "imeai"])
|
||||
.assert()
|
||||
.success()
|
||||
.stderr(contains("Removed the stored API key for `imeai`"));
|
||||
assert!(!path.exists());
|
||||
codex_command(codex_home.path())?
|
||||
.args(["login", "status"])
|
||||
.assert()
|
||||
.failure()
|
||||
.stderr(contains(
|
||||
"Provider `imeai`: no API key stored (codex login --provider imeai --with-api-key)",
|
||||
));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
source: cli/tests/features.rs
|
||||
expression: output
|
||||
---
|
||||
Error: failed to load bootstrap configuration
|
||||
Error: failed to load configuration
|
||||
|
||||
Caused by:
|
||||
unknown key `backslash` in keybinding `backslash`. Use a printable character (for example `a`), function keys (`f1`-`f24`), or one of: enter, tab, backspace, esc, delete, arrows, home/end, page-up/page-down, space, minus.
|
||||
See the Codex keymap documentation for supported actions and examples.
|
||||
in `tui.keymap.editor.insert_newline`
|
||||
0: [CODEX_HOME]/config.toml:<line>:<column>: unknown key `backslash` in keybinding `backslash`. Use a printable character (for example `a`), function keys (`f1`-`f24`), or one of: enter, tab, backspace, esc, delete, arrows, home/end, page-up/page-down, space, minus.
|
||||
See the Codex keymap documentation for supported actions and examples.
|
||||
1: unknown key `backslash` in keybinding `backslash`. Use a printable character (for example `a`), function keys (`f1`-`f24`), or one of: enter, tab, backspace, esc, delete, arrows, home/end, page-up/page-down, space, minus.
|
||||
See the Codex keymap documentation for supported actions and examples.
|
||||
in `tui.keymap.editor.insert_newline`
|
||||
|
||||
@@ -312,7 +312,8 @@ trust_level = "trusted"
|
||||
if auth_failure {
|
||||
fs::write(
|
||||
source.join(".codex/config.toml"),
|
||||
"forced_login_method = \"api\"\n",
|
||||
// The stored API key satisfies `api`; require a login method it cannot satisfy.
|
||||
"forced_login_method = \"chatgpt\"\n",
|
||||
)?;
|
||||
git(
|
||||
&source,
|
||||
@@ -330,16 +331,6 @@ trust_level = "trusted"
|
||||
.respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({})))
|
||||
.mount(&server)
|
||||
.await;
|
||||
Mock::given(wiremock::matchers::method("GET"))
|
||||
.and(wiremock::matchers::path(
|
||||
"/source/backend-api/wham/config/bundle",
|
||||
))
|
||||
.respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({
|
||||
"config_toml": { "enterprise_managed": [{ "id": "test", "name": "test",
|
||||
"contents": "developer_instructions = \"managed cloud instructions\"" }] }
|
||||
})))
|
||||
.mount(&server)
|
||||
.await;
|
||||
let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel();
|
||||
let response = app_test_support::create_final_assistant_message_sse_response("done")?;
|
||||
let observed_source = source.clone();
|
||||
@@ -456,7 +447,7 @@ trust_level = "trusted"
|
||||
let bytes = bytes.context("TUI exited before model request")?;
|
||||
let text = String::from_utf8_lossy(&bytes);
|
||||
output.push_str(&text);
|
||||
if auth_failure && output.contains("API key login is required") && output.contains("Do not use --force.") {
|
||||
if auth_failure && output.contains("API key login is not permitted") && output.contains("Do not use --force.") {
|
||||
anyhow::bail!("observed required API login rejection");
|
||||
}
|
||||
let replies = queries.feed(&bytes);
|
||||
@@ -470,7 +461,10 @@ trust_level = "trusted"
|
||||
let exit =
|
||||
tokio::time::timeout(Duration::from_secs(/*secs*/ 10), spawned.exit_rx).await??;
|
||||
assert_ne!(exit, 0);
|
||||
assert!(output.contains("API key login is required"), "{output}");
|
||||
assert!(
|
||||
output.contains("API key login is not permitted"),
|
||||
"{output}"
|
||||
);
|
||||
assert!(!home.join("auth.json").exists());
|
||||
assert!(output.contains("The checkout was kept"), "{output}");
|
||||
continue;
|
||||
@@ -646,7 +640,7 @@ trust_level = "trusted"
|
||||
);
|
||||
}
|
||||
assert_eq!(body["model"], "destination-model");
|
||||
assert!(context.contains("managed cloud instructions"), "{context}");
|
||||
// Managed cloud configuration (ChatGPT config bundles) was removed in aKode.
|
||||
if previous.is_empty() {
|
||||
// A legacy summary still says launcher A, but persisted turns use checkout B.
|
||||
let sqlite = codex_state::SqliteConfig::new_for_testing(
|
||||
@@ -659,26 +653,9 @@ trust_level = "trusted"
|
||||
.execute(&db)
|
||||
.await?;
|
||||
db.close().await;
|
||||
// B inherits trust from its primary repository; no exact trusted entry masks cloud distrust.
|
||||
let home_config = home.join("config.toml");
|
||||
let launcher_config = fs::read_to_string(&home_config)?;
|
||||
fs::write(
|
||||
&home_config,
|
||||
launcher_config.replace(
|
||||
"cli_auth_credentials_store = \"file\"",
|
||||
"cli_auth_credentials_store = \"ephemeral\"",
|
||||
),
|
||||
)?;
|
||||
let cache = home.join("cloud-config-bundle-cache.json");
|
||||
if cache.exists() {
|
||||
fs::remove_file(&cache)?;
|
||||
}
|
||||
let request_count = server.received_requests().await.context("requests")?.len();
|
||||
Mock::given(wiremock::matchers::path("/source/backend-api/wham/config/bundle"))
|
||||
.respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({
|
||||
"config_toml": {"enterprise_managed": [{"id":"distrust", "name":"distrust",
|
||||
"contents": format!("[projects.{}]\ntrust_level = \"untrusted\"\n", serde_json::to_string(&codex_config::loader::project_trust_key(Path::new(&checkout)))?)}]}
|
||||
}))).with_priority(/*priority*/ 1).mount(&server).await;
|
||||
// B inherits trust from its primary repository; an explicit distrust entry for B
|
||||
// (formerly delivered by a managed cloud bundle, now a config override) still
|
||||
// rejects the fork before any checkout is created.
|
||||
let before = git(&source, &["worktree", "list", "--porcelain"])?;
|
||||
rejected_start(
|
||||
&program,
|
||||
@@ -687,6 +664,13 @@ trust_level = "trusted"
|
||||
"--enable".into(),
|
||||
"worktrees".into(),
|
||||
"--no-alt-screen".into(),
|
||||
"-c".into(),
|
||||
format!(
|
||||
"projects={{{}={{trust_level=\"untrusted\"}}}}",
|
||||
serde_json::to_string(&codex_config::loader::project_trust_key(
|
||||
Path::new(&checkout)
|
||||
))?
|
||||
),
|
||||
"fork".into(),
|
||||
next_owner.clone(),
|
||||
],
|
||||
@@ -695,70 +679,7 @@ trust_level = "trusted"
|
||||
"cannot create a checkout from an explicitly untrusted source",
|
||||
)
|
||||
.await?;
|
||||
assert!(
|
||||
server
|
||||
.received_requests()
|
||||
.await
|
||||
.context("requests")?
|
||||
.iter()
|
||||
.skip(request_count)
|
||||
.any(|request| request.url.path() == "/source/backend-api/wham/config/bundle")
|
||||
);
|
||||
assert_eq!(git(&source, &["worktree", "list", "--porcelain"])?, before);
|
||||
server.reset().await;
|
||||
if cache.exists() {
|
||||
fs::remove_file(&cache)?;
|
||||
}
|
||||
let count = server.received_requests().await.context("requests")?.len();
|
||||
Mock::given(wiremock::matchers::path("/source/backend-api/wham/config/bundle"))
|
||||
.respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({
|
||||
"config_toml": {"enterprise_managed": [{"id":"distrust-source", "name":"distrust-source",
|
||||
"contents": format!("[projects.{}]\ntrust_level = \"untrusted\"\n", serde_json::to_string(&codex_config::loader::project_trust_key(&source.join(".codex")))?)}]}
|
||||
}))).mount(&server).await;
|
||||
let output = rejected_start(
|
||||
&program,
|
||||
&[
|
||||
"--worktree".into(),
|
||||
"--enable".into(),
|
||||
"worktrees".into(),
|
||||
"--no-alt-screen".into(),
|
||||
"--cd".into(),
|
||||
source.join(".codex").display().to_string(),
|
||||
],
|
||||
&launcher,
|
||||
&env,
|
||||
"cannot create a checkout from an explicitly untrusted source",
|
||||
)
|
||||
.await?;
|
||||
let requests = server.received_requests().await.context("requests")?;
|
||||
let paths = requests
|
||||
.iter()
|
||||
.skip(count)
|
||||
.map(|r| r.url.path())
|
||||
.collect::<Vec<_>>();
|
||||
assert!(paths.contains(&"/source/backend-api/wham/config/bundle"));
|
||||
assert!(!paths.contains(&"/v1/responses"));
|
||||
let after = git(&source, &["worktree", "list", "--porcelain"])?;
|
||||
let retained = after
|
||||
.lines()
|
||||
.filter_map(|line| line.strip_prefix("worktree "))
|
||||
.find(|path| {
|
||||
!before
|
||||
.lines()
|
||||
.any(|line| line.strip_prefix("worktree ") == Some(*path))
|
||||
})
|
||||
.context("retained untrusted checkout")?;
|
||||
assert!(output.contains("The checkout was kept"), "{output}");
|
||||
let metadata = git(
|
||||
Path::new(retained),
|
||||
&["rev-parse", "--git-path", "codex-thread.json"],
|
||||
)?;
|
||||
assert!(!Path::new(retained).join(metadata).exists());
|
||||
previous.push(retained.to_owned());
|
||||
fs::write(&home_config, launcher_config)?;
|
||||
if cache.exists() {
|
||||
fs::remove_file(&cache)?;
|
||||
}
|
||||
}
|
||||
previous.push(checkout);
|
||||
owner = Some(next_owner);
|
||||
|
||||
Reference in New Issue
Block a user