pub struct GitlabHost { /* private fields */ }Expand description
A validated GitLab instance host.
https-only, no userinfo, not a loopback/link-local/private/cloud-metadata address (per
the live RegistryAccessPolicy), and round-tripped through URL parsing so a
structurally-injected value (gitlab.com?x, gitlab.com/x) cannot smuggle extra URL
components past validation.
Both the verified host and its ASCII-serialized origin are computed once at construction
— the origin is needed repeatedly (the token-host comparison, the pinned-transport
trusted_origin argument, and the auth_id digest), and re-deriving it per call is how
normalization bugs enter.
Implementations§
Source§impl GitlabHost
impl GitlabHost
Sourcepub fn parse(
raw: &str,
policy: &RegistryAccessPolicy,
) -> Result<Self, IndexUrlError>
pub fn parse( raw: &str, policy: &RegistryAccessPolicy, ) -> Result<Self, IndexUrlError>
Validates raw as a GitLab instance host.
format!("https://{raw}") will happily absorb a raw containing :, ?, #, @
or / — gitlab.com?x parses to a clean https://gitlab.com origin while the
caller still believes the host is gitlab.com?x. This rejects any raw containing
those characters before formatting, and asserts the parsed URL’s host matches
raw (lowercased) afterwards, closing that gap.
§Errors
Returns IndexUrlError when raw contains a URL-structural character, fails to
parse, is not https-eligible, carries userinfo, round-trips to a different host, or
resolves to a deps_core::net_policy::HostClass the current policy blocks.
§Examples
use deps_core::net_policy::{RegistryAccessPolicy, WorkspaceRegistryAccess};
use deps_gitlab_ci::host::GitlabHost;
let policy = RegistryAccessPolicy::new(WorkspaceRegistryAccess::PublicOnly);
let host = GitlabHost::parse("gitlab.com", &policy).unwrap();
assert_eq!(host.host(), "gitlab.com");
assert_eq!(host.origin(), "https://gitlab.com");
assert!(GitlabHost::parse("gitlab.com/evil", &policy).is_err());
assert!(GitlabHost::parse("169.254.169.254", &policy).is_err());Trait Implementations§
Source§impl Clone for GitlabHost
impl Clone for GitlabHost
Source§fn clone(&self) -> GitlabHost
fn clone(&self) -> GitlabHost
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 GitlabHost
impl Debug for GitlabHost
impl Eq for GitlabHost
Source§impl Hash for GitlabHost
impl Hash for GitlabHost
Source§impl PartialEq for GitlabHost
impl PartialEq for GitlabHost
Source§fn eq(&self, other: &GitlabHost) -> bool
fn eq(&self, other: &GitlabHost) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for GitlabHost
Auto Trait Implementations§
impl Freeze for GitlabHost
impl RefUnwindSafe for GitlabHost
impl Send for GitlabHost
impl Sync for GitlabHost
impl Unpin for GitlabHost
impl UnsafeUnpin for GitlabHost
impl UnwindSafe for GitlabHost
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.