src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/generalHardcodedPassword.py

branch
eric7
changeset 11297
2c773823fb7d
parent 11147
dee6e106b4d3
child 11300
0119e3818e12
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/generalHardcodedPassword.py	Sun May 18 17:23:00 2025 +0200
+++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/generalHardcodedPassword.py	Mon May 19 14:33:49 2025 +0200
@@ -147,16 +147,19 @@
 
     # go through all (param, value)s and look for candidates
     for key, val in zip(context.node.args.args, defs):
-        if (
-            isinstance(key, (ast.Name, ast.arg))
-            and AstUtilities.isString(val)
-            and RE_CANDIDATES.search(key.arg)
-        ):
-            reportError(
-                context.node.lineno - 1,
-                context.node.col_offset,
-                "S-107",
-                "L",
-                "M",
-                val.value,
-            )
+        if isinstance(key, (ast.Name, ast.arg)):
+            # Skip if the default value is None
+            if val is None or (
+                isinstance(val, (ast.Constant, ast.NameConstant))
+                and val.value is None
+            ):
+                continue
+            if isinstance(val, ast.Str) and RE_CANDIDATES.search(key.arg):
+                reportError(
+                    context.node.lineno - 1,
+                    context.node.col_offset,
+                    "S-107",
+                    "L",
+                    "M",
+                    val.value,
+                )

eric ide

mercurial