Skip to content

Commit 3e37835

Browse files
committed
test cyclonedx inspect_manifest
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
1 parent c4538e4 commit 3e37835

2 files changed

Lines changed: 227 additions & 0 deletions

File tree

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
{
2+
"$schema": "http://cyclonedx.org/schema/bom-1.4.schema.json",
3+
"bomFormat": "CycloneDX",
4+
"specVersion": "1.4",
5+
"serialNumber": "urn:uuid:0daae489-f367-40a3-98ec-461ef43e8b11",
6+
"version": 1,
7+
"components": [
8+
{
9+
"type": "library",
10+
"bom-ref": "pkg:pypi/toml@0.10.2?extension=tar.gz",
11+
"name": "toml",
12+
"version": "0.10.2",
13+
"purl": "pkg:pypi/toml@0.10.2?extension=tar.gz",
14+
"hashes": [
15+
{
16+
"alg": "SHA-256",
17+
"content": "806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"
18+
}
19+
],
20+
"externalReferences": [
21+
{
22+
"type": "issue-tracker",
23+
"url": "https://cyclonedx.org/issue-tracker",
24+
"comment": "No comment",
25+
"hashes": [
26+
{
27+
"alg": "SHA-256",
28+
"content": "806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"
29+
}
30+
]
31+
},
32+
{
33+
"type": "website",
34+
"url": "https://cyclonedx.org/website",
35+
"comment": "No comment",
36+
"hashes": [
37+
{
38+
"alg": "SHA-256",
39+
"content": "806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"
40+
}
41+
]
42+
},
43+
{
44+
"type": "vcs",
45+
"url": "https://cyclonedx.org/vcs",
46+
"comment": "No comment",
47+
"hashes": [
48+
{
49+
"alg": "SHA-256",
50+
"content": "806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"
51+
}
52+
]
53+
},
54+
{
55+
"type": "advisories",
56+
"url": "https://cyclonedx.org/advisories",
57+
"comment": "No comment",
58+
"hashes": [
59+
{
60+
"alg": "SHA-256",
61+
"content": "806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"
62+
}
63+
]
64+
},
65+
{
66+
"type": "bom",
67+
"url": "https://cyclonedx.org/bom",
68+
"comment": "No comment",
69+
"hashes": [
70+
{
71+
"alg": "SHA-256",
72+
"content": "806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"
73+
}
74+
]
75+
},
76+
{
77+
"type": "mailing-list",
78+
"url": "https://cyclonedx.org/mailing-list",
79+
"comment": "No comment",
80+
"hashes": [
81+
{
82+
"alg": "SHA-256",
83+
"content": "806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"
84+
}
85+
]
86+
}
87+
],
88+
"licenses": [
89+
{
90+
"license": {
91+
"id": "OFL-1.1"
92+
}
93+
},
94+
{
95+
"license": {
96+
"name": "Apache-2.0"
97+
}
98+
}
99+
],
100+
"components": [
101+
{
102+
"type": "library",
103+
"bom-ref": "pkg:pypi/billiard@3.6.3.0",
104+
"name": "billiard",
105+
"version": "3.6.3.0",
106+
"description": "Multiprocessing Pool Extensions",
107+
"hashes": [
108+
{
109+
"alg": "MD5",
110+
"content": "ef0831df429e9ec89f3b40fea4e143d4"
111+
},
112+
{
113+
"alg": "SHA-1",
114+
"content": "c9100731b41e1bcb3bbaffd777f991057d3bd09b"
115+
}
116+
],
117+
"licenses": [
118+
{
119+
"expression": "BSD-3-Clause"
120+
}
121+
],
122+
"copyright": "Copyright (c) 2006-2008, R Oudkerk and Contributors",
123+
"purl": "pkg:pypi/billiard@3.6.3.0",
124+
"components": [
125+
{
126+
"type": "library",
127+
"bom-ref": "pkg:pypi/fictional@9.10.2",
128+
"name": "fictional",
129+
"version": "0.10.2",
130+
"purl": "pkg:pypi/fictional@9.10.2",
131+
"hashes": [
132+
{
133+
"alg": "SHA-256",
134+
"content": "960343ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"
135+
}
136+
],
137+
"externalReferences": [
138+
{
139+
"type": "distribution",
140+
"url": "https://cyclonedx.org",
141+
"comment": "No comment",
142+
"hashes": [
143+
{
144+
"alg": "SHA-256",
145+
"content": "960343ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"
146+
}
147+
]
148+
}
149+
],
150+
"licenses": [
151+
{
152+
"expression": "LGPL-3.0-or-later AND LicenseRef-scancode-openssl-exception-lgpl3.0plus"
153+
}
154+
]
155+
}
156+
]
157+
}
158+
]
159+
}
160+
]
161+
}

