Skip to content

feat(audit): add --include-attestations flag to output sigstore bundles#9049

Merged
wraithgar merged 4 commits intonpm:latestfrom
mitchdenny:feat/include-attestations
Mar 18, 2026
Merged

feat(audit): add --include-attestations flag to output sigstore bundles#9049
wraithgar merged 4 commits intonpm:latestfrom
mitchdenny:feat/include-attestations

Conversation

@mitchdenny
Copy link
Contributor

@mitchdenny mitchdenny commented Mar 3, 2026

Summary

Adds a new --include-attestations flag for npm audit signatures that includes the full sigstore attestation bundles in JSON output. Closes #9048.

Changes

  • workspaces/config/lib/definitions/definitions.js: New include-attestations boolean config definition
  • lib/commands/audit.js: Added include-attestations to audit command params
  • lib/utils/verify-signatures.js: Collects verified attestation data and includes it in JSON output when flag is set; adds human-readable hint when attestations are verified without the flag
  • docs/lib/content/commands/npm-audit.md: Documents the new flag
  • test/lib/commands/audit.js: Two new tests covering the flag behavior

Example output

npm audit signatures --json --include-attestations
{
  "invalid": [],
  "missing": [],
  "verified": [
    {
      "name": "sigstore",
      "version": "0.4.0",
      "attestations": {
        "url": "https://registry.npmjs.org/-/npm/v1/attestations/sigstore@0.4.0",
        "provenance": { "predicateType": "https://slsa.dev/provenance/v0.2" }
      },
      "attestationBundles": [
        {
          "predicateType": "https://slsa.dev/provenance/v0.2",
          "bundle": { "mediaType": "...", "verificationMaterial": {}, "dsseEnvelope": {} }
        }
      ]
    }
  ]
}

Dependencies

⚠️ Draft: This PR depends on npm/pacote#457 shipping first. That pacote change preserves the fetched attestation bundles on mani._attestationBundles instead of discarding them after verification.

cc @feelepxyz

@wraithgar
Copy link
Member

I ran this by our package security folks and the biggest point of feedback I got was making sure only verified bundles are output. It seems like you've attached the output inside the loop that catches only verified bundles already but I wanted to explicitly mention it so we are sure about it.

@wraithgar
Copy link
Member

Because npm's dependencies are bundled and in source control we don't allow dependency updates in external PRs. We will get pacote updated in latest so that this PR can move forward.

@wraithgar
Copy link
Member

pacote update PR #9086

@mitchdenny mitchdenny marked this pull request as ready for review March 11, 2026 00:18
@mitchdenny mitchdenny requested a review from a team as a code owner March 11, 2026 00:18
@mitchdenny
Copy link
Contributor Author

@wraithgar I think this PR is good to go, or do you have additional concerns?

@wraithgar
Copy link
Member

tests will need to pass before we can land this

@wraithgar
Copy link
Member

I tried testing this locally and it looks like you'll have to rebase this branch against latest so that it brings in the new version of pacote. Pretty sure tests will fail, I'll let them run but the reason is because pacote is not updated here.

@wraithgar
Copy link
Member

wraithgar commented Mar 16, 2026

Rebasing my own copy of this PR branch and the command works as expected.

Mitch Denny and others added 3 commits March 17, 2026 17:25
Add a new --include-attestations flag for `npm audit signatures` that
includes the full sigstore attestation bundles in JSON output. This
enables downstream tooling to consume and further process attestation
data (e.g. for policy engines, SBOMs, or custom verification).

When used with `npm audit signatures --json --include-attestations`,
the JSON output includes a `verified` array containing each package's
name, version, and attestation bundles.

Depends on npm/pacote#457 to expose the fetched attestation bundles
on the manifest's _attestations property.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…undles attribute

Update verify-signatures to destructure _attestationBundles from the
pacote manifest (a separate attribute from _attestations) and include
it in the verified entries JSON output. This aligns with the pacote
change that stores bundles on a separate _ attribute to avoid future
collisions with registry schema.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add test exercising the human-readable output path with
--include-attestations set, covering the false branch of the hint
message check at verify-signatures.js:96.

Update type-description snapshot to include the new
include-attestations config definition.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mitchdenny mitchdenny force-pushed the feat/include-attestations branch from 796d60e to 0afd822 Compare March 17, 2026 06:26
@mitchdenny
Copy link
Contributor Author

@wraithgar rebased

@wraithgar
Copy link
Member

npm run snap should clean this up.

@wraithgar
Copy link
Member

Just to be clear here the code looks good! No changes needed. Once it's green we will land it and it should go out this week.

@mitchdenny
Copy link
Contributor Author

@wraithgar just did npm run snap

@wraithgar wraithgar merged commit 8eff5fb into npm:latest Mar 18, 2026
38 checks passed
@github-actions github-actions bot mentioned this pull request Mar 17, 2026
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.

feat: npm audit signatures --json --include-attestations to output sigstore attestation bundles

3 participants