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

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9653
e67609152c5e
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
17 17
18 18
19 def getChecks(): 19 def getChecks():
20 """ 20 """
21 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.
22 22
23 @return dictionary containing checker lists containing checker function and 23 @return dictionary containing checker lists containing checker function and
24 list of codes 24 list of codes
25 @rtype dict 25 @rtype dict
26 """ 26 """
27 return { 27 return {
32 32
33 33
34 def checkMakoTemplateUsage(reportError, context, config): 34 def checkMakoTemplateUsage(reportError, context, config):
35 """ 35 """
36 Function to check for use of mako templates. 36 Function to check for use of mako templates.
37 37
38 @param reportError function to be used to report errors 38 @param reportError function to be used to report errors
39 @type func 39 @type func
40 @param context security context object 40 @param context security context object
41 @type SecurityContext 41 @type SecurityContext
42 @param config dictionary with configuration data 42 @param config dictionary with configuration data
43 @type dict 43 @type dict
44 """ 44 """
45 if isinstance(context.callFunctionNameQual, str): 45 if isinstance(context.callFunctionNameQual, str):
46 qualnameList = context.callFunctionNameQual.split('.') 46 qualnameList = context.callFunctionNameQual.split(".")
47 func = qualnameList[-1] 47 func = qualnameList[-1]
48 if 'mako' in qualnameList and func == 'Template': 48 if "mako" in qualnameList and func == "Template":
49 # unlike Jinja2, mako does not have a template wide autoescape 49 # unlike Jinja2, mako does not have a template wide autoescape
50 # feature and thus each variable must be carefully sanitized. 50 # feature and thus each variable must be carefully sanitized.
51 reportError( 51 reportError(
52 context.node.lineno - 1, 52 context.node.lineno - 1,
53 context.node.col_offset, 53 context.node.col_offset,

eric ide

mercurial