@@ -2845,6 +2845,14 @@ def get_queryset(self):
28452845 distinct = True ,
28462846 ),
28472847 max_risk_score = Max ("productpackages__package__affected_by_vulnerabilities__risk_score" ),
2848+ max_risk_level = Case (
2849+ When (max_risk_score__gte = 8.0 , then = Value ("critical" )),
2850+ When (max_risk_score__gte = 6.0 , then = Value ("high" )),
2851+ When (max_risk_score__gte = 3.0 , then = Value ("medium" )),
2852+ When (max_risk_score__gte = 0.1 , then = Value ("low" )),
2853+ default = Value ("" ),
2854+ output_field = CharField (max_length = 8 ),
2855+ ),
28482856 critical_count = Count (
28492857 "productpackages__package__affected_by_vulnerabilities" ,
28502858 filter = Q (
@@ -2857,6 +2865,20 @@ def get_queryset(self):
28572865 filter = Q (productpackages__package__affected_by_vulnerabilities__risk_level = "high" ),
28582866 distinct = True ,
28592867 ),
2868+ medium_count = Count (
2869+ "productpackages__package__affected_by_vulnerabilities" ,
2870+ filter = Q (
2871+ productpackages__package__affected_by_vulnerabilities__risk_level = "medium"
2872+ ),
2873+ distinct = True ,
2874+ ),
2875+ low_count = Count (
2876+ "productpackages__package__affected_by_vulnerabilities" ,
2877+ filter = Q (
2878+ productpackages__package__affected_by_vulnerabilities__risk_level = "low"
2879+ ),
2880+ distinct = True ,
2881+ ),
28602882 license_warning_count = Count (
28612883 "productpackages__licenses" ,
28622884 filter = Q (productpackages__licenses__usage_policy__compliance_alert = "warning" ),
@@ -2867,20 +2889,12 @@ def get_queryset(self):
28672889 filter = Q (productpackages__licenses__usage_policy__compliance_alert = "error" ),
28682890 distinct = True ,
28692891 ),
2870- max_risk_level = Case (
2871- When (max_risk_score__gte = 8.0 , then = Value ("critical" )),
2872- When (max_risk_score__gte = 6.0 , then = Value ("high" )),
2873- When (max_risk_score__gte = 3.0 , then = Value ("medium" )),
2874- When (max_risk_score__gte = 0.1 , then = Value ("low" )),
2875- default = Value ("" ),
2876- output_field = CharField (max_length = 8 ),
2877- ),
28782892 ).order_by (
28792893 F ("max_risk_score" ).desc (nulls_last = True ),
28802894 "-license_error_count" ,
28812895 "-license_warning_count" ,
28822896 "name" ,
2883- "version" ,
2897+ "- version" ,
28842898 )
28852899
28862900 def get_context_data (self , ** kwargs ):
@@ -2910,6 +2924,8 @@ def get_context_data(self, **kwargs):
29102924 total_vulnerabilities = Sum ("vulnerability_count" ),
29112925 total_critical = Sum ("critical_count" ),
29122926 total_high = Sum ("high_count" ),
2927+ total_medium = Sum ("medium_count" ),
2928+ total_low = Sum ("low_count" ),
29132929 )
29142930
29152931 context .update (
@@ -2921,6 +2937,8 @@ def get_context_data(self, **kwargs):
29212937 "total_vulnerabilities" : totals ["total_vulnerabilities" ] or 0 ,
29222938 "total_critical" : totals ["total_critical" ] or 0 ,
29232939 "total_high" : totals ["total_high" ] or 0 ,
2940+ "total_medium" : totals ["total_medium" ] or 0 ,
2941+ "total_low" : totals ["total_low" ] or 0 ,
29242942 }
29252943 )
29262944
0 commit comments