Skip to content

Commit 7df5892

Browse files
committed
feat: add structured rejection_reason field to CVEDerivationClusterProposal
1 parent 045351e commit 7df5892

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed

src/shared/listeners/automatic_linkage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ def build_new_links(container: Container) -> bool:
113113
CVEDerivationClusterProposal.objects.create(
114114
cve=container.cve,
115115
status=CVEDerivationClusterProposal.Status.REJECTED,
116+
rejection_reason=CVEDerivationClusterProposal.RejectionReason.EXCLUSIVELY_HOSTED_SERVICE,
116117
)
117118
return True
118119

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import django.db.models.deletion
2+
from django.db import migrations, models
3+
4+
5+
class Migration(migrations.Migration):
6+
dependencies = [
7+
("shared", "0069_remove_nixderivation_dependencies_and_more"),
8+
]
9+
10+
operations = [
11+
migrations.AddField(
12+
model_name="cvederivationclusterproposal",
13+
name="rejection_reason",
14+
field=models.CharField(
15+
blank=True,
16+
choices=[
17+
("exclusively_hosted_service", "exclusively hosted service"),
18+
],
19+
help_text="Machine-generated reason for automatic rejection",
20+
max_length=26,
21+
null=True,
22+
),
23+
),
24+
]

src/shared/models/linkage.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ class Status(models.TextChoices):
2828
ACCEPTED = "accepted", _("accepted")
2929
PUBLISHED = "published", _("published")
3030

31+
class RejectionReason(models.TextChoices):
32+
EXCLUSIVELY_HOSTED_SERVICE = "exclusively_hosted_service", _(
33+
"exclusively hosted service"
34+
)
35+
3136
cached: "shared.models.cached.CachedSuggestions"
3237

3338
cve = models.ForeignKey(
@@ -52,6 +57,14 @@ class Status(models.TextChoices):
5257
),
5358
)
5459

60+
rejection_reason = models.CharField(
61+
max_length=text_length(RejectionReason),
62+
choices=RejectionReason.choices,
63+
null=True,
64+
blank=True,
65+
help_text=_("Machine-generated reason for automatic rejection"),
66+
)
67+
5568
@property
5669
def is_editable(self) -> bool:
5770
return self.status in [

src/shared/tests/test_linkage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,5 @@ def test_exclusively_hosted_service_creates_rejected_proposal(
138138
assert result is True
139139
proposal = CVEDerivationClusterProposal.objects.get(cve=container.cve)
140140
assert proposal.status == CVEDerivationClusterProposal.Status.REJECTED
141+
assert proposal.rejection_reason == CVEDerivationClusterProposal.RejectionReason.EXCLUSIVELY_HOSTED_SERVICE
141142
assert proposal.derivations.count() == 0

0 commit comments

Comments
 (0)