17 |
17 |
18 class SecurityChecker(object): |
18 class SecurityChecker(object): |
19 """ |
19 """ |
20 Class implementing a checker for security issues. |
20 Class implementing a checker for security issues. |
21 """ |
21 """ |
|
22 Codes = [ |
|
23 # assert used |
|
24 "S101", |
|
25 |
|
26 # flask app |
|
27 "S201", |
|
28 |
|
29 # insecure function calls (blacklisted) |
|
30 "S301", "S302", "S303", "S304", "S305", "S306", "S307", "S308", "S309", |
|
31 "S310", "S311", "S312", "S313", "S314", "S315", "S316", "S317", "S318", |
|
32 "S319", "S320", "S321", "S322", "S323", "S325", |
|
33 |
|
34 # insecure imports (blacklisted) |
|
35 "S401", "S402", "S403", "S404", "S405", "S406", "S407", "S408", "S409", |
|
36 "S410", "S411", "S412", "S413", |
|
37 |
|
38 # insecure certificate usage |
|
39 "S501", |
|
40 |
|
41 # Django SQL injection |
|
42 "S610", "S611", |
|
43 |
|
44 # Django XSS vulnerability |
|
45 "S703", |
|
46 |
|
47 # YAML load |
|
48 "S506", |
|
49 ] |
|
50 |
22 def __init__(self, source, filename, select, ignore, expected, repeat, |
51 def __init__(self, source, filename, select, ignore, expected, repeat, |
23 args): |
52 args): |
24 """ |
53 """ |
25 Constructor |
54 Constructor |
26 |
55 |
75 not code.startswith(self.__select)) |
104 not code.startswith(self.__select)) |
76 |
105 |
77 def reportError(self, lineNumber, offset, code, severity, confidence, |
106 def reportError(self, lineNumber, offset, code, severity, confidence, |
78 *args): |
107 *args): |
79 """ |
108 """ |
80 Private method to record an issue. |
109 Public method to record an issue. |
81 |
110 |
82 @param lineNumber line number of the issue |
111 @param lineNumber line number of the issue |
83 @type int |
112 @type int |
84 @param offset position within line of the issue |
113 @param offset position within line of the issue |
85 @type int |
114 @type int |
86 @param code message code |
115 @param code message code |
87 @type str |
116 @type str |
88 @param severity severity code (H = high, M = medium, L = low, |
117 @param severity severity code (H = high, M = medium, L = low, |
89 U = undefined) |
118 U = undefined) |
90 @type str |
119 @type str |
91 @param configence confidence code (H = high, M = medium, L = low, |
120 @param confidence confidence code (H = high, M = medium, L = low, |
92 U = undefined) |
121 U = undefined) |
93 @type str |
122 @type str |
94 @param args arguments for the message |
123 @param args arguments for the message |
95 @type list |
124 @type list |
96 """ |
125 """ |