pub struct EgressPolicy {
pub schema_version: u32,
pub domains: DomainPolicy,
pub networks: NetworkPolicy,
pub rate_limits: RateLimitPolicy,
pub audit: AuditPolicy,
}Expand description
Top-level egress policy loaded from agentshield.egress.toml.
Fields§
§schema_version: u32Schema version for forward compatibility checks.
domains: DomainPolicyDomain allow/deny rules.
networks: NetworkPolicyNetwork-level IP blocking rules.
rate_limits: RateLimitPolicyRate limiting configuration.
audit: AuditPolicyAudit logging configuration.
Implementations§
Source§impl EgressPolicy
impl EgressPolicy
Sourcepub fn load(path: &Path) -> Result<Self, ShieldError>
pub fn load(path: &Path) -> Result<Self, ShieldError>
Load an egress policy from a TOML file.
Sourcepub fn save(&self, path: &Path) -> Result<(), ShieldError>
pub fn save(&self, path: &Path) -> Result<(), ShieldError>
Save an egress policy to a TOML file.
Sourcepub fn is_domain_allowed(&self, domain: &str) -> bool
pub fn is_domain_allowed(&self, domain: &str) -> bool
Check if a domain is allowed by this policy.
Deny rules take precedence over allow rules. If the allow list is empty, all domains not explicitly denied are allowed.
Sourcepub fn is_ip_blocked(&self, ip: &str) -> bool
pub fn is_ip_blocked(&self, ip: &str) -> bool
Check if an IP address is blocked by network policy.
Sourcepub fn rate_limit_for(&self, domain: &str) -> u32
pub fn rate_limit_for(&self, domain: &str) -> u32
Get rate limit for a domain (requests per minute).
Returns the per-domain override if one exists, otherwise the global default.
Sourcepub fn from_scan_targets(targets: &[ScanTarget]) -> Self
pub fn from_scan_targets(targets: &[ScanTarget]) -> Self
Build a starter egress policy by analyzing all ScanTargets.
Extracts domains from:
- Literal URL arguments in
NetworkOperationentries NetworkAccessdeclared permissions with a scope/target URL or domain
The resulting policy allows all discovered domains and uses safe defaults for network-level blocking and rate limiting.
Sourcepub fn merge_override(&self, operator: &EgressPolicy) -> EgressPolicy
pub fn merge_override(&self, operator: &EgressPolicy) -> EgressPolicy
Merge with an operator override policy. The override can only restrict, never expand.
Merge rules:
domains.allow= intersection(self.allow, override.allow) If override.allow is empty, self.allow is kept (empty means “no restriction”). If self.allow is empty (allow all), operator’s allow list becomes the effective list.domains.deny= union(self.deny, override.deny)networks: if either policy blocks a range, it is blocked in the resultrate_limits.max_requests_per_minute= min(self, override)rate_limits.per_domain: min rate per domain; missing entries inherit the global minaudit: operator override wins (operator controls where logs go)
Sourcepub fn starter_toml() -> &'static str
pub fn starter_toml() -> &'static str
Generate a starter policy TOML string for agentshield init --egress.
Trait Implementations§
Source§impl Clone for EgressPolicy
impl Clone for EgressPolicy
Source§fn clone(&self) -> EgressPolicy
fn clone(&self) -> EgressPolicy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more