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

branch
eric7
changeset 10638
12558008c269
parent 10439
21c28b0f9e41
child 10683
779cda568acb
equal deleted inserted replaced
10637:98160fe3eb4d 10638:12558008c269
50 return {"Other": value} 50 return {"Other": value}
51 51
52 return {} 52 return {}
53 53
54 54
55 def _isFilterData(context):
56 """
57 Function to check for the filter argument to be 'data'.
58
59 @param context security context object
60 @type SecurityContext
61 @return flag indicating the 'data' filter
62 @rtype bool
63 """
64 for kw in context.node.keywords:
65 if kw.arg == "filter":
66 arg = kw.value
67 return isinstance(arg, ast.Str) and arg.s == "data"
68
69 return False
70
71
55 def checkTarfileUnsafeMembers(reportError, context, config): # noqa: U100 72 def checkTarfileUnsafeMembers(reportError, context, config): # noqa: U100
56 """ 73 """
57 Function to check for insecure use of 'tarfile.extracall()'. 74 Function to check for insecure use of 'tarfile.extracall()'.
58 75
59 @param reportError function to be used to report errors 76 @param reportError function to be used to report errors
67 [ 84 [
68 context.isModuleImportedExact("tarfile"), 85 context.isModuleImportedExact("tarfile"),
69 "extractall" in context.callFunctionName, 86 "extractall" in context.callFunctionName,
70 ] 87 ]
71 ): 88 ):
89 if "filter" in context.callKeywords and _isFilterData(context):
90 return
91
72 if "members" in context.callKeywords: 92 if "members" in context.callKeywords:
73 members = _getMembersValue(context) 93 members = _getMembersValue(context)
74 if "Function" in members: 94 if "Function" in members:
75 reportError( 95 reportError(
76 context.node.lineno - 1, 96 context.node.lineno - 1,

eric ide

mercurial