Skip to content

feat: support multi-hash SRI strings in dist.integrity - #1546

Closed
trackoor wants to merge 2 commits into
CycloneDX:mainfrom
trackoor:feat/multi-hash-sri
Closed

trackoor wants to merge 2 commits into
CycloneDX:mainfrom
trackoor:feat/multi-hash-sri

Conversation

@trackoor

Copy link
Copy Markdown

Description

dist.integrity may hold several space-separated Subresource Integrity hash expressions, for example sha512-... sha1-... as written by some registries (JFrog Artifactory, Azure Artifacts). ExternalReferenceFactory.makeDist() passed the whole string to parsePackageIntegrity(), which only accepts one hash expression, so such packages got a distribution reference without any hashes.

This adds Contrib.FromNodePackageJson.Utils.parsePackageIntegrities(). It splits the value on whitespace, ignores SRI option expressions (?...), parses each hash expression with the existing parsePackageIntegrity(), and skips unparsable or unknown ones. makeDist() now uses it, so every parsable hash ends up in the reference. parsePackageIntegrity() itself is unchanged, so existing callers keep the single-hash behavior.

Tests:

  • unit tests for parsePackageIntegrities(): single hash, two hashes, extra whitespace and tabs, option expressions, an unknown algorithm next to a known one, an unparsable value, the empty string
  • integration tests for makeDist() with a multi-hash dist.integrity (real digests of concat-map@0.0.1) and with an unparsable one

Resolves or fixes issue: #1544

AI Tool Disclosure

  • My contribution does not include any AI-generated content
  • My contribution includes AI-generated content, as disclosed below:
    • AI Tools: Claude Code
    • LLMs and versions: Claude Opus 5.5
    • Prompts: Add support for space-separated multi-hash SRI strings in dist.integrity, as asked in #1544, without changing parsePackageIntegrity(); add unit and integration tests and a changelog entry.

Affirmation

Add Contrib.FromNodePackageJson.Utils.parsePackageIntegrities(), which parses
space-separated Subresource Integrity hash expressions, ignores option
expressions, and skips unparsable or unknown ones.
ExternalReferenceFactory.makeDist() now uses it, so every parsable hash of a
multi-hash dist.integrity ends up in the distribution reference.
parsePackageIntegrity() keeps its single-hash behavior.

Resolves CycloneDX#1544

Signed-off-by: trackoor <55851864+trackoor@users.noreply.github.com>
Signed-off-by: trackoor <55851864+trackoor@users.noreply.github.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 4 complexity · 0 duplication

Metric Results
Complexity 4
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@read-the-docs-community

Copy link
Copy Markdown

@trackoor trackoor closed this Nov 25, 2026
@jkowalleck

jkowalleck commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

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.

fet: support multi-hash SRI strings in Contrib.FromNodePackageJson.Utils.parsePackageIntegrity

2 participants