Skip to content

Commit 64848a2

Browse files
authored
Merge branch 'main' into fix-docker-env-secrets
2 parents a077fe1 + 624db21 commit 64848a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+5506
-23460
lines changed

README.rst

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ VulnerableCode
1919

2020

2121
VulnerableCode is a free and open database of open source software package
22-
vulnerabilities **because open source software vulnerabilities data and tools
22+
vulnerabilities **because open source software vulnerability data and tools
2323
should be free and open source themselves**:
2424

25-
we are trying to change this and evolve the status quo in a few other areas!
25+
We are trying to change this and evolve the status quo in a few other areas!
2626

2727
- Vulnerability databases have been **traditionally proprietary** even though they
2828
are mostly about free and open source software.
@@ -31,13 +31,13 @@ we are trying to change this and evolve the status quo in a few other areas!
3131
means a lot of false positive signals that require extensive expert reviews.
3232

3333
- Vulnerability databases are also mostly about vulnerabilities first and software
34-
package second, making it difficult to find if and when a vulnerability applies
35-
to a piece of code. VulnerableCode focus is on software package first where
36-
a Package URL is a key and natural identifier for packages; this is making it
34+
packages second, making it difficult to find if and when a vulnerability applies
35+
to a piece of code. VulnerableCode's focus is on software packages first where
36+
a Package URL (PURL) is a key and natural identifier for packages; this makes it
3737
easier to find a package and whether it is vulnerable.
3838

39-
Package URL themselves were designed first in ScanCode and VulnerableCode
40-
and are now a de-facto standard for vulnerability management and package references.
39+
PURLs were designed initially for ScanCode and VulnerableCode. PURL is
40+
now a de-facto standard for vulnerability management and package references.
4141
See https://github.com/package-url/purl-spec
4242

4343
The VulnerableCode project is a FOSS community resource to help improve the
@@ -49,17 +49,14 @@ the database current.
4949

5050
.. pull-quote::
5151
**Warning**
52+
VulnerableCode is under active development and may not be ready for production
53+
use depending on your use cases.
5254

53-
VulnerableCode is under active development and is not yet fully
54-
usable.
55+
Read more about VulnerableCode at https://vulnerablecode.readthedocs.org/
5556

56-
57-
Read more about VulnerableCode https://vulnerablecode.readthedocs.org/
58-
59-
VulnerableCode tech stack is Python, Django, PostgreSQL, nginx and Docker and
57+
The VulnerableCode tech stack is Python, Django, PostgreSQL, nginx and Docker and
6058
several libraries.
6159

62-
6360
Getting started
6461
===============
6562

docs/source/contributing.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ resources to help you get started.
1717
Do Your Homework
1818
----------------
1919

20-
Before adding a contribution or create a new issue, take a look at the projects
20+
Before adding a contribution or create a new issue, take a look at the project's
2121
`README <https://github.com/aboutcode-org/vulnerablecode>`_, read through our
2222
`documentation <https://vulnerablecode.readthedocs.io/en/latest/>`_,
2323
and browse existing `issues <https://github.com/aboutcode-org/vulnerablecode/issues>`_,
@@ -73,7 +73,7 @@ overlooked. We value any suggestions to improve
7373

7474
.. tip::
7575
Our documentation is treated like code. Make sure to check our
76-
`writing guidelines <https://scancode-toolkit.readthedocs.io/en/latest/contribute/contrib_doc.html>`_
76+
`writing guidelines <https://scancode-toolkit.readthedocs.io/en/stable/getting-started/contribute/contributing-docs.html>`_
7777
to help guide new users.
7878

7979
Other Ways
@@ -87,7 +87,7 @@ questions, and interact with us and other community members on
8787
Helpful Resources
8888
-----------------
8989

90-
- Review our `comprehensive guide <https://scancode-toolkit.readthedocs.io/en/latest/contribute/index.html>`_
90+
- Review our `comprehensive guide <https://scancode-toolkit.readthedocs.io/en/stable/getting-started/contribute/index.html>`_
9191
for more details on how to add quality contributions to our codebase and documentation
9292
- Check this free resource on `How to contribute to an open source project on github <https://egghead.io/lessons/javascript-identifying-how-to-contribute-to-an-open-source-project-on-github>`_
9393
- Follow `this wiki page <https://aboutcode.readthedocs.io/en/latest/contributing/writing_good_commit_messages.html>`_

