Skip to content

Commit e25b437

Browse files
committed
Reset migrations
Signed-off-by: Hritik Vijay <hritikxx8@gmail.com>
1 parent 7d84c41 commit e25b437

File tree

1 file changed

+113
-60
lines changed

1 file changed

+113
-60
lines changed

vulnerabilities/migrations/0001_initial.py

Lines changed: 113 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
# Generated by Django 3.2.9 on 2021-12-08 09:02
1+
# Generated by Django 3.2.9 on 2022-01-23 14:44
22

33
import django.core.validators
44
from django.db import migrations, models
55
import django.db.models.deletion
6+
import uuid
67

78

89
class Migration(migrations.Migration):
@@ -12,46 +13,6 @@ class Migration(migrations.Migration):
1213
dependencies = []
1314

1415
operations = [
15-
migrations.CreateModel(
16-
name="Advisory",
17-
fields=[
18-
(
19-
"id",
20-
models.AutoField(
21-
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
22-
),
23-
),
24-
("vulnerability_id", models.CharField(blank=True, max_length=50, null=True)),
25-
("summary", models.TextField(blank=True, null=True)),
26-
("affected_packages", models.TextField()),
27-
("references", models.TextField()),
28-
(
29-
"date_published",
30-
models.DateField(
31-
blank=True, help_text="UTC Date of publication of the advisory", null=True
32-
),
33-
),
34-
(
35-
"date_collected",
36-
models.DateField(help_text="UTC Date on which the advisory was collected"),
37-
),
38-
(
39-
"date_improved",
40-
models.DateTimeField(
41-
blank=True,
42-
help_text="Latest date on which the advisory was improved by an improver",
43-
null=True,
44-
),
45-
),
46-
(
47-
"created_by",
48-
models.CharField(
49-
help_text="Fully qualified name of the importer prefixed with the module name importing the advisory. Eg: vulnerabilities.importers.nginx.NginxDataSource",
50-
max_length=100,
51-
),
52-
),
53-
],
54-
),
5516
migrations.CreateModel(
5617
name="Importer",
5718
fields=[
@@ -155,23 +116,19 @@ class Migration(migrations.Migration):
155116
),
156117
(
157118
"vulnerability_id",
158-
models.CharField(
159-
help_text="Unique identifier for a vulnerability: this is either a published CVE id (as in CVE-2020-7965) if it exists. Otherwise this is a VulnerableCode-assigned VULCOID (as in VULCOID-20210222-1315-16461541). When a vulnerability CVE is assigned later we replace this with the CVE and keep the 'old' VULCOID in the 'old_vulnerability_id' field to support redirection to the CVE id.",
160-
max_length=50,
119+
models.UUIDField(
120+
default=uuid.uuid4,
121+
editable=False,
122+
help_text="Unique identifier for a vulnerability in this database, assigned automatically. In the external representation it is prefixed with VULCOID-",
161123
unique=True,
162124
),
163125
),
164126
(
165-
"old_vulnerability_id",
166-
models.CharField(
167-
blank=True,
168-
help_text="empty if no CVE else VC id",
169-
max_length=50,
170-
null=True,
171-
unique=True,
127+
"summary",
128+
models.TextField(
129+
blank=True, help_text="Summary of the vulnerability", null=True
172130
),
173131
),
174-
("summary", models.TextField(blank=True, help_text="Summary of the vulnerability")),
175132
],
176133
options={
177134
"verbose_name_plural": "Vulnerabilities",
@@ -226,7 +183,7 @@ class Migration(migrations.Migration):
226183
"created_by",
227184
models.CharField(
228185
blank=True,
229-
help_text="Fully qualified name of the improver prefixed with the module name responsible for creating this relation. Eg: vulnerabilities.importers.nginx.NginxTimeTravel",
186+
help_text="Fully qualified name of the improver prefixed with themodule name responsible for creating this relation. Eg:vulnerabilities.importers.nginx.NginxBasicImprover",
230187
max_length=100,
231188
),
232189
),
@@ -266,7 +223,6 @@ class Migration(migrations.Migration):
266223
],
267224
options={
268225
"verbose_name_plural": "PackageRelatedVulnerabilities",
269-
"unique_together": {("package", "vulnerability")},
270226
},
271227
),
272228
migrations.AddField(
@@ -279,7 +235,7 @@ class Migration(migrations.Migration):
279235
),
280236
),
281237
migrations.CreateModel(
282-
name="VulnerabilitySeverity",
238+
name="Alias",
283239
fields=[
284240
(
285241
"id",
@@ -288,8 +244,93 @@ class Migration(migrations.Migration):
288244
),
289245
),
290246
(
291-
"value",
292-
models.CharField(help_text="Example: 9.0, Important, High", max_length=50),
247+
"alias",
248+
models.CharField(
249+
help_text="An alias is a unique vulnerability identifier in some database, such as CVE-2020-2233",
250+
max_length=50,
251+
unique=True,
252+
),
253+
),
254+
(
255+
"vulnerability",
256+
models.ForeignKey(
257+
on_delete=django.db.models.deletion.CASCADE,
258+
related_name="aliases",
259+
to="vulnerabilities.vulnerability",
260+
),
261+
),
262+
],
263+
),
264+
migrations.CreateModel(
265+
name="Advisory",
266+
fields=[
267+
(
268+
"id",
269+
models.AutoField(
270+
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
271+
),
272+
),
273+
(
274+
"aliases",
275+
models.JSONField(blank=True, default=list, help_text="A list of alias strings"),
276+
),
277+
("summary", models.TextField(blank=True, null=True)),
278+
(
279+
"affected_packages",
280+
models.JSONField(
281+
blank=True,
282+
default=list,
283+
help_text="A list of serializable AffectedPackage objects",
284+
),
285+
),
286+
(
287+
"references",
288+
models.JSONField(
289+
blank=True,
290+
default=list,
291+
help_text="A list of serializable Reference objects",
292+
),
293+
),
294+
(
295+
"date_published",
296+
models.DateTimeField(
297+
blank=True, help_text="UTC Date of publication of the advisory", null=True
298+
),
299+
),
300+
(
301+
"date_collected",
302+
models.DateTimeField(help_text="UTC Date on which the advisory was collected"),
303+
),
304+
(
305+
"date_improved",
306+
models.DateTimeField(
307+
blank=True,
308+
help_text="Latest date on which the advisory was improved by an improver",
309+
null=True,
310+
),
311+
),
312+
(
313+
"created_by",
314+
models.CharField(
315+
help_text="Fully qualified name of the importer prefixed with themodule name importing the advisory. Eg:vulnerabilities.importers.nginx.NginxDataSource",
316+
max_length=100,
317+
),
318+
),
319+
],
320+
options={
321+
"unique_together": {
322+
("aliases", "summary", "affected_packages", "references", "date_published")
323+
},
324+
},
325+
),
326+
migrations.CreateModel(
327+
name="VulnerabilitySeverity",
328+
fields=[
329+
(
330+
"id",
331+
models.AutoField(
332+
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
333+
),
293334
),
294335
(
295336
"scoring_system",
@@ -308,10 +349,14 @@ class Migration(migrations.Migration):
308349
("generic_textual", "Generic textual severity rating"),
309350
("apache_httpd", "Apache Httpd Severity"),
310351
],
311-
help_text="identifier for the scoring system used. Available choices are: cvssv2 is vulnerability_id for CVSSv2 Base Score system, cvssv2_vector is vulnerability_id for CVSSv2 Vector system, cvssv3 is vulnerability_id for CVSSv3 Base Score system, cvssv3_vector is vulnerability_id for CVSSv3 Vector system, cvssv3.1 is vulnerability_id for CVSSv3.1 Base Score system, cvssv3.1_vector is vulnerability_id for CVSSv3.1 Vector system, rhbs is vulnerability_id for RedHat Bugzilla severity system, rhas is vulnerability_id for RedHat Aggregate severity system, avgs is vulnerability_id for Archlinux Vulnerability Group Severity system, cvssv3.1_qr is vulnerability_id for CVSSv3.1 Qualitative Severity Rating system, generic_textual is vulnerability_id for Generic textual severity rating system, apache_httpd is vulnerability_id for Apache Httpd Severity system ",
352+
help_text="Identifier for the scoring system used. Available choices are: cvssv2 is vulnerability_id for CVSSv2 Base Score system, cvssv2_vector is vulnerability_id for CVSSv2 Vector system, cvssv3 is vulnerability_id for CVSSv3 Base Score system, cvssv3_vector is vulnerability_id for CVSSv3 Vector system, cvssv3.1 is vulnerability_id for CVSSv3.1 Base Score system, cvssv3.1_vector is vulnerability_id for CVSSv3.1 Vector system, rhbs is vulnerability_id for RedHat Bugzilla severity system, rhas is vulnerability_id for RedHat Aggregate severity system, avgs is vulnerability_id for Archlinux Vulnerability Group Severity system, cvssv3.1_qr is vulnerability_id for CVSSv3.1 Qualitative Severity Rating system, generic_textual is vulnerability_id for Generic textual severity rating system, apache_httpd is vulnerability_id for Apache Httpd Severity system ",
312353
max_length=50,
313354
),
314355
),
356+
(
357+
"value",
358+
models.CharField(help_text="Example: 9.0, Important, High", max_length=50),
359+
),
315360
(
316361
"reference",
317362
models.ForeignKey(
@@ -328,11 +373,19 @@ class Migration(migrations.Migration):
328373
),
329374
],
330375
options={
331-
"unique_together": {("vulnerability", "reference", "scoring_system")},
376+
"unique_together": {("vulnerability", "reference", "scoring_system", "value")},
332377
},
333378
),
379+
migrations.AddIndex(
380+
model_name="packagerelatedvulnerability",
381+
index=models.Index(fields=["fix"], name="vulnerabili_fix_100a33_idx"),
382+
),
383+
migrations.AlterUniqueTogether(
384+
name="packagerelatedvulnerability",
385+
unique_together={("package", "vulnerability")},
386+
),
334387
migrations.AlterUniqueTogether(
335388
name="package",
336-
unique_together={("name", "namespace", "type", "version", "qualifiers", "subpath")},
389+
unique_together={("type", "namespace", "name", "version", "qualifiers", "subpath")},
337390
),
338391
]

0 commit comments

Comments
 (0)