Skip to content

Commit 14d8f64

Browse files
committed
Make sure we have extra space to store long CVSSv4 values correctly.
Signed-off-by: ziad hany <ziadhany2016@gmail.com>
1 parent 5da8c44 commit 14d8f64

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 09:48
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("vulnerabilities", "0106_alter_advisoryreference_url_and_more"),
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
@@ -201,7 +201,7 @@ class VulnerabilitySeverity(models.Model):
201201
value = models.CharField(max_length=50, help_text="Example: 9.0, Important, High")
202202

203203
scoring_elements = models.CharField(
204-
max_length=150,
204+
max_length=250,
205205
null=True,
206206
help_text="Supporting scoring elements used to compute the score values. "
207207
"For example a CVSS vector string as used to compute a CVSS score.",
@@ -2577,7 +2577,7 @@ class AdvisorySeverity(models.Model):
25772577
value = models.CharField(max_length=50, help_text="Example: 9.0, Important, High", null=True)
25782578

25792579
scoring_elements = models.CharField(
2580-
max_length=150,
2580+
max_length=250,
25812581
null=True,
25822582
help_text="Supporting scoring elements used to compute the score values. "
25832583
"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)