eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/djangoXssVulnerability.py

changeset 8221
0572a215bd2f
parent 8220
006ee31b4835
child 8259
2bbec88047dd
--- a/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/djangoXssVulnerability.py	Sun Apr 11 12:38:16 2021 +0200
+++ b/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/djangoXssVulnerability.py	Sun Apr 11 16:53:48 2021 +0200
@@ -159,19 +159,23 @@
         @rtype bool
         """
         assigned = False
-        if self.__ignoreNodes:
-            if isinstance(self.__ignoreNodes, (list, tuple, object)):
-                if isinstance(node, self.__ignoreNodes):
-                    return assigned
+        if (
+            self.__ignoreNodes and
+            isinstance(self.__ignoreNodes, (list, tuple, object)) and
+            isinstance(node, self.__ignoreNodes)
+        ):
+            return assigned
         
         if isinstance(node, ast.Expr):
             assigned = self.isAssigned(node.value)
         elif isinstance(node, ast.FunctionDef):
             for name in node.args.args:
-                if isinstance(name, ast.Name):
-                    if name.id == self.var_name.id:
-                        # If is param the assignations are not affected
-                        return assigned
+                if (
+                    isinstance(name, ast.Name) and
+                    name.id == self.var_name.id
+                ):
+                    # If is param the assignations are not affected
+                    return assigned
             
             assigned = self.isAssignedIn(node.body)
         elif isinstance(node, ast.With):
@@ -194,10 +198,12 @@
             assigned = []
             assigned.extend(self.isAssignedIn(node.body))
             assigned.extend(self.isAssignedIn(node.orelse))
-        elif isinstance(node, ast.AugAssign):
-            if isinstance(node.target, ast.Name):
-                if node.target.id == self.__varName.id:
-                    assigned = node.value
+        elif (
+            isinstance(node, ast.AugAssign) and
+            isinstance(node.target, ast.Name) and
+            node.target.id == self.__varName.id
+        ):
+            assigned = node.value
         elif isinstance(node, ast.Assign) and node.targets:
             target = node.targets[0]
             if isinstance(target, ast.Name):
@@ -229,10 +235,11 @@
     """
     secure = False
     if isinstance(xssVar, ast.Name):
-        if isinstance(parent, ast.FunctionDef):
-            for name in parent.args.args:
-                if name.arg == xssVar.id:
-                    return False  # Params are not secure
+        if (
+            isinstance(parent, ast.FunctionDef) and
+            any(name.arg == xssVar.id for name in parent.args.args)
+        ):
+            return False  # Params are not secure
         
         analyser = DeepAssignation(xssVar, ignoreNodes)
         for node in parent.body:
@@ -288,14 +295,15 @@
     secure = False
     evaluate = False
     
-    if isinstance(call, ast.Call) and isinstance(call.func, ast.Attribute):
-        if (
-            AstUtilities.isString(call.func.value) and
-            call.func.attr == 'format'
-        ):
-            evaluate = True
-            if call.keywords:
-                evaluate = False
+    if (
+        isinstance(call, ast.Call) and
+        isinstance(call.func, ast.Attribute) and
+        AstUtilities.isString(call.func.value) and
+        call.func.attr == 'format'
+    ):
+        evaluate = True
+        if call.keywords:
+            evaluate = False
     
     if evaluate:
         args = list(call.args)

eric ide

mercurial