Skip to content

fix: allow alternate scheme on url->licenseID lookup#4588

Merged
spiffcs merged 4 commits intomainfrom
license-lookup-http-or-https
Jan 30, 2026
Merged

fix: allow alternate scheme on url->licenseID lookup#4588
spiffcs merged 4 commits intomainfrom
license-lookup-http-or-https

Conversation

@spiffcs
Copy link
Contributor

@spiffcs spiffcs commented Jan 30, 2026

Description

Update url -> SPDXID lookup to try both http/https.

#4244 asked for http mapping -> BSD-3-Clause

This is because the SPDX license list only supported HTTPS for the lookup:
https://github.com/spdx/license-list-XML/blob/297da51b1b0ea5aab7de4a35faea34ffc43323a0/src/BSD-3-Clause.xml#L5-L9

Rather than add both schemes to the upstream list or manage our own internal map we update the lookup logic to just try both http/https given typos and manual editing that happens for License URL data in the various package managers and software license data.

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

  • I have added unit tests that cover changed behavior
  • I have tested my code in common scenarios and confirmed there are no regressions
  • I have added comments to my code, particularly in hard-to-understand sections

Fixes: #4233

Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
@spiffcs spiffcs changed the title chore: lookup alternate scheme on url->licenseID fix: lookup alternate scheme on url->licenseID Jan 30, 2026
@kzantow
Copy link
Contributor

kzantow commented Jan 30, 2026

I haven't reviewed the code specifically, but could we just trim the http/https:// prefix in the URL list and when looking it up? It would reduce the binary size every so slightly

@spiffcs
Copy link
Contributor Author

spiffcs commented Jan 30, 2026

I haven't reviewed the code specifically,

@kzantow we're not generating a new list with both https/http. We're simply trying both on the lookup.
I can rewrite the generation to trim the prefix from the map and then do a trim to do the lookup as well but that's a larger change.

@kzantow
Copy link
Contributor

kzantow commented Jan 30, 2026

Right, I'm suggesting we do that -- update the generation to trim http:// and https://, this way we can avoid creating new strings to do the alternate lookups every time, though acknowledge it's a minor optimization, but avoids creation and 2 lookups in cases where the URL isn't in the list at all, which probably is very common.

Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
Copy link
Contributor

@kzantow kzantow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
Copy link
Contributor

@kzantow kzantow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still 👍

@spiffcs spiffcs merged commit c94d1cc into main Jan 30, 2026
10 checks passed
@spiffcs spiffcs deleted the license-lookup-http-or-https branch January 30, 2026 19:25
@spiffcs spiffcs changed the title fix: lookup alternate scheme on url->licenseID fix: allow alternate scheme on url->licenseID lookup Jan 30, 2026
@spiffcs spiffcs added the enhancement New feature or request label Jan 30, 2026
spiffcs added a commit to patrickpichler/syft that referenced this pull request Jan 30, 2026
* main: (114 commits)
  fix: lookup alternate scheme on url->licenseID (anchore#4588)
  chore(deps): bump the go-minor-patch group with 2 updates (anchore#4583)
  feat: add Qt6 binary detection (anchore#4550)
  chore(deps): bump the actions-minor-patch group across 1 directory with 2 updates (anchore#4584)
  fix: snap cataloger incorrectly identifies snap container as deb package (anchore#4500)
  chore(deps): update tools to latest versions (anchore#4577)
  fix: update mixed case dependencies in python to be normalized (anchore#4573)
  chore(deps): update anchore dependencies (anchore#4575)
  chore(deps): update tools to latest versions (anchore#4570)
  feat: detect Debian version from /etc/debian_version (anchore#4569)
  fix: correctly report supporting evidence for binary packages (anchore#4558)
  chore(deps): bump the actions-minor-patch group across 2 directories with 3 updates (anchore#4568)
  chore(deps): bump the go-minor-patch group with 6 updates (anchore#4567)
  chore(deps): update tools to latest versions (anchore#4565)
  chore(deps): bump github.com/spdx/tools-golang (anchore#4557)
  ci: enable zizmor to fail PRs (anchore#4556)
  Chore new slack action (anchore#4553)
  chore(deps): update anchore dependencies (anchore#4552)
  chore(deps): update tools to latest versions (anchore#4551)
  chore(deps): update tools to latest versions (anchore#4545)
  ...

Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong format in license

2 participants