Skip to content

Commit 7903b17

Browse files
committed
Fix aosp CI test
Signed-off-by: ziad hany <ziadhany2016@gmail.com>
1 parent 64e477b commit 7903b17

12 files changed

+216
-196
lines changed

vulnerabilities/tests/pipelines/v2_importers/test_commits_aosp_dataset.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
# See https://aboutcode.org for more information about nexB OSS projects.
88
#
99

10-
import os
1110
from pathlib import Path
1211
from unittest.mock import Mock
12+
from unittest.mock import patch
1313

1414
import pytest
1515

@@ -18,11 +18,23 @@
1818

1919
TEST_DATA = Path(__file__).parent.parent.parent / "test_data" / "aosp"
2020

21+
TEST_CVE_FILES = [
22+
TEST_DATA / "CVE-aosp_test1.json",
23+
TEST_DATA / "CVE-aosp_test2.json",
24+
TEST_DATA / "CVE-aosp_test3.json",
25+
TEST_DATA / "CVE-aosp_test4.json",
26+
TEST_DATA / "CVE-aosp_test5.json",
27+
]
28+
2129

2230
@pytest.mark.django_db
23-
def test_aosp_advisories():
24-
expected_file = os.path.join(TEST_DATA, "aosp_advisoryv2-expected.json")
31+
@pytest.mark.parametrize("json_file", TEST_CVE_FILES)
32+
def test_aosp_advisories_per_file(json_file):
2533
pipeline = AospImporterPipeline()
2634
pipeline.vcs_response = Mock(dest_dir=TEST_DATA)
27-
result = [adv.to_dict() for adv in pipeline.collect_advisories()]
35+
36+
with patch.object(Path, "rglob", return_value=[json_file]):
37+
result = [adv.to_dict() for adv in pipeline.collect_advisories()]
38+
39+
expected_file = json_file.with_name(json_file.stem + "-expected.json")
2840
util_tests.check_results_against_json(result, expected_file)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[
2+
{
3+
"advisory_id": "CVE-2021-30294",
4+
"aliases": [],
5+
"summary": "Vulnerability",
6+
"affected_packages": [],
7+
"references_v2": [
8+
{
9+
"reference_id": "",
10+
"reference_type": "commit",
11+
"url": "https://source.codeaurora.org/quic/la/kernel/msm-5.4/commit/?id=d6876813add62f3cac7c429a41cc8710005d69e8"
12+
}
13+
],
14+
"severities": [
15+
{
16+
"system": "generic_textual",
17+
"value": "High",
18+
"scoring_elements": ""
19+
}
20+
],
21+
"date_published": null,
22+
"weaknesses": [],
23+
"url": "https://raw.githubusercontent.com/quarkslab/aosp_dataset/refs/heads/master/cves/CVE-aosp_test1.json"
24+
}
25+
]

vulnerabilities/tests/test_data/aosp/cves/CVE-aosp_test1.json renamed to vulnerabilities/tests/test_data/aosp/CVE-aosp_test1.json

File renamed without changes.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[
2+
{
3+
"advisory_id": "CVE-2017-13282",
4+
"aliases": [],
5+
"summary": "Remote Code Execution Vulnerability",
6+
"affected_packages": [],
7+
"references_v2": [
8+
{
9+
"reference_id": "6ecbbc093f4383e90cbbf681cd55da1303a8ef94",
10+
"reference_type": "commit",
11+
"url": "https://android.googlesource.com/platform/system/bt/+/6ecbbc093f4383e90cbbf681cd55da1303a8ef94"
12+
}
13+
],
14+
"severities": [
15+
{
16+
"system": "generic_textual",
17+
"value": "Critical",
18+
"scoring_elements": ""
19+
}
20+
],
21+
"date_published": "2018-04-04T00:00:00+00:00",
22+
"weaknesses": [],
23+
"url": "https://raw.githubusercontent.com/quarkslab/aosp_dataset/refs/heads/master/cves/CVE-aosp_test2.json"
24+
}
25+
]

vulnerabilities/tests/test_data/aosp/cves/CVE-aosp_test2.json renamed to vulnerabilities/tests/test_data/aosp/CVE-aosp_test2.json

File renamed without changes.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[
2+
{
3+
"advisory_id": "CVE-2015-9016",
4+
"aliases": [],
5+
"summary": "Elevation of Privilege Vulnerability",
6+
"affected_packages": [
7+
{
8+
"package": {
9+
"type": "github",
10+
"namespace": "torvalds",
11+
"name": "linux",
12+
"version": "",
13+
"qualifiers": "",
14+
"subpath": ""
15+
},
16+
"affected_version_range": null,
17+
"fixed_version_range": null,
18+
"introduced_by_commits": [],
19+
"fixed_by_commits": [
20+
{
21+
"commit_hash": "0048b4837affd153897ed1222283492070027aa9",
22+
"vcs_url": "https://github.com/torvalds/linux.git",
23+
"commit_patch": null
24+
}
25+
]
26+
}
27+
],
28+
"references_v2": [],
29+
"severities": [
30+
{
31+
"system": "generic_textual",
32+
"value": "High",
33+
"scoring_elements": ""
34+
}
35+
],
36+
"date_published": "2018-04-05T00:00:00+00:00",
37+
"weaknesses": [],
38+
"url": "https://raw.githubusercontent.com/quarkslab/aosp_dataset/refs/heads/master/cves/CVE-aosp_test3.json"
39+
}
40+
]

vulnerabilities/tests/test_data/aosp/cves/CVE-aosp_test3.json renamed to vulnerabilities/tests/test_data/aosp/CVE-aosp_test3.json

