Skip to content

Commit 73d8225

Browse files
committed
fix: resolve failing tests
Signed-off-by: joydeep049 <[email protected]>
1 parent 62d0fa0 commit 73d8225

File tree

3 files changed

+276
-10
lines changed

3 files changed

+276
-10
lines changed

dummy_vex_output

Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
{
2+
"document": {
3+
"category": "csaf_vex",
4+
"csaf_version": "2.0",
5+
"notes": [
6+
{
7+
"category": "summary",
8+
"title": "Technical Summary",
9+
"text": "Auto generated CSAF document"
10+
}
11+
],
12+
"publisher": {
13+
"category": "vendor",
14+
"name": "TestVendor",
15+
"namespace": "https://www.example.com",
16+
"contact_details": "TestVendor"
17+
},
18+
"title": "",
19+
"tracking": {
20+
"current_release_date": "2025-07-03T10:12:50Z",
21+
"generator": {
22+
"date": "2025-07-03T10:12:50Z",
23+
"engine": {
24+
"name": "csaf-tool",
25+
"version": "0.3.2"
26+
}
27+
},
28+
"id": "TESTPRODUCT-1.0-VEX",
29+
"initial_release_date": "2025-07-03T10:12:50Z",
30+
"revision_history": [
31+
{
32+
"date": "2025-07-03T10:12:50Z",
33+
"number": "1",
34+
"summary": "None"
35+
}
36+
],
37+
"status": "final",
38+
"version": "1"
39+
}
40+
},
41+
"product_tree": {
42+
"branches": [
43+
{
44+
"category": "vendor",
45+
"name": "TestVendor",
46+
"branches": [
47+
{
48+
"category": "product_name",
49+
"name": "TestProduct",
50+
"branches": [
51+
{
52+
"category": "product_version",
53+
"name": "1.0",
54+
"product": {
55+
"name": "TestVendor TestProduct 1.0",
56+
"product_id": "CSAFPID_0001",
57+
"product_identification_helper": {
58+
"sbom_urls": [
59+
"file:///home/joydeep/dev/cve-bin-tool"
60+
]
61+
}
62+
}
63+
}
64+
]
65+
}
66+
]
67+
}
68+
]
69+
},
70+
"vulnerabilities": [
71+
{
72+
"cve": "CVE-1234-1004",
73+
"notes": [
74+
{
75+
"category": "description",
76+
"title": "CVE description",
77+
"text": "https://nvd.nist.gov/vuln/detail/CVE-1234-1004"
78+
}
79+
],
80+
"product_status": {
81+
"under_investigation": [
82+
"CSAFPID_0001"
83+
]
84+
},
85+
"threats": [
86+
{
87+
"category": "impact",
88+
"details": "",
89+
"date": "2025-07-03T10:12:50Z",
90+
"product_ids": [
91+
"CSAFPID_0001"
92+
]
93+
}
94+
]
95+
},
96+
{
97+
"cve": "CVE-1234-1005",
98+
"notes": [
99+
{
100+
"category": "description",
101+
"title": "CVE description",
102+
"text": "https://nvd.nist.gov/vuln/detail/CVE-1234-1005"
103+
}
104+
],
105+
"product_status": {
106+
"known_not_affected": [
107+
"CSAFPID_0001"
108+
]
109+
},
110+
"flags": [
111+
{
112+
"date": "2025-07-03T10:12:50Z",
113+
"label": "component_not_present",
114+
"product_ids": [
115+
"CSAFPID_0001"
116+
]
117+
}
118+
],
119+
"threats": [
120+
{
121+
"category": "impact",
122+
"details": "Detail field populated.",
123+
"date": "2025-07-03T10:12:50Z",
124+
"product_ids": [
125+
"CSAFPID_0001"
126+
]
127+
}
128+
]
129+
},
130+
{
131+
"cve": "CVE-1234-1006",
132+
"notes": [
133+
{
134+
"category": "description",
135+
"title": "CVE description",
136+
"text": "https://nvd.nist.gov/vuln/detail/CVE-1234-1006"
137+
}
138+
],
139+
"product_status": {
140+
"under_investigation": [
141+
"CSAFPID_0001"
142+
]
143+
},
144+
"threats": [
145+
{
146+
"category": "impact",
147+
"details": "Data field populated.",
148+
"date": "2025-07-03T10:12:50Z",
149+
"product_ids": [
150+
"CSAFPID_0001"
151+
]
152+
}
153+
]
154+
},
155+
{
156+
"cve": "CVE-1234-1007",
157+
"notes": [
158+
{
159+
"category": "description",
160+
"title": "CVE description",
161+
"text": "https://nvd.nist.gov/vuln/detail/CVE-1234-1007"
162+
}
163+
],
164+
"product_status": {
165+
"fixed": [
166+
"CSAFPID_0001"
167+
]
168+
},
169+
"threats": [
170+
{
171+
"category": "impact",
172+
"details": "Data field populated.",
173+
"date": "2025-07-03T10:12:50Z",
174+
"product_ids": [
175+
"CSAFPID_0001"
176+
]
177+
}
178+
]
179+
},
180+
{
181+
"cve": "CVE-1234-1008",
182+
"notes": [
183+
{
184+
"category": "description",
185+
"title": "CVE description",
186+
"text": "https://nvd.nist.gov/vuln/detail/CVE-1234-1008"
187+
}
188+
],
189+
"product_status": {
190+
"under_investigation": [
191+
"CSAFPID_0001"
192+
]
193+
},
194+
"threats": [
195+
{
196+
"category": "impact",
197+
"details": "",
198+
"date": "2025-07-03T10:12:50Z",
199+
"product_ids": [
200+
"CSAFPID_0001"
201+
]
202+
}
203+
]
204+
},
205+
{
206+
"cve": "CVE-1234-1009",
207+
"notes": [
208+
{
209+
"category": "description",
210+
"title": "CVE description",
211+
"text": "https://nvd.nist.gov/vuln/detail/CVE-1234-1009"
212+
}
213+
],
214+
"product_status": {
215+
"under_investigation": [
216+
"CSAFPID_0001"
217+
]
218+
},
219+
"threats": [
220+
{
221+
"category": "impact",
222+
"details": "",
223+
"date": "2025-07-03T10:12:50Z",
224+
"product_ids": [
225+
"CSAFPID_0001"
226+
]
227+
}
228+
]
229+
},
230+
{
231+
"cve": "CVE-1234-1010",
232+
"notes": [
233+
{
234+
"category": "description",
235+
"title": "CVE description",
236+
"text": "https://nvd.nist.gov/vuln/detail/CVE-1234-1010"
237+
}
238+
],
239+
"product_status": {
240+
"under_investigation": [
241+
"CSAFPID_0001"
242+
]
243+
},
244+
"threats": [
245+
{
246+
"category": "impact",
247+
"details": "",
248+
"date": "2025-07-03T10:12:50Z",
249+
"product_ids": [
250+
"CSAFPID_0001"
251+
]
252+
}
253+
]
254+
}
255+
]
256+
}