scanpipe/tests/test_pipelines.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,3 +705,69 @@ def test_scanpipe_inspect_manifest_pipeline_spdx_document_integration_test(self)
705705
self.assertEqual("https://github.com/uiri/toml", discoveredpackage.homepage_url)
706706
self.assertEqual("MIT", discoveredpackage.declared_license)
707707
self.assertEqual("mit", discoveredpackage.license_expression)
708+
709+
def test_scanpipe_inspect_manifest_pipeline_cyclonedx_document_integration_test(
710+
self,
711+
):
712+
pipeline_name = "inspect_manifest"
713+
project1 = Project.objects.create(name="Analysis")
714+
715+
input_location = self.data_location / "cyclonedx/nested.bom.json"
716+
project1.copy_input_from(input_location)
717+
718+
run = project1.add_pipeline(pipeline_name)
719+
pipeline = run.make_pipeline_instance()
720+
721+
exitcode, out = pipeline.execute()
722+
self.assertEqual(0, exitcode, msg=out)
723+
724+
self.assertEqual(3, project1.discoveredpackages.count())
725+
packages = project1.discoveredpackages.all()
726+
expected_data = {
727+
"pkg:pypi/toml@0.10.2?extension=tar.gz": {
728+
"type": "pypi",
729+
"name": "toml",
730+
"version": "0.10.2",
731+
"declared_license": "OFL-1.1\nApache-2.0",
732+
"license_expression": "ofl-1.1 AND unknown",
733+
"homepage_url": "https://cyclonedx.org/website",
734+
"bug_tracking_url": "https://cyclonedx.org/issue-tracker",
735+
"vcs_url": "https://cyclonedx.org/vcs",
736+
},
737+
"pkg:pypi/billiard@3.6.3.0": {
738+
"type": "pypi",
739+
"name": "billiard",
740+
"version": "3.6.3.0",
741+
"declared_license": "BSD-3-Clause",
742+
"license_expression": "bsd-new",
743+
"homepage_url": "",
744+
"bug_tracking_url": "",
745+
"vcs_url": "",
746+
"extra_data": "",
747+
},
748+
"pkg:pypi/fictional@9.10.2": {
749+
"type": "pypi",
750+
"name": "fictional",
751+
"version": "9.10.2",
752+
"declared_license": (
753+
"LGPL-3.0-or-later"
754+
" AND "
755+
"LicenseRef-scancode-openssl-exception-lgpl3.0plus"
756+
),
757+
"license_expression": (
758+
"lgpl-3.0-plus AND openssl-exception-lgpl-3.0-plus"
759+
),
760+
"homepage_url": "",
761+
"bug_tracking_url": "",
762+
"vcs_url": "",
763+
"extra_data": "",
764+
},
765+
}
766+
for package in packages:
767+
expected = expected_data[str(package)]
768+
self.assertEqual(expected["type"], package.type)
769+
self.assertEqual(expected["name"], package.name)
770+
self.assertEqual(expected["version"], package.version)
771+
self.assertEqual(expected["homepage_url"], package.homepage_url)
772+
self.assertEqual(expected["declared_license"], package.declared_license)
773+
self.assertEqual(expected["license_expression"], package.license_expression)

0 commit comments

Comments
 (0)