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

#1581 Issue: Sorting the Compliance Alerts of each project based on thier Severity level #1612

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
12 changes: 11 additions & 1 deletion scanpipe/pipes/compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def analyze_compliance_licenses(project):
scan_results, scan_errors = scancode.scan_file(codebase_resource.location)
codebase_resource.set_scan_results(scan_results)

SEVERITY_ORDER = ["error", "warning", "missing", ""]

def group_compliance_alerts_by_severity(queryset):
"""
Expand Down Expand Up @@ -108,4 +109,13 @@ def get_project_compliance_alerts(project, fail_level="error"):
if (compliance_alerts := group_compliance_alerts_by_severity(queryset))
}

return project_compliance_alerts
sorted_alerts = {}
for model_name, alerts in project_compliance_alerts.items():
sorted_dict = {}
for severity in SEVERITY_ORDER:
if severity in alerts:
sorted_dict[severity] = alerts[severity]
sorted_alerts[model_name] = sorted_dict


return sorted_alerts
Loading