Skip to content

Commit a547450

Browse files
authored
add fields for kev-related data to finding model (#12678)
* add fields for kev-related data to finding model: known_exploited, ransomeware_used, kev_date * linter fix * test updates * remove maxdiff setting
1 parent 868e5d8 commit a547450

File tree

3 files changed

+78
-18
lines changed

3 files changed

+78
-18
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Generated by Django 5.1.8 on 2025-06-23 19:34
2+
3+
import django.core.validators
4+
import dojo.models
5+
from django.db import migrations, models
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('dojo', '0229_alter_finding_unique_id_from_tool'),
12+
]
13+
14+
operations = [
15+
migrations.AddField(
16+
model_name='finding',
17+
name='kev_date',
18+
field=models.DateField(blank=True, help_text='The date the vulnerability was added to the KEV catalog.', null=True, validators=[django.core.validators.MaxValueValidator(dojo.models.tomorrow)], verbose_name='KEV Date Added'),
19+
),
20+
migrations.AddField(
21+
model_name='finding',
22+
name='known_exploited',
23+
field=models.BooleanField(default=False, help_text='Whether this vulnerability is known to have been exploited in the wild.', verbose_name='Known Exploited'),
24+
),
25+
migrations.AddField(
26+
model_name='finding',
27+
name='ransomware_used',
28+
field=models.BooleanField(default=False, help_text='Whether this vulnerability is known to have been leveraged as part of a ransomware campaign.', verbose_name='Used in Ransomware'),
29+
),
30+
migrations.AddIndex(
31+
model_name='finding',
32+
index=models.Index(fields=['known_exploited'], name='dojo_findin_known_e_8c584e_idx'),
33+
),
34+
migrations.AddIndex(
35+
model_name='finding',
36+
index=models.Index(fields=['ransomware_used'], name='dojo_findin_ransomw_c185c6_idx'),
37+
),
38+
migrations.AddIndex(
39+
model_name='finding',
40+
index=models.Index(fields=['kev_date'], name='dojo_findin_kev_dat_b54260_idx'),
41+
),
42+
]

dojo/models.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import re
66
import warnings
77
from contextlib import suppress
8-
from datetime import datetime
8+
from datetime import datetime, timedelta
99
from decimal import Decimal
1010
from pathlib import Path
1111
from uuid import uuid4
@@ -137,6 +137,11 @@ def _copy_model_util(model_in_database, exclude_fields: list[str] | None = None)
137137
return new_model_instance
138138

139139

140+
def tomorrow():
141+
"""Returns a date representing the day after today."""
142+
return timezone.now().date() + timedelta(days=1)
143+
144+
140145
@deconstructible
141146
class UniqueUploadNameProvider:
142147

@@ -2331,6 +2336,16 @@ class Finding(models.Model):
23312336
verbose_name=_("EPSS percentile"),
23322337
help_text=_("EPSS percentile for the CVE. Describes how many CVEs are scored at or below this one."),
23332338
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)])
23342349
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'")
23352350
cvssv3 = models.TextField(validators=[cvssv3_regex],
23362351
max_length=117,
@@ -2660,6 +2675,9 @@ class Meta:
26602675
models.Index(fields=["duplicate"]),
26612676
models.Index(fields=["is_mitigated"]),
26622677
models.Index(fields=["duplicate_finding", "id"]),
2678+
models.Index(fields=["known_exploited"]),
2679+
models.Index(fields=["ransomware_used"]),
2680+
models.Index(fields=["kev_date"]),
26632681
]
26642682

26652683
def __init__(self, *args, **kwargs):

0 commit comments

Comments
 (0)