Skip to content

Commit 5b6c5dd

Browse files
committed
Remove added_advisories method and
assign cve to empty string if its N/A Signed-off-by: Tushar912 <tushar.912u@gmail.com>
1 parent 43e4add commit 5b6c5dd

5 files changed

Lines changed: 86 additions & 68 deletions

File tree

vulnerabilities/importer_yielder.py

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,7 @@
102102
"license": "",
103103
"last_run": None,
104104
"data_source": "SUSEBackportsDataSource",
105-
"data_source_cfg": {
106-
"url": "http://ftp.suse.com/pub/projects/security/yaml/",
107-
"etags": {},
108-
},
105+
"data_source_cfg": {"url": "http://ftp.suse.com/pub/projects/security/yaml/", "etags": {}},
109106
},
110107
{
111108
"name": "suse_scores",
@@ -119,10 +116,7 @@
119116
"license": "",
120117
"last_run": None,
121118
"data_source": "DebianOvalDataSource",
122-
"data_source_cfg": {
123-
"etags": {},
124-
"releases": ["wheezy", "stretch", "jessie", "buster"],
125-
},
119+
"data_source_cfg": {"etags": {}, "releases": ["wheezy", "stretch", "jessie", "buster"]},
126120
},
127121
{
128122
"name": "redhat",
@@ -136,9 +130,7 @@
136130
"license": "",
137131
"last_run": None,
138132
"data_source": "NVDDataSource",
139-
"data_source_cfg": {
140-
"etags": {},
141-
},
133+
"data_source_cfg": {"etags": {}},
142134
},
143135
{
144136
"name": "gentoo",
@@ -228,13 +220,6 @@
228220
"data_source": "ApacheTomcatDataSource",
229221
"data_source_cfg": {"etags": {}},
230222
},
231-
{
232-
"name": "apache_tomcat",
233-
"license": "",
234-
"last_run": None,
235-
"data_source": "ApacheTomcatDataSource",
236-
"data_source_cfg": {"etags": {}},
237-
},
238223
{
239224
"name": "apache_kafka",
240225
"license": "",
@@ -243,13 +228,11 @@
243228
"data_source_cfg": {},
244229
},
245230
{
246-
'name': 'istio',
247-
'license': '',
248-
'last_run': None,
249-
'data_source': 'IstioDataSource',
250-
'data_source_cfg': {
251-
'repository_url': 'https://github.com/istio/istio.io'
252-
},
231+
"name": "istio",
232+
"license": "apache-2.0",
233+
"last_run": None,
234+
"data_source": "IstioDataSource",
235+
"data_source_cfg": {"repository_url": "https://github.com/istio/istio.io"},
253236
},
254237
]
255238

@@ -258,9 +241,7 @@ def load_importers():
258241

259242
for importer in IMPORTER_REGISTRY:
260243
imp, created = Importer.objects.get_or_create(
261-
name=importer["name"],
262-
data_source=importer["data_source"],
263-
license=importer["license"],
244+
name=importer["name"], data_source=importer["data_source"], license=importer["license"]
264245
)
265246

266247
if created:

vulnerabilities/importers/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,4 @@
4848
from vulnerabilities.importers.ubuntu import UbuntuDataSource
4949
from vulnerabilities.importers.ubuntu_usn import UbuntuUSNDataSource
5050
from vulnerabilities.importers.apache_tomcat import ApacheTomcatDataSource
51-
from vulnerabilities.importers.apache_kafka import ApacheKafkaDataSource
5251
from vulnerabilities.importers.istio import IstioDataSource

vulnerabilities/importers/istio.py

Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,14 @@
2121
# Visit https://github.com/nexB/vulnerablecode/ for support and download.
2222

2323
import asyncio
24+
import re
2425
from typing import List, Set
2526

2627
import yaml
28+
2729
from dephell_specifier import RangeSpecifier
2830
from packageurl import PackageURL
29-
30-
from vulnerabilities.data_source import Advisory
31-
from vulnerabilities.data_source import GitDataSource
32-
from vulnerabilities.data_source import Reference
31+
from vulnerabilities.data_source import Advisory, GitDataSource, Reference
3332
from vulnerabilities.package_managers import GitHubTagsAPI
3433

