Skip to content

impl(068): qualification requires npm provenance after 0.5.0 (increment 1) - #571

Merged
bartekus merged 1 commit into
mainfrom
impl/068-provenance
Nov 8, 2026
Merged

bartekus merged 1 commit into
mainfrom
impl/068-provenance

Conversation

@bartekus

@bartekus bartekus commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Spec 068 increment 1 (#559): the fresh-consumer qualification's npm step requires npm provenance for every release after 0.5.0, and rustev-release qualify refuses an npm step of such a version unless every @rustev/* package records verified.

  • Which rule (3.1, I-2). PROVENANCE_AFTER = (0, 5, 0) is a constant of the running harness, compared component by component; it is never read from RUSTEV_QUALIFY_RELEASE_TREE or the manifest, so a default-branch harness qualifying an earlier tag cannot be loosened.
  • Provenance rule (3.2). After 0.5.0, per installed @rustev/* package: the version document names an SLSA provenance attestation (npm_named, the predicate of hosted.rs's npm_has_provenance); npm audit signatures --include-attestations lists it in neither invalid nor missing; the bundle (only from https://registry.npmjs.org/) holds exactly one SLSA statement whose single subject is pkg:npm/%40rustev/<name>@X.Y.Z with the manifest integrity's SHA-512, built by https://github.com/statecrafting/rustev .github/workflows/release.yml at refs/tags/vX.Y.Z. Any network error, non-200, unparsable body or missing member fails the step naming the package and the check.
  • Grandfathered and evidence (3.3). 0.1.0 to 0.5.0 keep A-74's rule (no registry fetch); the npm step's record gains npm_provenance per package (verified or not_required), filled only once a package passed. qualification::Step gains the member (optional, so older steps still parse); evidence refuses a required npm step after 0.5.0 unless it lists at least one @rustev/* package and every one records verified (3.3.3).
  • Tests over fixtures, no network. A test-only harness.py npm-check runs the same checks over a recorded consumer, an audit report and fixture registry answers, and writes no step record. tests/qualify_harness.rs covers every row of section 5 and the boundary (0.3.0 and 0.5.0 grandfathered, 0.5.1, 0.6.0 and 1.0.0 not); tests/family.rs covers the step-file refusal and acceptance. tests/fixtures/npm-provenance-documents.json is shared: family.rs runs it through npm_response and the harness test through npm_named, and both must agree.
  • README states the two rules and the boundary. Spec record: verification declared, increments listed, increment 1 recorded, implementation: in-progress.

No workflow edit (qualify.yml, release.yml unchanged), so no review exception is needed. Increment 2 (closure) records the real requalification runs of 0.6.0 (verified) and v0.5.0 (not_required) once this is on main, and adds 068 to VERIFIED_SPECS.

Read-only check against the public registry: the harness's live path reports verified for @rustev/rustev and @rustev/rustev-wasm 0.6.0, and would refuse both at 0.5.0 (no provenance), which is why 3.3.1 grandfathers them.

Checks

cargo test -p rustev-release --locked --test qualify_harness --test family (pass), make gate (pass), cargo fmt. Full crate tests, clippy -D warnings and spec-spine verify 068 run locally in parallel with CI.

@bartekus
bartekus force-pushed the impl/068-provenance branch from f7fc826 to 66956cc Compare November 8, 2026 19:13
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

AI review (findings)

Review

The PR implements increment 1 of spec 068, adding npm provenance checking to the qualification harness and the evidence() gate in qualification.rs.

Structural observations

  • Spec lifecycle transition from pending → in-progress is a valid transition per the contract (approved + in-progress is schedulable). The ratification claim (A-88) is noted as a claim in the diff.
  • The two-implementation design (Python harness writes the step file; Rust evidence() refuses a step that lacks Verified) is internally consistent: a harness crash prevents a step file from being written, so it can't whittle down the security check.
  • The redirect-origin check in registry_fetch correctly reads response.geturl() before reading the body.
  • npm_bound's early-return on a malformed SLSA-prefixed envelope is defensive: a bundle that carries a SLSA-prefixed attestation with a non-in-toto payload type is refused, which is consistent with the "exactly one" requirement.

Concrete defect

harness.py provenance_required crashes on pre-release version strings.

def provenance_required(version):
    return tuple(int(part) for part in version.split('.')) > PROVENANCE_AFTER

For a version such as "1.0.0-rc.1", version.split('.') yields ['1', '0', '0-rc', '1']; int('0-rc') raises an unhandled ValueError, crashing the harness before any step file is written. The Rust counterpart in qualification.rs correctly strips pre-release/build suffixes first:

let core = version.split(['-', '+']).next().unwrap_or_default();

and defaults to true (provenance required) on any non-parseable core, as the spec requires ("a version whose core does not parse requires provenance, never less"). The Python function does neither, diverging from the spec text. The impact is low because only clean X.Y.Z release versions are normally qualified, but a hypothetical pre-release qualification run would crash instead of enforcing the rule.

{"head": "66956ccbefff3debbbeb2f6732d2f520b6335667", "verdict": "findings", "findings": [{"path": "tools/rustev-release/qualify/harness.py", "line": 96, "severity": "low", "category": "correctness", "summary": "provenance_required splits on '.' and calls int() without stripping pre-release/build suffixes, so a version like '1.0.0-rc.1' raises an unhandled ValueError and crashes the harness; the Rust counterpart strips such suffixes per spec before comparing."}]}

Subject: e457670...66956cc, diff digest 6e5c56a3460edd32c6beb01c797ad11f9d564dfd4757b173a2ef5ab76ae29f7e, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus temporarily deployed to statecraft-review-exception November 8, 2026 19:17 — with GitHub Actions Inactive
…nt 1)

The npm step of the fresh-consumer harness requires, for every release
version after 0.5.0, an SLSA provenance attestation on each installed
@rustev/* package, verified by npm and bound to the package's manifest
integrity and this repository's release workflow at vX.Y.Z. Versions up
to 0.5.0 keep A-74's rule. The step records npm_provenance per package,
and rustev-release qualify refuses an npm step after 0.5.0 unless every
package records verified.
@bartekus
bartekus force-pushed the impl/068-provenance branch from 66956cc to 8a653dd Compare November 8, 2026 19:18
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff carefully against the governance documents and the implementation.

spec.md: The lifecycle transition from implementation: pending to in-progress is valid per the contract table (both are schedulable under status: approved, both yield W-001 warnings on unresolved units). The ratification claim is unchanged (A-88, 2026-11-08); this change records progress, not a new approval act.

harness.py – registry_fetch: The status check and redirect guard run before response.read(). Order is correct. The validate=True flag in base64.b64decode calls correctly rejects malformed padding. binascii.Error is a subclass of ValueError so the except ValueError clauses catch it.

harness.py – npm_bound: The loop filters by outer predicateType, decodes the payload, and after the loop enforces exactly one statement and re-checks the decoded statement's inner predicateType. A malformed SLSA envelope early-returns rather than silently being skipped, which is correct since the spec requires exactly one valid statement.

harness.py – provenance_required: Python and Rust implementations both use strict > comparison against (0, 5, 0). Both treat unparseable version strings as requiring provenance (Python: len(core) != 3; Rust: _ => true). The "0.6" test case in qualify_harness.rs confirms the Rust side; the Python npm_provenance_boundary_is_0_5_0 test drives the same via harness.py. Consistent.

qualification.rs – npm_verified: Builds the union of checksums.keys() and npm_provenance.keys(), then requires NpmProvenance::Verified in npm_provenance for every package in that union. A package in checksums only → npm_provenance.get(p) is None → correctly fails. A step with npm_provenance absent (older harness, #[serde(default)] → empty map) → every package from checksums fails the check → correctly refused. The test cases ("0.6.0", None, false) and ("0.6.0", Some(&["verified"][..]), false) exercise these paths.

qualify_harness.rs – b64: Padding logic is i > c.len(). For chunks of length 1, 2, 3 this produces 2, 1, 0 = characters respectively — correct standard base64. base64.b64decode(payload, validate=True) on the Python side will accept these.

npm-check subcommand: Writes no step file (confirmed by code). The fixture_fetch closure never calls the network. Correctly isolated.

Shared fixture npm-provenance-documents.json: Both family.rs (via npm_response) and qualify_harness.rs (via npm_named) assert that each case's provenance boolean agrees. The fixture covers SLSA v1, a later SLSA version, absent attestations, wrong predicate types, empty URL and missing URL — sufficient to pin the predicate.

Security surface: URL prefix enforcement (NPM_REGISTRY) appears at both the version-document fetch and the bundle URL check inside npm_provenance, blocking open-redirect abuse. The workflow binding checks (repository, path, ref) are verified against constants, not values from the step or the release tree.

No concrete defect was found against any named input.

{"head": "8a653dd4db1e32eba4c508079b4e3cd6fa6f6a1f", "verdict": "no-findings", "findings": []}

Subject: e457670...8a653dd, diff digest 1d0fb66da850e99deb0e427250e297bedaa822a33d2da6371dfd782b9090a6e3, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus enabled auto-merge November 8, 2026 19:26
@bartekus
bartekus added this pull request to the merge queue Nov 8, 2026
Merged via the queue into main with commit f81dc04 Nov 8, 2026
26 checks passed
@bartekus
bartekus deleted the impl/068-provenance branch November 8, 2026 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant