Skip to content

Deduplicate OSV and YAML reports in golang_vulndb importer (#2520) - #2544

Open
sumitkhond111-del wants to merge 1 commit into
aboutcode-org:mainfrom
sumitkhond111-del:fix-golang-vulndb-2520
Open

sumitkhond111-del wants to merge 1 commit into
aboutcode-org:mainfrom
sumitkhond111-del:fix-golang-vulndb-2520

Conversation

@sumitkhond111-del

Copy link
Copy Markdown

Fixes #2520

Summary

  • Updated GolangVulndbImporterPipeline.collect_advisories() and advisories_count() in vulnerabilities/pipelines/v2_importers/golang_vulndb_importer.py to import data/reports/*.yaml (which retains cve_metadata.cwe weaknesses and pkg.go.dev/vuln/GO-... references) and only fall back to data/osv/*.json when no matching YAML report exists, preventing duplicate AdvisoryV2 rows per GO- vulnerability.
  • Added test_collect_advisories_deduplicates_osv_and_report in vulnerabilities/tests/pipelines/v2_importers/test_golang_vulndb_importer_v2.py.

Testing

  • pytest vulnerabilities/tests/pipelines/v2_importers/test_golang_vulndb_importer_v2.py -q → 9 passed.

@Jean-Regis-M Jean-Regis-M left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for picking up #2520. I ran both converters from this branch over all 4,885 IDs in golang/vulndb (d8a8b1a). Aliases, version ranges, references and dates survive the switch to reports, but 45 IDs change package name, e.g. GO-2021-0068:

source purl
data/osv pkg:golang/toolchain
data/reports pkg:golang/cmd

Reports call the module cmd, while the generated OSV files call it toolchain. golang_module_to_purl already translates std to stdlib, but there's no equivalent for cmd. On main the OSV row still carries toolchain; here it is skipped, so a lookup for pkg:golang/toolchain loses those 45.

This fixes it, and the comparison then shows no differences:

    if module_path == "cmd":
        module_path = "toolchain"
    elif module_path == "std":
        module_path = "stdlib"

A cmd module case in the new test would keep it that way.

Tests: tests/pipelines/v2_importers on Windows with PostgreSQL 17 gives 202 passed, 8 failed here and 201 passed, 8 failed on 9a9c9b3, same failing names (two golang ones are backslashes in the advisory URL).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

golang_vulndb importer stores two advisories per Go vulnerability (OSV and report share one avid)

2 participants