fix(parser): exclude the SPDX document subject from components#39
Open
dmchaledev wants to merge 1 commit into
Open
fix(parser): exclude the SPDX document subject from components#39dmchaledev wants to merge 1 commit into
dmchaledev wants to merge 1 commit into
Conversation
SPDX documents list their own root/subject package (the application being described) inside `packages[]`. `parseSPDX` mapped every package into `components`, so a release-to-release diff of the same app reported the app itself as a spurious component change — typically a "[MAJOR] upgrade" whose version bumps on every release, drowning out the real dependency deltas. CycloneDX already keeps its subject (`metadata.component`) out of `components`; this brings SPDX into line. The document's subject is identified via the `documentDescribes` shortcut and/or a `DESCRIBES` relationship from `SPDXRef-DOCUMENT` (and its `DESCRIBED_BY` inverse). Packages are only excluded when the SBOM explicitly marks them as the subject, so documents that declare no root are unaffected. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RrdcuDGmzaQ6s8JqCbGTs8
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.
Summary
SPDX documents list their own root/subject package — the application the SBOM describes — inside
packages[].parseSPDXmapped every package intocomponents(src/parser.ts), so a release‑to‑release diff of the same app reports the app itself as a spurious component change. Because the subject'sversionInfobumps on every release, this shows up as a[MAJOR]"upgrade" of the application on essentially every SPDX diff, drowning out the real dependency deltas.CycloneDX already keeps its subject (
metadata.component) out ofcomponents; this brings SPDX into line so both formats diff dependencies, not the artifact being described.Reproduction (before this change)
Two SPDX SBOMs of the same app,
1.0.0→2.0.0, with onlylodashunchanged:The application is reported as the only "change," even though no dependency moved. After this change the same inputs produce an empty (accurate) dependency diff.
Change
parseSPDXnow filters out the document subject before mapping packages to components.documentDescribesshortcut array (SPDX 2.2+), and/orDESCRIBESrelationship fromSPDXRef-DOCUMENT(plus itsDESCRIBED_BYinverse).Tests
Added to
src/__tests__/parser.test.ts:documentDescribesis excluded;DESCRIBESrelationship is excluded;All existing tests still pass (
32 passed), andlint/typecheck/buildare green.Scope
Parser‑localized and orthogonal to the open diff/reporter/CLI work — no open issue or PR addresses SPDX subject exclusion.
🤖 Generated with Claude Code
https://claude.ai/code/session_01RrdcuDGmzaQ6s8JqCbGTs8
Generated by Claude Code