|
11 | 11 | from django.apps import apps |
12 | 12 | from django.db.models import Exists |
13 | 13 | from django.db.models import OuterRef |
| 14 | +from django.db.models import Q |
14 | 15 | from django.utils import timezone |
15 | 16 |
|
16 | 17 | from policy.rules import BaseRule |
@@ -94,6 +95,26 @@ def get_matching_vulnerabilities(self, product, parameters=None): |
94 | 95 | ).distinct() |
95 | 96 |
|
96 | 97 |
|
| 98 | +class SSVCDecisionTriageRule(BaseTriageRule): |
| 99 | + rule_type = "ssvc_decision" |
| 100 | + label = "SSVC Decision" |
| 101 | + description = ( |
| 102 | + "Vulnerabilities whose SSVC decision tree recommends Attend or Act" |
| 103 | + " (immediate attention required)." |
| 104 | + ) |
| 105 | + |
| 106 | + def get_matching_vulnerabilities(self, product, parameters=None): |
| 107 | + Vulnerability = apps.get_model("vulnerabilities", "Vulnerability") |
| 108 | + return ( |
| 109 | + Vulnerability.objects.filter(affected_packages__productpackages__product=product) |
| 110 | + .filter( |
| 111 | + Q(ssvc_trees__contains=[{"decision": "Attend"}]) |
| 112 | + | Q(ssvc_trees__contains=[{"decision": "Act"}]) |
| 113 | + ) |
| 114 | + .distinct() |
| 115 | + ) |
| 116 | + |
| 117 | + |
97 | 118 | class ReachableVulnerabilityTriageRule(BaseTriageRule): |
98 | 119 | rule_type = "reachable_vulnerability" |
99 | 120 | label = "Reachable Vulnerability" |
@@ -229,6 +250,7 @@ def get_matching_vulnerabilities(self, product, parameters=None): |
229 | 250 | RiskScoreTriageRule.rule_type: RiskScoreTriageRule(), |
230 | 251 | WeightedRiskTriageRule.rule_type: WeightedRiskTriageRule(), |
231 | 252 | ExploitedVulnerabilityTriageRule.rule_type: ExploitedVulnerabilityTriageRule(), |
| 253 | + SSVCDecisionTriageRule.rule_type: SSVCDecisionTriageRule(), |
232 | 254 | ReachableVulnerabilityTriageRule.rule_type: ReachableVulnerabilityTriageRule(), |
233 | 255 | UnresolvedVulnerabilityTriageRule.rule_type: UnresolvedVulnerabilityTriageRule(), |
234 | 256 | StaleVulnerabilityTriageRule.rule_type: StaleVulnerabilityTriageRule(), |
|
0 commit comments