-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: tdruez <tdruez@nexb.com>
- Loading branch information
Showing
18 changed files
with
202 additions
and
32 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
component_catalog/migrations/0008_remove_package_affected_by_vulnerabilities_and_more.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,24 @@ | ||
# Generated by Django 5.0.6 on 2024-09-04 08:17 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('component_catalog', '0007_vulnerability_fixed_packages_count_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='package', | ||
name='affected_by_vulnerabilities', | ||
), | ||
migrations.RemoveField( | ||
model_name='component', | ||
name='affected_by_vulnerabilities', | ||
), | ||
migrations.DeleteModel( | ||
name='Vulnerability', | ||
), | ||
] |
53 changes: 53 additions & 0 deletions
53
component_catalog/migrations/0009_componentaffectedbyvulnerability_and_more.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,53 @@ | ||
# Generated by Django 5.0.6 on 2024-09-04 08:17 | ||
|
||
import django.db.models.deletion | ||
import uuid | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('component_catalog', '0008_remove_package_affected_by_vulnerabilities_and_more'), | ||
('dje', '0004_dataspace_vulnerabilities_updated_at'), | ||
('vulnerabilities', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='ComponentAffectedByVulnerability', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, verbose_name='UUID')), | ||
('component', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='component_catalog.component')), | ||
('dataspace', models.ForeignKey(editable=False, help_text='A Dataspace is an independent, exclusive set of DejaCode data, which can be either nexB master reference data or installation-specific data.', on_delete=django.db.models.deletion.PROTECT, to='dje.dataspace')), | ||
('vulnerability', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='vulnerabilities.vulnerability')), | ||
], | ||
options={ | ||
'unique_together': {('component', 'vulnerability'), ('dataspace', 'uuid')}, | ||
}, | ||
), | ||
migrations.AddField( | ||
model_name='component', | ||
name='affected_by_vulnerabilities', | ||
field=models.ManyToManyField(help_text='Vulnerabilities affecting this object.', related_name='affected_%(class)ss', through='component_catalog.ComponentAffectedByVulnerability', to='vulnerabilities.vulnerability'), | ||
), | ||
migrations.CreateModel( | ||
name='PackageAffectedByVulnerability', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, verbose_name='UUID')), | ||
('dataspace', models.ForeignKey(editable=False, help_text='A Dataspace is an independent, exclusive set of DejaCode data, which can be either nexB master reference data or installation-specific data.', on_delete=django.db.models.deletion.PROTECT, to='dje.dataspace')), | ||
('package', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='component_catalog.package')), | ||
('vulnerability', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='vulnerabilities.vulnerability')), | ||
], | ||
options={ | ||
'unique_together': {('dataspace', 'uuid'), ('package', 'vulnerability')}, | ||
}, | ||
), | ||
migrations.AddField( | ||
model_name='package', | ||
name='affected_by_vulnerabilities', | ||
field=models.ManyToManyField(help_text='Vulnerabilities affecting this object.', related_name='affected_%(class)ss', through='component_catalog.PackageAffectedByVulnerability', to='vulnerabilities.vulnerability'), | ||
), | ||
] |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Generated by Django 5.0.6 on 2024-09-04 08:13 | ||
|
||
import django.db.models.deletion | ||
import dje.fields | ||
import uuid | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
('dje', '0004_dataspace_vulnerabilities_updated_at'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Vulnerability', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, verbose_name='UUID')), | ||
('created_date', models.DateTimeField(auto_now_add=True, db_index=True, help_text='The date and time the object was created.')), | ||
('last_modified_date', models.DateTimeField(auto_now=True, db_index=True, help_text='The date and time the object was last modified.')), | ||
('vulnerability_id', models.CharField(help_text="A unique identifier for the vulnerability, prefixed with 'VCID-'. For example, 'VCID-2024-0001'.", max_length=20)), | ||
('summary', models.TextField(blank=True, help_text='A brief summary of the vulnerability, outlining its nature and impact.')), | ||
('aliases', dje.fields.JSONListField(blank=True, default=list, help_text="A list of aliases for this vulnerability, such as CVE identifiers (e.g., 'CVE-2017-1000136').")), | ||
('references', dje.fields.JSONListField(blank=True, default=list, help_text='A list of references for this vulnerability. Each reference includes a URL, an optional reference ID, scores, and the URL for further details. ')), | ||
('fixed_packages', dje.fields.JSONListField(blank=True, default=list, help_text='A list of packages that are not affected by this vulnerability.')), | ||
('fixed_packages_count', models.GeneratedField(db_persist=True, expression=models.Func(models.F('fixed_packages'), function='jsonb_array_length'), output_field=models.IntegerField())), | ||
('min_score', models.FloatField(blank=True, help_text='The minimum score of the range.', null=True)), | ||
('max_score', models.FloatField(blank=True, help_text='The maximum score of the range.', null=True)), | ||
('dataspace', models.ForeignKey(editable=False, help_text='A Dataspace is an independent, exclusive set of DejaCode data, which can be either nexB master reference data or installation-specific data.', on_delete=django.db.models.deletion.PROTECT, to='dje.dataspace')), | ||
], | ||
options={ | ||
'verbose_name_plural': 'Vulnerabilities', | ||
'indexes': [models.Index(fields=['vulnerability_id'], name='vulnerabili_vulnera_92f044_idx')], | ||
'unique_together': {('dataspace', 'uuid'), ('dataspace', 'vulnerability_id')}, | ||
}, | ||
), | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# | ||
# Copyright (c) nexB Inc. and others. All rights reserved. | ||
# DejaCode is a trademark of nexB Inc. | ||
# SPDX-License-Identifier: AGPL-3.0-only | ||
# See https://github.com/aboutcode-org/dejacode for support or download. | ||
# See https://aboutcode.org for more information about AboutCode FOSS projects. | ||
# | ||
|
||
from dje.tests import make_string | ||
from vulnerabilities.models import Vulnerability | ||
|
||
|
||
def make_vulnerability(dataspace, affecting=None, **data): | ||
"""Create a vulnerability for test purposes.""" | ||
if "vulnerability_id" not in data: | ||
data["vulnerability_id"] = f"VCID-0000-{make_string(4)}" | ||
|
||
vulnerability = Vulnerability.objects.create( | ||
dataspace=dataspace, | ||
**data, | ||
) | ||
|
||
if affecting: | ||
vulnerability.add_affected(affecting) | ||
|
||
return vulnerability |
File renamed without changes.
File renamed without changes.
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
Oops, something went wrong.