Skip to content

Conversation

@knqyf263
Copy link
Collaborator

@knqyf263 knqyf263 commented Nov 20, 2025

Description

This PR adds support for reading SPDX 2.3 attestations in DSSE envelope format (in-toto attestation).

Key Changes

  • Add FormatAttestSPDXJSON format constant
  • Implement unified decodeAttestationFormat() function that handles both CycloneDX and SPDX attestations
  • Support https://spdx.dev/Document predicate type in rekor.go
  • Add comprehensive unit tests for SPDX attestation detection and decoding

Implementation Details

The implementation follows the existing CycloneDX attestation pattern and reuses the SPDX unmarshaling logic. The attestation format follows the in-toto SPDX predicate specification.

Format Structure

DSSE envelope
  └─ payload (base64-encoded in-toto statement)
      ├─ predicateType: "https://spdx.dev/Document"
      └─ predicate: {SPDX document}

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).

This commit adds support for reading SPDX 2.3 attestations in DSSE
envelope format following the in-toto attestation specification.

Changes:
- Add FormatAttestSPDXJSON format constant
- Implement unified decodeAttestationFormat() function
- Support https://spdx.dev/Document predicate type
- Add comprehensive unit tests

Related issue: aquasecurity#9828
@knqyf263 knqyf263 marked this pull request as ready for review November 20, 2025 09:38
@knqyf263 knqyf263 self-assigned this Nov 20, 2025
Copy link
Contributor

@DmitriyLewen DmitriyLewen left a comment

Choose a reason for hiding this comment

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

LGTM

left small comment

pkg/sbom/sbom.go Outdated

// Check SPDX
if s.PredicateType == in_toto.PredicateSPDX {
if spdxID, ok := m["SPDXID"].(string); ok && strings.HasPrefix(spdxID, "SPDX") {
Copy link
Contributor

Choose a reason for hiding this comment

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

The document SPDXID is always SPDXRef-DOCUMENT
(see https://spdx.github.io/spdx-spec/v2.3/document-creation-information/#63-spdx-identifier-field).
So we can compare the strings directly instead of checking for a prefix.

Change SPDXID validation from prefix check to exact match with
'SPDXRef-DOCUMENT' as per SPDX 2.3 specification.

This addresses the review comment:
aquasecurity#9829 (comment)
@knqyf263 knqyf263 enabled auto-merge November 20, 2025 12:07
Update SPDXID in test SPDX files to use 'SPDXRef-DOCUMENT'
as required by SPDX 2.3 specification.
@knqyf263 knqyf263 added this pull request to the merge queue Nov 21, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 21, 2025
@knqyf263 knqyf263 added this pull request to the merge queue Nov 21, 2025
Merged via the queue into aquasecurity:main with commit d8eaaeb Nov 21, 2025
14 checks passed
@knqyf263 knqyf263 deleted the spdx_predicate branch November 21, 2025 09:04
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(sbom): add support for SPDX attestations

2 participants