Skip to content

Commit 6db35f0

Browse files
authored
Make sure we have extra space to store long CVSSv4 values correctly (#2094)
Signed-off-by: ziad hany <ziadhany2016@gmail.com>
1 parent 74382d6 commit 6db35f0

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Generated by Django 4.2.25 on 2025-12-31 10:45
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("vulnerabilities", "0108_advisoryv2_advisory_latest_by_avid_idx"),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name="advisoryseverity",
15+
name="scoring_elements",
16+
field=models.CharField(
17+
help_text="Supporting scoring elements used to compute the score values. For example a CVSS vector string as used to compute a CVSS score.",
18+
max_length=250,
19+
null=True,
20+
),
21+
),
22+
migrations.AlterField(
23+
model_name="vulnerabilityseverity",
24+
name="scoring_elements",
25+
field=models.CharField(
26+
help_text="Supporting scoring elements used to compute the score values. For example a CVSS vector string as used to compute a CVSS score.",
27+
max_length=250,
28+
null=True,
29+
),
30+
),
31+
]

vulnerabilities/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ class VulnerabilitySeverity(models.Model):
203203
value = models.CharField(max_length=50, help_text="Example: 9.0, Important, High")
204204

205205
scoring_elements = models.CharField(
206-
max_length=150,
206+
max_length=250,
207207
null=True,
208208
help_text="Supporting scoring elements used to compute the score values. "
209209
"For example a CVSS vector string as used to compute a CVSS score.",
@@ -2565,7 +2565,7 @@ class AdvisorySeverity(models.Model):
25652565
value = models.CharField(max_length=50, help_text="Example: 9.0, Important, High", null=True)
25662566

25672567
scoring_elements = models.CharField(
2568-
max_length=150,
2568+
max_length=250,
25692569
null=True,
25702570
help_text="Supporting scoring elements used to compute the score values. "
25712571
"For example a CVSS vector string as used to compute a CVSS score.",

vulnerabilities/tests/test_models.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@
2525
from vulnerabilities.importer import AdvisoryData
2626
from vulnerabilities.importer import AffectedPackage
2727
from vulnerabilities.importer import Reference
28+
from vulnerabilities.models import AdvisorySeverity
2829
from vulnerabilities.models import Alias
2930
from vulnerabilities.models import Package
3031
from vulnerabilities.models import Patch
3132
from vulnerabilities.models import Vulnerability
33+
from vulnerabilities.severity_systems import CVSSV4
3234
from vulnerabilities.utils import compute_content_id
3335

3436

@@ -720,3 +722,16 @@ def test_constraint_none_empty(self):
720722
with self.assertRaises(IntegrityError) as raised:
721723
Patch.objects.create(patch_url=None, patch_text="")
722724
self.assertIn("patch_url_or_patch_text", str(raised.exception))
725+
726+
727+
class TestStoreLongCVSSV4(TestCase):
728+
@pytest.mark.django_db
729+
def test_constraint_none(self):
730+
AdvisorySeverity.objects.create(
731+
scoring_system=CVSSV4,
732+
scoring_elements="CVSS:4.0/AV:N/AC:L/AT:P/PR:H/UI:P/VC:N/VI:N/VA:N/SC:H/SI:H/SA:H/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X",
733+
)
734+
AdvisorySeverity.objects.create(
735+
scoring_system=CVSSV4,
736+
scoring_elements="CVSS:4.0/AV:P/AC:H/AT:P/PR:H/UI:A/VC:L/VI:L/VA:H/SC:H/SI:L/SA:L/E:A/CR:M/IR:M/AR:M/MAV:A/MAC:L/MAT:P/MPR:L/MVC:L/MVI:L/MVA:L/MSC:H/MSI:H/MSA:H/S:P/AU:Y/R:U/V:C/RE:M/U:Amber",
737+
)

0 commit comments

Comments
 (0)