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

branch
eric7
changeset 10683
779cda568acb
parent 10439
21c28b0f9e41
child 11090
f5f5f5803935
equal deleted inserted replaced
10682:47be220abdaf 10683:779cda568acb
43 (checkHardcodedPasswordAsDefault, ("S107",)), 43 (checkHardcodedPasswordAsDefault, ("S107",)),
44 ], 44 ],
45 } 45 }
46 46
47 47
48 def checkHardcodedPasswordAsString(reportError, context, config): # noqa: U100 48 def checkHardcodedPasswordAsString(reportError, context, _config):
49 """ 49 """
50 Function to check for use of hardcoded password strings. 50 Function to check for use of hardcoded password strings.
51 51
52 @param reportError function to be used to report errors 52 @param reportError function to be used to report errors
53 @type func 53 @type func
54 @param context security context object 54 @param context security context object
55 @type SecurityContext 55 @type SecurityContext
56 @param config dictionary with configuration data 56 @param _config dictionary with configuration data (unused)
57 @type dict 57 @type dict
58 """ 58 """
59 node = context.node 59 node = context.node
60 if isinstance(node._securityParent, ast.Assign): 60 if isinstance(node._securityParent, ast.Assign):
61 # looks for "candidate='some_string'" 61 # looks for "candidate='some_string'"
102 "M", 102 "M",
103 comp.comparators[0].s, 103 comp.comparators[0].s,
104 ) 104 )
105 105
106 106
107 def checkHardcodedPasswordAsFunctionArg(reportError, context, config): # noqa: U100 107 def checkHardcodedPasswordAsFunctionArg(reportError, context, _config):
108 """ 108 """
109 Function to check for use of hard-coded password function arguments. 109 Function to check for use of hard-coded password function arguments.
110 110
111 @param reportError function to be used to report errors 111 @param reportError function to be used to report errors
112 @type func 112 @type func
113 @param context security context object 113 @param context security context object
114 @type SecurityContext 114 @type SecurityContext
115 @param config dictionary with configuration data 115 @param _config dictionary with configuration data (unused)
116 @type dict 116 @type dict
117 """ 117 """
118 # looks for "function(candidate='some_string')" 118 # looks for "function(candidate='some_string')"
119 for kw in context.node.keywords: 119 for kw in context.node.keywords:
120 if AstUtilities.isString(kw.value) and RE_CANDIDATES.search(kw.arg): 120 if AstUtilities.isString(kw.value) and RE_CANDIDATES.search(kw.arg):
126 "M", 126 "M",
127 kw.value.value, 127 kw.value.value,
128 ) 128 )
129 129
130 130
131 def checkHardcodedPasswordAsDefault(reportError, context, config): # noqa: U100 131 def checkHardcodedPasswordAsDefault(reportError, context, _config):
132 """ 132 """
133 Function to check for use of hard-coded password argument defaults. 133 Function to check for use of hard-coded password argument defaults.
134 134
135 @param reportError function to be used to report errors 135 @param reportError function to be used to report errors
136 @type func 136 @type func
137 @param context security context object 137 @param context security context object
138 @type SecurityContext 138 @type SecurityContext
139 @param config dictionary with configuration data 139 @param _config dictionary with configuration data (unused)
140 @type dict 140 @type dict
141 """ 141 """
142 # looks for "def function(candidate='some_string')" 142 # looks for "def function(candidate='some_string')"
143 143
144 # this pads the list of default values with "None" if nothing is given 144 # this pads the list of default values with "None" if nothing is given

eric ide

mercurial