Skip to content

Commit a5f6023

Browse files
committed
Resolve a bug in OSV related to collecting Cargo vulnerabilities
Signed-off-by: ziad hany <ziadhany2016@gmail.com>
1 parent 4a24324 commit a5f6023

File tree

4 files changed

+97
-2
lines changed

4 files changed

+97
-2
lines changed

vulnerabilities/pipes/osv_v2.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from cvss.exceptions import CVSS3MalformedError
1818
from cvss.exceptions import CVSS4MalformedError
1919
from packageurl import PackageURL
20-
from univers.version_constraint import InvalidConstraintsError
2120
from univers.version_constraint import VersionConstraint
2221
from univers.version_constraint import validate_comparators
2322
from univers.version_range import RANGE_CLASS_BY_SCHEMES
@@ -49,7 +48,7 @@
4948
"rubygems": "gem",
5049
"go": "golang",
5150
"hex": "hex",
52-
"cargo": "cargo",
51+
"crates.io": "cargo",
5352
}
5453

5554

vulnerabilities/tests/pipes/test_osv_v2.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,16 @@ def test_to_advisories_github3(self):
184184
result = imported_data.to_dict()
185185
util_tests.check_results_against_json(result, expected_file)
186186

187+
def test_to_advisories_github4(self):
188+
with open(os.path.join(TEST_DATA, "github/github-4.json")) as f:
189+
mock_response = json.load(f)
190+
expected_file = os.path.join(TEST_DATA, "github/github-expected-4.json")
191+
imported_data = parse_advisory_data_v3(
192+
mock_response, "cargo", advisory_url="https://test.com", advisory_text=""
193+
)
194+
result = imported_data.to_dict()
195+
util_tests.check_results_against_json(result, expected_file)
196+
187197
def test_to_advisories_oss_fuzz1(self):
188198
with open(os.path.join(TEST_DATA, "oss-fuzz/oss-fuzz-1.yaml")) as f:
189199
mock_response = saneyaml.load(f)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"schema_version": "1.4.0",
3+
"id": "GHSA-wjxc-pjx9-4wvm",
4+
"modified": "2024-02-03T00:18:06Z",
5+
"published": "2024-02-03T00:18:06Z",
6+
"aliases": [],
7+
"summary": "Nervos CKB Panic on malformed input",
8+
"details": "### Impact\nCKB process will panic when received malformed p2p message because of snappy, which is used to compress network messages\n\n### References\nhttps://github.com/BurntSushi/rust-snappy/issues/29",
9+
"severity": [],
10+
"affected": [
11+
{
12+
"package": {
13+
"ecosystem": "crates.io",
14+
"name": "ckb"
15+
},
16+
"ranges": [
17+
{
18+
"type": "ECOSYSTEM",
19+
"events": [
20+
{
21+
"introduced": "0"
22+
},
23+
{
24+
"fixed": "0.34.2"
25+
}
26+
]
27+
}
28+
],
29+
"database_specific": {
30+
"last_known_affected_version_range": "<= 0.34.1"
31+
}
32+
}
33+
],
34+
"references": [
35+
{
36+
"type": "WEB",
37+
"url": "https://github.com/nervosnetwork/ckb/security/advisories/GHSA-wjxc-pjx9-4wvm"
38+
}
39+
],
40+
"database_specific": {
41+
"cwe_ids": [],
42+
"severity": "HIGH",
43+
"github_reviewed": true,
44+
"github_reviewed_at": "2024-02-03T00:18:06Z",
45+
"nvd_published_at": null
46+
}
47+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"advisory_id": "GHSA-wjxc-pjx9-4wvm",
3+
"aliases": [],
4+
"summary": "Nervos CKB Panic on malformed input\n### Impact\nCKB process will panic when received malformed p2p message because of snappy, which is used to compress network messages\n\n### References\nhttps://github.com/BurntSushi/rust-snappy/issues/29",
5+
"affected_packages": [
6+
{
7+
"package": {
8+
"type": "cargo",
9+
"namespace": "",
10+
"name": "ckb",
11+
"version": "",
12+
"qualifiers": "",
13+
"subpath": ""
14+
},
15+
"affected_version_range": "vers:cargo/<=0.34.1",
16+
"fixed_version_range": "vers:cargo/0.34.2",
17+
"introduced_by_commit_patches": [],
18+
"fixed_by_commit_patches": []
19+
}
20+
],
21+
"references_v2": [
22+
{
23+
"reference_id": "",
24+
"reference_type": "",
25+
"url": "https://github.com/nervosnetwork/ckb/security/advisories/GHSA-wjxc-pjx9-4wvm"
26+
}
27+
],
28+
"patches": [],
29+
"severities": [
30+
{
31+
"system": "generic_textual",
32+
"value": "HIGH",
33+
"scoring_elements": ""
34+
}
35+
],
36+
"date_published": "2024-02-03T00:18:06+00:00",
37+
"weaknesses": [],
38+
"url": "https://test.com"
39+
}

0 commit comments

Comments
 (0)