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
@@ -1,4 +1,5 @@
use std::collections::BTreeMap;
use std::fmt;
use aether_data_contracts::repository::video_tasks::StoredVideoTask;
use aether_video_tasks_core::{
@@ -29,7 +30,7 @@ pub enum ProviderVideoCreateFamily {
Gemini,
}
#[derive(Debug, Clone, Copy)]
#[derive(Clone, Copy)]
pub struct ProviderVideoCreateHeadersInput<'a> {
pub headers: &'a http::HeaderMap,
pub auth_header: &'a str,
@@ -39,6 +40,37 @@ pub struct ProviderVideoCreateHeadersInput<'a> {
pub original_request_body: &'a Value,
}
impl fmt::Debug for ProviderVideoCreateHeadersInput<'_> {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter
.debug_struct("ProviderVideoCreateHeadersInput")
.field(
"request_header_names",
&self
.headers
.keys()
.map(|name| name.as_str())
.collect::<Vec<_>>(),
)
.field("auth_header", &self.auth_header)
.field("has_auth_value", &(!self.auth_value.is_empty()))
.field("has_header_rules", &self.header_rules.is_some())
.field(
"provider_request_body_bytes",
&serde_json::to_vec(self.provider_request_body)
.ok()
.map(|bytes| bytes.len()),
)
.field(
"original_request_body_bytes",
&serde_json::to_vec(self.original_request_body)
.ok()
.map(|bytes| bytes.len()),
)
.finish()
}
}
#[async_trait]
pub trait VideoTaskTransportSnapshotLookup: Send + Sync {
async fn read_video_task_provider_transport_snapshot(
@@ -210,6 +242,12 @@ pub fn build_video_create_headers(
) {
return None;
}
let declared_connection_headers =
super::headers::declared_connection_header_names(input.headers, &BTreeMap::new());
super::headers::remove_declared_connection_headers(
&mut provider_request_headers,
&declared_connection_headers,
);
Some(provider_request_headers)
}