Skip to content

Conversation

@RingoDev
Copy link
Contributor

@RingoDev RingoDev commented Sep 23, 2025

Description

Add support for extracting DSSE payloads from Sigstore bundles when processing OCI referrer SBOMs. This enables Trivy to handle SBOM attestations created with newer Cosign versions that use the new sigstore bundle format.

  • Update parseReferrer to handle Sigstore bundle artifact type as referrer artifacts
  • Add extractDSSEFromSigstoreBundle method to parse DSSE envelope out of Sigstore bundles
  • Hand over extracted DSSE envelope to already pre-existing In-Toto attestation parsing of sbom.go
  • Include a test to verify functionality

Related issues

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

Add support for extracting DSSE payloads from Sigstore bundles when processing OCI referrer SBOMs. This enables Trivy to handle SBOM attestations created with newer Cosign versions that use the bundle format.

- Add extractDSSEFromSigstoreBundle method to parse Sigstore bundles
- Update parseReferrer to handle Sigstore bundle artifact type
- Add SigstoreBundleArtifactType constant and include in supported types
- Includes test coverage with test data files
@RingoDev
Copy link
Contributor Author

RingoDev commented Sep 25, 2025

I just saw that it might be a bit cleaner to add a "SigstoreBundle" as a Pseudo SBOM format such as the DSSE -> In-toto -> CycloneDx wrapper here
That would move the Sigstore to DSSE unpacking that I added in remote_sbom here to general SBOM parsing logic and would have the nice benefit that a locally downloaded Sigstore Bundle could also be directly scanned as an SBOM I suppose.

Happy to change the implementation if that would be preferred.

}
defer os.Remove(dsseFilePath)
filePath = dsseFilePath
fmt.Printf("DEBUG: Extracted DSSE to file: %s\n", dsseFilePath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use a.logger.Debug

Comment on lines +160 to +167
tmpFile.Close()
os.Remove(tmpFile.Name())
return "", xerrors.Errorf("failed to write DSSE envelope: %w", err)
}
if err = tmpFile.Close(); err != nil {
os.Remove(tmpFile.Name())
return "", xerrors.Errorf("failed to close temp file: %w", err)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use defer for this?

MediaType string `json:"mediaType"`
}

func (a Artifact) extractDSSEFromSigstoreBundle(bundlePath string) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use temp dir from parseReferrer?

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.

2 participants