Skip to content

Commit c4958b3

Browse files
committed
feat: exclude advisories that do not report fix/affected package from todo computation
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
1 parent 20a0ff3 commit c4958b3

11 files changed

Lines changed: 39 additions & 0 deletions

vulnerabilities/importers/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from vulnerabilities.importers import ubuntu_usn
3333
from vulnerabilities.importers import vulnrichment
3434
from vulnerabilities.importers import xen
35+
from vulnerabilities.pipelines import VulnerableCodeBaseImporterPipelineV2
3536
from vulnerabilities.pipelines import alpine_linux_importer
3637
from vulnerabilities.pipelines import github_importer
3738
from vulnerabilities.pipelines import gitlab_importer
@@ -189,3 +190,9 @@
189190
collect_fix_commits_v2.CollectGitlabFixCommitsPipeline,
190191
]
191192
)
193+
194+
TODO_EXCLUDED_PIPELINES = [
195+
key
196+
for key, value in IMPORTERS_REGISTRY.items()
197+
if issubclass(value, VulnerableCodeBaseImporterPipelineV2) and value.exclude_from_package_todo
198+
]

vulnerabilities/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2958,6 +2958,12 @@ def latest_advisories_for_purl(self, purl):
29582958
qs = self.filter(id__in=Subquery(adv_ids))
29592959
return qs.latest_per_avid()
29602960

2961+
def todo_excluded(self):
2962+
"""Exclude advisory ineligible for ToDo computation."""
2963+
from vulnerabilities.importers import TODO_EXCLUDED_PIPELINES
2964+
2965+
return self.exclude(datasource_id__in=TODO_EXCLUDED_PIPELINES)
2966+
29612967

29622968
class AdvisorySet(models.Model):
29632969

vulnerabilities/pipelines/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,11 @@ class VulnerableCodeBaseImporterPipelineV2(VulnerableCodePipeline):
278278
ignorable_versions = []
279279
precedence = 0
280280

281+
# Set this to True if computing fixed/affected package ToDo is not fruitful for this source.
282+
# An example of such advisory would be pipeline dedicated to collecting issues,
283+
# pull requests, commit messages, EPSS, exploits, etc.
284+
exclude_from_package_todo = False
285+
281286
# Control how often progress log is shown (range: 1–100, higher value = less frequent log)
282287
progress_step = 10
283288

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#
2+
# Copyright (c) nexB Inc. and others. All rights reserved.
3+
# VulnerableCode is a trademark of nexB Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
6+
# See https://github.com/aboutcode-org/vulnerablecode for support or download.
7+
# See https://aboutcode.org for more information about nexB OSS projects.
8+
#

vulnerabilities/pipelines/v2_importers/aosp_importer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class AospImporterPipeline(VulnerableCodeBaseImporterPipelineV2):
3232
license_url = "https://github.com/quarkslab/aosp_dataset/blob/master/LICENSE"
3333

3434
precedence = 200
35+
exclude_from_package_todo = True
3536

3637
@classmethod
3738
def steps(cls):

vulnerabilities/pipelines/v2_importers/epss_importer_v2.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class EPSSImporterPipeline(VulnerableCodeBaseImporterPipelineV2):
3030
spdx_license_expression = "unknown"
3131
importer_name = "EPSS Importer"
3232

33+
exclude_from_package_todo = True
34+
3335
precedence = 200
3436

3537
def advisories_count(self):

vulnerabilities/pipelines/v2_importers/nvd_importer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ class NVDImporterPipeline(VulnerableCodeBaseImporterPipelineV2):
7171
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
7272
"""
7373

74+
exclude_from_package_todo = True
75+
7476
precedence = 100
7577

7678
@classmethod

vulnerabilities/pipelines/v2_importers/project_kb_msr2019_importer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class ProjectKBMSR2019Pipeline(VulnerableCodeBaseImporterPipelineV2):
3030
license_url = "https://github.com/SAP/project-kb/blob/main/LICENSE.txt"
3131
repo_url = "git+https://github.com/SAP/project-kb"
3232

33+
exclude_from_package_todo = True
34+
3335
precedence = 200
3436

3537
@classmethod

vulnerabilities/pipelines/v2_importers/project_kb_statements_importer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class ProjectKBStatementsPipeline(VulnerableCodeBaseImporterPipelineV2):
3737
license_url = "https://github.com/SAP/project-kb/blob/main/LICENSE.txt"
3838
repo_url = "git+https://github.com/SAP/project-kb@vulnerability-data"
3939

40+
exclude_from_package_todo = True
41+
4042
precedence = 200
4143

4244
@classmethod

vulnerabilities/pipelines/v2_importers/suse_score_importer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class SUSESeverityScoreImporterPipeline(VulnerableCodeBaseImporterPipelineV2):
2323
pipeline_id = "suse_importer_v2"
2424
url = "https://ftp.suse.com/pub/projects/security/yaml/suse-cvss-scores.yaml"
2525

26+
exclude_from_package_todo = True
27+
2628
@classmethod
2729
def steps(cls):
2830
return (

0 commit comments

Comments
 (0)