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:
@@ -729,10 +729,14 @@ fn append_query_param(mut url: String, key: &str, value: &str) -> String {
|
||||
return url;
|
||||
}
|
||||
let separator = if url.contains('?') { '&' } else { '?' };
|
||||
let encoded_key =
|
||||
url::form_urlencoded::byte_serialize(key.trim().as_bytes()).collect::<String>();
|
||||
let encoded_value =
|
||||
url::form_urlencoded::byte_serialize(value.trim().as_bytes()).collect::<String>();
|
||||
url.push(separator);
|
||||
url.push_str(key.trim());
|
||||
url.push_str(&encoded_key);
|
||||
url.push('=');
|
||||
url.push_str(value.trim());
|
||||
url.push_str(&encoded_value);
|
||||
url
|
||||
}
|
||||
|
||||
@@ -773,9 +777,10 @@ mod tests {
|
||||
use serde_json::json;
|
||||
|
||||
use super::{
|
||||
build_antigravity_fetch_available_models_plan, build_antigravity_load_code_assist_plan,
|
||||
build_gemini_cli_load_code_assist_plan, build_kiro_list_available_models_plan,
|
||||
build_models_fetch_execution_plan, build_models_fetch_execution_plan_for_client_version,
|
||||
append_query_param, build_antigravity_fetch_available_models_plan,
|
||||
build_antigravity_load_code_assist_plan, build_gemini_cli_load_code_assist_plan,
|
||||
build_kiro_list_available_models_plan, build_models_fetch_execution_plan,
|
||||
build_models_fetch_execution_plan_for_client_version,
|
||||
build_standard_models_fetch_execution_plan, build_vertex_models_fetch_execution_plan,
|
||||
ModelFetchTransportRuntime, ANTIGRAVITY_REQUEST_USER_AGENT,
|
||||
};
|
||||
@@ -1327,4 +1332,16 @@ mod tests {
|
||||
);
|
||||
assert!(plan.headers.contains_key("sec-ch-ua"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pagination_cursor_cannot_inject_additional_query_parameters() {
|
||||
assert_eq!(
|
||||
append_query_param(
|
||||
"https://api.example.test/models?limit=100".to_string(),
|
||||
"after_id",
|
||||
"cursor&limit=10000#fragment",
|
||||
),
|
||||
"https://api.example.test/models?limit=100&after_id=cursor%26limit%3D10000%23fragment"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user