Skip to content

Commit 83cb6c4

Browse files
authored
Merge branch 'main' into cve_vulntotal
2 parents 927e851 + 1c9a82c commit 83cb6c4

File tree

8 files changed

+18
-16
lines changed

8 files changed

+18
-16
lines changed

vulntotal/datasources/github.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def supported_ecosystem(cls):
8181
"pypi": "PIP",
8282
"gem": "RUBYGEMS",
8383
"golang": "GO",
84-
"rust": "RUST",
84+
"cargo": "RUST",
8585
"npm": "NPM",
8686
"erlang": "ERLANG",
8787
"pub": "PUB",

vulntotal/datasources/osv.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ def supported_ecosystem(cls):
5252
"golang": "Go",
5353
"nuget": "NuGet",
5454
"pypi": "PyPI",
55-
"rubygems": "RubyGems",
56-
"crates.io": "crates.io",
55+
"gem": "RubyGems",
56+
"cargo": "crates.io",
5757
"composer": "Packagist",
5858
"linux": "Linux",
5959
"oss-fuzz": "OSS-Fuzz",
60-
"debian": "Debian",
60+
"deb": "Debian",
6161
"hex": "Hex",
6262
"android": "Android",
6363
}

vulntotal/datasources/snyk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def supported_ecosystem(cls):
6161
"npm": "npm",
6262
"nuget": "nuget",
6363
"pypi": "pip",
64-
"rubygems": "rubygems",
64+
"gem": "rubygems",
6565
# any purl.type not in supported_ecosystem shall implicitly be treated as unmanaged type
6666
"unmanaged": "unmanaged",
6767
}

vulntotal/datasources/vulnerablecode.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,13 @@ def parse_advisory(fetched_advisory, purl) -> VendorData:
7979
affected_versions = []
8080
fixed_versions = []
8181
for instance in fetched_advisory["affected_packages"]:
82-
affected_versions.append(PackageURL.from_string(instance["purl"]).version)
82+
affected_purl = PackageURL.from_string(instance["purl"])
83+
if affected_purl.type == purl.type:
84+
affected_versions.append(affected_purl.version)
8385
for instance in fetched_advisory["fixed_packages"]:
84-
fixed_versions.append(PackageURL.from_string(instance["purl"]).version)
86+
fixed_purl = PackageURL.from_string(instance["purl"])
87+
if fixed_purl.type == purl.type:
88+
fixed_versions.append(fixed_purl.version)
8589
return VendorData(
8690
purl=PackageURL(purl.type, purl.namespace, purl.name),
8791
aliases=aliases,

vulntotal/tests/test_github.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ def test_generate_graphql_payload_from_purl(self):
2828
"pkg:npm/[email protected]",
2929
"pkg:golang/github.com/cloudflare/[email protected]",
3030
"pkg:composer/symfony/[email protected]",
31-
"pkg:rust/[email protected]",
32-
"pkg:erlang/[email protected]",
31+
"pkg:cargo/[email protected]",
32+
"pkg:hex/[email protected]",
3333
"pkg:gem/[email protected]",
3434
]
3535
results = [

vulntotal/tests/test_osv.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ def test_generate_payload(self):
2525
purls = [
2626
"pkg:pypi/[email protected]",
2727
"pkg:android/System@10",
28-
"pkg:debian:8/[email protected]",
28+
"pkg:deb:8/[email protected]",
2929
"pkg:maven/org.apache.tomcat/[email protected]",
3030
"pkg:linux/[email protected]",
3131
"pkg:packagist/dolibarr/[email protected]",
32-
"pkg:crates.io/[email protected]",
32+
"pkg:cargo/[email protected]",
3333
"pkg:npm/[email protected]",
3434
"pkg:golang/github.com/cloudflare/[email protected]",
3535
]

vulntotal/tests/test_snyk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_generate_package_advisory_url(self):
3030
"pkg:nuget/[email protected]",
3131
"pkg:cocoapods/[email protected]",
3232
"pkg:hex/[email protected]",
33-
"pkg:rubygems/[email protected]",
33+
"pkg:gem/[email protected]",
3434
"pkg:unmanaged/[email protected]",
3535
]
3636
results = [

vulntotal/tests/test_vulnerablecode.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ def test_parse_advisory(self):
2424
advisory_file = self.get_test_loc("advisory.json")
2525
with open(advisory_file) as f:
2626
advisory = json.load(f)
27-
results = [
28-
vulnerablecode.parse_advisory(adv, PackageURL("generic", "namespace", "test")).to_dict()
29-
for adv in advisory
30-
]
27+
input_purl = PackageURL.from_string("pkg:maven/org.apache.tomcat/[email protected]")
28+
results = [vulnerablecode.parse_advisory(adv, input_purl).to_dict() for adv in advisory]
3129
expected_file = self.get_test_loc("parse_advisory-expected.json", must_exist=False)
3230
util_tests.check_results_against_json(results, expected_file)

0 commit comments

Comments
 (0)