Skip to content

Commit d8e4ec3

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 d8e4ec3

5 files changed

Lines changed: 88 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: 32 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,16 @@ 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")
63+
# if not version_range_list:
64+
# return all_version, []
7365
safe_pkg_versions = []
7466
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}
67+
version_ranges = [RangeSpecifier(r) for r in version_range_list]
7968
for version in all_version:
8069
if any([version in v for v in version_ranges]):
8170
vuln_pkg_versions.append(version)
@@ -113,9 +102,9 @@ def get_yaml_lines(self, lines):
113102
,'cves: [CVE-2019-12243]']
114103
"""
115104

116-
for line in lines:
105+
for index, line in enumerate(lines):
117106
line = line.strip()
118-
if line.startswith("---"):
107+
if line.startswith("---") and index == 0:
119108
continue
120109
elif line.endswith("---"):
121110
break
@@ -131,36 +120,41 @@ def process_file(self, path):
131120
releases = []
132121
if data.get("releases"):
133122
for release in data["releases"]:
134-
release = release.strip()
135-
release = release.split(" ")
136-
if len(release) > 2:
123+
# If it is of form "All versions prior to x"
124+
if "All releases" in release:
125+
release = release.strip()
126+
release = release.split(" ")
127+
releases.append("<" + release[4])
128+
# If it is of form "a to b"
129+
elif "to" in release:
130+
release = release.strip()
131+
release = release.split(" ")
137132
lbound = ">=" + release[0]
138133
ubound = "<=" + release[2]
139134
releases.append(lbound + "," + ubound)
135+
# If it is a single release
136+
elif re.search("^[\d.]+$", release):
137+
releases.append(release)
140138

141-
data["releases"] = releases
139+
data["release_ranges"] = releases
142140

143141
if not data.get("cves"):
144142
data["cves"] = [""]
145143

146144
for cve_id in data["cves"]:
147145

148146
if not cve_id.startswith("CVE"):
149-
continue
147+
cve_id = ""
150148

151149
safe_pkg_versions = []
152150
vuln_pkg_versions = []
153151

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"])
152+
if not data.get("release_ranges"):
153+
data["release_ranges"] = []
159154

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

165159
safe_purls_golang = {
166160
PackageURL(type="golang", name="istio", version=version)
@@ -171,7 +165,7 @@ def process_file(self, path):
171165
PackageURL(type="github", name="istio", version=version)
172166
for version in safe_pkg_versions
173167
}
174-
safe_purls = safe_purls_github | safe_purls_golang
168+
safe_purls = safe_purls_github.union(safe_purls_golang)
175169

176170
vuln_purls_golang = {
177171
PackageURL(type="golang", name="istio", version=version)
@@ -182,14 +176,14 @@ def process_file(self, path):
182176
PackageURL(type="github", name="istio", version=version)
183177
for version in vuln_pkg_versions
184178
}
185-
vuln_purls = vuln_purls_github | vuln_purls_golang
179+
vuln_purls = vuln_purls_github.union(vuln_purls_golang)
186180

187181
advisories.append(
188182
Advisory(
189183
summary=data["description"],
190184
impacted_package_urls=vuln_purls,
191185
resolved_package_urls=safe_purls,
192-
cve_id=cve_id,
186+
vulnerability_id=cve_id,
193187
)
194188
)
195189

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)