Skip to content

Accept SPDX 3.0 patch releases above 3.0.1 - #434

Open
aurangzaib048 wants to merge 5 commits into
sbomify:masterfrom
aurangzaib048:fix/accept-spdx-3-0-patches
Open

aurangzaib048 wants to merge 5 commits into
sbomify:masterfrom
aurangzaib048:fix/accept-spdx-3-0-patches

Conversation

@aurangzaib048

Copy link
Copy Markdown
Contributor

What was wrong
SPDX_SCHEMAS is keyed by exact version, so a 3.0.2 document matched no schema and was refused as unsupported. The sbomify backend checks the same document against the 3.0.1 schema and accepts it. The upload tool refused a document the upload endpoint takes.

The fix
A 3.0 patch above the newest bundled one uses the 3.0.1 schema, unchanged, as the backend does. The schema's @context pin stays on the 3.0.1 URL, so a 3.0.2 document that keeps the 3.0.1 context passes, and one that declares a 3.0.2 context is refused on both ends. The SPEC_VERSION hint offers SBOM_FILE for such a version too.

Verified
A 3.0.2 document with the 3.0.1 context validates, which is what the backend's own 3.0.2 test sends. A 3.0.2 context is refused with a schema error, not "not supported", and a schema violation still fails. The acceptance test fails on master.

SPDX_SCHEMAS is keyed by exact version, so a 3.0.2 document matched no
schema and was refused as unsupported, while the sbomify backend holds
the same document to the 3.0.1 schema and accepts it.

A 3.0 patch above the newest bundled one now uses the 3.0.1 schema. That
schema pins @context to the 3.0.1 URL, so for these documents the pin
accepts the document's own patch context as well, and nothing else. The
SPEC_VERSION hint now offers SBOM_FILE for such a version too.
Match the backend exactly. A 3.0 patch above 3.0.1 is held to the 3.0.1
schema unchanged, so it passes while it keeps the 3.0.1 context and is
refused when it declares a later patch context, as the backend refuses
it.
Copilot AI lite review requested due to automatic review settings September 28, 2026 13:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

Review effort: Lite
Findings: 2 Medium severity

Open (2)
What changed in this PR

Aligns SPDX 3.0.x patch handling with the sbomify backend so newer 3.0 patch documents (e.g., 3.0.2) validate against the newest bundled 3.0 schema instead of being rejected as “unsupported”.

Changes:

  • Add SPDX schema version resolution to map later 3.0 patch spec versions to the bundled 3.0.1 schema.
  • Update CLI hinting so later 3.0 patches are offered SBOM_FILE guidance.
  • Add/adjust tests and documentation to cover/describe later SPDX 3.0 patch acceptance behavior.
File Description
sbomify_action/​validation.py Introduces spdx_schema_version() and uses it to pick a schema for later SPDX 3.0 patch versions.
sbomify_action/​cli/​main.py Uses schema resolution logic to decide whether to offer SBOM_FILE for SPDX 3.x versions.
tests/​test_validation.py Adds acceptance tests for SPDX 3.0.2 held to the 3.0.1 schema/context rules.
tests/​test_config.py Ensures CLI error text offers SBOM_FILE guidance for SPDX 3.0.2.
README.md Documents that SPDX 3.0.1 and later 3.0 patches are accepted for JSON-LD uploads.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread sbomify_action/validation.py Outdated
Comment thread sbomify_action/validation.py Outdated
Copilot AI review requested due to automatic review settings September 29, 2026 08:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

User-facing docs and CLI hints should explicitly mention the pinned @context requirement for later SPDX 3.0.x patches to avoid misleading users into thinking any 3.0.2 document will validate.

Review effort: Lite
Findings: 1 Medium severity · 2 Low severity

Open (3)
Resolved since last review (2)

Comment thread sbomify_action/cli/main.py
Comment thread README.md Outdated
Comment thread sbomify_action/validation.py Outdated
A 3.0 patch above the newest bundled one is held to the newest bundled
schema, which pins @context to its own URL. The configuration hint offered
SBOM_FILE for such a version without saying so, and the README listed
"later 3.0 patches" with no condition, so a 3.0.2 document declaring the
3.0.2 context would hit a schema error neither had warned about.

The hint now adds, only when the requested version maps to an older
bundled schema, that an SBOM_FILE at that version validates only if it
keeps that schema's @context. The README row states the same condition.
The comment on the patch mapping no longer names 3.0.1, since the newest
bundled schema is derived and will move when another is bundled.
Copilot AI lite review requested due to automatic review settings October 15, 2026 08:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The SPDX 3.0 patch schema-mapping behavior is implemented consistently across validation and CLI messaging, with targeted tests and documentation updates covering the intended acceptance rules.

0 open findings

3 resolved since last review

🧠 Review effort: Lite

@aurangzaib048

Copy link
Copy Markdown
Contributor Author

@vpetersson-bot could you review this one? Copilot has no open findings on the current head and CI is green.

@vpetersson-bot vpetersson-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@aurangzaib048 this looks correct to me. Approving.

What I checked on c0d54aa:

  • spdx_schema_version maps 3.0.0 and 3.0.1 to themselves, any 3.0.N with N >= 1 to the newest bundled 3.0 schema, and returns None for 3.0.02, 3.0.2-rc1, 3.1 and whitespace-padded input. _NEWEST_SPDX30 comes from the registry, so bundling 3.0.2 later moves it without any further edits.
  • A 3.0.2 document that keeps the 3.0.1 @context validates. If you parse it with parse_spdx3_file and write it back out with write_spdx3_file, which is the augmentation path, it keeps the 3.0.1 context and specVersion: 3.0.2 and still validates. So augmenting it doesn't break validation further down.
  • The new acceptance tests in tests/test_validation.py and tests/test_config.py fail when I run them against master's sbomify_action/, and they pass on this branch.
  • Locally, ruff check, ruff format --check and mypy are clean, and the validation, config and schema-compliance tests pass (166). On the full suite, 3889 pass. Three fail, and none of them comes from this PR: two uv build tests in test_tool_manifest.py hit a problem with my host's uv setup, and test_generate_uses_first_matching_generator needs cdxgen/syft, which I don't have installed. That last one fails on master too.

Two non-blocking nits:

  1. sbomify_action/validation.py:307: the success log says "validated successfully against SPDX 3.0.2 schema", but the schema actually used was 3.0.1. Logging the resolved schema version, e.g. "SPDX 3.0.2 (3.0.1 schema)", would be more accurate when someone is debugging a context-pin failure.
  2. tests/test_validation.py:481: result.error_message or "" would also pass if the result were skipped (valid is None). Adding self.assertIs(result.valid, False) would make the test confirm the document got as far as schema validation.

The branch is 2 commits behind master (the urllib3 bump), and GitHub reports it as mergeable.

aurangzaib048 added a commit to aurangzaib048/sbomify-github-action that referenced this pull request Oct 21, 2026
This branch checks every SPDX 3 document against its schema before upload. Without sbomify#434, a 3.0.2 or later document has no bundled schema, so the check would hold back a document the backend accepts. Merging sbomify#434 here means the two land together, whichever merges first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
aurangzaib048 added a commit to aurangzaib048/sbomify-github-action that referenced this pull request Oct 21, 2026
The check this branch adds would hold back a 3.0.2 document under the 3.0.1 @context without sbomify#434's acceptance. This pins the two together: it fails if either half goes missing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

No deployments
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.

3 participants