Repository navigation
Add provenance metadata command - #244
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new git pkgs provenance command that inspects resolved dependency versions and queries registries for provenance/attestation signals, then reports trusted-publishing attestations, npm signatures, missing provenance, unsupported ecosystems, and lookup errors. This extends the tool’s “extrinsic data” feature set (network-backed checks) and documents the new capability.
Changes:
- Introduces
git pkgs provenancewith flags for commit/branch/ecosystem selection,--missing, and--format=json. - Implements concurrent registry lookups with a worker pool and overall timeout, plus text/JSON renderers.
- Documents the command and adds unit tests for npm parsing and filtering behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents the new provenance command and adds usage examples. |
| docs/internals.md | Updates internals docs to describe provenance as an extrinsic, registry-backed lookup (non-cached). |
| cmd/root.go | Registers the new provenance subcommand on the root command. |
| cmd/provenance.go | Implements the provenance command, registry lookups, concurrency, and output formatting. |
| cmd/provenance_test.go | Adds unit tests for npm provenance/signature handling and --missing filtering. |
| cmd/pager_test.go | Ensures the new command is included in pager-flag acceptance coverage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
andrew
left a comment
There was a problem hiding this comment.
Requesting changes for four issues:
-
[P1] PyPI provenance is queried through the wrong API.
lookupPyPIProvenancerequests the legacy/pypi/<project>/<version>/jsonendpoint and scans it for aprovenancekey, but PyPI exposes file attestations through the Simple Index and Integrity API. This produces false negatives: PyPI's documented attested example,sampleproject@4.0.0, has no provenance field in that release JSON, so this command reports it asmissing. Please use the supported per-file provenance API and account for release files individually. References: https://docs.pypi.org/attestations/consuming-attestations/ and https://docs.pypi.org/api/integrity/ -
[P1] The RubyGems V2 version endpoint does not expose a per-release attestation or trusted-publishing signal. Scanning its ordinary metadata for generic provenance keys therefore cannot distinguish trusted-published releases and reports them as
missing. Please report RubyGems asunsupporteduntil there is a reliable per-release API, or use such an API if one exists. References: https://guides.rubygems.org/rubygems-org-api-v2/ and https://guides.rubygems.org/trusted-publishing/ -
[P2]
runProvenancebypasses the format validation now used on currentmain. After merging currentmain,git pkgs provenance --format yamlsucceeds and silently emits text. Please usegetFormatFlag(cmd, formatText, formatJSON)and add provenance to the unsupported-format regression coverage. -
Please separate the registry implementations before merging this command. Keep the Cobra/database orchestration and output in
cmd/provenance.go, and move package-neutral types, shared HTTP behavior, dispatch, and ecosystem checkers into a provenance package, with separate files and tests for npm, PyPI, and RubyGems (for exampleinternal/provenance/{types,client,npm,pypi,rubygems}.go). Avoid Cobra and database dependencies in that package so it can be extracted into its own module later without another large rewrite.
The exact head and a clean merge with current main both pass go test ./..., but the existing mocked tests do not exercise PyPI or RubyGems.
362aad4 to
b6c0f74
Compare
|
Fixed all four items and rebased onto current
|
andrew
left a comment
There was a problem hiding this comment.
Re-reviewing b6c0f74: the four earlier requests are resolved, and both the exact head and a clean merge with current main pass the full test suite and lint. One blocking correctness issue remains:
- [P1] npm attestation metadata is not proof of trusted publishing.
internal/provenance/npm.go:21maps any non-emptydist.attestations(ordist.provenance) totrusted_publishing, but npm supported token-authenticatednpm publish --provenancelong before OIDC trusted publishing; trusted publishing only makes provenance generation automatic. A concrete false positive issigstore@1.0.0: it was published on 2023-02-09 and exposesdist.attestations, so this implementation reports it as trusted-published even though npm trusted publishing became generally available on 2025-07-31. This also misses issue #110s requested distinction between OIDC publishing and manual/token uploads. Please either report npm attestations as an attested/provenance signal without claiming trusted publishing, or use a registry signal that actually identifies OIDC authentication if one is available.
References: https://docs.npmjs.com/generating-provenance-statements/ and https://github.blog/changelog/2025-07-31-npm-trusted-publishing-with-oidc-is-generally-available/
|
npm The command now reports an |
andrew
left a comment
There was a problem hiding this comment.
The npm change is right: dist.attestations now maps to StatusAttested with TrustedPublishing=false, StatusTrustedPublishing is only reachable via PyPI (where PEP 740 requires it), and the summary/evidence make the distinction clear. Tests, tidy, and lint pass on a clean merge with current main.
One remaining UX issue before merge: --missing still only filters StatusTrustedPublishing (cmd/provenance.go:282). Now that npm never returns that status, git pkgs provenance --missing on an npm-only project lists every dependency, attested or not, so the flag stops narrowing anything. The point of --missing is to surface packages that lack provenance metadata so users can chase upstream; attested packages have that metadata, they just cannot prove OIDC authentication.
Please have --missing also skip StatusAttested:
if showMissing && (data.Status == provenanceStatusTrustedPublishing || data.Status == provenanceStatusAttested) {
continue
}and update TestBuildProvenanceResultMissingFilter so the attested entry is excluded from result.Dependencies under showMissing=true (expected length drops back to 2). The summary counts already separate attested from without_provenance, so this keeps the flag consistent with the summary buckets.
|
Thanks...
|
andrew
left a comment
There was a problem hiding this comment.
--missing now filters StatusAttested alongside StatusTrustedPublishing, and TestBuildProvenanceResultMissingFilter asserts the attested entry is excluded. Merges cleanly with current main (2a373da); build and tests pass on the merged tree.
Closes #110.
Summary
Adds a new
git pkgs provenancecommand for checking resolved dependency versions against registry provenance and attestation metadata.The command reports:
Details
--commit,--branch,--ecosystem,--format=json, and--missingTests