mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-04 16:37:46 +08:00
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:
@@ -1163,7 +1163,8 @@ fn admin_provider_write_uses_specific_local_owners() {
|
||||
"crate::handlers::admin::provider::write::normalize::{",
|
||||
"normalize_auth_type,",
|
||||
"validate_vertex_api_formats,",
|
||||
"encrypt_catalog_secret_with_fallbacks, json_string_list,",
|
||||
".seal_provider_catalog_key_api_key(",
|
||||
".seal_provider_catalog_key_auth_config(",
|
||||
"normalize_json_object, normalize_string_list,",
|
||||
] {
|
||||
assert!(
|
||||
@@ -1243,7 +1244,6 @@ fn admin_provider_ops_providers_mod_stays_thin() {
|
||||
"apps/aether-gateway/src/handlers/admin/provider/ops/providers/support.rs",
|
||||
);
|
||||
for pattern in [
|
||||
"pub(super) const ADMIN_PROVIDER_OPS_SENSITIVE_FIELDS:",
|
||||
"pub(super) const ADMIN_PROVIDER_OPS_CONNECT_RUST_ONLY_MESSAGE:",
|
||||
"pub(super) const ADMIN_PROVIDER_OPS_ACTION_RUST_ONLY_MESSAGE:",
|
||||
"pub(super) const ADMIN_PROVIDER_OPS_VERIFY_RUST_ONLY_MESSAGE:",
|
||||
@@ -1257,6 +1257,30 @@ fn admin_provider_ops_providers_mod_stays_thin() {
|
||||
"handlers/admin/provider/ops/providers/support.rs should own {pattern}"
|
||||
);
|
||||
}
|
||||
assert!(
|
||||
!providers_support.contains("ADMIN_PROVIDER_OPS_SENSITIVE_FIELDS"),
|
||||
"provider ops support should not duplicate the shared credential sensitivity policy"
|
||||
);
|
||||
|
||||
let provider_ops_credentials =
|
||||
read_workspace_file("apps/aether-gateway/src/handlers/shared/provider_ops_credential.rs");
|
||||
for pattern in [
|
||||
"pub(crate) const PROVIDER_OPS_PERSISTENT_SECRET_FIELDS:",
|
||||
"pub(crate) const PROVIDER_OPS_TRANSIENT_SECRET_FIELDS:",
|
||||
"pub(crate) fn provider_ops_credential_field_is_secret(",
|
||||
] {
|
||||
assert!(
|
||||
provider_ops_credentials.contains(pattern),
|
||||
"handlers/shared/provider_ops_credential.rs should own provider credential sensitivity policy {pattern}"
|
||||
);
|
||||
}
|
||||
let providers_config = read_workspace_file(
|
||||
"apps/aether-gateway/src/handlers/admin/provider/ops/providers/config.rs",
|
||||
);
|
||||
assert!(
|
||||
providers_config.contains("provider_ops_credential_field_is_secret"),
|
||||
"provider ops config should consume the shared credential sensitivity policy"
|
||||
);
|
||||
|
||||
for path in [
|
||||
"apps/aether-gateway/src/maintenance/runtime.rs",
|
||||
|
||||
@@ -208,7 +208,6 @@ fn admin_wrapped_state_owns_provider_oauth_capabilities() {
|
||||
"pub(crate) async fn create_provider_oauth_catalog_key(",
|
||||
"pub(crate) async fn update_existing_provider_oauth_catalog_key(",
|
||||
"pub(crate) async fn refresh_provider_oauth_account_state_after_update(",
|
||||
"pub(crate) async fn update_provider_catalog_key_oauth_credentials(",
|
||||
] {
|
||||
assert!(
|
||||
admin_request.contains(pattern),
|
||||
@@ -841,12 +840,12 @@ fn admin_proxy_uses_single_admin_routes_entrypoint() {
|
||||
"pub(crate) fn has_usage_data_reader(&self) -> bool",
|
||||
"pub(crate) fn has_auth_module_writer(&self) -> bool",
|
||||
"pub(crate) async fn get_ldap_module_config(",
|
||||
"pub(crate) async fn upsert_ldap_module_config(",
|
||||
"pub(crate) async fn compare_and_swap_ldap_module_config(",
|
||||
"pub(crate) async fn count_active_local_admin_users_with_valid_password(",
|
||||
"pub(crate) async fn list_oauth_provider_configs(",
|
||||
"pub(crate) async fn get_oauth_provider_config(",
|
||||
"pub(crate) async fn upsert_oauth_provider_config(",
|
||||
"pub(crate) async fn delete_oauth_provider_config(",
|
||||
"pub(crate) async fn delete_oauth_provider_config_if_unlinked(",
|
||||
"pub(crate) async fn get_management_token_with_user(",
|
||||
"pub(crate) async fn delete_management_token(",
|
||||
"pub(crate) async fn remove_admin_security_blacklist(",
|
||||
|
||||
@@ -717,6 +717,9 @@ fn ai_serving_crate_api_is_confined_to_root_seams() {
|
||||
if relative == "apps/aether-gateway/src/ai_serving/pure/mod.rs"
|
||||
|| relative == "apps/aether-gateway/src/ai_serving/transport.rs"
|
||||
|| relative == "apps/aether-gateway/src/ai_serving/api.rs"
|
||||
// This module is included by the finalize implementation solely as a
|
||||
// test fixture. Keep the architecture rule focused on production seams.
|
||||
|| relative == "apps/aether-gateway/src/ai_serving/finalize/tests_sync.rs"
|
||||
|| relative.ends_with("/tests.rs")
|
||||
|| relative.contains("/tests/")
|
||||
|| relative.starts_with("apps/aether-gateway/src/tests/")
|
||||
@@ -4226,7 +4229,7 @@ fn ai_serving_finalize_standard_sync_products_are_owned_by_format_crate() {
|
||||
"pub struct OpenAiImageSyncFinalizeProduct",
|
||||
"OPENAI_IMAGE_SYNC_FINALIZE_REPORT_KIND",
|
||||
"CODEX_OPENAI_IMAGE_DEFAULT_OUTPUT_FORMAT",
|
||||
"base64::engine::general_purpose::STANDARD.decode",
|
||||
"decode_sync_report_body_base64",
|
||||
] {
|
||||
assert!(
|
||||
surface_openai_image_stream.contains(expected),
|
||||
|
||||
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user