Skip to content

Commit

Permalink
improve-ispsycopg2-call
Browse files Browse the repository at this point in the history
  • Loading branch information
moylop260 committed Sep 8, 2021
1 parent f4d773e commit 0eb93ce
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions pylint_odoo/checkers/no_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,9 @@ def colon_list_to_dict(self, colon_list):
return dict(item.split(":") for item in colon_list)

def _sqli_allowable(self, node):
# sql.SQL or sql.Identifier is OK
if self._is_psycopg2_sql(node):
return True
if isinstance(node, astroid.Call):
node = node.func
# self._thing is OK (mostly self._table), self._thing() also because
Expand Down Expand Up @@ -483,14 +486,6 @@ def _check_node_for_sqli_risk(self, node):
and isinstance(node.func, astroid.Attribute) \
and node.func.attrname == 'format':

# exclude sql.SQL or sql.Identifier
is_psycopg2 = (
list(map(self._is_psycopg2_sql, node.args)) +
[self._is_psycopg2_sql(keyword.value)
for keyword in (node.keywords or [])])
if is_psycopg2 and all(is_psycopg2):
return False

if not all(map(self._sqli_allowable, node.args or [])):
return True

Expand Down

0 comments on commit 0eb93ce

Please sign in to comment.