Repository navigation
Deduplicate OSV and YAML reports in golang_vulndb importer (#2520) - #2544
sumitkhond111-del wants to merge 1 commit into
Conversation
…-org#2520) Signed-off-by: sumitkhond111-del <[email protected]>
Jean-Regis-M
left a comment
There was a problem hiding this comment.
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).
Fixes #2520
Summary
GolangVulndbImporterPipeline.collect_advisories()andadvisories_count()invulnerabilities/pipelines/v2_importers/golang_vulndb_importer.pyto importdata/reports/*.yaml(which retainscve_metadata.cweweaknesses andpkg.go.dev/vuln/GO-...references) and only fall back todata/osv/*.jsonwhen no matching YAML report exists, preventing duplicateAdvisoryV2rows perGO-vulnerability.test_collect_advisories_deduplicates_osv_and_reportinvulnerabilities/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.