Skip to content

Commit d40a55f

Browse files
authored
Merge pull request #2386 from aboutcode-org/mitigation-curation
Add support for extra mitigation curation
2 parents e5d3881 + 64c1c20 commit d40a55f

7 files changed

Lines changed: 555 additions & 0 deletions

File tree

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Generated by Django 5.2.11 on 2026-07-22 18:14
2+
3+
import django.db.models.deletion
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
("vulnerabilities", "0140_alter_advisorytodo_issue_type_and_more"),
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name="AdvisoryMitigations",
16+
fields=[
17+
(
18+
"id",
19+
models.AutoField(
20+
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
21+
),
22+
),
23+
(
24+
"base_purl",
25+
models.CharField(
26+
help_text="Version less PURL related to mitigation.", max_length=500
27+
),
28+
),
29+
("upgrade_to_versions_note", models.TextField(blank=True)),
30+
("downgrade_to_versions_note", models.TextField(blank=True)),
31+
("patches_note", models.TextField(blank=True)),
32+
(
33+
"config_change",
34+
models.TextField(
35+
blank=True, help_text="Configuration change to mitigate the advisory."
36+
),
37+
),
38+
("config_change_note", models.TextField(blank=True)),
39+
(
40+
"filter_ports_ips",
41+
models.TextField(
42+
blank=True, help_text="Filter Ports and IPs to mitigate the advisory."
43+
),
44+
),
45+
("filter_ports_ips_note", models.TextField(blank=True)),
46+
("replace_package_note", models.TextField(blank=True)),
47+
("created_at", models.DateTimeField(auto_now_add=True)),
48+
("updated_at", models.DateTimeField(auto_now=True)),
49+
(
50+
"advisory",
51+
models.ForeignKey(
52+
on_delete=django.db.models.deletion.CASCADE,
53+
related_name="mitigations",
54+
to="vulnerabilities.advisoryv2",
55+
),
56+
),
57+
(
58+
"downgrade_to_versions",
59+
models.ManyToManyField(
60+
blank=True,
61+
help_text="Packages that mitigates the advisory by downgrading.",
62+
related_name="downgrade_mitigations",
63+
to="vulnerabilities.packagev2",
64+
),
65+
),
66+
(
67+
"patches",
68+
models.ManyToManyField(
69+
help_text="Patches to mitigate the advisory.",
70+
related_name="patch_mitigations",
71+
to="vulnerabilities.packagecommitpatch",
72+
),
73+
),
74+
(
75+
"replace_with_packages",
76+
models.ManyToManyField(
77+
blank=True,
78+
help_text="Packages that can replace the vulnerable package.",
79+
related_name="replacement_mitigations",
80+
to="vulnerabilities.packagev2",
81+
),
82+
),
83+
(
84+
"upgrade_to_versions",
85+
models.ManyToManyField(
86+
blank=True,
87+
help_text="Packages that mitigates the advisory by upgrading.",
88+
related_name="upgrade_mitigations",
89+
to="vulnerabilities.packagev2",
90+
),
91+
),
92+
],
93+
),
94+
]

vulnerabilities/models.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3470,6 +3470,67 @@ class Meta:
34703470
]
34713471

34723472

3473+
class AdvisoryMitigations(models.Model):
3474+
3475+
advisory = models.ForeignKey(
3476+
AdvisoryV2,
3477+
related_name="mitigations",
3478+
on_delete=models.CASCADE,
3479+
)
3480+
3481+
base_purl = models.CharField(
3482+
max_length=500,
3483+
blank=False,
3484+
help_text="Version less PURL related to mitigation.",
3485+
)
3486+
3487+
upgrade_to_versions = models.ManyToManyField(
3488+
"PackageV2",
3489+
blank=True,
3490+
related_name="upgrade_mitigations",
3491+
help_text="Packages that mitigates the advisory by upgrading.",
3492+
)
3493+
upgrade_to_versions_note = models.TextField(blank=True)
3494+
3495+
downgrade_to_versions = models.ManyToManyField(
3496+
"PackageV2",
3497+
blank=True,
3498+
related_name="downgrade_mitigations",
3499+
help_text="Packages that mitigates the advisory by downgrading.",
3500+
)
3501+
downgrade_to_versions_note = models.TextField(blank=True)
3502+
3503+
patches = models.ManyToManyField(
3504+
"PackageCommitPatch",
3505+
related_name="patch_mitigations",
3506+
help_text="Patches to mitigate the advisory.",
3507+
)
3508+
patches_note = models.TextField(blank=True)
3509+
3510+
config_change = models.TextField(
3511+
blank=True,
3512+
help_text="Configuration change to mitigate the advisory.",
3513+
)
3514+
config_change_note = models.TextField(blank=True)
3515+
3516+
filter_ports_ips = models.TextField(
3517+
blank=True,
3518+
help_text="Filter Ports and IPs to mitigate the advisory.",
3519+
)
3520+
filter_ports_ips_note = models.TextField(blank=True)
3521+
3522+
replace_with_packages = models.ManyToManyField(
3523+
"PackageV2",
3524+
blank=True,
3525+
related_name="replacement_mitigations",
3526+
help_text="Packages that can replace the vulnerable package.",
3527+
)
3528+
replace_package_note = models.TextField(blank=True)
3529+
3530+
created_at = models.DateTimeField(auto_now_add=True)
3531+
updated_at = models.DateTimeField(auto_now=True)
3532+
3533+
34733534
class ToDoRelatedAdvisory(models.Model):
34743535
todo = models.ForeignKey(
34753536
AdvisoryToDo,

vulnerabilities/templates/advisory_todos.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ <h1>Advisory To-Dos</h1>
129129
<a href="{% url 'todo-severity-detail' todo_id=todo.todo_id %}" class="has-text-info">
130130
{% elif todo.issue_type == "CONFLICTING_WEAKNESSES" %}
131131
<a href="{% url 'todo-weakness-detail' todo_id=todo.todo_id %}" class="has-text-info">
132+
{% elif todo.issue_type == "MISSING_FIXED_BY_PACKAGE" %}
133+
<a href="{% url 'todo-mitigation-detail' todo_id=todo.todo_id %}" class="has-text-info">
132134
{% endif %}
133135
<div class="columns px-1 is-vcentered">
134136
<div class="column has-text-left" style="flex: 0 0 20%;">

0 commit comments

Comments
 (0)