|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric6.Plugins.CheckerPlugins.CodeStyleChecker.Security.SecurityNodeVisitor</title> |
|
4 <meta charset="UTF-8"> |
|
5 <style> |
|
6 body { |
|
7 background: #EDECE6; |
|
8 margin: 0em 1em 10em 1em; |
|
9 color: black; |
|
10 } |
|
11 |
|
12 h1 { color: white; background: #85774A; } |
|
13 h2 { color: white; background: #85774A; } |
|
14 h3 { color: white; background: #9D936E; } |
|
15 h4 { color: white; background: #9D936E; } |
|
16 |
|
17 a { color: #BA6D36; } |
|
18 |
|
19 </style> |
|
20 </head> |
|
21 <body> |
|
22 <a NAME="top" ID="top"></a> |
|
23 <h1>eric6.Plugins.CheckerPlugins.CodeStyleChecker.Security.SecurityNodeVisitor</h1> |
|
24 |
|
25 <p> |
|
26 Module implementing an AST node visitor for security checks. |
|
27 </p> |
|
28 <h3>Global Attributes</h3> |
|
29 |
|
30 <table> |
|
31 <tr><td>None</td></tr> |
|
32 </table> |
|
33 <h3>Classes</h3> |
|
34 |
|
35 <table> |
|
36 |
|
37 <tr> |
|
38 <td><a href="#SecurityNodeVisitor">SecurityNodeVisitor</a></td> |
|
39 <td>Class implementing an AST node visitor for security checks.</td> |
|
40 </tr> |
|
41 </table> |
|
42 <h3>Functions</h3> |
|
43 |
|
44 <table> |
|
45 <tr><td>None</td></tr> |
|
46 </table> |
|
47 <hr /> |
|
48 <hr /> |
|
49 <a NAME="SecurityNodeVisitor" ID="SecurityNodeVisitor"></a> |
|
50 <h2>SecurityNodeVisitor</h2> |
|
51 |
|
52 <p> |
|
53 Class implementing an AST node visitor for security checks. |
|
54 </p> |
|
55 <h3>Derived from</h3> |
|
56 object |
|
57 <h3>Class Attributes</h3> |
|
58 |
|
59 <table> |
|
60 <tr><td>None</td></tr> |
|
61 </table> |
|
62 <h3>Class Methods</h3> |
|
63 |
|
64 <table> |
|
65 <tr><td>None</td></tr> |
|
66 </table> |
|
67 <h3>Methods</h3> |
|
68 |
|
69 <table> |
|
70 |
|
71 <tr> |
|
72 <td><a href="#SecurityNodeVisitor.__init__">SecurityNodeVisitor</a></td> |
|
73 <td>Constructor</td> |
|
74 </tr> |
|
75 <tr> |
|
76 <td><a href="#SecurityNodeVisitor.__postVisit">__postVisit</a></td> |
|
77 <td>Private method to clean up after a node was visited.</td> |
|
78 </tr> |
|
79 <tr> |
|
80 <td><a href="#SecurityNodeVisitor.__preVisit">__preVisit</a></td> |
|
81 <td>Private method to set up a context for the visit method.</td> |
|
82 </tr> |
|
83 <tr> |
|
84 <td><a href="#SecurityNodeVisitor.__runChecks">__runChecks</a></td> |
|
85 <td>Private method to run all enabled checks for a given check type.</td> |
|
86 </tr> |
|
87 <tr> |
|
88 <td><a href="#SecurityNodeVisitor.generic_visit">generic_visit</a></td> |
|
89 <td>Public method to drive the node visitor.</td> |
|
90 </tr> |
|
91 <tr> |
|
92 <td><a href="#SecurityNodeVisitor.visit">visit</a></td> |
|
93 <td>Public method to inspected an AST node.</td> |
|
94 </tr> |
|
95 <tr> |
|
96 <td><a href="#SecurityNodeVisitor.visit_Bytes">visit_Bytes</a></td> |
|
97 <td>Public method defining a visitor for Bytes nodes.</td> |
|
98 </tr> |
|
99 <tr> |
|
100 <td><a href="#SecurityNodeVisitor.visit_Call">visit_Call</a></td> |
|
101 <td>Public method defining a visitor for AST Call nodes.</td> |
|
102 </tr> |
|
103 <tr> |
|
104 <td><a href="#SecurityNodeVisitor.visit_ClassDef">visit_ClassDef</a></td> |
|
105 <td>Public method defining a visitor for AST ClassDef nodes.</td> |
|
106 </tr> |
|
107 <tr> |
|
108 <td><a href="#SecurityNodeVisitor.visit_Constant">visit_Constant</a></td> |
|
109 <td>Public method defining a visitor for Constant nodes.</td> |
|
110 </tr> |
|
111 <tr> |
|
112 <td><a href="#SecurityNodeVisitor.visit_FunctionDef">visit_FunctionDef</a></td> |
|
113 <td>Public method defining a visitor for AST FunctionDef nodes.</td> |
|
114 </tr> |
|
115 <tr> |
|
116 <td><a href="#SecurityNodeVisitor.visit_Import">visit_Import</a></td> |
|
117 <td>Public method defining a visitor for AST Import nodes.</td> |
|
118 </tr> |
|
119 <tr> |
|
120 <td><a href="#SecurityNodeVisitor.visit_ImportFrom">visit_ImportFrom</a></td> |
|
121 <td>Public method defining a visitor for AST Import nodes.</td> |
|
122 </tr> |
|
123 <tr> |
|
124 <td><a href="#SecurityNodeVisitor.visit_Str">visit_Str</a></td> |
|
125 <td>Public method defining a visitor for String nodes.</td> |
|
126 </tr> |
|
127 </table> |
|
128 <h3>Static Methods</h3> |
|
129 |
|
130 <table> |
|
131 <tr><td>None</td></tr> |
|
132 </table> |
|
133 |
|
134 <a NAME="SecurityNodeVisitor.__init__" ID="SecurityNodeVisitor.__init__"></a> |
|
135 <h4>SecurityNodeVisitor (Constructor)</h4> |
|
136 <b>SecurityNodeVisitor</b>(<i>checker, secCheckers, filename</i>) |
|
137 |
|
138 <p> |
|
139 Constructor |
|
140 </p> |
|
141 <dl> |
|
142 |
|
143 <dt><i>checker</i> (SecurityChecker)</dt> |
|
144 <dd> |
|
145 reference to the main security checker object |
|
146 </dd> |
|
147 <dt><i>secCheckers</i> (dict)</dt> |
|
148 <dd> |
|
149 dictionary containing the available checker routines |
|
150 </dd> |
|
151 <dt><i>filename</i> (str)</dt> |
|
152 <dd> |
|
153 name of the checked file |
|
154 </dd> |
|
155 </dl> |
|
156 <a NAME="SecurityNodeVisitor.__postVisit" ID="SecurityNodeVisitor.__postVisit"></a> |
|
157 <h4>SecurityNodeVisitor.__postVisit</h4> |
|
158 <b>__postVisit</b>(<i>node</i>) |
|
159 |
|
160 <p> |
|
161 Private method to clean up after a node was visited. |
|
162 </p> |
|
163 <dl> |
|
164 |
|
165 <dt><i>node</i> (ast.AST)</dt> |
|
166 <dd> |
|
167 AST node that was visited |
|
168 </dd> |
|
169 </dl> |
|
170 <a NAME="SecurityNodeVisitor.__preVisit" ID="SecurityNodeVisitor.__preVisit"></a> |
|
171 <h4>SecurityNodeVisitor.__preVisit</h4> |
|
172 <b>__preVisit</b>(<i>node</i>) |
|
173 |
|
174 <p> |
|
175 Private method to set up a context for the visit method. |
|
176 </p> |
|
177 <dl> |
|
178 |
|
179 <dt><i>node</i> (ast.AST)</dt> |
|
180 <dd> |
|
181 node to base the context on |
|
182 </dd> |
|
183 </dl> |
|
184 <dl> |
|
185 <dt>Returns:</dt> |
|
186 <dd> |
|
187 flag indicating to visit the node |
|
188 </dd> |
|
189 </dl> |
|
190 <dl> |
|
191 <dt>Return Type:</dt> |
|
192 <dd> |
|
193 bool |
|
194 </dd> |
|
195 </dl> |
|
196 <a NAME="SecurityNodeVisitor.__runChecks" ID="SecurityNodeVisitor.__runChecks"></a> |
|
197 <h4>SecurityNodeVisitor.__runChecks</h4> |
|
198 <b>__runChecks</b>(<i>checkType</i>) |
|
199 |
|
200 <p> |
|
201 Private method to run all enabled checks for a given check type. |
|
202 </p> |
|
203 <dl> |
|
204 |
|
205 <dt><i>checkType</i> (str)</dt> |
|
206 <dd> |
|
207 type of checks to be run |
|
208 </dd> |
|
209 </dl> |
|
210 <a NAME="SecurityNodeVisitor.generic_visit" ID="SecurityNodeVisitor.generic_visit"></a> |
|
211 <h4>SecurityNodeVisitor.generic_visit</h4> |
|
212 <b>generic_visit</b>(<i>node</i>) |
|
213 |
|
214 <p> |
|
215 Public method to drive the node visitor. |
|
216 </p> |
|
217 <dl> |
|
218 |
|
219 <dt><i>node</i> (ast.AST)</dt> |
|
220 <dd> |
|
221 node to be inspected |
|
222 </dd> |
|
223 </dl> |
|
224 <a NAME="SecurityNodeVisitor.visit" ID="SecurityNodeVisitor.visit"></a> |
|
225 <h4>SecurityNodeVisitor.visit</h4> |
|
226 <b>visit</b>(<i>node</i>) |
|
227 |
|
228 <p> |
|
229 Public method to inspected an AST node. |
|
230 </p> |
|
231 <dl> |
|
232 |
|
233 <dt><i>node</i> (ast.AST)</dt> |
|
234 <dd> |
|
235 AST node to be inspected |
|
236 </dd> |
|
237 </dl> |
|
238 <a NAME="SecurityNodeVisitor.visit_Bytes" ID="SecurityNodeVisitor.visit_Bytes"></a> |
|
239 <h4>SecurityNodeVisitor.visit_Bytes</h4> |
|
240 <b>visit_Bytes</b>(<i>node</i>) |
|
241 |
|
242 <p> |
|
243 Public method defining a visitor for Bytes nodes. |
|
244 </p> |
|
245 <p> |
|
246 This adds relevant information about node to |
|
247 the context for use in tests which inspect strings. |
|
248 </p> |
|
249 <dl> |
|
250 |
|
251 <dt><i>node</i> (ast.Bytes)</dt> |
|
252 <dd> |
|
253 reference to the node being inspected |
|
254 </dd> |
|
255 </dl> |
|
256 <a NAME="SecurityNodeVisitor.visit_Call" ID="SecurityNodeVisitor.visit_Call"></a> |
|
257 <h4>SecurityNodeVisitor.visit_Call</h4> |
|
258 <b>visit_Call</b>(<i>node</i>) |
|
259 |
|
260 <p> |
|
261 Public method defining a visitor for AST Call nodes. |
|
262 </p> |
|
263 <p> |
|
264 Add relevant information about the node to the context for use in tests |
|
265 which inspect function calls. |
|
266 </p> |
|
267 <dl> |
|
268 |
|
269 <dt><i>node</i> (ast.Call)</dt> |
|
270 <dd> |
|
271 reference to the node being inspected |
|
272 </dd> |
|
273 </dl> |
|
274 <a NAME="SecurityNodeVisitor.visit_ClassDef" ID="SecurityNodeVisitor.visit_ClassDef"></a> |
|
275 <h4>SecurityNodeVisitor.visit_ClassDef</h4> |
|
276 <b>visit_ClassDef</b>(<i>node</i>) |
|
277 |
|
278 <p> |
|
279 Public method defining a visitor for AST ClassDef nodes. |
|
280 </p> |
|
281 <p> |
|
282 Add class name to current namespace for all descendants. |
|
283 </p> |
|
284 <dl> |
|
285 |
|
286 <dt><i>node</i> (ast.ClassDef)</dt> |
|
287 <dd> |
|
288 reference to the node being inspected |
|
289 </dd> |
|
290 </dl> |
|
291 <a NAME="SecurityNodeVisitor.visit_Constant" ID="SecurityNodeVisitor.visit_Constant"></a> |
|
292 <h4>SecurityNodeVisitor.visit_Constant</h4> |
|
293 <b>visit_Constant</b>(<i>node</i>) |
|
294 |
|
295 <p> |
|
296 Public method defining a visitor for Constant nodes. |
|
297 </p> |
|
298 <p> |
|
299 This calls the appropriate method for the node type. |
|
300 It maintains compatibility with <3.6 and 3.8+ |
|
301 </p> |
|
302 <dl> |
|
303 |
|
304 <dt><i>node</i> (ast.Constant)</dt> |
|
305 <dd> |
|
306 reference to the node being inspected |
|
307 </dd> |
|
308 </dl> |
|
309 <a NAME="SecurityNodeVisitor.visit_FunctionDef" ID="SecurityNodeVisitor.visit_FunctionDef"></a> |
|
310 <h4>SecurityNodeVisitor.visit_FunctionDef</h4> |
|
311 <b>visit_FunctionDef</b>(<i>node</i>) |
|
312 |
|
313 <p> |
|
314 Public method defining a visitor for AST FunctionDef nodes. |
|
315 </p> |
|
316 <p> |
|
317 Add relevant information about the node to the context for use in tests |
|
318 which inspect function definitions. Add the function name to the |
|
319 current namespace for all descendants. |
|
320 </p> |
|
321 <dl> |
|
322 |
|
323 <dt><i>node</i> (ast.FunctionDef)</dt> |
|
324 <dd> |
|
325 reference to the node being inspected |
|
326 </dd> |
|
327 </dl> |
|
328 <a NAME="SecurityNodeVisitor.visit_Import" ID="SecurityNodeVisitor.visit_Import"></a> |
|
329 <h4>SecurityNodeVisitor.visit_Import</h4> |
|
330 <b>visit_Import</b>(<i>node</i>) |
|
331 |
|
332 <p> |
|
333 Public method defining a visitor for AST Import nodes. |
|
334 </p> |
|
335 <dl> |
|
336 |
|
337 <dt><i>node</i> (ast.Import)</dt> |
|
338 <dd> |
|
339 reference to the node being inspected |
|
340 </dd> |
|
341 </dl> |
|
342 <a NAME="SecurityNodeVisitor.visit_ImportFrom" ID="SecurityNodeVisitor.visit_ImportFrom"></a> |
|
343 <h4>SecurityNodeVisitor.visit_ImportFrom</h4> |
|
344 <b>visit_ImportFrom</b>(<i>node</i>) |
|
345 |
|
346 <p> |
|
347 Public method defining a visitor for AST Import nodes. |
|
348 </p> |
|
349 <p> |
|
350 This adds relevant information about the node to |
|
351 the context for use in tests which inspect imports. |
|
352 </p> |
|
353 <dl> |
|
354 |
|
355 <dt><i>node</i> (ast.ImportFrom)</dt> |
|
356 <dd> |
|
357 reference to the node being inspected |
|
358 </dd> |
|
359 </dl> |
|
360 <a NAME="SecurityNodeVisitor.visit_Str" ID="SecurityNodeVisitor.visit_Str"></a> |
|
361 <h4>SecurityNodeVisitor.visit_Str</h4> |
|
362 <b>visit_Str</b>(<i>node</i>) |
|
363 |
|
364 <p> |
|
365 Public method defining a visitor for String nodes. |
|
366 </p> |
|
367 <p> |
|
368 This adds relevant information about node to |
|
369 the context for use in tests which inspect strings. |
|
370 </p> |
|
371 <dl> |
|
372 |
|
373 <dt><i>node</i> (ast.Str)</dt> |
|
374 <dd> |
|
375 reference to the node being inspected |
|
376 </dd> |
|
377 </dl> |
|
378 <div align="right"><a href="#top">Up</a></div> |
|
379 <hr /> |
|
380 </body></html> |