|
5 | 5 | import re |
6 | 6 | import warnings |
7 | 7 | from contextlib import suppress |
8 | | -from datetime import datetime |
| 8 | +from datetime import datetime, timedelta |
9 | 9 | from decimal import Decimal |
10 | 10 | from pathlib import Path |
11 | 11 | from uuid import uuid4 |
@@ -137,6 +137,11 @@ def _copy_model_util(model_in_database, exclude_fields: list[str] | None = None) |
137 | 137 | return new_model_instance |
138 | 138 |
|
139 | 139 |
|
| 140 | +def tomorrow(): |
| 141 | + """Returns a date representing the day after today.""" |
| 142 | + return timezone.now().date() + timedelta(days=1) |
| 143 | + |
| 144 | + |
140 | 145 | @deconstructible |
141 | 146 | class UniqueUploadNameProvider: |
142 | 147 |
|
@@ -2331,6 +2336,16 @@ class Finding(models.Model): |
2331 | 2336 | verbose_name=_("EPSS percentile"), |
2332 | 2337 | help_text=_("EPSS percentile for the CVE. Describes how many CVEs are scored at or below this one."), |
2333 | 2338 | validators=[MinValueValidator(0.0), MaxValueValidator(1.0)]) |
| 2339 | + known_exploited = models.BooleanField(default=False, |
| 2340 | + verbose_name=_("Known Exploited"), |
| 2341 | + help_text=_("Whether this vulnerability is known to have been exploited in the wild.")) |
| 2342 | + ransomware_used = models.BooleanField(default=False, |
| 2343 | + verbose_name=_("Used in Ransomware"), |
| 2344 | + help_text=_("Whether this vulnerability is known to have been leveraged as part of a ransomware campaign.")) |
| 2345 | + kev_date = models.DateField(null=True, blank=True, |
| 2346 | + verbose_name=_("KEV Date Added"), |
| 2347 | + help_text=_("The date the vulnerability was added to the KEV catalog."), |
| 2348 | + validators=[MaxValueValidator(tomorrow)]) |
2334 | 2349 | cvssv3_regex = RegexValidator(regex=r"^AV:[NALP]|AC:[LH]|PR:[UNLH]|UI:[NR]|S:[UC]|[CIA]:[NLH]", message="CVSS must be entered in format: 'AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H'") |
2335 | 2350 | cvssv3 = models.TextField(validators=[cvssv3_regex], |
2336 | 2351 | max_length=117, |
@@ -2660,6 +2675,9 @@ class Meta: |
2660 | 2675 | models.Index(fields=["duplicate"]), |
2661 | 2676 | models.Index(fields=["is_mitigated"]), |
2662 | 2677 | models.Index(fields=["duplicate_finding", "id"]), |
| 2678 | + models.Index(fields=["known_exploited"]), |
| 2679 | + models.Index(fields=["ransomware_used"]), |
| 2680 | + models.Index(fields=["kev_date"]), |
2663 | 2681 | ] |
2664 | 2682 |
|
2665 | 2683 | def __init__(self, *args, **kwargs): |
|
0 commit comments