Skip to content

Commit ec64fc9

Browse files
keshav-spacepombredanne
authored andcommitted
test snyk Datasource
Signed-off-by: Keshav Priyadarshi <[email protected]>
1 parent 13328c7 commit ec64fc9

File tree

5 files changed

+361
-0
lines changed

5 files changed

+361
-0
lines changed
Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
[
2+
{
3+
"SNYK-GOLANG-GITHUBCOMCLOUDFLARECFRPKICMDOCTORPKI-2401203": [
4+
"<1.4.3"
5+
],
6+
"SNYK-GOLANG-GITHUBCOMCLOUDFLARECFRPKICMDOCTORPKI-1924465": [
7+
"<1.4.1"
8+
],
9+
"SNYK-GOLANG-GITHUBCOMCLOUDFLARECFRPKICMDOCTORPKI-1915648": [
10+
"<1.4.0"
11+
],
12+
"SNYK-GOLANG-GITHUBCOMCLOUDFLARECFRPKICMDOCTORPKI-1915560": [
13+
"<1.4.0"
14+
],
15+
"SNYK-GOLANG-GITHUBCOMCLOUDFLARECFRPKICMDOCTORPKI-1915390": [
16+
"<1.4.0"
17+
],
18+
"SNYK-GOLANG-GITHUBCOMCLOUDFLARECFRPKISYNCLIB-1915559": [
19+
"<1.4.0"
20+
],
21+
"SNYK-GOLANG-GITHUBCOMCLOUDFLARECFRPKIVALIDATORLIB-1915544": [
22+
"<1.4.0"
23+
],
24+
"SNYK-GOLANG-GITHUBCOMCLOUDFLARECFRPKIVALIDATORLIB-1915643": [
25+
"<1.4.0"
26+
],
27+
"SNYK-GOLANG-GITHUBCOMCLOUDFLARECFRPKIVALIDATORLIB-1583445": [
28+
"<1.3.0"
29+
],
30+
"SNYK-GOLANG-GITHUBCOMCLOUDFLARECFRPKIVALIDATORPKI-2401204": [
31+
"<1.4.3"
32+
],
33+
"SNYK-GOLANG-GITHUBCOMCLOUDFLARECFRPKIVALIDATORPKI-1915649": [
34+
"<v1.4.0"
35+
]
36+
},
37+
{
38+
"SNYK-PHP-CENTREONCENTREON-2971021": [
39+
"<21.4.16",
40+
">=21.10.0-beta.1, <21.10.8",
41+
">=22.4.0-beta.1, <22.4.1"
42+
],
43+
"SNYK-PHP-CENTREONCENTREON-2971034": [
44+
"<21.4.16",
45+
">=21.10.0-beta.1, <21.10.8",
46+
">=22.4.0-beta.1, <22.4.1"
47+
],
48+
"SNYK-PHP-CENTREONCENTREON-1567260": [
49+
">=19.10.0, <20.4.0-beta.1",
50+
">=19.4.0, <19.4.15"
51+
],
52+
"SNYK-PHP-CENTREONCENTREON-1536559": [
53+
">=21.4.0, <21.4.2",
54+
">=20.10.0, <20.10.8",
55+
"<20.4.14"
56+
],
57+
"SNYK-PHP-CENTREONCENTREON-1536560": [
58+
">=21.4.0, <21.4.2",
59+
">=20.10.0, <20.10.8",
60+
"<20.4.14"
61+
],
62+
"SNYK-PHP-CENTREONCENTREON-1536561": [
63+
">=21.4.0, <21.4.2",
64+
">=20.10.0, <20.10.8",
65+
"<20.4.14"
66+
],
67+
"SNYK-PHP-CENTREONCENTREON-1534849": [
68+
">=19.0.0, <19.4.5",
69+
">=18.10.0, <18.10.8",
70+
"<2.8.30"
71+
],
72+
"SNYK-PHP-CENTREONCENTREON-1320017": [
73+
"<20.4.13"
74+
],
75+
"SNYK-PHP-CENTREONCENTREON-1320018": [
76+
"<20.4.13"
77+
],
78+
"SNYK-PHP-CENTREONCENTREON-1296846": [
79+
"<21.4.0"
80+
],
81+
"SNYK-PHP-CENTREONCENTREON-1247370": [
82+
"<2.8.37",
83+
">=20.10, <20.10.7",
84+
">=20.4, <20.4.13",
85+
">=19.10, <19.10.23"
86+
],
87+
"SNYK-PHP-CENTREONCENTREON-1075031": [
88+
"<2.8.37",
89+
">=21.4, <21.4.1",
90+
">=20.10, <20.10.7",
91+
">=20.4, <20.4.13",
92+
">=19.10, <19.10.23"
93+
],
94+
"SNYK-PHP-CENTREONCENTREON-570529": [
95+
">=0.0.0, <1.6.4",
96+
">=18.10.0, <18.10.5",
97+
">=19.4.0, <19.4.3",
98+
">=19.10.0-beta.1, <19.10.2"
99+
],
100+
"SNYK-PHP-CENTREONCENTREON-570528": [
101+
">=0.0.0, <1.6.4",
102+
">=18.10.0, <18.10.5",
103+
">=19.4.0, <19.4.3",
104+
">=19.10.0-beta.1, <19.10.2"
105+
],
106+
"SNYK-PHP-CENTREONCENTREON-570527": [
107+
"<19.10.7"
108+
],
109+
"SNYK-PHP-CENTREONCENTREON-570051": [
110+
"<19.4.15"
111+
],
112+
"SNYK-PHP-CENTREONCENTREON-564443": [
113+
"<19.10.13"
114+
],
115+
"SNYK-PHP-CENTREONCENTREON-560860": [
116+
"<19.4.5"
117+
],
118+
"SNYK-PHP-CENTREONCENTREON-560859": [
119+
"<19.4.5"
120+
],
121+
"SNYK-PHP-CENTREONCENTREON-560847": [
122+
"<19.4.5"
123+
],
124+
"SNYK-PHP-CENTREONCENTREON-559334": [
125+
">=18.10.6, <18.10.8",
126+
">=19.10.0, <19.10.2",
127+
">=19.04.2, <19.04.5"
128+
],
129+
"SNYK-PHP-CENTREONCENTREON-559444": [
130+
">=19.10.0, <19.10.2",
131+
">=19.4.0, <19.4.5",
132+
">=18.10.0, <18.10.8",
133+
"<2.8.30"
134+
],
135+
"SNYK-PHP-CENTREONCENTREON-559445": [
136+
">=19.10.0, <19.10.2",
137+
">=19.4.0, <19.4.5",
138+
"<18.10.8"
139+
],
140+
"SNYK-PHP-CENTREONCENTREON-559335": [
141+
">=18.10.6, <18.10.9",
142+
">=19.10.0, <19.10.3",
143+
">=19.04.2, <19.04.7"
144+
],
145+
"SNYK-PHP-CENTREONCENTREON-551996": [
146+
">=19.10.0, <19.10.2",
147+
"<19.4.5"
148+
],
149+
"SNYK-PHP-CENTREONCENTREON-536206": [
150+
">=19.10.0, <19.10.2",
151+
">=19.4.0, <19.4.5",
152+
">=18.10.0, <18.10.8",
153+
">=2.8.0, <2.8.30"
154+
],
155+
"SNYK-PHP-CENTREONCENTREON-536202": [
156+
">=19.10.0, <19.10.2",
157+
">=18.10.0, <18.10.8",
158+
">=2.8.0, <2.8.30",
159+
">=19.4.0, <19.4.5"
160+
],
161+
"SNYK-PHP-CENTREONCENTREON-535972": [
162+
">=18.10.6, <18.10.8",
163+
">=19.4.2, <19.4.5",
164+
">=2.7.3, <2.8.30"
165+
],
166+
"SNYK-PHP-CENTREONCENTREON-473006": [
167+
">=0.0.0"
168+
],
169+
"SNYK-PHP-CENTREONCENTREON-472423": [
170+
">=2.8.0, <2.8.28",
171+
">=18.10.0, <18.10.4"
172+
],
173+
"SNYK-PHP-CENTREONCENTREON-472430": [
174+
">=20.10.0, <20.10.3",
175+
">=20.4.0, <20.4.9",
176+
">=19.10.0, <19.10.19"
177+
],
178+
"SNYK-PHP-CENTREONCENTREON-472429": [
179+
">=2.8.0, <2.8.28",
180+
">=18.10.0, <18.10.5"
181+
],
182+
"SNYK-PHP-CENTREONCENTREON-472428": [
183+
">=18.10.0, <18.10.4"
184+
],
185+
"SNYK-PHP-CENTREONCENTREON-472425": [
186+
">=2.8.0, <2.8.27",
187+
">=18.10.0, <18.10.4"
188+
],
189+
"SNYK-PHP-CENTREONCENTREON-472424": [
190+
">=2.8.0, <18.10.5"
191+
],
192+
"SNYK-PHP-CENTREONCENTREON-472422": [
193+
">=2.8.0, <2.8.27",
194+
">=18.10.0, <18.10.4"
195+
],
196+
"SNYK-PHP-CENTREONCENTREON-472418": [
197+
">=2.8.0, <2.8.28",
198+
">=18.10.0, <18.10.4"
199+
],
200+
"SNYK-PHP-CENTREONCENTREON-472371": [
201+
">=2.8.0, <2.8.28",
202+
">=18.10.0, <18.10.4"
203+
],
204+
"SNYK-PHP-CENTREONCENTREON-472370": [
205+
"<19.4.17"
206+
],
207+
"SNYK-PHP-CENTREONCENTREON-469159": [
208+
"<19.10.0-rc.1"
209+
],
210+
"SNYK-PHP-CENTREONCENTREON-451340": [
211+
"<19.10.0"
212+
],
213+
"SNYK-PHP-CENTREONCENTREON-450214": [
214+
">=18.10.0, <18.10.5",
215+
">=2.8.0, <2.8.28"
216+
]
217+
}
218+
]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[
2+
"https://security.snyk.io/package/pip/jinja2",
3+
"https://security.snyk.io/package/maven/org.apache.tomcat%3Atomcat",
4+
"https://security.snyk.io/package/npm/semver-regex",
5+
"https://security.snyk.io/package/golang/github.com%2Fmattermost%2Fmattermost-server%2Fv6%2Fapi4",
6+
"https://security.snyk.io/package/composer/bolt%2Fcore",
7+
"https://security.snyk.io/package/linux/debain:11/trafficserver",
8+
"https://security.snyk.io/package/nuget/moment.js",
9+
"https://security.snyk.io/package/cocoapods/ffmpeg",
10+
"https://security.snyk.io/package/hex/coherence",
11+
"https://security.snyk.io/package/rubygems/log4j-jars",
12+
"https://security.snyk.io/api/listing?search=firefox&type=unmanaged"
13+
]
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
[
2+
{
3+
"affected_versions": [
4+
"TEST-AFFECTED"
5+
],
6+
"fixed_versions": [
7+
"6.0.3"
8+
],
9+
"aliases": [
10+
"CVE-2021-37861",
11+
"TEST-SNYKID"
12+
]
13+
},
14+
{
15+
"affected_versions": [
16+
"TEST-AFFECTED"
17+
],
18+
"fixed_versions": [
19+
"0.6.1"
20+
],
21+
"aliases": [
22+
"CVE-2021-37863",
23+
"TEST-SNYKID"
24+
]
25+
},
26+
{
27+
"affected_versions": [
28+
"TEST-AFFECTED"
29+
],
30+
"fixed_versions": [
31+
"5.37.9",
32+
"6.2.5",
33+
"6.3.5",
34+
"6.4.2"
35+
],
36+
"aliases": [
37+
"CVE-2022-1332",
38+
"TEST-SNYKID"
39+
]
40+
},
41+
{
42+
"affected_versions": [
43+
"TEST-AFFECTED"
44+
],
45+
"fixed_versions": [
46+
"5.37.7",
47+
"6.1.2",
48+
"6.2.2",
49+
"6.3.1"
50+
],
51+
"aliases": [
52+
"CVE-2022-0708",
53+
"TEST-SNYKID"
54+
]
55+
}
56+
]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
pkg:maven/org.apache.tomcat/[email protected]
3+
4+
pkg:golang/github.com/mattermost/mattermost-server/v6/[email protected]
5+
pkg:composer/bolt/[email protected]
6+
pkg:linux/[email protected]?distro=debain:11
7+
8+
pkg:cocoapods/[email protected]
9+
10+
pkg:rubygems/[email protected]
11+
pkg:unmanaged/[email protected]