test.sbom

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
SPDXVersion: SPDX-2.3
2+
DataLicense: CC0-1.0
3+
SPDXID: SPDXRef-DOCUMENT
4+
DocumentName: SBOM_CVEBINTOOL-CVE-SCAN
5+
DocumentNamespace: http://spdx.org/spdxdocs/SBOM_CVEBINTOOL-CVE-SCAN-b6d76494-d9f1-4865-bd58-bad88edc8e07
6+
LicenseListVersion: 3.25
7+
Creator: Tool: cve-bin-tool-3.4.1
8+
Created: 2025-07-03T16:08:35Z
9+
CreatorComment: <text>This document has been automatically generated.</text>
10+
#####
11+

test/test_output_engine.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from rich.console import Console
2121

2222
from cve_bin_tool.output_engine import OutputEngine, output_csv, output_pdf
23-
from cve_bin_tool.output_engine.console import output_console
23+
from cve_bin_tool.output_engine.console import _output_console_nowrap, output_console
2424
from cve_bin_tool.output_engine.html import normalize_severity, output_html
2525
from cve_bin_tool.output_engine.json_output import output_json, output_json2
2626
from cve_bin_tool.output_engine.util import format_output
@@ -1151,10 +1151,9 @@ def test_output_console(self):
11511151
exploits = False
11521152
metrics = True
11531153
console = Console(file=self.mock_file)
1154-
outfile = None
11551154
all_product_data = None
11561155

1157-
output_console(
1156+
_output_console_nowrap(
11581157
self.MOCK_OUTPUT,
11591158
self.MOCK_ALL_CVE_VERSION_INFO,
11601159
".",
@@ -1167,7 +1166,7 @@ def test_output_console(self):
11671166
True,
11681167
120,
11691168
console,
1170-
outfile,
1169+
False,
11711170
)
11721171

11731172
expected_output = (
@@ -1202,10 +1201,9 @@ def test_output_console_affected_versions(self):
12021201
exploits = False
12031202
metrics = True
12041203
console = Console(file=self.mock_file)
1205-
outfile = None
12061204
all_product_data = None
12071205

1208-
output_console(
1206+
_output_console_nowrap(
12091207
self.MOCK_ALL_CVE_DATA,
12101208
self.MOCK_ALL_CVE_VERSION_INFO,
12111209
".",
@@ -1218,7 +1216,7 @@ def test_output_console_affected_versions(self):
12181216
True,
12191217
120,
12201218
console,
1221-
outfile,
1219+
False,
12221220
)
12231221

12241222
expected_output = (
@@ -1270,6 +1268,7 @@ def test_output_console_outfile(self):
12701268
True,
12711269
120,
12721270
outfile,
1271+
False,
12731272
)
12741273

12751274
expected_output = (
@@ -1305,10 +1304,9 @@ def test_output_console_metrics_false(self):
13051304
exploits = False
13061305
metrics = False
13071306
console = Console(file=self.mock_file)
1308-
outfile = None
13091307
all_product_data = None
13101308

1311-
output_console(
1309+
_output_console_nowrap(
13121310
self.MOCK_OUTPUT_2,
13131311
self.MOCK_ALL_CVE_VERSION_INFO,
13141312
".",
@@ -1321,7 +1319,7 @@ def test_output_console_metrics_false(self):
13211319
True,
13221320
120,
13231321
console,
1324-
outfile,
1322+
False,
13251323
)
13261324

13271325
expected_output = (
@@ -1635,6 +1633,7 @@ def test_output_with_unset_fields(self):
16351633
vex_product_info=vex_info,
16361634
offline=False,
16371635
organized_arguements={},
1636+
no_scan=False,
16381637
)
16391638
# Use an in-memory output file.
16401639
dummy_out = io.StringIO()

0 commit comments

Comments
 (0)