Skip to content

Commit 5c8770b

Browse files
committed
Use boolean field to flag ghost package
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
1 parent aa0e57c commit 5c8770b

3 files changed

Lines changed: 25 additions & 44 deletions

File tree

vulnerabilities/migrations/0060_package_status.py

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Generated by Django 4.1.13 on 2024-08-23 10:03
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("vulnerabilities", "0060_alter_kev_known_ransomware_campaign_use_and_more"),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name="package",
15+
name="is_ghost",
16+
field=models.BooleanField(
17+
default=False,
18+
help_text="True if the package does not exist in the upstream package manager or its repository.",
19+
),
20+
),
21+
]

vulnerabilities/models.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -591,13 +591,6 @@ 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-
]
601594

602595
vulnerabilities = models.ManyToManyField(
603596
to="Vulnerability", through="PackageRelatedVulnerability"
@@ -617,12 +610,9 @@ class Package(PackageURLMixin):
617610
db_index=True,
618611
)
619612

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,
613+
is_ghost = models.BooleanField(
614+
default=False,
615+
help_text="True if the package does not exist in the upstream package manager or its repository.",
626616
)
627617

628618
objects = PackageQuerySet.as_manager()
@@ -1457,7 +1447,7 @@ class Kev(models.Model):
14571447

14581448
known_ransomware_campaign_use = models.BooleanField(
14591449
default=False,
1460-
help_text="""Known if this vulnerability is known to have been leveraged as part of a ransomware campaign;
1450+
help_text="""Known if this vulnerability is known to have been leveraged as part of a ransomware campaign;
14611451
or 'Unknown' if CISA lacks confirmation that the vulnerability has been utilized for ransomware.""",
14621452
)
14631453

0 commit comments

Comments
 (0)