Skip to content

fix(parser): treat SPDX NOASSERTION/NONE version & supplier as unknown#55

Open
dmchaledev wants to merge 1 commit into
mainfrom
claude/magical-ptolemy-vqy2um
Open

fix(parser): treat SPDX NOASSERTION/NONE version & supplier as unknown#55
dmchaledev wants to merge 1 commit into
mainfrom
claude/magical-ptolemy-vqy2um

Conversation

@dmchaledev

Copy link
Copy Markdown
Contributor

Summary

SPDX SBOM generators (syft, and many others) routinely emit the spec sentinels NOASSERTION and NONE for package fields they can't determine. parseSPDX() stored these strings verbatim in Component.version and Component.supplier, so the sentinel leaked into the diff as if it were real data.

The concrete failure is in the tool's headline output — upgrade detection. A package whose version is NOASSERTION in the old SBOM and a real version in the new one is reported as a bogus upgrade:

Before (real CLI output, internal-lib has versionInfo: "NOASSERTION""2.0.0"):

↑ Upgraded Components:
  ~ internal-lib: NOASSERTION → 2.0.0

NOASSERTION means "the version was never asserted" — we do not know the old version, so we cannot claim it was upgraded. This is noise that undermines a CI gate / audit report.

After: the sentinel collapses to undefined, and diff()'s existing "both versions known" guard (aComp.version && bComp.version, src/diff.ts:23) correctly skips it — no spurious upgrade.

Changes

  • src/parser.ts: new normalizeSPDXValue() helper treats NOASSERTION, NONE, and empty/whitespace strings as "no value" (undefined). Applied to versionInfo and supplier in parseSPDX().
  • src/__tests__/parser.test.ts: adds coverage for sentinel normalization and for the no-spurious-upgrade behavior end-to-end through diff().

Scope / relationship to other work

Intentionally narrow and confined to parseSPDX(). License normalization for NOASSERTION is a separate concern already handled by #32, so this PR deliberately leaves licenseConcluded untouched to avoid conflict. It also doesn't overlap with the in-flight purl-keying / upgrade-detection PRs — it fixes a distinct data-quality bug at the parse layer.

Testing

  • npx tsc --noEmit — clean
  • npm run lint — clean
  • npm test — 40 passed (3 new)

Backward compatible: only previously-NOASSERTION/NONE/empty version and supplier values change (from a meaningless string to undefined); any concrete value is unaffected.

🤖 Generated with Claude Code


Generated by Claude Code

SPDX generators frequently emit the spec sentinels "NOASSERTION" (and
"NONE") for fields they can't determine. parseSPDX stored these verbatim,
so a package with versionInfo "NOASSERTION" in the old SBOM and a real
version in the new one was reported as a spurious upgrade
("NOASSERTION -> 2.0.0"), corrupting the tool's headline output.

Normalize these sentinels (and empty strings) to undefined for the
version and supplier fields, so the diff's "both versions known" guard
correctly skips packages whose prior version was never asserted. License
normalization is intentionally left to PR #32.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HvD9bHmeu7mjeUpLNKzovy
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