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
@@ -8,19 +8,42 @@ pub enum WireType {
Fixed32 = 5,
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Clone, PartialEq, Eq)]
pub enum FieldValue {
Varint(u64),
Bytes(Vec<u8>),
}
#[derive(Debug, Clone, PartialEq, Eq)]
impl fmt::Debug for FieldValue {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Varint(value) => formatter.debug_tuple("Varint").field(value).finish(),
Self::Bytes(bytes) => formatter
.debug_struct("Bytes")
.field("len", &bytes.len())
.finish(),
}
}
}
#[derive(Clone, PartialEq, Eq)]
pub struct Field {
pub number: u32,
pub wire_type: WireType,
pub value: FieldValue,
}
impl fmt::Debug for Field {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter
.debug_struct("Field")
.field("number", &self.number)
.field("wire_type", &self.wire_type)
.field("value", &self.value)
.finish()
}
}
impl Field {
pub fn bytes(&self) -> &[u8] {
match &self.value {
@@ -138,7 +161,7 @@ pub fn parse_fields(buf: &[u8]) -> Result<Vec<Field>, ProtoError> {
other => {
return Err(ProtoError::new(format!(
"unknown wire type {other} at offset {pos}"
)))
)));
}
};
let value = match wire_type {