feat(security): harden gateway boundaries and usage policies

Consolidate subscription usage policy enforcement, privacy-safe persistence, and gateway security hardening into one reviewable change.

Includes bounded HTTP and execution envelopes, header and protocol guards, DNS and relay validation, authentication and secret projection hardening, secure backup/install paths, and regression coverage.
This commit is contained in:
elky
2026-09-04 03:45:52 +08:00
parent ddcbeb3ae9
commit 579f2c7cc1
1019 changed files with 190437 additions and 26080 deletions
@@ -1537,6 +1537,68 @@ fn hotspot_modules_do_not_log_sensitive_payload_like_fields() {
}
}
#[test]
fn identity_oauth_does_not_persist_raw_userinfo_claims() {
let source = read_workspace_file("apps/aether-gateway/src/oauth/identity_repo.rs");
assert!(
!source.contains("claims.raw"),
"identity OAuth must persist only dedicated claim fields, never raw userinfo JSON"
);
}
#[test]
fn gateway_does_not_log_raw_request_queries_or_credential_bearing_urls() {
let patterns = [
"request_query_string = %",
"request_query_string = ?",
"request_path_and_query = %request_context.request_path_and_query()",
"request_path_and_query = ?request_context.request_path_and_query()",
"upstream_url = %",
"upstream_url = ?",
"plan_url = %",
"plan_url = ?",
"token_url = %",
"token_url = ?",
"endpoint_base_url = %",
"endpoint_base_url = ?",
"url = %plan.url",
"url = ?plan.url",
];
for root in [
"src/ai_serving",
"src/execution_runtime",
"src/handlers",
"src/maintenance",
"src/oauth",
"src/state",
] {
assert_no_sensitive_log_patterns(root, &patterns);
}
let provider_transport_root =
Path::new(env!("CARGO_MANIFEST_DIR")).join("../../crates/aether-provider/transport/src");
let mut provider_transport_files = Vec::new();
collect_rust_files(&provider_transport_root, &mut provider_transport_files);
let violations = provider_transport_files
.into_iter()
.filter_map(|path| {
let source = std::fs::read_to_string(&path).expect("source file should be readable");
let hits = patterns
.iter()
.filter(|pattern| source.contains(**pattern))
.copied()
.collect::<Vec<_>>();
(!hits.is_empty()).then(|| format!("{} -> {}", path.display(), hits.join(", ")))
})
.collect::<Vec<_>>();
assert!(
violations.is_empty(),
"provider transport must log URL origins/hosts instead of raw URLs or queries:\n{}",
violations.join("\n")
);
}
#[test]
fn execution_runtime_video_finalize_paths_depend_on_shared_video_task_core() {
let response =