Skip to content

Commit

Permalink
review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanpulver committed Dec 9, 2024
1 parent 0c4fb78 commit c33d8b6
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions safety/scan/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"}}
)

Expand Down

0 comments on commit c33d8b6

Please sign in to comment.