3534

@@ -56,26 +55,14 @@ def updated_advisories(self) -> Set[Advisory]:
5655
advisories.extend(processed_data)
5756
return self.batch_advisories(advisories)
5857

59-
def added_advisories(self) -> Set[Advisory]:
60-
files = self._added_files
61-
advisories = []
62-
for f in files:
63-
processed_data = self.process_file(f)
64-
if processed_data:
65-
advisories.extend(processed_data)
66-
return self.batch_advisories(advisories)
67-
68-
def get_versions_for_pkg_from_range_list(self, version_range_list):
58+
def get_pkg_versions_from_ranges(self, version_range_list):
6959
"""Takes a list of version ranges(affected) of a package
7060
as parameter and returns a tuple of safe package versions and
7161
vulnerable package versions"""
72-
62+
all_version = self.version_api.get("istio/istio")
7363
safe_pkg_versions = []
7464
vuln_pkg_versions = []
75-
all_version = self.version_api.get("istio/istio")
76-
if not version_range_list:
77-
return all_version, []
78-
version_ranges = {RangeSpecifier(r) for r in version_range_list}
65+
version_ranges = [RangeSpecifier(r) for r in version_range_list]
7966
for version in all_version:
8067
if any([version in v for v in version_ranges]):
8168
vuln_pkg_versions.append(version)
@@ -113,9 +100,9 @@ def get_yaml_lines(self, lines):
113100
,'cves: [CVE-2019-12243]']
114101
"""
115102

116-
for line in lines:
103+
for index, line in enumerate(lines):
117104
line = line.strip()
118-
if line.startswith("---"):
105+
if line.startswith("---") and index == 0:
119106
continue
120107
elif line.endswith("---"):
121108
break
@@ -131,36 +118,41 @@ def process_file(self, path):
131118
releases = []
132119
if data.get("releases"):
133120
for release in data["releases"]:
134-
release = release.strip()
135-
release = release.split(" ")
136-
if len(release) > 2:
121+
# If it is of form "All versions prior to x"
122+
if "All releases" in release:
123+
release = release.strip()
124+
release = release.split(" ")
125+
releases.append("<" + release[4])
126+
# If it is of form "a to b"
127+
elif "to" in release:
128+
release = release.strip()
129+
release = release.split(" ")
137130
lbound = ">=" + release[0]
138131
ubound = "<=" + release[2]
139132
releases.append(lbound + "," + ubound)
133+
# If it is a single release
134+
elif re.search("^[\d.]+$", release):
135+
releases.append(release)
140136

141-
data["releases"] = releases
137+
data["release_ranges"] = releases
142138

143139
if not data.get("cves"):
144140
data["cves"] = [""]
145141

146142
for cve_id in data["cves"]:
147143

148144
if not cve_id.startswith("CVE"):
149-
continue
145+
cve_id = ""
150146

151147
safe_pkg_versions = []
152148
vuln_pkg_versions = []
153149

154-
if not data.get("releases"):
155-
data["releases"] = []
156-
157-
safe_pkg_versions, vuln_pkg_versions = self.get_versions_for_pkg_from_range_list(
158-
data["releases"])
150+
if not data.get("release_ranges"):
151+
data["release_ranges"] = []
159152

160-
safe_purls = []
161-
vuln_purls = []
162-
163-
cve_id = cve_id
153+
safe_pkg_versions, vuln_pkg_versions = self.get_pkg_versions_from_ranges(
154+
data["release_ranges"]
155+
)
164156

165157
safe_purls_golang = {
166158
PackageURL(type="golang", name="istio", version=version)
@@ -171,7 +163,7 @@ def process_file(self, path):
171163
PackageURL(type="github", name="istio", version=version)
172164
for version in safe_pkg_versions
173165
}
174-
safe_purls = safe_purls_github | safe_purls_golang
166+
safe_purls = safe_purls_github.union(safe_purls_golang)
175167

176168
vuln_purls_golang = {
177169
PackageURL(type="golang", name="istio", version=version)
@@ -182,14 +174,14 @@ def process_file(self, path):
182174
PackageURL(type="github", name="istio", version=version)
183175
for version in vuln_pkg_versions
184176
}
185-
vuln_purls = vuln_purls_github | vuln_purls_golang
177+
vuln_purls = vuln_purls_github.union(vuln_purls_golang)
186178

187179
advisories.append(
188180
Advisory(
189181
summary=data["description"],
190182
impacted_package_urls=vuln_purls,
191183
resolved_package_urls=safe_purls,
192-
cve_id=cve_id,
184+
vulnerability_id=cve_id,
193185
)
194186
)
195187

vulnerabilities/tests/test_data/istio/test_file.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,50 @@ cvss: "8.9"
77
vector: "CVSS:3.0/AV:A/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N/E:H/RL:O/RC:C"
88
releases: ["1.1 to 1.1.15", "1.2 to 1.2.6", "1.3 to 1.3.1"]
99
publishdate: 2019-05-28
10+
1011
---
12+
13+
{{< security_bulletin >}}
14+
15+
During review of the [Istio 1.1.7](/news/releases/1.1.x/announcing-1.1.7) release notes, we realized that [issue 13868](https://github.com/istio/istio/issues/13868),
16+
which is fixed in the release, actually represents a security vulnerability.
17+
18+
Initially we thought the bug was impacting the [TCP Authorization](/about/feature-stages/#security-and-policy-enforcement) feature advertised
19+
as alpha stability, which would not have required invoking this security advisory process, but we later realized that the
20+
[Deny Checker](https://istio.io/v1.6/docs/reference/config/policy-and-telemetry/adapters/denier/) and
21+
[List Checker](https://istio.io/v1.6/docs/reference/config/policy-and-telemetry/adapters/list/) feature were affected and those are considered stable features.
22+
We are revisiting our processes to flag vulnerabilities that are initially reported as bugs instead of through the
23+
[private disclosure process](/about/security-vulnerabilities/).
24+
25+
We tracked the bug to a code change introduced in Istio 1.1 and affecting all releases up to 1.1.6.
26+
27+
## Impact and detection
28+
29+
Since Istio 1.1, In the default Istio installation profile, policy enforcement is disabled by default.
30+
31+
You can check the status of policy enforcement for your mesh with the following command:
32+
33+
{{< text bash >}}
34+
$ kubectl -n istio-system get cm istio -o jsonpath="{@.data.mesh}" | grep disablePolicyChecks
35+
disablePolicyChecks: true
36+
{{< /text >}}
37+
38+
You are not impacted by this vulnerability if `disablePolicyChecks` is set to true.
39+
40+
You are impacted by the vulnerability issue if the following conditions are all true:
41+
42+
* You are running one of the affected Istio releases.
43+
* `disablePolicyChecks` is set to false (follow the steps mentioned above to check)
44+
* Your workload is NOT using HTTP, HTTP/2, or gRPC protocols
45+
* A mixer adapter (e.g., Deny Checker, List Checker) is used to provide authorization for your backend TCP service.
46+
47+
## Mitigation
48+
49+
* Users of Istio 1.0.x are not affected.
50+
* For Istio 1.1.x deployments: update to [Istio 1.1.7](/news/releases/1.1.x/announcing-1.1.7) or later.
51+
52+
## Credit
53+
54+
The Istio team would like to thank `Haim Helman` for the original bug report.
55+
56+
{{< boilerplate "security-vulnerability" >}}

vulnerabilities/tests/test_istio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def test_process_file(self):
173173
version="1.1.0-rc.6",
174174
),
175175
},
176-
cve_id="CVE-2019-12243",
176+
vulnerability_id="CVE-2019-12243",
177177
)
178178
]
179179

0 commit comments

Comments
 (0)