Skip to content

fix(parser): reject non-SBOM input instead of silently passing empty report - #68

Merged
dmchaledev merged 1 commit into
mainfrom
fix/parse-validate-input
Aug 7, 2026
Merged

fix(parser): reject non-SBOM input instead of silently passing empty report#68
dmchaledev merged 1 commit into
mainfrom
fix/parse-validate-input

Conversation

@dmchaledev

Copy link
Copy Markdown
Contributor

Closes #21

Problem

parse() accepted any JSON — a package.json passed by mistake, a truncated export, or garbage — and silently returned an empty CycloneDX SBOM. In a CI gate that read "nothing changed" (a false negative).

Fix

  • parse() throws ParseError when input is not a recognized CycloneDX or SPDX document (missing bomFormat/spdxVersion), is invalid JSON, or is not an object (array/null/primitives)
  • CLI's loadSbom wraps it in a clear "Failed to parse" message; verified exit 1

Verification

  • 6 new tests cover rejection paths + valid-document acceptance
  • 106 tests pass, tsc clean

…report

Closes #21

parse() previously accepted any JSON — a package.json passed by mistake,
a truncated export, or garbage — and silently returned an empty CycloneDX
SBOM. In a CI gate that read 'nothing changed' (a false negative).

- parse() now throws ParseError when input is not a recognized CycloneDX
  or SPDX document (missing bomFormat/spdxVersion), is invalid JSON, or
  is not an object (array/null/primitives)
- The CLI's loadSbom already wraps this in a clear 'Failed to parse'
  message; main() exits 1 (verified)
- 6 new tests cover the rejection paths + valid-document acceptance

106 tests pass, tsc clean.
@dmchaledev
dmchaledev merged commit d0e2009 into main Aug 7, 2026
2 checks passed
@dmchaledev
dmchaledev deleted the fix/parse-validate-input branch August 7, 2026 19:24
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.

parse() silently accepts non-SBOM / wrong-format input, producing a false "pass" for CI gates

1 participant