pub struct HttpEgressContract {
pub tenant_egress_namespace: String,
pub allowed_schemes: BTreeSet<String>,
pub allowed_authority_set: BTreeSet<String>,
pub deny_loopback: bool,
pub deny_link_local: bool,
pub deny_ipv6_ula: bool,
pub max_redirect_chain: u8,
pub max_response_bytes: u64,
}Expand description
Typed egress policy that must be declared before substrate HTTP egress.
Fields§
§tenant_egress_namespace: StringTenant-scoped namespace used by callers to bind egress receipts and deployment policy to one authority domain.
allowed_schemes: BTreeSet<String>Lowercase HTTP URL schemes allowed by this contract: http or https.
Exact normalized URL authorities allowed by this contract.
Domain authorities are lowercase. IPv6 authorities use brackets, for
example [2001:db8::10]:443.
deny_loopback: boolReject loopback address literals and localhost names even if an authority entry was configured.
deny_link_local: boolReject IPv4 and IPv6 link-local address literals.
deny_ipv6_ula: boolReject IPv6 unique-local address literals.
max_redirect_chain: u8Maximum redirect hop count accepted for a request chain.
max_response_bytes: u64Maximum response bytes accepted before the substrate must abort.
Implementations§
Source§impl HttpEgressContract
impl HttpEgressContract
Sourcepub fn enforce_required(
contract: Option<&HttpEgressContract>,
target_url: &str,
redirect_chain_len: u8,
observed_response_bytes: Option<u64>,
) -> Result<ValidatedHttpEgressTarget, HttpEgressError>
pub fn enforce_required( contract: Option<&HttpEgressContract>, target_url: &str, redirect_chain_len: u8, observed_response_bytes: Option<u64>, ) -> Result<ValidatedHttpEgressTarget, HttpEgressError>
Enforce a required contract. None is a fail-closed denial.
Sourcepub fn enforce_attempt(
&self,
target_url: &str,
redirect_chain_len: u8,
observed_response_bytes: Option<u64>,
) -> Result<ValidatedHttpEgressTarget, HttpEgressError>
pub fn enforce_attempt( &self, target_url: &str, redirect_chain_len: u8, observed_response_bytes: Option<u64>, ) -> Result<ValidatedHttpEgressTarget, HttpEgressError>
Enforce target, redirect, and optional response-size bounds.
Sourcepub fn enforce_url(
&self,
target_url: &str,
redirect_chain_len: u8,
) -> Result<ValidatedHttpEgressTarget, HttpEgressError>
pub fn enforce_url( &self, target_url: &str, redirect_chain_len: u8, ) -> Result<ValidatedHttpEgressTarget, HttpEgressError>
Enforce target URL and redirect hop constraints.
Sourcepub fn enforce_url_with_dns(
&self,
target_url: &str,
redirect_chain_len: u8,
) -> Result<ValidatedHttpEgressTarget, HttpEgressError>
pub fn enforce_url_with_dns( &self, target_url: &str, redirect_chain_len: u8, ) -> Result<ValidatedHttpEgressTarget, HttpEgressError>
Enforce target URL, redirect hop constraints, and DNS safety.
Literal IPs and localhost names are enforced directly. Domain names are resolved here and every resolved IP is checked against the address-class policy before the caller opens a socket.
Sourcepub fn enforce_response_bytes(
&self,
observed: u64,
) -> Result<(), HttpEgressError>
pub fn enforce_response_bytes( &self, observed: u64, ) -> Result<(), HttpEgressError>
Enforce the response-byte ceiling after headers or streaming counters expose the observed size.
Sourcepub fn validate(&self) -> Result<(), HttpEgressError>
pub fn validate(&self) -> Result<(), HttpEgressError>
Validate the contract shape before use.
Sourcepub fn prepare(&self) -> Result<PreparedHttpEgressContract, HttpEgressError>
pub fn prepare(&self) -> Result<PreparedHttpEgressContract, HttpEgressError>
Validate this raw contract and return an immutable enforcement handle.
Sourcepub fn validate_dispatchable_with_pinned_dns(
&self,
) -> Result<(), HttpEgressError>
pub fn validate_dispatchable_with_pinned_dns( &self, ) -> Result<(), HttpEgressError>
Validate that this contract can be used by the reqwest-backed dispatcher whose resolver enforces address-class policy at connect time.
Sourcepub fn enforce_resolved_ip(
&self,
host: &str,
address: IpAddr,
) -> Result<(), HttpEgressError>
pub fn enforce_resolved_ip( &self, host: &str, address: IpAddr, ) -> Result<(), HttpEgressError>
Enforce address-class denials after a domain has resolved to an IP.
Source§impl HttpEgressContract
impl HttpEgressContract
Sourcepub fn permissive_for_tests(authority: &str) -> HttpEgressContract
pub fn permissive_for_tests(authority: &str) -> HttpEgressContract
Construct a permissive contract suitable for tests that exercise a wiremock or other local loopback HTTP server. Production code MUST NOT use this; production always builds a contract from tenant-scoped substrate config.
Loopback, link-local and IPv6 ULA denials are disabled so wiremock’s
127.0.0.1:<port> URL is accepted. Authority allow-list is wildcard
per allowed_authority_set semantics: caller supplies the wiremock
authority. Schemes default to http and https.
Trait Implementations§
Source§impl Clone for HttpEgressContract
impl Clone for HttpEgressContract
Source§fn clone(&self) -> HttpEgressContract
fn clone(&self) -> HttpEgressContract
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HttpEgressContract
impl Debug for HttpEgressContract
Source§impl<'de> Deserialize<'de> for HttpEgressContract
impl<'de> Deserialize<'de> for HttpEgressContract
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<HttpEgressContract, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<HttpEgressContract, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for HttpEgressContract
Source§impl PartialEq for HttpEgressContract
impl PartialEq for HttpEgressContract
Source§impl Serialize for HttpEgressContract
impl Serialize for HttpEgressContract
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for HttpEgressContract
Auto Trait Implementations§
impl Freeze for HttpEgressContract
impl RefUnwindSafe for HttpEgressContract
impl Send for HttpEgressContract
impl Sync for HttpEgressContract
impl Unpin for HttpEgressContract
impl UnsafeUnpin for HttpEgressContract
impl UnwindSafe for HttpEgressContract
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more