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

changeset 7637
c878e8255972
parent 7614
646742c260bd
child 7923
91e843545d9a
equal deleted inserted replaced
7636:61566f35ab22 7637:c878e8255972
13 # Original Copyright 2014 Hewlett-Packard Development Company, L.P. 13 # Original Copyright 2014 Hewlett-Packard Development Company, L.P.
14 # 14 #
15 # SPDX-License-Identifier: Apache-2.0 15 # SPDX-License-Identifier: Apache-2.0
16 # 16 #
17 17
18 import sys
19
20 18
21 def getChecks(): 19 def getChecks():
22 """ 20 """
23 Public method to get a dictionary with checks handled by this module. 21 Public method to get a dictionary with checks handled by this module.
24 22
25 @return dictionary containing checker lists containing checker function and 23 @return dictionary containing checker lists containing checker function and
26 list of codes 24 list of codes
27 @rtype dict 25 @rtype dict
28 """ 26 """
29 if sys.version_info[0] == 2: 27 return {
30 return { 28 "Call": [
31 "Exec": [ 29 (checkExecUsed, ("S102",)),
32 (checkExecUsed, ("S102",)), 30 ],
33 ], 31 }
34 }
35 else:
36 return {
37 "Call": [
38 (checkExecUsed, ("S102",)),
39 ],
40 }
41 32
42 33
43 def checkExecUsed(reportError, context, config): 34 def checkExecUsed(reportError, context, config):
44 """ 35 """
45 Function to check for the use of 'exec'. 36 Function to check for the use of 'exec'.
49 @param context security context object 40 @param context security context object
50 @type SecurityContext 41 @type SecurityContext
51 @param config dictionary with configuration data 42 @param config dictionary with configuration data
52 @type dict 43 @type dict
53 """ 44 """
54 if ( 45 if context.callFunctionNameQual == 'exec':
55 sys.version_info[0] == 2 or
56 context.callFunctionNameQual == 'exec'
57 ):
58 reportError( 46 reportError(
59 context.node.lineno - 1, 47 context.node.lineno - 1,
60 context.node.col_offset, 48 context.node.col_offset,
61 "S102", 49 "S102",
62 "M", 50 "M",

eric ide

mercurial