docs/source/tutorial_add_importer_pipeline.rst

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ At this point, an example importer will look like this:
152152
.. code-block:: python
153153
:caption: vulnerabilities/pipelines/example_importer.py
154154
:linenos:
155-
:emphasize-lines: 16-17, 20-21, 23-24
155+
:emphasize-lines: 17-18, 21-22, 24-25
156156
157157
from vulnerabilities.pipelines import VulnerableCodeBaseImporterPipeline
158158
@@ -165,6 +165,7 @@ At this point, an example importer will look like this:
165165
license_url = "https://exmaple.org/license/"
166166
spdx_license_expression = "CC-BY-4.0"
167167
importer_name = "Example Importer"
168+
run_once = False
168169
169170
@classmethod
170171
def steps(cls):
@@ -196,7 +197,7 @@ version management from `univers <https://github.com/aboutcode-org/univers>`_.
196197
.. code-block:: python
197198
:caption: vulnerabilities/pipelines/example_importer.py
198199
:linenos:
199-
:emphasize-lines: 34-35, 37-40
200+
:emphasize-lines: 35-36, 38-41
200201
201202
from datetime import datetime
202203
from datetime import timezone
@@ -223,6 +224,7 @@ version management from `univers <https://github.com/aboutcode-org/univers>`_.
223224
license_url = "https://example.org/license/"
224225
spdx_license_expression = "CC-BY-4.0"
225226
importer_name = "Example Importer"
227+
run_once = False
226228
227229
@classmethod
228230
def steps(cls):
@@ -303,6 +305,17 @@ version management from `univers <https://github.com/aboutcode-org/univers>`_.
303305
Implement ``on_failure`` to handle cleanup in case of pipeline failure.
304306
Cleanup of downloaded archives or cloned repos is necessary to avoid potential resource leakage.
305307

