Skip to content

Commit 1a0cd84

Browse files
committed
Fixes bandit failures
Auto-formatters moves "# nosec" markers in assertions
1 parent 65d5182 commit 1a0cd84

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

services/web/server/src/simcore_service_webserver/application_config.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
1010
The app configuration is created before the application instance exists.
1111
12-
13-
TODO: add more strict checks with re
14-
TODO: add support for versioning.
15-
- check shema fits version
16-
- parse/format version in schema
1712
"""
13+
# TODO: add more strict checks with re
14+
# TODO: add support for versioning.
15+
# - check shema fits version
16+
# - parse/format version in schema
17+
1818
import logging
1919
from pathlib import Path
2020
from typing import Dict
@@ -101,9 +101,9 @@ def create_schema() -> T.Dict:
101101

102102
section_names = [k.name for k in schema.keys]
103103

104-
assert len(section_names) == len(set(section_names)), (
105-
"Found repeated section names in %s" % section_names
106-
) # nosec
104+
# fmt: off
105+
assert len(section_names) == len(set(section_names)), f"Found repeated section names in {section_names}" # nosec
106+
# fmt: on
107107

108108
return schema
109109

@@ -113,4 +113,4 @@ def load_default_config(environs=None) -> Dict:
113113
return read_and_validate(filepath, trafaret=app_schema, vars=environs)
114114

115115

116-
app_schema = create_schema() # TODO: rename as schema
116+
app_schema = create_schema()

services/web/server/src/simcore_service_webserver/diagnostics_monitoring.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ async def _middleware_handler(request: web.Request, handler):
4545
resp = await handler(request)
4646
log_exception = None
4747

48-
assert isinstance(
49-
resp, web.StreamResponse
50-
), "Forgot envelope middleware?" # nsec
48+
# fmt: off
49+
assert isinstance(resp, web.StreamResponse), "Forgot envelope middleware?" # nsec
50+
# fmt: om
5151

5252
except web.HTTPServerError as exc:
5353
# Transforms exception into response object and log exception

services/web/server/src/simcore_service_webserver/login/sql.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from logging import getLogger
22

3+
# FIXME: Possible SQL injection vector through string-based query construction.
4+
35
log = getLogger(__name__)
46
LOG_TPL = "%s <--%s"
57

@@ -20,7 +22,7 @@ def find_one_sql(table, filter_, fields=None):
2022
keys, values = _split_dict(filter_)
2123
fields = ", ".join(fields) if fields else "*"
2224
where = _pairs(keys)
23-
sql = "SELECT {} FROM {} WHERE {}".format(fields, table, where)
25+
sql = "SELECT {} FROM {} WHERE {}".format(fields, table, where) # nosec
2426
return sql, values
2527

2628

@@ -42,7 +44,7 @@ def insert_sql(table, data, returning="id"):
4244
('INSERT INTO tbl (foo, id) VALUES ($1, $2) RETURNING pk', ['bar', 1])
4345
"""
4446
keys, values = _split_dict(data)
45-
sql = "INSERT INTO {} ({}) VALUES ({}){}".format(
47+
sql = "INSERT INTO {} ({}) VALUES ({}){}".format( # nosec
4648
table,
4749
", ".join(keys),
4850
", ".join(_placeholders(data)),
@@ -66,7 +68,7 @@ def update_sql(table, filter_, updates):
6668
up_keys, up_vals = _split_dict(updates)
6769
changes = _pairs(up_keys, sep=", ")
6870
where = _pairs(where_keys, start=len(up_keys) + 1)
69-
sql = "UPDATE {} SET {} WHERE {}".format(table, changes, where)
71+
sql = "UPDATE {} SET {} WHERE {}".format(table, changes, where) # nosec
7072
return sql, up_vals + where_vals
7173

7274

@@ -83,7 +85,7 @@ def delete_sql(table, filter_):
8385
"""
8486
keys, values = _split_dict(filter_)
8587
where = _pairs(keys)
86-
sql = "DELETE FROM {} WHERE {}".format(table, where)
88+
sql = "DELETE FROM {} WHERE {}".format(table, where) # nosec
8789
return sql, values
8890

8991

0 commit comments

Comments
 (0)