Skip to content

Commit ea603b1

Browse files
committed
Add TODO model for Advisory
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
1 parent e484e33 commit ea603b1

File tree

2 files changed

+139
-0
lines changed

2 files changed

+139
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Generated by Django 4.2.17 on 2025-01-16 06:36
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("vulnerabilities", "0087_update_alpine_advisory_created_by"),
10+
]
11+
12+
operations = [
13+
migrations.CreateModel(
14+
name="AdvisoryTODO",
15+
fields=[
16+
(
17+
"id",
18+
models.AutoField(
19+
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
20+
),
21+
),
22+
(
23+
"issue_type",
24+
models.CharField(
25+
choices=[
26+
("MISSING_AFFECTED_PACKAGE", "Advisory is missing affected package"),
27+
("MISSING_FIXED_BY_PACKAGE", "Advisory is missing fixed-by package"),
28+
(
29+
"MISSING_AFFECTED_AND_FIXED_PACKAGE",
30+
"Advisory is missing both affected and fixed-by package",
31+
),
32+
("MISSING_SUMMARY", "Advisory is missing summary"),
33+
(
34+
"CONFLICTING_FIXED_BY_PACKAGE",
35+
"Advisories has conflicting fixed-by package",
36+
),
37+
(
38+
"CONFLICTING_AFFECTED_PACKAGE",
39+
"Advisories has conflicting affected package",
40+
),
41+
("CONFLICTING_SEVERITY", "Advisories has conflicting severity score"),
42+
],
43+
db_index=True,
44+
help_text="Select the issue that needs to be addressed from the available options.",
45+
max_length=50,
46+
),
47+
),
48+
("issue_detail", models.TextField(help_text="Additional details about the issue.")),
49+
(
50+
"created_at",
51+
models.DateTimeField(
52+
auto_now_add=True,
53+
help_text="Timestamp indicating when this TODO was created.",
54+
),
55+
),
56+
(
57+
"is_resolved",
58+
models.BooleanField(
59+
db_index=True, default=False, help_text="This TODO is resolved or not."
60+
),
61+
),
62+
(
63+
"resolved_at",
64+
models.DateTimeField(
65+
help_text="Timestamp indicating when this TODO was resolved."
66+
),
67+
),
68+
(
69+
"resolution_detail",
70+
models.TextField(help_text="Additional detail on how this TODO was resolved."),
71+
),
72+
(
73+
"advisories",
74+
models.ManyToManyField(
75+
help_text="Advisory/ies where this TODO is applicable.",
76+
related_name="advisory_todos",
77+
to="vulnerabilities.advisory",
78+
),
79+
),
80+
],
81+
),
82+
]

vulnerabilities/models.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,3 +1663,60 @@ class CodeFix(CodeChange):
16631663
related_name="code_fix",
16641664
help_text="The fixing package version with this code fix",
16651665
)
1666+
1667+
1668+
class AdvisoryTODO(models.Model):
1669+
"""Track the TODOs for advisory/ies that need to be addressed."""
1670+
1671+
ISSUE_TYPE_CHOICES = [
1672+
("MISSING_AFFECTED_PACKAGE", "Advisory is missing affected package"),
1673+
("MISSING_FIXED_BY_PACKAGE", "Advisory is missing fixed-by package"),
1674+
(
1675+
"MISSING_AFFECTED_AND_FIXED_BY_PACKAGES",
1676+
"Advisory is missing both affected and fixed-by packages",
1677+
),
1678+
("MISSING_SUMMARY", "Advisory is missing summary"),
1679+
("CONFLICTING_FIXED_BY_PACKAGES", "Advisories have conflicting fixed-by packages"),
1680+
("CONFLICTING_AFFECTED_PACKAGES", "Advisories have conflicting affected packages"),
1681+
(
1682+
"CONFLICTING_AFFECTED_AND_FIXED_BY_PACKAGES",
1683+
"Advisories have conflicting affected and fixed-by packages",
1684+
),
1685+
("CONFLICTING_SEVERITY_SCORES", "Advisories have conflicting severity scores"),
1686+
]
1687+
1688+
issue_type = models.CharField(
1689+
max_length=50,
1690+
choices=ISSUE_TYPE_CHOICES,
1691+
blank=False,
1692+
null=False,
1693+
db_index=True,
1694+
help_text="Select the issue that needs to be addressed from the available options.",
1695+
)
1696+
issue_detail = models.TextField(
1697+
help_text="Additional details about the issue.",
1698+
)
1699+
advisories = models.ManyToManyField(
1700+
Advisory,
1701+
related_name="advisory_todos",
1702+
help_text="Advisory/ies where this TODO is applicable.",
1703+
)
1704+
1705+
created_at = models.DateTimeField(
1706+
auto_now_add=True,
1707+
help_text="Timestamp indicating when this TODO was created.",
1708+
)
1709+
1710+
is_resolved = models.BooleanField(
1711+
default=False,
1712+
db_index=True,
1713+
help_text="This TODO is resolved or not.",
1714+
)
1715+
1716+
resolved_at = models.DateTimeField(
1717+
help_text="Timestamp indicating when this TODO was resolved.",
1718+
)
1719+
1720+
resolution_detail = models.TextField(
1721+
help_text="Additional detail on how this TODO was resolved.",
1722+
)

0 commit comments

Comments
 (0)