Skip to content

Commit

Permalink
remove-duplicated-code
Browse files Browse the repository at this point in the history
  • Loading branch information
moylop260 committed Sep 8, 2021
1 parent 121608f commit 1bdd61c
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions pylint_odoo/checkers/no_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,20 +518,9 @@ def _check_sql_injection_risky(self, node):
first_arg = node.args[0]
is_concatenation = self._check_node_for_sqli_risk(first_arg)
# if first parameter is a variable, check how it was built instead
if (not is_concatenation and
isinstance(first_arg, (astroid.Name, astroid.Subscript))):

# 1) look for parent scope (where the definition lives)
current = node
while (current and not isinstance(current.parent, astroid.FunctionDef)):
current = current.parent
parent = current.parent

# 2) check how was the variable built
for node_ofc in parent.nodes_of_class(astroid.Assign):
if node_ofc.targets[0].as_string() != first_arg.as_string():
continue
is_concatenation = self._check_node_for_sqli_risk(node_ofc.value)
if not is_concatenation:
for node_assignation in self._get_assignation_nodes(first_arg):
is_concatenation = self._check_node_for_sqli_risk(node_assignation)
if is_concatenation:
break
return is_concatenation
Expand Down

0 comments on commit 1bdd61c

Please sign in to comment.