Skip to content

Commit a66516f

Browse files
committed
Store cyclonedx vulnerability data as dict in place of json
Signed-off-by: tdruez <tdruez@aboutcode.org>
1 parent 368567a commit a66516f

3 files changed

Lines changed: 6 additions & 8 deletions

File tree

scanpipe/pipes/cyclonedx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def cyclonedx_component_to_package_data(
190190
{
191191
"vulnerability_id": str(cdx_vulnerability.id),
192192
"summary": cdx_vulnerability.description,
193-
"cdx_vulnerability_json": cdx_vulnerability_json,
193+
"cdx_vulnerability_data": json.loads(cdx_vulnerability_json),
194194
}
195195
)
196196

scanpipe/tests/pipes/test_cyclonedx.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,8 @@ def test_scanpipe_cyclonedx_resolve_cyclonedx_packages_vulnerabilities(self):
255255
"Tar 1.15.1 does not properly warn the user when...",
256256
affected_by[0]["summary"],
257257
)
258-
self.assertIn("cdx_vulnerability_json", affected_by[0])
259-
vulnerability_json = affected_by[0]["cdx_vulnerability_json"]
260-
cdx_vulnerability = json.loads(vulnerability_json)
258+
self.assertIn("cdx_vulnerability_data", affected_by[0])
259+
cdx_vulnerability_data = affected_by[0]["cdx_vulnerability_data"]
261260
expected = [
262261
"advisories",
263262
"affects",
@@ -268,7 +267,7 @@ def test_scanpipe_cyclonedx_resolve_cyclonedx_packages_vulnerabilities(self):
268267
"source",
269268
"updated",
270269
]
271-
self.assertEqual(expected, list(cdx_vulnerability.keys()))
270+
self.assertEqual(expected, sorted(cdx_vulnerability_data.keys()))
272271

273272
def test_scanpipe_cyclonedx_resolve_cyclonedx_packages_pre_validation(self):
274273
# This SBOM includes multiple deserialization issues that are "fixed"

scanpipe/tests/test_pipelines.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,13 +1639,12 @@ def test_scanpipe_load_sbom_pipeline_cyclonedx_with_vulnerabilities(self):
16391639
self.assertEqual(1, project1.discoveredpackages.count())
16401640
package = project1.discoveredpackages.get()
16411641
affected_by = package.affected_by_vulnerabilities[0]
1642-
cdx_vulnerability_json = affected_by.pop("cdx_vulnerability_json")
1642+
cdx_vulnerability_data = affected_by.pop("cdx_vulnerability_data")
16431643
expected = {
16441644
"vulnerability_id": "CVE-2005-2541",
16451645
"summary": "Tar 1.15.1 does not properly warn the user when...",
16461646
}
16471647
self.assertEqual(expected, affected_by)
1648-
cdx_vulnerability = json.loads(cdx_vulnerability_json)
16491648
expected = [
16501649
"advisories",
16511650
"affects",
@@ -1656,7 +1655,7 @@ def test_scanpipe_load_sbom_pipeline_cyclonedx_with_vulnerabilities(self):
16561655
"source",
16571656
"updated",
16581657
]
1659-
self.assertEqual(expected, list(cdx_vulnerability.keys()))
1658+
self.assertEqual(expected, sorted(cdx_vulnerability_data.keys()))
16601659

16611660
@mock.patch("scanpipe.pipes.purldb.request_post")
16621661
@mock.patch("uuid.uuid4")

0 commit comments

Comments
 (0)