forked from aboutcode-org/vulnerablecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate from VULCOID to VCID aboutcode-org#811
Use uuid instead of base36 Reference: aboutcode-org#811 Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
- Loading branch information
Showing
7 changed files
with
67 additions
and
28 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
vulnerabilities/migrations/0020_alter_vulnerability_vulnerability_id.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Generated by Django 4.0.4 on 2022-09-05 11:40 | ||
|
||
from django.db import migrations | ||
from django.db import models | ||
import vulnerabilities.models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('vulnerabilities', '0019_alter_vulnerabilityreference_options'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='vulnerability', | ||
name='vulnerability_id', | ||
field=models.CharField(blank=True, default=vulnerabilities.models.get_vcid, help_text='Unique identifier for a vulnerability in the external representation. It is prefixed with VCID-', max_length=45, unique=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from django.db import migrations | ||
from django.db.models import Q | ||
|
||
from vulnerabilities.models import get_vcid | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('vulnerabilities', '0020_alter_vulnerability_vulnerability_id'), | ||
] | ||
|
||
def save_vulnerability_id(apps, schema_editor): | ||
Vulnerabilities = apps.get_model("vulnerabilities", "Vulnerability") | ||
for vulnerability in Vulnerabilities.objects.filter(~Q(vulnerability_id__startswith="VCID-")): | ||
vulnerability.vulnerability_id = get_vcid() | ||
vulnerability.save() | ||
|
||
operations = [ | ||
migrations.RunPython(save_vulnerability_id, migrations.RunPython.noop) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters