Expand description
Reachability policy for registry index URLs declared by a workspace file.
A .cargo/config.toml/Cargo.toml value is attacker-controlled the moment a hostile
repository is cloned and opened — this LSP fetches on parse, before any build ever runs
(spec .local/specs/023-cargo-custom-registries/spec.md NFR-003). classify_host
answers “is this URL’s host the kind no legitimate registry index or redirect ever
targets” from the URL alone (no DNS resolution — see classify_host’s docs for why),
and RegistryAccessPolicy is the live-updatable, process-wide switch a caller checks
before ever fetching a workspace-declared URL.
Placed in deps-core, not an ecosystem crate: RegistryAccessPolicy must be held by
ServerState without a #[cfg(feature = "cargo")] gate, and host classification belongs
beside crate::cache’s existing ensure_https/loopback checks, which already perform
the same class of validation (DRY). crate::cache’s redirect-hop hardening also needs
this exact classifier — see HostClass::never_a_registry.
Structs§
- Registry
Access Policy - Live-updatable,
Arc-shareable handle to the currentWorkspaceRegistryAccesssetting.
Enums§
- Host
Class - Classification of a URL’s host, for
RegistryAccessPolicyto evaluate againstWorkspaceRegistryAccess. - Index
UrlError - Why a candidate registry/index URL failed
validate_index_url. - Policy
Gate - Whether
validate_index_urlmust check a candidate’s host against a liveRegistryAccessPolicy. - Workspace
Registry Access - The user-facing policy governing whether a workspace-declared registry index is ever fetched at all.
Functions§
- classify_
addr - Classifies a DNS-resolved socket address into a
HostClass. - classify_
host - Classifies
url‘s host into aHostClass, from the URL alone — no DNS resolution is performed (see the module docs’ residual-risk note). - redact_
userinfo - Replaces any embedded
user:pass@/user@userinfo component inrawwith a fixed***@marker, for a caller to log or retain instead of the raw credential-bearing value. - validate_
index_ url - Validates a candidate registry/index URL:
httpsscheme, no userinfo, and — whengateisPolicyGate::Enforce— a host the liveRegistryAccessPolicyallows.