mirror of https://github.com/nicolargo/glances.git
fix(security): resolve B701 and B113 bandit issues (#3353)
Detailed changes: - Enable autoescape=True for Jinja2 environment to prevent XSS (B701). - Add timeout=15s to requests.get in nginx amp (B113). - Add timeout=15s to post in restful export (B113).
This commit is contained in:
parent
7b22761c75
commit
9b5cc01b06
|
|
@ -66,7 +66,7 @@ class Amp(GlancesAmp):
|
|||
"""Update the AMP"""
|
||||
# Get the Nginx status
|
||||
logger.debug('{}: Update stats using status URL {}'.format(self.NAME, self.get('status_url')))
|
||||
res = requests.get(self.get('status_url'))
|
||||
res = requests.get(self.get('status_url'), timeout=15)
|
||||
if res.ok:
|
||||
# u'Active connections: 1 \nserver accepts handled requests\n 1 1 1 \nReading: 0 Writing: 1 Waiting: 0 \n'
|
||||
self.set_result(res.text.rstrip())
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class Export(GlancesExport):
|
|||
# One complete loop have been done
|
||||
logger.debug(f"Export stats ({listkeys(self.buffer)}) to RESTful endpoint ({self.client})")
|
||||
# Export stats
|
||||
post(self.client, json=self.buffer, allow_redirects=True)
|
||||
post(self.client, json=self.buffer, allow_redirects=True, timeout=15)
|
||||
# Reset buffer
|
||||
self.buffer = {}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ class GlancesStdoutFetch:
|
|||
fetch_template = f.read()
|
||||
|
||||
# Create a Jinja2 environment
|
||||
jinja_env = jinja2.Environment(loader=jinja2.BaseLoader())
|
||||
jinja_env = jinja2.Environment(loader=jinja2.BaseLoader(), autoescape=True)
|
||||
template = jinja_env.from_string(fetch_template)
|
||||
output = template.render(gl=self.gl)
|
||||
print(output)
|
||||
|
|
|
|||
Loading…
Reference in New Issue