Skip to content

Commit 12fc89f

Browse files
fix failing tests (CICD)
1 parent 97d51df commit 12fc89f

File tree

1 file changed

+63
-5
lines changed

1 file changed

+63
-5
lines changed

entrypoint/tests/test_orchestrator.py

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,30 @@ def test_system_against_dockerfile_findings(self):
119119
"args",
120120
[
121121
"out_scan",
122-
"artifact_path",
122+
"artifact_path",
123123
"artifact_type",
124124
"out_scan_csv",
125125
"out_scan_markdown",
126126
"out_dockerfile_scan_csv",
127127
"out_dockerfile_scan_md",
128128
"show_only_fixable_vulns",
129+
# ScanConfig required fields
130+
"sbomgen_version",
131+
"timeout",
132+
"platform",
133+
"scanners",
134+
"skip_scanners",
135+
"skip_files",
136+
# OutputConfig required fields
137+
"display_vuln_findings",
138+
"out_sbom",
139+
"thresholds",
140+
"critical",
141+
"high",
142+
"medium",
143+
"low",
144+
"other",
145+
"threshold_fixable_only",
129146
],
130147
)
131148
args = ArgMock(
@@ -137,9 +154,31 @@ def test_system_against_dockerfile_findings(self):
137154
out_dockerfile_scan_csv="/tmp/out_dockerfile_scan.csv",
138155
out_dockerfile_scan_md="/tmp/out_dockerfile_scan.md",
139156
show_only_fixable_vulns=False,
157+
# ScanConfig defaults
158+
sbomgen_version="latest",
159+
timeout="600",
160+
platform=None,
161+
scanners="''",
162+
skip_scanners="''",
163+
skip_files="''",
164+
# OutputConfig defaults
165+
display_vuln_findings="disabled",
166+
out_sbom="/tmp/sbom.json",
167+
thresholds=False,
168+
critical=0,
169+
high=0,
170+
medium=0,
171+
low=0,
172+
other=0,
173+
threshold_fixable_only=False,
140174
)
141175

142-
succeeded, scan_result, fixed_vuln_counts = orchestrator.get_scan_result(args)
176+
# Create config objects for new function signature
177+
from entrypoint.data_model import ScanConfig, OutputConfig
178+
config = ScanConfig.from_args(args)
179+
output_config = OutputConfig.from_args(args)
180+
181+
succeeded, scan_result, fixed_vuln_counts = orchestrator.get_scan_result(args, config, output_config)
143182
self.assertTrue(succeeded)
144183

145184
orchestrator.write_pkg_vuln_report_csv(args.out_scan_csv, scan_result)
@@ -262,15 +301,25 @@ def test_threshold_exceeded_on_fixable_vulns(self):
262301
# Given a scan containing fixable and unfixable vulns,
263302
# threshold should be exceeded
264303
vulns_with_fixes = fixed_vulns.FixedVulns(criticals=10, highs=0, mediums=0, lows=0, others=0)
265-
orchestrator.set_env_var_if_vuln_threshold_exceeded(threshold_args, vulns_with_fixes)
304+
from entrypoint.data_model import OutputConfig
305+
threshold_output_config = OutputConfig(
306+
critical_threshold=threshold_args.critical,
307+
high_threshold=threshold_args.high,
308+
medium_threshold=threshold_args.medium,
309+
low_threshold=threshold_args.low,
310+
other_threshold=threshold_args.other,
311+
thresholds=threshold_args.thresholds,
312+
threshold_fixable_only=threshold_args.threshold_fixable_only
313+
)
314+
orchestrator.set_env_var_if_vuln_threshold_exceeded(threshold_output_config, vulns_with_fixes)
266315
want = "1"
267316
got = os.environ.get("vulnerability_threshold_exceeded")
268317
self.assertEqual(want, got)
269318

270319
# Given a scan containing NO fixable vulns,
271320
# threshold exceeded should NOT be set
272321
no_vulns_with_fix = fixed_vulns.FixedVulns(criticals=0, highs=0, mediums=0, lows=0, others=0)
273-
orchestrator.set_env_var_if_vuln_threshold_exceeded(threshold_args, no_vulns_with_fix)
322+
orchestrator.set_env_var_if_vuln_threshold_exceeded(threshold_output_config, no_vulns_with_fix)
274323
want = "0"
275324
got = os.environ.get("vulnerability_threshold_exceeded")
276325
self.assertEqual(want, got)
@@ -287,7 +336,16 @@ def test_threshold_exceeded_on_fixable_vulns(self):
287336
threshold_fixable_only=True
288337
)
289338
vulns_with_fixes = fixed_vulns.FixedVulns(criticals=10, highs=10, mediums=10, lows=10, others=10)
290-
orchestrator.set_env_var_if_vuln_threshold_exceeded(disable_threshold_args, vulns_with_fixes)
339+
disable_threshold_output_config = OutputConfig(
340+
critical_threshold=disable_threshold_args.critical,
341+
high_threshold=disable_threshold_args.high,
342+
medium_threshold=disable_threshold_args.medium,
343+
low_threshold=disable_threshold_args.low,
344+
other_threshold=disable_threshold_args.other,
345+
thresholds=disable_threshold_args.thresholds,
346+
threshold_fixable_only=disable_threshold_args.threshold_fixable_only
347+
)
348+
orchestrator.set_env_var_if_vuln_threshold_exceeded(disable_threshold_output_config, vulns_with_fixes)
291349
want = "0"
292350
got = os.environ.get("vulnerability_threshold_exceeded")
293351
self.assertEqual(want, got)

0 commit comments

Comments
 (0)