vulntotal/tests/test_snyk.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#
2+
# Copyright (c) nexB Inc. and others. All rights reserved.
3+
# http://nexb.com and https://github.com/nexB/vulnerablecode/
4+
# The VulnTotal software is licensed under the Apache License version 2.0.
5+
# Data generated with VulnTotal require an acknowledgment.
6+
#
7+
# You may not use this software except in compliance with the License.
8+
# You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0
9+
# Unless required by applicable law or agreed to in writing, software distributed
10+
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11+
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
12+
# specific language governing permissions and limitations under the License.
13+
#
14+
# When you publish or redistribute any data created with VulnTotal or any VulnTotal
15+
# derivative work, you must accompany this data with the following acknowledgment:
16+
#
17+
# Generated with VulnTotal and provided on an "AS IS" BASIS, WITHOUT WARRANTIES
18+
# OR CONDITIONS OF ANY KIND, either express or implied. No content created from
19+
# VulnTotal should be considered or used as legal advice. Consult an Attorney
20+
# for any legal advice.
21+
# VulnTotal is a free software tool from nexB Inc. and others.
22+
# Visit https://github.com/nexB/vulnerablecode/ for support and download.
23+
24+
import json
25+
from pathlib import Path
26+
27+
from commoncode import testcase
28+
from packageurl import PackageURL
29+
30+
from vulnerabilities.tests import util_tests
31+
from vulntotal.datasources import snyk
32+
33+
34+
class TestSnyk(testcase.FileBasedTesting):
35+
test_data_dir = str(Path(__file__).resolve().parent / "test_data" / "snyk")
36+
37+
def test_generate_package_advisory_url(self):
38+
file_purls = self.get_test_loc("purls.txt")
39+
with open(file_purls) as f:
40+
purls = f.readlines()
41+
results = [
42+
snyk.generate_package_advisory_url(PackageURL.from_string(purl)) for purl in purls
43+
]
44+
expected_file = self.get_test_loc("package_advisory_url-expected.json", must_exist=False)
45+
util_tests.check_results_against_json(results, expected_file)
46+
47+
def test_extract_html_json_advisories(self):
48+
file = self.get_test_loc("raw_pacakage_advisories.json")
49+
with open(file) as f:
50+
pages = json.load(f)
51+
results = [snyk.extract_html_json_advisories(i) for i in pages]
52+
expected_file = self.get_test_loc("extract_html_json-expected.json", must_exist=False)
53+
util_tests.check_results_against_json(results, expected_file)
54+
55+
def test_parse_html_advisory(self):
56+
file = self.get_test_loc("raw_html_advisory.json")
57+
with open(file) as f:
58+
pages = json.load(f)
59+
results = [
60+
snyk.parse_html_advisory(i, "TEST-SNYKID", ["TEST-AFFECTED"]).to_dict() for i in pages
61+
]
62+
expected_file = self.get_test_loc("parsed_advisory-expected.json", must_exist=False)
63+
util_tests.check_results_against_json(results, expected_file)

0 commit comments

Comments
 (0)