@@ -22,6 +22,10 @@ def count_violations(self, product, threshold, parameters):
2222 """Count objects violating the rule for the given product."""
2323 raise NotImplementedError
2424
25+ def get_package_filter (self ):
26+ """Return queryset filter kwargs for ProductPackage to identify violating packages."""
27+ return {}
28+
2529
2630class PackageBaseRule (BaseRule ):
2731 """Base for rules that count packages matching a fixed filter within a product."""
@@ -38,6 +42,9 @@ def count_violations(self, product, threshold, parameters):
3842
3943 return count if count > threshold else 0
4044
45+ def get_package_filter (self ):
46+ return {f"package__{ key } " : value for key , value in self .package_filter .items ()}
47+
4148
4249class LicensePolicyErrorRule (PackageBaseRule ):
4350 rule_type = "license_policy_error"
@@ -74,6 +81,9 @@ class VulnerabilityDetectedRule(BaseRule):
7481 "min_risk_score" : "Minimum risk score (0.0-10.0). Default: any vulnerability." ,
7582 }
7683
84+ def get_package_filter (self ):
85+ return {"package__risk_score__isnull" : False }
86+
7787 def count_violations (self , product , threshold , parameters ):
7888 Package = apps .get_model ("component_catalog" , "package" )
7989
0 commit comments