Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Enable metrics if epss-{percentile,probability} is set #3642

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions cve_bin_tool/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,12 @@ def main(argv=None):
output_group.add_argument(
"--epss-percentile",
action="store",
help="minimum epss percentile of CVE range between 0 to 100 to report (default: 0)",
default=0,
help="minimum epss percentile of CVE range between 0 to 100 to report",
)
output_group.add_argument(
"--epss-probability",
action="store",
help="minimum epss probability of CVE range between 0 to 100 to report (default: 0)",
default=0,
help="minimum epss probability of CVE range between 0 to 100 to report",
)
output_group.add_argument(
"--no-0-cve-report",
Expand Down Expand Up @@ -589,15 +587,35 @@ def main(argv=None):
if int(args["cvss"]) > 0:
score = int(args["cvss"])

metrics = args["metrics"]
if args["epss_percentile"] or args["epss_probability"]:
metrics = True

epss_percentile = 0
if float(args["epss_percentile"]) > 0 or float(args["epss_percentile"]) < 100:
if (
args["epss_percentile"]
and float(args["epss_percentile"]) >= 0
and float(args["epss_percentile"]) <= 100
):
epss_percentile = float(args["epss_percentile"]) / 100
LOGGER.debug(f"epss percentile stored {epss_percentile}")
elif args["epss_percentile"]:
LOGGER.debug(
f'epss percentile {args["epss_percentile"]} is invalid so set it to 0'
)

epss_probability = 0
terriko marked this conversation as resolved.
Show resolved Hide resolved
if float(args["epss_probability"]) > 0 or float(args["epss_probability"]) < 100:
if (
args["epss_probability"]
and float(args["epss_probability"]) >= 0
and float(args["epss_probability"]) <= 100
):
epss_probability = float(args["epss_probability"]) / 100
LOGGER.debug(f"epss probability stored {epss_probability}")
elif args["epss_probability"]:
LOGGER.debug(
f'epss probability {args["epss_probability"]} is invalid so set it to 0'
)

config_generate = set(args["generate_config"].split(","))
config_generate = [config_type.strip() for config_type in config_generate]
Expand Down Expand Up @@ -899,7 +917,7 @@ def main(argv=None):

with CVEScanner(
score=score,
check_metrics=args["metrics"],
check_metrics=metrics,
epss_percentile=epss_percentile,
epss_probability=epss_probability,
check_exploits=args["exploits"],
Expand Down Expand Up @@ -1024,7 +1042,7 @@ def main(argv=None):
merge_report=merged_reports,
affected_versions=args["affected_versions"],
exploits=args["exploits"],
metrics=args["metrics"],
metrics=metrics,
detailed=args["detailed"],
vex_filename=args["vex"],
sbom_filename=args["sbom_output"],
Expand Down
Loading