pub const HTTP_TOKEN_VARS: &[&str] = &[
bugwarden::http_auth::WRITE_TOKEN_VAR,
bugwarden::http_auth::READ_TOKEN_VAR,
];
#[allow(dead_code, reason = "only the binary_user_agent includer pins")]
pub const PROXY_PIN_VARS: &[&str] = &["ALL_PROXY", "all_proxy", "HTTP_PROXY", "http_proxy"];
pub const AMBIENT_VARS: &[&str] = &[
"BUGZILLA_SERVER",
"BUGZILLA_API_KEY",
"BUGZILLA_API_KEY_FILE",
"BUGWARDEN_POLICY",
"BUGWARDEN_AUDIT_CONFIG",
"BUGWARDEN_HTTP_TOKEN",
"BUGWARDEN_HTTP_READ_TOKEN",
"BUGZILLA_USE_AUTH_HEADER",
"MCP_TRANSPORT",
"MCP_HOST",
"MCP_PORT",
"MCP_ALLOWED_HOSTS",
"MCP_READ_ONLY",
"MCP_API_KEY_HEADER",
"RUST_LOG",
"ALL_PROXY",
"all_proxy",
"HTTP_PROXY",
"http_proxy",
"HTTPS_PROXY",
"https_proxy",
"NO_PROXY",
"no_proxy",
"OTEL_EXPORTER_OTLP_ENDPOINT",
"OTEL_EXPORTER_OTLP_HEADERS",
"OTEL_EXPORTER_OTLP_PROTOCOL",
"OTEL_SERVICE_NAME",
"OTEL_EXPORTER_OTLP_LOGS_ENDPOINT",
"OTEL_EXPORTER_OTLP_LOGS_HEADERS",
"OTEL_EXPORTER_OTLP_LOGS_PROTOCOL",
];
pub fn assert_the_scrub_list_covers_every_environment_fallback(
scrubbed: &[&str],
by_name: &[&str],
) {
let mut cmd = bugwarden::config::command();
cmd.build();
let unscrubbed: Vec<String> = cmd
.get_arguments()
.filter_map(clap::Arg::get_env)
.map(|env| env.to_string_lossy().into_owned())
.filter(|env| !scrubbed.contains(&env.as_str()))
.collect();
assert!(
!scrubbed.is_empty() && cmd.get_arguments().any(|arg| arg.get_env().is_some()),
"the check is only evidence while both lists are non-empty"
);
assert!(
unscrubbed.is_empty(),
"these environment fallbacks reach the spawned binary: {unscrubbed:?}"
);
for var in by_name {
assert!(scrubbed.contains(var), "{var} must be scrubbed");
}
let unscrubbed_otel: Vec<&str> = bugwarden::otel::ENV_VARS
.iter()
.copied()
.filter(|var| !scrubbed.contains(var))
.collect();
assert!(
unscrubbed_otel.is_empty(),
"these OTLP variables reach the spawned binary: {unscrubbed_otel:?}"
);
}