C07 - Dependency Gate
Purpose: The test cases for the dependency gate: registry paths,
minimum age and known vulnerabilities, the Go checksum database clock,
and Homebrew bottles from ghcr.io.
Verifies: S07-12-dependency-gateS07-12-dependency-gate: Dependency GateHow wb-proxyd keeps young and vulnerable package versions from the guest on the gated registries., S07-10-anonymous-credentialsS07-10-anonymous-credentials: Anonymous CredentialsHow wb-proxyd answers hosts that want a token even for public reads, without forwarding the guest's token. (“Token fallback”), B76-gosumdb-clockB76-gosumdb-clock: Does the checksum database work as Go's clock for the dependency gate?Yes.
Fuzzing
Section titled “Fuzzing”The dependency gate’s parsers:
- npm request paths;
- PyPI distribution file names;
- Go escaped module paths and versions, checking that the clock lookup key and the download URL come from the same parse;
- crates.io index lines;
sum.golang.orglookup responses.
Conformance
Section titled “Conformance”Registry paths
Section titled “Registry paths”- Install a scoped npm package (
/@scope%2fname), and read a GitLab project by its encoded path (/api/v4/projects/group%2Fproject), and see both pass. - Fetch
/@scope/name,/@scope%2fnameand/@scope%2Fname, and get the same gate decision for each. - Fetch a gated registry path that fits no known form, and get a
403naming the rule. - With a test double for the Go module proxy, redirect a download elsewhere, and see it refused.
Minimum age and vulnerabilities
Section titled “Minimum age and vulnerabilities”- Download a package version younger than the minimum age, or with a known vulnerability, and find the too-young version missing from the registry metadata.
- Do the same for Go, with the checksum-database clock and
sum.golang.orgreached through the gate (I76I76 (closed): Measure the Go checksum-database clock of the dependency gate end to endFollow-up from the X21-dep-gate-registries spike (#32) and the review of its result (#75).). - With
index.golang.orgunreachable before the first calibration, see every Go download and@v/listrefused withgo-clock-uncalibrated.
The Go clock
Section titled “The Go clock”With test doubles for sum.golang.org and index.golang.org, give the
Go clock each violation, and see it fail closed with its rule:
- a lookup reply that fails verification: the download refused with
go-clock-lookup-failedand nothing cached; - a tree head inconsistent with the last accepted one:
go-clock-lookup-failedand ago-sumdb-inconsistentfinding inwb status; - more lookups than the VM’s in-flight cap, its per-minute cap and its
queue: the excess refused with
go-clock-lookup-rate, and no extra request reaching the double; - a double that answers slower than the deadline allows:
go-clock-deadline, with the completed lookups cached; - a download admitted behind a cold list of 2,000 versions in the same
VM: served, not refused with
go-clock-deadline; - a
@v/listof 2,001 versions:go-list-too-long; - an index window whose point exceeds the tree bound: the point
rejected with
go-clock-implausible, the last accepted point kept, and the rejection with both numbers inwb status; - an index that fails after a point was accepted: the point kept,
go-clock-stalelogged, and the point’s age inwb status.
The Go clock across a restart
Section titled “The Go clock across a restart”Restart wb-proxyd with records in state.db, and see:
- a stored point equal to the current tree size isn’t used, and requests wait for the first computation;
- a record that fails
wb-hostd’s checks (an oversized head, a 193rd head, a negative point, a cutoff after the receipt time minus the minimum age) is logged and discarded; - a stored head that isn’t a consistent prefix of the first head
fetched, and one larger than it that the fresh head isn’t a prefix
of, each give
go-sumdb-inconsistent, with both heads stored and every Go request refused; - a consistency proof the double won’t serve gives
go-clock-lookup-failedand no finding; - a fresh head whose proof against the stored head can’t be fetched
isn’t used for calibration, requests get
go-clock-uncalibrated, and the stored head is checked again at the next attempt; - a stored finding whose heads don’t verify, or are consistent, is
discarded with a
go-sumdb-finding-invalidDetection Finding (2004); - a head inconsistency within a run refuses every Go download, still
does after a restart, and stops only after
wb gate reset go-clockis confirmed, with a 5019 event naming the command and the finding.
Resetting the clock
Section titled “Resetting the clock”- Run
wb gate reset go-clockwithout a terminal, and see it refuse and leave the clock as it was. - Run it with one, and see that the restart of
wb-proxydit causes doesn’t count toward the restart limit of S04-07-supervisionS04-07-supervision: SupervisionWho starts and restarts each host process, what happens when wb-hostd stops or the bundle is upgraded, and daemon outages., “Restarting a daemon”, so five resets in 10 minutes leavewb-proxydrunning.
Homebrew bottles
Section titled “Homebrew bottles”Spec: S07-10-anonymous-credentialsS07-10-anonymous-credentials: Anonymous CredentialsHow wb-proxyd answers hosts that want a token even for public reads, without forwarding the guest's token., “Token fallback”.
- Download a Homebrew bottle from
ghcr.iowith the guest’sAuthorizationremoved and the anonymous binding injected, through the redirect topkg-containers.githubusercontent.com. - Send any other method to
/v2/homebrew/core/, and see it refused. - Send
ghcr.io/token?scope=repository:homebrew/core/jq:pull,pushwith guest Basic credentials, and see it denied. - With a stand-in for
ghcr.iothat refuses the fixed value, see the token fallback:- fetch only the fixed
ghcr.io/tokenURL when the 401 names another realm; - refuse a bottle name outside the OCI repository-name grammar;
- refuse requests past the per-VM rate with
anonymous-token-cap; - not retry a 401 with a fresh token.
- fetch only the fixed
- Request
/v2/homebrew/core/x/../../other/image/...and/v2/homebrew%2Fcore/...onghcr.io, and paths with%zz, a backslash, a%2e%2esegment, or a segment likewget%2F..%2Fcurlorwget%2F%2e%2e%2Fcurl, and see all refused with nothing sent upstream.
Status: Draft