fix(cyclonedx): dedupe advisory URLs using canonical URIs#10877
Open
h4r7w3l1 wants to merge 1 commit into
Open
fix(cyclonedx): dedupe advisory URLs using canonical URIs#10877h4r7w3l1 wants to merge 1 commit into
h4r7w3l1 wants to merge 1 commit into
Conversation
|
|
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.
Description
This PR canonicalizes CycloneDX advisory URLs before deduplication.
CycloneDX advisories were previously deduplicated using raw URL strings. Equivalent URI references from different advisory sources could therefore survive as separate advisory entries when the same advisory URL was provided using different path encodings.
For example, these synthetic references identify the same semantic URI path but differ as raw strings:
Before this change, these values could be emitted as separate CycloneDX advisory entries.
The root cause is that advisory URLs were deduplicated before URI canonicalization. A simple
url.Parse(raw).String()roundtrip is not sufficient here because Go may preserveRawPath, causing equivalent paths such as:to remain serialized differently.
This PR fixes the issue by canonicalizing advisory URLs before deduplication:
url.URLfrom decoded URL components.RawPath.String().The change is intentionally limited to CycloneDX advisory output. It does not change JSON report generation, vulnerability database records, upstream reference collection, SPDX output, or non-SBOM vulnerability reporting.
Before:
[ { "url": "https://lists.apache.org/thread.html/example%40%3Cdev.apache.org%3E" }, { "url": "https://lists.apache.org/thread.html/example@%3Cdev.apache.org%3E" }, { "url": "https://lists.apache.org/thread.html/example@<dev.apache.org>" } ]After:
[ { "url": "https://lists.apache.org/thread.html/example@%3Cdev.apache.org%3E" } ]The output no longer contains raw
<or>characters in advisory URLs.Tests added cover:
PrimaryURLandReferences<or>charactersTest command:
GOEXPERIMENT=jsonv2 go test -vet=off ./pkg/sbom/cyclonedx/...Result:
Note: without
GOEXPERIMENT=jsonv2, this checkout fails to compile due to the repository'sencoding/json/v2dependency. The failure is unrelated to this change.Related issues
N/A
Checklist