Skip to content

Commit bc532d4

Browse files
author
Maria Carolina Conceição
committed
FR-91: Add cli arg only fixable vulnerability; use the variable in get_vuln_counts
1 parent 5dc8a4b commit bc532d4

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

entrypoint/entrypoint/cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ def init(sys_argv=None) -> argparse.Namespace:
5050
help="Specifies one or more files and/or directories that should NOT be inventoried.")
5151
parser.add_argument("--timeout", type=str, default="600",
5252
help="The amount of time in seconds that inspector-sbomgne will run. When this timeout is exceeded, sbomgen will gracefully conclude and present any findings discovered up to that point.")
53+
parser.add_argument("--only-show-fixable-vulnerabilities", type=str, default="False",
54+
help="If set, this program will only show vulnerabilities that have a fix available.")
5355

5456
parser.add_argument("--platform", type=str,
5557
help="Specifies the OS and CPU arch of the container image you wish to scan. Valid inputs are "

entrypoint/entrypoint/orchestrator.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def invoke_inspector_scan(src_sbom, dst_scan):
233233

234234

235235
def get_scan_result(args) -> tuple[bool, exporter.InspectorScanResult]:
236-
succeeded, criticals, highs, mediums, lows, others = get_vuln_counts(args.out_scan)
236+
succeeded, criticals, highs, mediums, lows, others = get_vuln_counts(args.out_scan, args.only_show_fixable_vulnerabilities)
237237
if succeeded is False:
238238
return False, None
239239

@@ -270,7 +270,7 @@ def set_github_actions_output(key, value):
270270
return
271271

272272

273-
def get_vuln_counts(inspector_scan_path: str):
273+
def get_vuln_counts(inspector_scan_path: str, only_show_fixable_vulns: bool = False) -> tuple[bool, int, int, int, int, int]:
274274
# vuln severities
275275
criticals = 0
276276
highs = 0
@@ -315,7 +315,10 @@ def get_vuln_counts(inspector_scan_path: str):
315315
logging.error(f"expected property with 'value' key but none was found in file {inspector_scan_path}")
316316
continue
317317

318-
if name == "amazon:inspector:sbom_scanner:critical_vulnerabilities":
318+
if only_show_fixable_vulns and "amazon:inspector:sbom_scanner:fixed_version:comp-" not in name:
319+
# skip this property
320+
continue
321+
elif name == "amazon:inspector:sbom_scanner:critical_vulnerabilities":
319322
criticals = int(value)
320323
elif name == "amazon:inspector:sbom_scanner:high_vulnerabilities":
321324
highs = int(value)

0 commit comments

Comments
 (0)