Skip to content

Commit c3cdb9b

Browse files
committed
Make advisory content id unique
- make the url field non-empty and non-nullable Signed-off-by: Keshav Priyadarshi <[email protected]>
1 parent 3fb3e75 commit c3cdb9b

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-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.17 on 2025-04-04 16:08
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("vulnerabilities", "0090_migrate_advisory_aliases"),
10+
]
11+
12+
operations = [
13+
migrations.AlterUniqueTogether(
14+
name="advisory",
15+
unique_together=set(),
16+
),
17+
migrations.AlterField(
18+
model_name="advisory",
19+
name="unique_content_id",
20+
field=models.CharField(
21+
help_text="A 64 character unique identifier for the content of the advisory since we use sha256 as hex",
22+
max_length=64,
23+
unique=True,
24+
),
25+
),
26+
migrations.AlterField(
27+
model_name="advisory",
28+
name="url",
29+
field=models.URLField(help_text="Link to the advisory on the upstream website"),
30+
),
31+
]

vulnerabilities/models.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,6 +1321,7 @@ class Advisory(models.Model):
13211321
max_length=64,
13221322
blank=False,
13231323
null=False,
1324+
unique=True,
13241325
help_text="A 64 character unique identifier for the content of the advisory since we use sha256 as hex",
13251326
)
13261327
aliases = models.ManyToManyField(
@@ -1355,14 +1356,14 @@ class Advisory(models.Model):
13551356
"vulnerabilities.pipeline.nginx_importer.NginxImporterPipeline",
13561357
)
13571358
url = models.URLField(
1358-
blank=True,
1359+
blank=False,
1360+
null=False,
13591361
help_text="Link to the advisory on the upstream website",
13601362
)
13611363

13621364
objects = AdvisoryQuerySet.as_manager()
13631365

13641366
class Meta:
1365-
unique_together = ["unique_content_id", "date_published", "url"]
13661367
ordering = ["date_published", "unique_content_id"]
13671368

13681369
def save(self, *args, **kwargs):

0 commit comments

Comments
 (0)