Skip to content

Commit 739de9d

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

File tree

2 files changed

+144
-0
lines changed

2 files changed

+144
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Generated by Django 4.2.17 on 2025-01-16 10:47
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_BY_PACKAGES",
30+
"Advisory is missing both affected and fixed-by packages",
31+
),
32+
("MISSING_SUMMARY", "Advisory is missing summary"),
33+
(
34+
"CONFLICTING_FIXED_BY_PACKAGES",
35+
"Advisories have conflicting fixed-by packages",
36+
),
37+
(
38+
"CONFLICTING_AFFECTED_PACKAGES",
39+
"Advisories have conflicting affected packages",
40+
),
41+
(
42+
"CONFLICTING_AFFECTED_AND_FIXED_BY_PACKAGES",
43+
"Advisories have conflicting affected and fixed-by packages",
44+
),
45+
(
46+
"CONFLICTING_SEVERITY_SCORES",
47+
"Advisories have conflicting severity scores",
48+
),
49+
],
50+
db_index=True,
51+
help_text="Select the issue that needs to be addressed from the available options.",
52+
max_length=50,
53+
),
54+
),
55+
("issue_detail", models.TextField(help_text="Additional details about the issue.")),
56+
(
57+
"created_at",
58+
models.DateTimeField(
59+
auto_now_add=True,
60+
help_text="Timestamp indicating when this TODO was created.",
61+
),
62+
),
63+
(
64+
"is_resolved",
65+
models.BooleanField(
66+
db_index=True, default=False, help_text="This TODO is resolved or not."
67+
),
68+
),
69+
(
70+
"resolved_at",
71+
models.DateTimeField(
72+
help_text="Timestamp indicating when this TODO was resolved."
73+
),
74+
),
75+
(
76+
"resolution_detail",
77+
models.TextField(help_text="Additional detail on how this TODO was resolved."),
78+
),
79+
(
80+
"advisories",
81+
models.ManyToManyField(
82+
help_text="Advisory/ies where this TODO is applicable.",
83+
related_name="advisory_todos",
84+
to="vulnerabilities.advisory",
85+
),
86+
),
87+
],
88+
),
89+
]

vulnerabilities/models.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2258,3 +2258,58 @@ def create_new_job(self, execute_now=False):
22582258
schedules.clear_job(self.schedule_work_id)
22592259

22602260
return schedules.schedule_execution(self, execute_now) if self.is_active else None
2261+
class AdvisoryTODO(models.Model):
2262+
"""Track the TODOs for advisory/ies that need to be addressed."""
2263+
2264+
ISSUE_TYPE_CHOICES = [
2265+
("MISSING_AFFECTED_PACKAGE", "Advisory is missing affected package"),
2266+
("MISSING_FIXED_BY_PACKAGE", "Advisory is missing fixed-by package"),
2267+
(
2268+
"MISSING_AFFECTED_AND_FIXED_BY_PACKAGES",
2269+
"Advisory is missing both affected and fixed-by packages",
2270+
),
2271+
("MISSING_SUMMARY", "Advisory is missing summary"),
2272+
("CONFLICTING_FIXED_BY_PACKAGES", "Advisories have conflicting fixed-by packages"),
2273+
("CONFLICTING_AFFECTED_PACKAGES", "Advisories have conflicting affected packages"),
2274+
(
2275+
"CONFLICTING_AFFECTED_AND_FIXED_BY_PACKAGES",
2276+
"Advisories have conflicting affected and fixed-by packages",
2277+
),
2278+
("CONFLICTING_SEVERITY_SCORES", "Advisories have conflicting severity scores"),
2279+
]
2280+
2281+
issue_type = models.CharField(
2282+
max_length=50,
2283+
choices=ISSUE_TYPE_CHOICES,
2284+
blank=False,
2285+
null=False,
2286+
db_index=True,
2287+
help_text="Select the issue that needs to be addressed from the available options.",
2288+
)
2289+
issue_detail = models.TextField(
2290+
help_text="Additional details about the issue.",
2291+
)
2292+
advisories = models.ManyToManyField(
2293+
Advisory,
2294+
related_name="advisory_todos",
2295+
help_text="Advisory/ies where this TODO is applicable.",
2296+
)
2297+
2298+
created_at = models.DateTimeField(
2299+
auto_now_add=True,
2300+
help_text="Timestamp indicating when this TODO was created.",
2301+
)
2302+
2303+
is_resolved = models.BooleanField(
2304+
default=False,
2305+
db_index=True,
2306+
help_text="This TODO is resolved or not.",
2307+
)
2308+
2309+
resolved_at = models.DateTimeField(
2310+
help_text="Timestamp indicating when this TODO was resolved.",
2311+
)
2312+
2313+
resolution_detail = models.TextField(
2314+
help_text="Additional detail on how this TODO was resolved.",
2315+
)

0 commit comments

Comments
 (0)