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

changeset 7614
646742c260bd
child 7637
c878e8255972
equal deleted inserted replaced
7613:382f89c11e27 7614:646742c260bd
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2020 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a check for the use of 'exec'.
8 """
9
10 #
11 # This is a modified version of the one found in the bandit package.
12 #
13 # Original Copyright 2014 Hewlett-Packard Development Company, L.P.
14 #
15 # SPDX-License-Identifier: Apache-2.0
16 #
17
18 import sys
19
20
21 def getChecks():
22 """
23 Public method to get a dictionary with checks handled by this module.
24
25 @return dictionary containing checker lists containing checker function and
26 list of codes
27 @rtype dict
28 """
29 if sys.version_info[0] == 2:
30 return {
31 "Exec": [
32 (checkExecUsed, ("S102",)),
33 ],
34 }
35 else:
36 return {
37 "Call": [
38 (checkExecUsed, ("S102",)),
39 ],
40 }
41
42
43 def checkExecUsed(reportError, context, config):
44 """
45 Function to check for the use of 'exec'.
46
47 @param reportError function to be used to report errors
48 @type func
49 @param context security context object
50 @type SecurityContext
51 @param config dictionary with configuration data
52 @type dict
53 """
54 if (
55 sys.version_info[0] == 2 or
56 context.callFunctionNameQual == 'exec'
57 ):
58 reportError(
59 context.node.lineno - 1,
60 context.node.col_offset,
61 "S102",
62 "M",
63 "H"
64 )

eric ide

mercurial