diff --git a/safety/scan/command.py b/safety/scan/command.py index 39451968..86392069 100644 --- a/safety/scan/command.py +++ b/safety/scan/command.py @@ -167,7 +167,7 @@ def process_report( if output is ScanOutput.JSON or ScanOutput.is_format(output, ScanOutput.SPDX): if output is ScanOutput.JSON: - if detailed_output and output is ScanOutput.JSON: + if detailed_output: report_to_output = add_cve_details_to_report(report_to_output, obj.project.files) if filter_keys: @@ -227,13 +227,7 @@ def sort_cve_data(cve_data: List[Dict[str, Any]]) -> List[Dict[str, Any]]: Returns: List[Dict[str, Any]]: The sorted list of CVE details, prioritized by severity (e.g., CRITICAL > HIGH > MEDIUM). """ - severity_order = { - "CRITICAL": 4, - "HIGH": 3, - "MEDIUM": 2, - "LOW": 1, - "UNKNOWN": 0, - } + severity_order = {key.name: id for (id, key) in enumerate(VulnerabilitySeverityLabels)} return sorted(cve_data, key=lambda x: severity_order.get(x["severity"].upper(), 0), reverse=True) @@ -358,9 +352,9 @@ def scan(ctx: typer.Context, show_default=False) ] = False, filter_keys: Annotated[ - Optional[List[str]], - typer.Option("--filter", help="Filter output by specific top-level JSON keys.") - ] = None, + Optional[List[str]], + typer.Option("--filter", help="Filter output by specific top-level JSON keys.") + ] = None, ): """ Scans a project (defaulted to the current directory) for supply-chain security and configuration issues @@ -583,7 +577,6 @@ def sort_vulns_by_score(vuln: Vulnerability) -> int: save_as=save_as if save_as and all(save_as) else None, detailed_output=detailed_output, filter_keys=filter_keys, - **{k: v for k, v in ctx.params.items() if k not in {"detailed_output", "output", "save_as", "filter_keys"}} )