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

branch
eric7
changeset 11147
dee6e106b4d3
parent 11136
437db2f032fd
equal deleted inserted replaced
11146:59e04f7003e9 11147:dee6e106b4d3
27 list of codes 27 list of codes
28 @rtype dict 28 @rtype dict
29 """ 29 """
30 return { 30 return {
31 "Call": [ 31 "Call": [
32 (checkHashlib, ("S331", "S332")), 32 (checkHashlib, ("S-331", "S-332")),
33 ], 33 ],
34 } 34 }
35 35
36 36
37 def _hashlibFunc(reportError, context, func, config): 37 def _hashlibFunc(reportError, context, func, config):
60 if func in insecureHashes: 60 if func in insecureHashes:
61 if keywords.get("usedforsecurity", "True") == "True": 61 if keywords.get("usedforsecurity", "True") == "True":
62 reportError( 62 reportError(
63 context.node.lineno - 1, 63 context.node.lineno - 1,
64 context.node.col_offset, 64 context.node.col_offset,
65 "S332", 65 "S-332",
66 "H", 66 "H",
67 "H", 67 "H",
68 func.upper(), 68 func.upper(),
69 ) 69 )
70 elif func == "new": 70 elif func == "new":
76 and keywords.get("usedforsecurity", "True") == "True" 76 and keywords.get("usedforsecurity", "True") == "True"
77 ): 77 ):
78 reportError( 78 reportError(
79 context.node.lineno - 1, 79 context.node.lineno - 1,
80 context.node.col_offset, 80 context.node.col_offset,
81 "S332", 81 "S-332",
82 "H", 82 "H",
83 "H", 83 "H",
84 name.upper(), 84 name.upper(),
85 ) 85 )
86 86
112 name = args[1] if len(args) > 1 else keywords.get("salt") 112 name = args[1] if len(args) > 1 else keywords.get("salt")
113 if isinstance(name, str) and name in insecureHashes: 113 if isinstance(name, str) and name in insecureHashes:
114 reportError( 114 reportError(
115 context.node.lineno - 1, 115 context.node.lineno - 1,
116 context.node.col_offset, 116 context.node.col_offset,
117 "S331", 117 "S-331",
118 "M", 118 "M",
119 "H", 119 "H",
120 name.upper(), 120 name.upper(),
121 ) 121 )
122 122
124 name = args[0] if args else keywords.get("method") 124 name = args[0] if args else keywords.get("method")
125 if isinstance(name, str) and name in insecureHashes: 125 if isinstance(name, str) and name in insecureHashes:
126 reportError( 126 reportError(
127 context.node.lineno - 1, 127 context.node.lineno - 1,
128 context.node.col_offset, 128 context.node.col_offset,
129 "S331", 129 "S-331",
130 "M", 130 "M",
131 "H", 131 "H",
132 name.upper(), 132 name.upper(),
133 ) 133 )
134 134

eric ide

mercurial