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

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9653
e67609152c5e
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
11 # This is a modified version of the one found in the bandit package. 11 # This is a modified version of the one found in the bandit package.
12 # 12 #
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 #...r\Security\Checks\generalHardcodedTmp.py 16 # ...r\Security\Checks\generalHardcodedTmp.py
17 17
18 from Security.SecurityDefaults import SecurityDefaults 18 from Security.SecurityDefaults import SecurityDefaults
19 19
20 20
21 def getChecks(): 21 def getChecks():
22 """ 22 """
23 Public method to get a dictionary with checks handled by this module. 23 Public method to get a dictionary with checks handled by this module.
24 24
25 @return dictionary containing checker lists containing checker function and 25 @return dictionary containing checker lists containing checker function and
26 list of codes 26 list of codes
27 @rtype dict 27 @rtype dict
28 """ 28 """
29 return { 29 return {
34 34
35 35
36 def checkHardcodedTmpDirectory(reportError, context, config): 36 def checkHardcodedTmpDirectory(reportError, context, config):
37 """ 37 """
38 Function to check for insecure usage of tmp file/directory. 38 Function to check for insecure usage of tmp file/directory.
39 39
40 @param reportError function to be used to report errors 40 @param reportError function to be used to report errors
41 @type func 41 @type func
42 @param context security context object 42 @param context security context object
43 @type SecurityContext 43 @type SecurityContext
44 @param config dictionary with configuration data 44 @param config dictionary with configuration data
45 @type dict 45 @type dict
46 """ 46 """
47 tmpDirs = ( 47 tmpDirs = (
48 config["hardcoded_tmp_directories"] 48 config["hardcoded_tmp_directories"]
49 if config and "hardcoded_tmp_directories" in config else 49 if config and "hardcoded_tmp_directories" in config
50 SecurityDefaults["hardcoded_tmp_directories"] 50 else SecurityDefaults["hardcoded_tmp_directories"]
51 ) 51 )
52 52
53 if any(context.stringVal.startswith(s) for s in tmpDirs): 53 if any(context.stringVal.startswith(s) for s in tmpDirs):
54 reportError( 54 reportError(
55 context.node.lineno - 1, 55 context.node.lineno - 1,
56 context.node.col_offset, 56 context.node.col_offset,
57 "S108", 57 "S108",

eric ide

mercurial