Skip to content

Commit 3ebb0fe

Browse files
committed
Add extra unit test for the OSV-Scanner support
Signed-off-by: tdruez <[email protected]>
1 parent 1a15f87 commit 3ebb0fe

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
3+
"bomFormat": "CycloneDX",
4+
"specVersion": "1.5",
5+
"version": 1,
6+
"components": [
7+
{
8+
"bom-ref": "pkg:composer/league/[email protected]",
9+
"type": "library",
10+
"name": "league/flysystem",
11+
"version": "1.0.8",
12+
"licenses": [],
13+
"purl": "pkg:composer/league/[email protected]"
14+
},
15+
{
16+
"bom-ref": "pkg:npm/[email protected]",
17+
"type": "library",
18+
"name": "has-flag",
19+
"version": "4.0.0",
20+
"licenses": [],
21+
"purl": "pkg:npm/[email protected]"
22+
},
23+
{
24+
"bom-ref": "pkg:npm/[email protected]",
25+
"type": "library",
26+
"name": "wrappy",
27+
"version": "1.0.2",
28+
"licenses": [],
29+
"purl": "pkg:npm/[email protected]"
30+
}
31+
],
32+
"vulnerabilities": [
33+
{
34+
"id": "GHSA-9f46-5r25-5wfm",
35+
"references": [
36+
{
37+
"id": "CVE-2021-32708",
38+
"source": {}
39+
}
40+
],
41+
"ratings": [
42+
{
43+
"method": "CVSSv3",
44+
"vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
45+
}
46+
],
47+
"description": "Time-of-check Time-of-use (TOCTOU) Race Condition in league/flysystem",
48+
"detail": "### Impact\n\nThe whitespace normalisation using in 1.x and 2.x removes any unicode whitespace. Under certain specific conditions this could potentially allow a malicious user to execute code remotely.\n\nThe conditions: \n\n- A user is allowed to supply the path or filename of an uploaded file.\n- The supplied path or filename is not checked against unicode chars.\n- The supplied pathname checked against an extension deny-list, not an allow-list.\n- The supplied path or filename contains a unicode whitespace char in the extension.\n- The uploaded file is stored in a directory that allows PHP code to be executed.\n\nGiven these conditions are met a user can upload and execute arbitrary code on the system under attack.\n\n### Patches\n\nThe unicode whitespace removal has been replaced with a rejection (exception).\n\nThe library has been patched in:\n- 1.x: https://github.com/thephpleague/flysystem/commit/f3ad69181b8afed2c9edf7be5a2918144ff4ea32\n- 2.x: https://github.com/thephpleague/flysystem/commit/a3c694de9f7e844b76f9d1b61296ebf6e8d89d74\n\n### Workarounds\n\nFor 1.x users, upgrade to 1.1.4. For 2.x users, upgrade to 2.1.1.\n",
49+
"advisories": [
50+
{
51+
"url": "https://nvd.nist.gov/vuln/detail/CVE-2021-32708"
52+
}
53+
],
54+
"published": "2021-06-29T03:13:28Z",
55+
"updated": "2024-02-16T08:21:35Z",
56+
"credits": {
57+
"organizations": []
58+
},
59+
"affects": [
60+
{
61+
"ref": "pkg:composer/league/[email protected]"
62+
}
63+
]
64+
}
65+
]
66+
}

scanpipe/tests/test_sca_integrations.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,24 @@ def test_scanpipe_scan_integrations_load_sbom_osv_scanner(self):
164164
self.assertEqual(16, project1.discoveredpackages.count())
165165
self.assertEqual(0, project1.discoveredpackages.vulnerable().count())
166166
self.assertEqual(15, project1.discovereddependencies.count())
167+
168+
def test_scanpipe_scan_integrations_load_sbom_osv_scanner_cdx_vulnerabilities(self):
169+
# Input file taken from: https://google.github.io/osv-scanner/output/#cyclonedx
170+
input_location = (
171+
self.data / "sca-integrations" / "osv-scanner-vulns-sbom.cdx.json"
172+
)
173+
174+
pipeline_name = "load_sbom"
175+
project1 = make_project()
176+
project1.copy_input_from(input_location)
177+
178+
run = project1.add_pipeline(pipeline_name)
179+
pipeline = run.make_pipeline_instance()
180+
181+
exitcode, out = pipeline.execute()
182+
self.assertEqual(0, exitcode, msg=out)
183+
184+
self.assertEqual(1, project1.codebaseresources.count())
185+
self.assertEqual(3, project1.discoveredpackages.count())
186+
self.assertEqual(1, project1.discoveredpackages.vulnerable().count())
187+
self.assertEqual(0, project1.discovereddependencies.count())

0 commit comments

Comments
 (0)