308+
.. tip::
309+
310+
Set ``run_once`` to ``True`` if pipeline is meant to be run once.
311+
312+
- To rerun onetime pipeline, reset ``is_active`` to ``True`` via a migration, pipeline will
313+
run one more time and then deactivate.
314+
315+
- To convert a onetime pipeline to a regular pipeline, set the ``run_once`` class variable
316+
to ``False`` and reset ``is_active` field to ``True`` via a migration.
317+
318+
306319
.. note::
307320

308321
| Use ``make valid`` to format your new code using black and isort automatically.

vulnerabilities/importer.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -512,24 +512,30 @@ def from_dict(cls, affected_pkg: dict):
512512
fixed_version_range = None
513513
affected_range = affected_pkg["affected_version_range"]
514514
fixed_range = affected_pkg["fixed_version_range"]
515-
introduced_by_commit_patches = (
516-
affected_pkg.get("introduced_by_package_commit_patches") or []
517-
)
518-
fixed_by_commit_patches = affected_pkg.get("fixed_by_package_commit_patches") or []
515+
introduced_by_commit_patches = affected_pkg.get("introduced_by_commit_patches") or []
516+
fixed_by_commit_patches = affected_pkg.get("fixed_by_commit_patches") or []
519517

520518
try:
521-
affected_version_range = VersionRange.from_string(affected_range)
522-
fixed_version_range = VersionRange.from_string(fixed_range)
519+
affected_version_range = (
520+
VersionRange.from_string(affected_range) if affected_range else None
521+
)
522+
fixed_version_range = VersionRange.from_string(fixed_range) if fixed_range else None
523523
except:
524524
tb = traceback.format_exc()
525525
logger.error(
526526
f"Cannot create AffectedPackage with invalid or unknown range: {affected_pkg!r} with error: {tb!r}"
527527
)
528528
return
529529

530-
if not fixed_version_range and not affected_version_range:
530+
if (
531+
not fixed_version_range
532+
and not affected_version_range
533+
and not introduced_by_commit_patches
534+
and not fixed_by_commit_patches
535+
):
531536
logger.error(
532-
f"Cannot create AffectedPackage without fixed or affected range: {affected_pkg!r}"
537+
f"Cannot create an AffectedPackage for: {affected_pkg!r}, at least one of the following must be provided: "
538+
"a fixed version range, an affected version range, introduced commit patches, or fixed commit patches"
533539
)
534540
return
535541

@@ -575,6 +581,10 @@ class AdvisoryData:
575581
original_advisory_text: Optional[str] = None
576582

577583
def __post_init__(self):
584+
if self.advisory_id and self.advisory_id in self.aliases:
585+
raise ValueError(
586+
f"advisory_id {self.advisory_id} should not be present in aliases {self.aliases}"
587+
)
578588
if self.summary:
579589
self.summary = self.clean_summary(self.summary)
580590

vulnerabilities/importers/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,18 @@
5555
from vulnerabilities.pipelines.v2_importers import istio_importer as istio_importer_v2
5656
from vulnerabilities.pipelines.v2_importers import mattermost_importer as mattermost_importer_v2
5757
from vulnerabilities.pipelines.v2_importers import mozilla_importer as mozilla_importer_v2
58+
from vulnerabilities.pipelines.v2_importers import nginx_importer as nginx_importer_v2
5859
from vulnerabilities.pipelines.v2_importers import npm_importer as npm_importer_v2
5960
from vulnerabilities.pipelines.v2_importers import nvd_importer as nvd_importer_v2
61+
from vulnerabilities.pipelines.v2_importers import openssl_importer as openssl_importer_v2
6062
from vulnerabilities.pipelines.v2_importers import oss_fuzz as oss_fuzz_v2
6163
from vulnerabilities.pipelines.v2_importers import postgresql_importer as postgresql_importer_v2
64+
from vulnerabilities.pipelines.v2_importers import (
65+
project_kb_msr2019_importer as project_kb_msr2019_importer_v2,
66+
)
67+
from vulnerabilities.pipelines.v2_importers import (
68+
project_kb_statements_importer as project_kb_statements_importer_v2,
69+
)
6270
from vulnerabilities.pipelines.v2_importers import pypa_importer as pypa_importer_v2
6371
from vulnerabilities.pipelines.v2_importers import pysec_importer as pysec_importer_v2
6472
from vulnerabilities.pipelines.v2_importers import redhat_importer as redhat_importer_v2
@@ -87,8 +95,11 @@
8795
github_osv_importer_v2.GithubOSVImporterPipeline,
8896
redhat_importer_v2.RedHatImporterPipeline,
8997
aosp_importer_v2.AospImporterPipeline,
98+
project_kb_statements_importer_v2.ProjectKBStatementsPipeline,
99+
project_kb_msr2019_importer_v2.ProjectKBMSR2019Pipeline,
90100
ruby_importer_v2.RubyImporterPipeline,
91101
epss_importer_v2.EPSSImporterPipeline,
102+
nginx_importer_v2.NginxImporterPipeline,
92103
mattermost_importer_v2.MattermostImporterPipeline,
93104
nvd_importer.NVDImporterPipeline,
94105
github_importer.GitHubAPIImporterPipeline,
@@ -109,6 +120,7 @@
109120
ruby.RubyImporter,
110121
apache_kafka.ApacheKafkaImporter,
111122
openssl.OpensslImporter,
123+
openssl_importer_v2.OpenSSLImporterPipeline,
112124
redhat.RedhatImporter,
113125
archlinux.ArchlinuxImporter,
114126
ubuntu.UbuntuImporter,

vulnerabilities/management/commands/run_scheduler.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,21 @@
1717

1818

1919
def init_pipeline_scheduled():
20-
"""Initialize schedule jobs for active PipelineSchedule."""
21-
active_pipeline_qs = models.PipelineSchedule.objects.filter(is_active=True).order_by(
22-
"created_date"
23-
)
24-
for pipeline_schedule in active_pipeline_qs:
25-
if scheduled_job_exists(pipeline_schedule.schedule_work_id):
26-
continue
27-
new_id = pipeline_schedule.create_new_job()
28-
pipeline_schedule.schedule_work_id = new_id
29-
pipeline_schedule.save(update_fields=["schedule_work_id"])
20+
"""
21+
Initialize schedule jobs for active PipelineSchedule.
22+
- Create new schedule if there is no schedule for active pipeline
23+
- Create new schedule if schedule is corrupted for an active pipeline
24+
- Delete schedule for inactive pipeline
25+
"""
26+
pipeline_qs = models.PipelineSchedule.objects.order_by("created_date")
27+
for pipeline in pipeline_qs:
28+
reset_schedule = pipeline.is_active != bool(pipeline.schedule_work_id)
29+
if not scheduled_job_exists(pipeline.schedule_work_id):
30+
reset_schedule = True
31+
32+
if reset_schedule:
33+
pipeline.schedule_work_id = pipeline.create_new_job()
34+
pipeline.save(update_fields=["schedule_work_id"])
3035

3136

3237
class Command(rqscheduler.Command):
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Generated by Django 4.2.22 on 2026-01-08 13:41
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("vulnerabilities", "0109_alter_advisoryseverity_scoring_elements_and_more"),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name="pipelineschedule",
15+
name="is_run_once",
16+
field=models.BooleanField(
17+
db_index=True,
18+
default=False,
19+
help_text="When set to True, this Pipeline will run only once.",
20+
),
21+
),
22+
]
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Generated by Django 4.2.25 on 2026-01-19 06:22
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("vulnerabilities", "0110_pipelineschedule_is_run_once"),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name="advisoryseverity",
15+
name="scoring_system",
16+
field=models.CharField(
17+
choices=[
18+
("cvssv2", "CVSSv2 Base Score"),
19+
("cvssv3", "CVSSv3 Base Score"),
20+
("cvssv3.1", "CVSSv3.1 Base Score"),
21+
("cvssv4", "CVSSv4 Base Score"),
22+
("rhbs", "RedHat Bugzilla severity"),
23+
("rhas", "RedHat Aggregate severity"),
24+
("archlinux", "Archlinux Vulnerability Group Severity"),
25+
("cvssv3.1_qr", "CVSSv3.1 Qualitative Severity Rating"),
26+
("generic_textual", "Generic textual severity rating"),
27+
("apache_httpd", "Apache Httpd Severity"),
28+
("apache_tomcat", "Apache Tomcat Severity"),
29+
("epss", "Exploit Prediction Scoring System"),
30+
("ssvc", "Stakeholder-Specific Vulnerability Categorization"),
31+
("openssl", "OpenSSL Severity"),
32+
],
33+
help_text="Identifier for the scoring system used. Available choices are: cvssv2: CVSSv2 Base Score,\ncvssv3: CVSSv3 Base Score,\ncvssv3.1: CVSSv3.1 Base Score,\ncvssv4: CVSSv4 Base Score,\nrhbs: RedHat Bugzilla severity,\nrhas: RedHat Aggregate severity,\narchlinux: Archlinux Vulnerability Group Severity,\ncvssv3.1_qr: CVSSv3.1 Qualitative Severity Rating,\ngeneric_textual: Generic textual severity rating,\napache_httpd: Apache Httpd Severity,\napache_tomcat: Apache Tomcat Severity,\nepss: Exploit Prediction Scoring System,\nssvc: Stakeholder-Specific Vulnerability Categorization,\nopenssl: OpenSSL Severity ",
34+
max_length=50,
35+
),
36+
),
37+
migrations.AlterField(
38+
model_name="vulnerabilityseverity",
39+
name="scoring_system",
40+
field=models.CharField(
41+
choices=[
42+
("cvssv2", "CVSSv2 Base Score"),
43+
("cvssv3", "CVSSv3 Base Score"),
44+
("cvssv3.1", "CVSSv3.1 Base Score"),
45+
("cvssv4", "CVSSv4 Base Score"),
46+
("rhbs", "RedHat Bugzilla severity"),
47+
("rhas", "RedHat Aggregate severity"),
48+
("archlinux", "Archlinux Vulnerability Group Severity"),
49+
("cvssv3.1_qr", "CVSSv3.1 Qualitative Severity Rating"),
50+
("generic_textual", "Generic textual severity rating"),
51+
("apache_httpd", "Apache Httpd Severity"),
52+
("apache_tomcat", "Apache Tomcat Severity"),
53+
("epss", "Exploit Prediction Scoring System"),
54+
("ssvc", "Stakeholder-Specific Vulnerability Categorization"),
55+
("openssl", "OpenSSL Severity"),
56+
],
57+
help_text="Identifier for the scoring system used. Available choices are: cvssv2: CVSSv2 Base Score,\ncvssv3: CVSSv3 Base Score,\ncvssv3.1: CVSSv3.1 Base Score,\ncvssv4: CVSSv4 Base Score,\nrhbs: RedHat Bugzilla severity,\nrhas: RedHat Aggregate severity,\narchlinux: Archlinux Vulnerability Group Severity,\ncvssv3.1_qr: CVSSv3.1 Qualitative Severity Rating,\ngeneric_textual: Generic textual severity rating,\napache_httpd: Apache Httpd Severity,\napache_tomcat: Apache Tomcat Severity,\nepss: Exploit Prediction Scoring System,\nssvc: Stakeholder-Specific Vulnerability Categorization,\nopenssl: OpenSSL Severity ",
58+
max_length=50,
59+
),
60+
),
61+
]

0 commit comments

Comments
 (0)