File renamed without changes.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
[
2+
{
3+
"advisory_id": "CVE-2014-9322",
4+
"aliases": [],
5+
"summary": "Elevation of Privilege Vulnerability",
6+
"affected_packages": [],
7+
"references_v2": [
8+
{
9+
"reference_id": "c22e479e335628ce8766cfbf06e2ba17e8f9a1bb",
10+
"reference_type": "commit",
11+
"url": "https://android.googlesource.com/kernel/common/+/c22e479e335628ce8766cfbf06e2ba17e8f9a1bb"
12+
},
13+
{
14+
"reference_id": "1b627d4e5e61e89b840f77abb3ca6711ad6ffbeb",
15+
"reference_type": "commit",
16+
"url": "https://android.googlesource.com/kernel/common/+/1b627d4e5e61e89b840f77abb3ca6711ad6ffbeb"
17+
},
18+
{
19+
"reference_id": "4c941665c7368a34b146929b31949555e680a4ee",
20+
"reference_type": "commit",
21+
"url": "https://android.googlesource.com/kernel/common/+/4c941665c7368a34b146929b31949555e680a4ee"
22+
},
23+
{
24+
"reference_id": "758f0dac9104b46016af98304656a0268ac3e105",
25+
"reference_type": "commit",
26+
"url": "https://android.googlesource.com/kernel/common/+/758f0dac9104b46016af98304656a0268ac3e105"
27+
},
28+
{
29+
"reference_id": "44d057a37868a60bc2eb6e7d1dcea701f234d56a",
30+
"reference_type": "commit",
31+
"url": "https://android.googlesource.com/kernel/common/+/44d057a37868a60bc2eb6e7d1dcea701f234d56a"
32+
},
33+
{
34+
"reference_id": "b9b9f908c8ae82b73b9d75181982028b6bc06c2b",
35+
"reference_type": "commit",
36+
"url": "https://android.googlesource.com/kernel/common/+/b9b9f908c8ae82b73b9d75181982028b6bc06c2b"
37+
},
38+
{
39+
"reference_id": "e068734f9e7344997a61022629b92d142a985ab3",
40+
"reference_type": "commit",
41+
"url": "https://android.googlesource.com/kernel/common/+/e068734f9e7344997a61022629b92d142a985ab3"
42+
},
43+
{
44+
"reference_id": "fdc6c1052bc7d89a5826904fbb4318677e8442ce",
45+
"reference_type": "commit",
46+
"url": "https://android.googlesource.com/kernel/common/+/fdc6c1052bc7d89a5826904fbb4318677e8442ce"
47+
},
48+
{
49+
"reference_id": "211d59c0034ec9d88690c750ccd6da27f6952dc5",
50+
"reference_type": "commit",
51+
"url": "https://android.googlesource.com/kernel/common/+/211d59c0034ec9d88690c750ccd6da27f6952dc5"
52+
},
53+
{
54+
"reference_id": "c9e31d5a4747e9967ace6d05896c78516c4c0850",
55+
"reference_type": "commit",
56+
"url": "https://android.googlesource.com/kernel/common/+/c9e31d5a4747e9967ace6d05896c78516c4c0850"
57+
},
58+
{
59+
"reference_id": "e01834bfbafd25fd392bf10014451c4e5f34f829",
60+
"reference_type": "commit",
61+
"url": "https://android.googlesource.com/kernel/common/+/e01834bfbafd25fd392bf10014451c4e5f34f829"
62+
}
63+
],
64+
"severities": [
65+
{
66+
"system": "generic_textual",
67+
"value": "Critical",
68+
"scoring_elements": ""
69+
}
70+
],
71+
"date_published": "2015-12-25T00:00:00+00:00",
72+
"weaknesses": [],
73+
"url": "https://raw.githubusercontent.com/quarkslab/aosp_dataset/refs/heads/master/cves/CVE-aosp_test4.json"
74+
}
75+
]

vulnerabilities/tests/test_data/aosp/cves/CVE-aosp_test4.json renamed to vulnerabilities/tests/test_data/aosp/CVE-aosp_test4.json

File renamed without changes.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[
2+
{
3+
"advisory_id": "CVE-2017-13077",
4+
"aliases": [],
5+
"summary": "Elevation of Privilege Vulnerability",
6+
"affected_packages": [],
7+
"references_v2": [
8+
{
9+
"reference_id": "c66556ca2473620df9751e73eb97ec50a40ffd3e",
10+
"reference_type": "commit",
11+
"url": "https://android.googlesource.com/platform/external/wpa_supplicant_8/+/c66556ca2473620df9751e73eb97ec50a40ffd3e"
12+
},
13+
{
14+
"reference_id": "",
15+
"reference_type": "commit",
16+
"url": "https://source.codeaurora.org/quic/la/platform/vendor/qcom-opensource/wlan/qcacld-3.0/commit/?id=776f17c87599fae3202e69bb5718ac9062f14695"
17+
},
18+
{
19+
"reference_id": "",
20+
"reference_type": "commit",
21+
"url": "https://source.codeaurora.org/quic/la/platform/vendor/qcom-opensource/wlan/qcacld-2.0/commit/?id=edb507885fc47cf3cdf061bfba1dc77451a6a332"
22+
}
23+
],
24+
"severities": [
25+
{
26+
"system": "generic_textual",
27+
"value": "High",
28+
"scoring_elements": ""
29+
}
30+
],
31+
"date_published": "2017-10-17T00:00:00+00:00",
32+
"weaknesses": [],
33+
"url": "https://raw.githubusercontent.com/quarkslab/aosp_dataset/refs/heads/master/cves/CVE-aosp_test5.json"
34+
}
35+
]

0 commit comments

Comments
 (0)