pub enum HostClass {
Loopback,
LinkLocal,
CloudMetadata,
PrivateV4,
Cgnat,
UniqueLocalV6,
Unspecified,
InternalName,
Global,
}Expand description
Classification of a URL’s host, for RegistryAccessPolicy to evaluate against
WorkspaceRegistryAccess.
Computed from the URL alone (see classify_host) — never from a DNS resolution, so an
attacker-controlled hostname that merely resolves to a blocked range is not caught here
(the residual risk spec NFR-003/§5 of the plan documents; closing it needs a
reqwest::dns::Resolve filter, deferred as a follow-up).
Variants§
Loopback
127.0.0.0/8, ::1, localhost, *.localhost.
LinkLocal
169.254.0.0/16, fe80::/10 — includes HostClass::CloudMetadata’s narrower range.
CloudMetadata
169.254.169.254 / fd00:ec2::254, or the names cloud providers document for their
instance-metadata endpoint (metadata.google.internal, metadata.goog) — a
deliberately narrower label inside HostClass::LinkLocal/HostClass::InternalName,
kept separate only so a blocked-host warning can name it specifically.
PrivateV4
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16.
Cgnat
100.64.0.0/10 — carrier-grade NAT.
UniqueLocalV6
fc00::/7.
Unspecified
0.0.0.0, ::.
InternalName
A name ending in .internal/.local/.home.arpa, or any single-label host (no dot) —
never a real public registry’s hostname.
Global
Everything else: a public IP literal, or a multi-label name not matching any of the above suffixes.
Implementations§
Source§impl HostClass
impl HostClass
Sourcepub const fn never_a_registry(self) -> bool
pub const fn never_a_registry(self) -> bool
Whether this class is one no legitimate registry index (or a redirect from one) could ever legitimately target.
Used unconditionally by crate::cache’s redirect-hop hardening, independent of
WorkspaceRegistryAccess: deliberately narrower than WorkspaceRegistryAccess::PublicOnly
blocks outright, since HostClass::PrivateV4/HostClass::Cgnat/
HostClass::UniqueLocalV6/HostClass::InternalName are legitimate redirect
targets for a corporate registry’s own network — only the classes below are never a
registry under any policy.
Trait Implementations§
impl Copy for HostClass
impl Eq for HostClass
impl StructuralPartialEq for HostClass
Auto Trait Implementations§
impl Freeze for HostClass
impl RefUnwindSafe for HostClass
impl Send for HostClass
impl Sync for HostClass
impl Unpin for HostClass
impl UnsafeUnpin for HostClass
impl UnwindSafe for HostClass
Blanket Implementations§
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.