Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

fix(vulnfeeds): normalize malformed git reference URLs - #6441

Open
jess-lowe wants to merge 2 commits into
google:masterfrom
jess-lowe:fix/normalize-reference-urls
Open

jess-lowe wants to merge 2 commits into
google:masterfrom
jess-lowe:fix/normalize-reference-urls

Conversation

@jess-lowe

Copy link
Copy Markdown
Contributor

Overview

Normalizes malformed and SCP-style Git reference URLs (such as git://git@gitlab.com:gitlab-org/gitlab.git) to valid https:// URIs and drops non-URI reference strings in vulns.ClassifyReferences.

This resolves ~417 SCH:001 (references.0.url: Does not match format 'uri') cve-osv linter findings caused by GitLab CVE5 affected[].repo entries being copied verbatim into OSV references.

Note: This pull request was developed with AI assistance.

Details

  • Added vulns.NormalizeReferenceURL in vulnfeeds/vulns/vulns.go to:
    • Trim surrounding whitespace.
    • Rewrite malformed scheme + SCP-style Git URLs (git://, ssh://, git+ssh:// with git@<host>:<non-port-path>) and bare SCP-style Git URLs (git@<host>:<path>) to https://<host>/<path>, while preserving valid ssh://git@host:<port>/... and git://host/... URIs.
    • Validate the resulting URL against the OSV JSON schema uri format requirements (url.Parse, non-empty scheme, no backslashes) and skip invalid URIs.
  • Updated vulns.ClassifyReferences (used by both cve5 and nvd converters) to classify and deduplicate references using normalized URLs without altering ReposFromReferencesCVEList repo derivation or combine-to-osv repo matching.

Testing

  • Added unit tests in vulnfeeds/vulns/vulns_test.go (TestNormalizeReferenceURL and cases in TestClassifyReferences) covering valid URIs, malformed/bare SCP Git URLs, numeric ports vs. digit-prefixed org names, whitespace, and invalid URIs.
  • Added a regression test in vulnfeeds/conversion/cve5/converter_test.go (TestFromCVE5_NormalizesMalformedGitRepoRef) against the real CVE-2025-1110 GitLab CVE5 fixture.
  • Ran go test ./... and golangci-lint@v2.14.0 run ./... in vulnfeeds/ — all tests pass with 0 lint issues.

@codecov-commenter

codecov-commenter commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.86%. Comparing base (51cc587) to head (0bcdfc9).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6441      +/-   ##
==========================================
+ Coverage   55.83%   55.86%   +0.03%     
==========================================
  Files         223      223              
  Lines       22984    22999      +15     
==========================================
+ Hits        12833    12849      +16     
+ Misses      10148    10147       -1     
  Partials        3        3              
Flag Coverage Δ
vulnfeeds 46.70% <100.00%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jess-lowe
jess-lowe marked this pull request as ready for review November 24, 2026 05:39
@jess-lowe
jess-lowe requested review from a team and another-rex November 24, 2026 05:39

@another-rex another-rex left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, AI found some extra test cases to add

Comment thread vulnfeeds/vulns/vulns.go Resolved
Comment thread vulnfeeds/vulns/vulns.go Resolved
Comment thread vulnfeeds/vulns/vulns_test.go Resolved
Comment thread vulnfeeds/vulns/vulns_test.go Resolved
@jess-lowe
jess-lowe requested review from a team and another-rex November 26, 2026 05:17

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants