Skip to content

Commit d870b4f

Browse files
committed
Add status field to Package model
- Package can have malicious, ghost, yanked, valid and unknown status Signed-off-by: Keshav Priyadarshi <git@keshav.space>
1 parent f5ac60a commit d870b4f

3 files changed

Lines changed: 58 additions & 1 deletion

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Generated by Django 4.1.13 on 2024-08-21 08:59
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("vulnerabilities", "0059_vulnerabilityseverity_published_at_and_more"),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name="package",
15+
name="status",
16+
field=models.CharField(
17+
choices=[
18+
("malicious", "Malicious Package"),
19+
("ghost", "Ghost Package"),
20+
("yanked", "Yanked Package"),
21+
("valid", "Valid Package"),
22+
("unknown", "Unknown"),
23+
],
24+
db_index=True,
25+
default="unknown",
26+
help_text="The status of the package, malicious, ghost, yanked, valid or unknown.",
27+
max_length=20,
28+
),
29+
),
30+
]

‎vulnerabilities/models.py‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,13 @@ class Package(PackageURLMixin):
591591
# https://github.com/package-url/packageurl-python/pull/35
592592
# https://github.com/package-url/packageurl-python/pull/67
593593
# gets merged
594+
STATUS_CHOICES = [
595+
("malicious", "Malicious Package"),
596+
("ghost", "Ghost Package"),
597+
("yanked", "Yanked Package"),
598+
("valid", "Valid Package"),
599+
("unknown", "Unknown"),
600+
]
594601

595602
vulnerabilities = models.ManyToManyField(
596603
to="Vulnerability", through="PackageRelatedVulnerability"
@@ -610,6 +617,14 @@ class Package(PackageURLMixin):
610617
db_index=True,
611618
)
612619

620+
status = models.CharField(
621+
max_length=20,
622+
choices=STATUS_CHOICES,
623+
default="unknown",
624+
help_text="The status of the package, malicious, ghost, yanked, valid or unknown.",
625+
db_index=True,
626+
)
627+
613628
objects = PackageQuerySet.as_manager()
614629

615630
def save(self, *args, **kwargs):
@@ -1442,7 +1457,7 @@ class Kev(models.Model):
14421457

14431458
known_ransomware_campaign_use = models.BooleanField(
14441459
default=False,
1445-
help_text="""Known if this vulnerability is known to have been leveraged as part of a ransomware campaign;
1460+
help_text="""Known if this vulnerability is known to have been leveraged as part of a ransomware campaign;
14461461
or 'Unknown' if CISA lacks confirmation that the vulnerability has been utilized for ransomware.""",
14471462
)
14481463

‎vulnerabilities/templates/package_details.html‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@
6262
{{ fixed_package_details.purl.to_string }}
6363
</td>
6464
</tr>
65+
<tr>
66+
<td class="two-col-left">
67+
<span
68+
class="has-tooltip-multiline has-tooltip-black has-tooltip-arrow has-tooltip-text-left"
69+
data-tooltip="The package url or purl is a URL string used to identify and locate a software package.">
70+
status
71+
</span>
72+
</td>
73+
<td class="two-col-right">
74+
{{ package.get_status_display }}
75+
</td>
76+
</tr>
6577
</tbody>
6678
</table>
6779
</div>

0 commit comments

Comments
 (0)