Use Sigstore attestation helper APIs for provenance checking#14931
Merged
mitchdenny merged 4 commits intorelease/13.2from Mar 5, 2026
Merged
Use Sigstore attestation helper APIs for provenance checking#14931mitchdenny merged 4 commits intorelease/13.2from
mitchdenny merged 4 commits intorelease/13.2from
Conversation
Replace manual JSON parsing in SigstoreNpmProvenanceChecker with the new attestation APIs already available in Sigstore 0.3.0: - Remove ParseAttestation (~80 lines) and ParseProvenanceFromStatement (~20 lines) methods and NpmAttestationParseResult class - Add ExtractSlsaBundleJson to extract bundle JSON from npm response - Add ExtractProvenanceFromResult using VerificationResult.Statement (InTotoStatement) and VerifiedIdentity.Extensions (FulcioCertificateExtensions) - Use bundle.DsseEnvelope.Payload directly instead of manual base64 decode - Prefer certificate extensions (cryptographically bound) over SLSA predicate values for source repository and ref - Fix JsonArray safety: use pattern matching instead of AsArray() Add comprehensive adversarial/security tests (68 total): - Malformed JSON attacks (deeply nested, truncated, wrong types, null) - Attestation structure manipulation (swapped predicates, mixed arrays) - Provenance spoofing (homoglyph URLs, path traversal, null bytes) - Build type spoofing (query params, wrong domains, empty values) - URL parsing edge cases (subdomain attacks, non-absolute URIs) - WorkflowRefInfo parsing edge cases (path traversal in names) - Statement extraction edge cases (missing fields, empty predicates) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Delete NpmProvenanceChecker and its tests — production code only uses SigstoreNpmProvenanceChecker (registered in DI), so the non-Sigstore fallback was dead code. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14931Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14931" |
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors npm provenance verification in the Aspire CLI to rely on Sigstore’s attestation helper/typed APIs (Sigstore 0.3.0) rather than manual JSON parsing, and removes the unused non-Sigstore provenance checker path.
Changes:
- Simplified attestation handling by extracting the SLSA bundle JSON and using
VerificationResult.Statement+VerifiedIdentity.Extensionsto derive provenance fields. - Updated Sigstore verification flow to pass DSSE payload bytes directly (and return both failure + verification result from the verifier helper).
- Removed the unused
NpmProvenanceCheckerimplementation and its tests; expanded/adapted Sigstore provenance tests (including adversarial cases).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/Aspire.Cli/Npm/SigstoreNpmProvenanceChecker.cs | Reworks parsing/verification to use Sigstore typed APIs and extracts provenance from verification results. |
| src/Aspire.Cli/Npm/NpmProvenanceChecker.cs | Deletes unused legacy provenance checker implementation. |
| tests/Aspire.Cli.Tests/Agents/SigstoreNpmProvenanceCheckerTests.cs | Updates tests for the new helper methods and adds extensive adversarial coverage. |
| tests/Aspire.Cli.Tests/Agents/NpmProvenanceCheckerTests.cs | Deletes tests for the removed legacy checker. |
tests/Aspire.Cli.Tests/Agents/SigstoreNpmProvenanceCheckerTests.cs
Outdated
Show resolved
Hide resolved
Contributor
🎬 CLI E2E Test RecordingsThe following terminal recordings are available for commit
📹 Recordings uploaded automatically from CI run #22690603293 |
- ExtractSlsaBundleJson now returns 'out bool parseFailed' to distinguish invalid JSON (AttestationParseFailed) from missing SLSA provenance (SlsaProvenanceNotFound) - Add explicit JsonObject type checks when iterating attestation array elements so non-object values (strings, numbers, null) are safely skipped - Replace GetProperty/GetString with TryGetProperty + ValueKind checks in ExtractProvenanceFromResult to handle wrong-typed predicate values without throwing InvalidOperationException - Fix misleading comment about CertificateExtensionPolicy; the actual enforcement is CertificateIdentity.ForGitHubActions SAN/issuer matching - Fix deeply nested JSON test to use valid JSON structure - Add tests for non-object array elements, non-string predicateType, wrong-typed predicate values, and parseFailed assertions Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| var attestations = doc?["attestations"]?.AsArray(); | ||
| if (attestations is null || attestations.Count == 0) | ||
| var attestationsNode = doc?["attestations"]; | ||
| if (attestationsNode is not JsonArray attestations || attestations.Count == 0) |
Member
There was a problem hiding this comment.
Suggested change
| if (attestationsNode is not JsonArray attestations || attestations.Count == 0) | |
| if (attestationsNode is not JsonArray { Count: >0 } attestations) |
Member
|
This looks good to me but I'll leave to eng folks to provide approvals. |
Use property pattern matching (JsonArray { Count: >0 }) instead of
separate is-check and Count comparison, as suggested by @DamianEdwards.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
karolz-ms
approved these changes
Mar 4, 2026
eerhardt
pushed a commit
to eerhardt/aspire
that referenced
this pull request
Mar 7, 2026
…ft#14931) * refactor: use Sigstore attestation helper APIs for provenance checking Replace manual JSON parsing in SigstoreNpmProvenanceChecker with the new attestation APIs already available in Sigstore 0.3.0: - Remove ParseAttestation (~80 lines) and ParseProvenanceFromStatement (~20 lines) methods and NpmAttestationParseResult class - Add ExtractSlsaBundleJson to extract bundle JSON from npm response - Add ExtractProvenanceFromResult using VerificationResult.Statement (InTotoStatement) and VerifiedIdentity.Extensions (FulcioCertificateExtensions) - Use bundle.DsseEnvelope.Payload directly instead of manual base64 decode - Prefer certificate extensions (cryptographically bound) over SLSA predicate values for source repository and ref - Fix JsonArray safety: use pattern matching instead of AsArray() Add comprehensive adversarial/security tests (68 total): - Malformed JSON attacks (deeply nested, truncated, wrong types, null) - Attestation structure manipulation (swapped predicates, mixed arrays) - Provenance spoofing (homoglyph URLs, path traversal, null bytes) - Build type spoofing (query params, wrong domains, empty values) - URL parsing edge cases (subdomain attacks, non-absolute URIs) - WorkflowRefInfo parsing edge cases (path traversal in names) - Statement extraction edge cases (missing fields, empty predicates) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * chore: remove non-Sigstore NpmProvenanceChecker codepath Delete NpmProvenanceChecker and its tests — production code only uses SigstoreNpmProvenanceChecker (registered in DI), so the non-Sigstore fallback was dead code. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address PR review: type-safe JSON handling and richer error reporting - ExtractSlsaBundleJson now returns 'out bool parseFailed' to distinguish invalid JSON (AttestationParseFailed) from missing SLSA provenance (SlsaProvenanceNotFound) - Add explicit JsonObject type checks when iterating attestation array elements so non-object values (strings, numbers, null) are safely skipped - Replace GetProperty/GetString with TryGetProperty + ValueKind checks in ExtractProvenanceFromResult to handle wrong-typed predicate values without throwing InvalidOperationException - Fix misleading comment about CertificateExtensionPolicy; the actual enforcement is CertificateIdentity.ForGitHubActions SAN/issuer matching - Fix deeply nested JSON test to use valid JSON structure - Add tests for non-object array elements, non-string predicateType, wrong-typed predicate values, and parseFailed assertions Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Apply pattern matching suggestion for JsonArray count check Use property pattern matching (JsonArray { Count: >0 }) instead of separate is-check and Count comparison, as suggested by @DamianEdwards. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Mitch Denny <mitch@mitchdeny.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI
pushed a commit
that referenced
this pull request
Mar 10, 2026
* refactor: use Sigstore attestation helper APIs for provenance checking
Replace manual JSON parsing in SigstoreNpmProvenanceChecker with the
new attestation APIs already available in Sigstore 0.3.0:
- Remove ParseAttestation (~80 lines) and ParseProvenanceFromStatement
(~20 lines) methods and NpmAttestationParseResult class
- Add ExtractSlsaBundleJson to extract bundle JSON from npm response
- Add ExtractProvenanceFromResult using VerificationResult.Statement
(InTotoStatement) and VerifiedIdentity.Extensions (FulcioCertificateExtensions)
- Use bundle.DsseEnvelope.Payload directly instead of manual base64 decode
- Prefer certificate extensions (cryptographically bound) over SLSA
predicate values for source repository and ref
- Fix JsonArray safety: use pattern matching instead of AsArray()
Add comprehensive adversarial/security tests (68 total):
- Malformed JSON attacks (deeply nested, truncated, wrong types, null)
- Attestation structure manipulation (swapped predicates, mixed arrays)
- Provenance spoofing (homoglyph URLs, path traversal, null bytes)
- Build type spoofing (query params, wrong domains, empty values)
- URL parsing edge cases (subdomain attacks, non-absolute URIs)
- WorkflowRefInfo parsing edge cases (path traversal in names)
- Statement extraction edge cases (missing fields, empty predicates)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* chore: remove non-Sigstore NpmProvenanceChecker codepath
Delete NpmProvenanceChecker and its tests — production code only uses
SigstoreNpmProvenanceChecker (registered in DI), so the non-Sigstore
fallback was dead code.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address PR review: type-safe JSON handling and richer error reporting
- ExtractSlsaBundleJson now returns 'out bool parseFailed' to distinguish
invalid JSON (AttestationParseFailed) from missing SLSA provenance
(SlsaProvenanceNotFound)
- Add explicit JsonObject type checks when iterating attestation array
elements so non-object values (strings, numbers, null) are safely skipped
- Replace GetProperty/GetString with TryGetProperty + ValueKind checks
in ExtractProvenanceFromResult to handle wrong-typed predicate values
without throwing InvalidOperationException
- Fix misleading comment about CertificateExtensionPolicy; the actual
enforcement is CertificateIdentity.ForGitHubActions SAN/issuer matching
- Fix deeply nested JSON test to use valid JSON structure
- Add tests for non-object array elements, non-string predicateType,
wrong-typed predicate values, and parseFailed assertions
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Apply pattern matching suggestion for JsonArray count check
Use property pattern matching (JsonArray { Count: >0 }) instead of
separate is-check and Count comparison, as suggested by @DamianEdwards.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Mitch Denny <mitch@mitchdeny.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Refactor
SigstoreNpmProvenanceCheckerto use the attestation helper APIs already available in Sigstore 0.3.0, replacing manual JSON parsing with typed APIs. Also removes the unused non-SigstoreNpmProvenanceCheckercodepath.What changed
Simplified provenance checking (~540 lines removed):
ParseAttestation(~80 lines),ParseProvenanceFromStatement(~20 lines), andNpmAttestationParseResultclass — replaced byExtractSlsaBundleJson(simple bundle extraction) andExtractProvenanceFromResultwhich usesVerificationResult.Statement(auto-populatedInTotoStatement) andVerifiedIdentity.Extensions(parsedFulcioCertificateExtensions)bundle.DsseEnvelope.Payloaddirectly instead of manual base64 decoding from JSONJsonArraysafety: uses pattern matching (is not JsonArray) instead ofAsArray()to gracefully handle wrong JSON typesRemoved dead code:
NpmProvenanceChecker.csandNpmProvenanceCheckerTests.cs— production DI only registeredSigstoreNpmProvenanceChecker, so this was unused codeAdded comprehensive adversarial/security tests (68 total):
Security improvement
Source repository is now verified at two levels:
Fixes # (issue)
Checklist