Skip to content

Commit b6ad5ef

Browse files
committed
Add V2 pipelines
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
1 parent ee162af commit b6ad5ef

9 files changed

+988
-158
lines changed

vulnerabilities/importers/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,18 @@
4343
from vulnerabilities.pipelines import nvd_importer
4444
from vulnerabilities.pipelines import pypa_importer
4545
from vulnerabilities.pipelines import pysec_importer
46+
from vulnerabilities.pipelines.v2_importers import apache_httpd_pipeline_v2 as apache_httpd_v2
4647
from vulnerabilities.pipelines.v2_importers import github_importer as github_importer_v2
48+
from vulnerabilities.pipelines.v2_importers import npm_importer as npm_importer_v2
4749
from vulnerabilities.pipelines.v2_importers import nvd_importer as nvd_importer_v2
50+
from vulnerabilities.pipelines.v2_importers import vulnrichment_importer as vulnrichment_importer_v2
4851

4952
IMPORTERS_REGISTRY = [
5053
nvd_importer_v2.NVDImporterPipeline,
5154
github_importer_v2.GitHubAPIImporterPipeline,
55+
npm_importer_v2.NpmImporterPipeline,
56+
vulnrichment_importer_v2.VulnrichImporterPipeline,
57+
apache_httpd_v2.ApacheHTTPDImporterPipeline,
5258
nvd_importer.NVDImporterPipeline,
5359
github_importer.GitHubAPIImporterPipeline,
5460
gitlab_importer.GitLabImporterPipeline,

vulnerabilities/migrations/0092_advisoryalias_advisoryreference_advisoryseverity_and_more.py

Lines changed: 140 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by Django 4.2.20 on 2025-04-24 09:58
1+
# Generated by Django 4.2.20 on 2025-05-21 05:33
22

33
from django.db import migrations, models
44

@@ -152,6 +152,103 @@ class Migration(migrations.Migration):
152152
("cwe_id", models.IntegerField(help_text="CWE id")),
153153
],
154154
),
155+
migrations.CreateModel(
156+
name="PackageV2",
157+
fields=[
158+
(
159+
"id",
160+
models.AutoField(
161+
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
162+
),
163+
),
164+
(
165+
"type",
166+
models.CharField(
167+
blank=True,
168+
help_text="A short code to identify the type of this package. For example: gem for a Rubygem, docker for a container, pypi for a Python Wheel or Egg, maven for a Maven Jar, deb for a Debian package, etc.",
169+
max_length=16,
170+
),
171+
),
172+
(
173+
"namespace",
174+
models.CharField(
175+
blank=True,
176+
help_text="Package name prefix, such as Maven groupid, Docker image owner, GitHub user or organization, etc.",
177+
max_length=255,
178+
),
179+
),
180+
(
181+
"name",
182+
models.CharField(blank=True, help_text="Name of the package.", max_length=100),
183+
),
184+
(
185+
"version",
186+
models.CharField(
187+
blank=True, help_text="Version of the package.", max_length=100
188+
),
189+
),
190+
(
191+
"qualifiers",
192+
models.CharField(
193+
blank=True,
194+
help_text="Extra qualifying data for a package such as the name of an OS, architecture, distro, etc.",
195+
max_length=1024,
196+
),
197+
),
198+
(
199+
"subpath",
200+
models.CharField(
201+
blank=True,
202+
help_text="Extra subpath within a package, relative to the package root.",
203+
max_length=200,
204+
),
205+
),
206+
(
207+
"package_url",
208+
models.CharField(
209+
db_index=True,
210+
help_text="The Package URL for this package.",
211+
max_length=1000,
212+
),
213+
),
214+
(
215+
"plain_package_url",
216+
models.CharField(
217+
db_index=True,
218+
help_text="The Package URL for this package without qualifiers and subpath.",
219+
max_length=1000,
220+
),
221+
),
222+
(
223+
"is_ghost",
224+
models.BooleanField(
225+
db_index=True,
226+
default=False,
227+
help_text="True if the package does not exist in the upstream package manager or its repository.",
228+
),
229+
),
230+
(
231+
"risk_score",
232+
models.DecimalField(
233+
decimal_places=1,
234+
help_text="Risk score between 0.00 and 10.00, where higher values indicate greater vulnerability risk for the package.",
235+
max_digits=3,
236+
null=True,
237+
),
238+
),
239+
(
240+
"version_rank",
241+
models.IntegerField(
242+
db_index=True,
243+
default=0,
244+
help_text="Rank of the version to support ordering by version. Rank zero means the rank has not been defined yet",
245+
),
246+
),
247+
],
248+
options={
249+
"abstract": False,
250+
},
251+
),
155252
migrations.CreateModel(
156253
name="AdvisoryV2",
157254
fields=[
@@ -177,14 +274,6 @@ class Migration(migrations.Migration):
177274
),
178275
),
179276
("summary", models.TextField(blank=True)),
180-
(
181-
"affected_packages",
182-
models.JSONField(
183-
blank=True,
184-
default=list,
185-
help_text="A list of serializable AffectedPackage objects",
186-
),
187-
),
188277
(
189278
"date_published",
190279
models.DateTimeField(
@@ -211,6 +300,40 @@ class Migration(migrations.Migration):
211300
),
212301
),
213302
("url", models.URLField(help_text="Link to the advisory on the upstream website")),
303+
(
304+
"status",
305+
models.IntegerField(
306+
choices=[(1, "Published"), (2, "Disputed"), (3, "Invalid")], default=1
307+
),
308+
),
309+
(
310+
"exploitability",
311+
models.DecimalField(
312+
blank=True,
313+
decimal_places=1,
314+
help_text="Exploitability indicates the likelihood that a vulnerability in a software package could be used by malicious actors to compromise systems, applications, or networks. This metric is determined automatically based on the discovery of known exploits.",
315+
max_digits=2,
316+
null=True,
317+
),
318+
),
319+
(
320+
"weighted_severity",
321+
models.DecimalField(
322+
blank=True,
323+
decimal_places=1,
324+
help_text="Weighted severity is the highest value calculated by multiplying each severity by its corresponding weight, divided by 10.",
325+
max_digits=3,
326+
null=True,
327+
),
328+
),
329+
(
330+
"affecting_packages",
331+
models.ManyToManyField(
332+
help_text="A list of packages that are affected by this advisory.",
333+
related_name="fixing_advisories",
334+
to="vulnerabilities.packagev2",
335+
),
336+
),
214337
(
215338
"aliases",
216339
models.ManyToManyField(
@@ -219,6 +342,14 @@ class Migration(migrations.Migration):
219342
to="vulnerabilities.advisoryalias",
220343
),
221344
),
345+
(
346+
"fixed_by_packages",
347+
models.ManyToManyField(
348+
help_text="A list of packages that are reported by this advisory.",
349+
related_name="affected_by_advisories",
350+
to="vulnerabilities.packagev2",
351+
),
352+
),
222353
(
223354
"references",
224355
models.ManyToManyField(
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 4.2.20 on 2025-05-21 06:40
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("vulnerabilities", "0092_advisoryalias_advisoryreference_advisoryseverity_and_more"),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name="advisoryreference",
15+
name="reference_id",
16+
field=models.CharField(
17+
blank=True,
18+
db_index=True,
19+
help_text="An optional reference ID, such as DSA-4465-1 when available",
20+
max_length=500,
21+
),
22+
),
23+
]

vulnerabilities/migrations/0093_packagev2_remove_advisoryv2_affected_packages_and_more.py

Lines changed: 0 additions & 132 deletions
This file was deleted.

0 commit comments

Comments
 (0)