Skip to content

Commit 3b39e3c

Browse files
committed
Resolve migration conflicts
Rename the pipeline name Add the missing pygithub dependency Signed-off-by: ziad hany <ziadhany2016@gmail.com>
1 parent 3dd4af6 commit 3b39e3c

File tree

5 files changed

+23
-26
lines changed

5 files changed

+23
-26
lines changed

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,4 @@ wcwidth==0.2.5
126126
websocket-client==0.59.0
127127
yarl==1.7.2
128128
zipp==3.19.1
129+
PyGithub==2.8.1

vulnerabilities/importers/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
from vulnerabilities.pipelines.v2_importers import (
4949
elixir_security_importer as elixir_security_importer_v2,
5050
)
51-
from vulnerabilities.pipelines.v2_importers import github_issue_pr as github_issue_pr_v2
5251
from vulnerabilities.pipelines.v2_importers import epss_importer_v2
5352
from vulnerabilities.pipelines.v2_importers import fireeye_importer_v2
53+
from vulnerabilities.pipelines.v2_importers import github_issue_pr as github_issue_pr_v2
5454
from vulnerabilities.pipelines.v2_importers import github_osv_importer as github_osv_importer_v2
5555
from vulnerabilities.pipelines.v2_importers import gitlab_importer as gitlab_importer_v2
5656
from vulnerabilities.pipelines.v2_importers import istio_importer as istio_importer_v2
@@ -101,6 +101,7 @@
101101
epss_importer_v2.EPSSImporterPipeline,
102102
nginx_importer_v2.NginxImporterPipeline,
103103
mattermost_importer_v2.MattermostImporterPipeline,
104+
github_issue_pr_v2.GithubPipelineIssuePRPipeline,
104105
nvd_importer.NVDImporterPipeline,
105106
github_importer.GitHubAPIImporterPipeline,
106107
gitlab_importer.GitLabImporterPipeline,
@@ -136,6 +137,5 @@
136137
ubuntu_usn.UbuntuUSNImporter,
137138
fireeye.FireyeImporter,
138139
oss_fuzz.OSSFuzzImporter,
139-
github_issue_pr_v2.GithubPipelineIssuePR,
140140
]
141141
)

vulnerabilities/pipelines/v2_importers/github_issue_pr.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
GITHUB_TOKEN = env.str("GITHUB_TOKEN")
2121

2222

23-
class GithubPipelineIssuePR(VulnerableCodeBaseImporterPipelineV2):
23+
class GithubPipelineIssuePRPipeline(VulnerableCodeBaseImporterPipelineV2):
2424
"""
2525
Pipeline to collect GitHub issues and PRs related to vulnerabilities.
2626
"""
2727

28-
pipeline_id = "collect_issues_pr"
28+
pipeline_id = "collect_github_issues_pr"
2929

3030
@classmethod
3131
def steps(cls):
@@ -86,7 +86,7 @@ def collect_advisories(self):
8686

8787
yield AdvisoryData(
8888
advisory_id=vuln_id,
89-
aliases=[vuln_id],
89+
aliases=[],
9090
references_v2=references,
9191
url=self.repo_url,
9292
)

vulnerabilities/tests/pipelines/v2_importers/test_github_issue_pr.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414

1515
import pytest
1616

17-
from vulnerabilities.pipelines.v2_importers.github_issue_pr import GithubPipelineIssuePR
17+
from vulnerabilities.pipelines.v2_importers.github_issue_pr import GithubPipelineIssuePRPipeline
1818
from vulnerabilities.tests import util_tests
1919

20+
TEST_DATA = Path(__file__).parent.parent.parent / "test_data" / "github_issue_pr"
21+
2022

2123
@pytest.fixture
2224
def pipeline():
23-
pipeline = GithubPipelineIssuePR()
25+
pipeline = GithubPipelineIssuePRPipeline()
2426
pipeline.repo_url = "https://github.com/test/repo"
2527
pipeline.log = MagicMock()
2628
return pipeline
@@ -32,44 +34,41 @@ def test_collect_issues_and_prs(pipeline):
3234
SimpleNamespace(
3335
title="Fix for CVE-2023-1234 found",
3436
body="This resolves a security issue",
35-
html_url="http://example.com/issue1",
37+
html_url="https://example.com/issue1",
3638
),
3739
SimpleNamespace(
3840
title="No vulnerability mentioned",
3941
body="This is unrelated",
40-
html_url="http://example.com/issue2",
42+
html_url="https://example.com/issue2",
4143
),
4244
]
4345

4446
pipeline.pull_requestes = [
4547
SimpleNamespace(
4648
title="Patch addressing GHSA-zzz-111",
4749
body="Also fixes PYSEC-2024-5678",
48-
html_url="http://example.com/pr1",
50+
html_url="https://example.com/pr1",
4951
)
5052
]
5153

5254
result = pipeline.collect_issues_and_prs()
5355
expected = {
54-
"CVE-2023-1234": [("Issue", "http://example.com/issue1")],
55-
"GHSA-zzz-111": [("PR", "http://example.com/pr1")],
56-
"PYSEC-2024-5678": [("PR", "http://example.com/pr1")],
56+
"CVE-2023-1234": [("Issue", "https://example.com/issue1")],
57+
"GHSA-zzz-111": [("PR", "https://example.com/pr1")],
58+
"PYSEC-2024-5678": [("PR", "https://example.com/pr1")],
5759
}
5860

5961
assert result == expected
6062

6163

62-
TEST_DATA = Path(__file__).parent.parent.parent / "test_data" / "github_issue_pr"
63-
64-
6564
@pytest.mark.django_db
6665
def test_collect_advisories_from_json():
6766
input_file = TEST_DATA / "issues_and_pr.json"
6867
expected_file = TEST_DATA / "expected_advisory_output.json"
6968

7069
issues_and_prs = json.loads(input_file.read_text(encoding="utf-8"))
7170

72-
pipeline = GithubPipelineIssuePR()
71+
pipeline = GithubPipelineIssuePRPipeline()
7372
pipeline.repo_url = "https://github.com/test/repo"
7473
pipeline.log = MagicMock()
7574

vulnerabilities/tests/test_data/github_issue_pr/expected_advisory_output.json

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
[
22
{
33
"advisory_id": "CVE-2023-1234",
4-
"aliases": [
5-
"CVE-2023-1234"
6-
],
4+
"aliases": [],
75
"summary": "",
86
"affected_packages": [],
97
"references_v2": [
@@ -18,16 +16,15 @@
1816
"url": "https://example.com/pr1"
1917
}
2018
],
19+
"patches": [],
2120
"severities": [],
2221
"date_published": null,
2322
"weaknesses": [],
2423
"url": "https://github.com/test/repo"
2524
},
2625
{
2726
"advisory_id": "GHSA-zzz-111",
28-
"aliases": [
29-
"GHSA-zzz-111"
30-
],
27+
"aliases": [],
3128
"summary": "",
3229
"affected_packages": [],
3330
"references_v2": [
@@ -37,16 +34,15 @@
3734
"url": "https://example.com/pr1"
3835
}
3936
],
37+
"patches": [],
4038
"severities": [],
4139
"date_published": null,
4240
"weaknesses": [],
4341
"url": "https://github.com/test/repo"
4442
},
4543
{
4644
"advisory_id": "PYSEC-2024-5678",
47-
"aliases": [
48-
"PYSEC-2024-5678"
49-
],
45+
"aliases": [],
5046
"summary": "",
5147
"affected_packages": [],
5248
"references_v2": [
@@ -56,6 +52,7 @@
5652
"url": "https://example.com/pr1"
5753
}
5854
],
55+
"patches": [],
5956
"severities": [],
6057
"date_published": null,
6158
"weaknesses": [],

0 commit comments

Comments
 (0)