5 <link rel="stylesheet" href="styles.css"> |
5 <link rel="stylesheet" href="styles.css"> |
6 </head> |
6 </head> |
7 <body> |
7 <body> |
8 <a NAME="top" ID="top"></a> |
8 <a NAME="top" ID="top"></a> |
9 <h1>eric7.Plugins.CheckerPlugins.CodeStyleChecker.Security.SecurityUtils</h1> |
9 <h1>eric7.Plugins.CheckerPlugins.CodeStyleChecker.Security.SecurityUtils</h1> |
10 |
|
11 <p> |
10 <p> |
12 Module implementing utility functions used by the security checks. |
11 Module implementing utility functions used by the security checks. |
13 </p> |
12 </p> |
|
13 |
14 <h3>Global Attributes</h3> |
14 <h3>Global Attributes</h3> |
15 |
|
16 <table> |
15 <table> |
17 <tr><td>None</td></tr> |
16 <tr><td>None</td></tr> |
18 </table> |
17 </table> |
|
18 |
19 <h3>Classes</h3> |
19 <h3>Classes</h3> |
20 |
20 <table> |
21 <table> |
|
22 |
|
23 <tr> |
21 <tr> |
24 <td><a href="#InvalidModulePathError">InvalidModulePathError</a></td> |
22 <td><a href="#InvalidModulePathError">InvalidModulePathError</a></td> |
25 <td>Class defining an exception for invalid module paths.</td> |
23 <td>Class defining an exception for invalid module paths.</td> |
26 </tr> |
24 </tr> |
27 </table> |
25 </table> |
|
26 |
28 <h3>Functions</h3> |
27 <h3>Functions</h3> |
29 |
28 <table> |
30 <table> |
|
31 |
|
32 <tr> |
29 <tr> |
33 <td><a href="#_get">_get</a></td> |
30 <td><a href="#_get">_get</a></td> |
34 <td></td> |
31 <td></td> |
35 </tr> |
32 </tr> |
36 <tr> |
33 <tr> |
80 <tr> |
77 <tr> |
81 <td><a href="#namespacePathSplit">namespacePathSplit</a></td> |
78 <td><a href="#namespacePathSplit">namespacePathSplit</a></td> |
82 <td>Function to split a namespace path into a head and tail.</td> |
79 <td>Function to split a namespace path into a head and tail.</td> |
83 </tr> |
80 </tr> |
84 </table> |
81 </table> |
|
82 |
85 <hr /> |
83 <hr /> |
86 <hr /> |
84 <hr /> |
87 <a NAME="InvalidModulePathError" ID="InvalidModulePathError"></a> |
85 <a NAME="InvalidModulePathError" ID="InvalidModulePathError"></a> |
88 <h2>InvalidModulePathError</h2> |
86 <h2>InvalidModulePathError</h2> |
89 |
|
90 <p> |
87 <p> |
91 Class defining an exception for invalid module paths. |
88 Class defining an exception for invalid module paths. |
92 </p> |
89 </p> |
|
90 |
93 <h3>Derived from</h3> |
91 <h3>Derived from</h3> |
94 Exception |
92 Exception |
95 <h3>Class Attributes</h3> |
93 <h3>Class Attributes</h3> |
96 |
|
97 <table> |
94 <table> |
98 <tr><td>None</td></tr> |
95 <tr><td>None</td></tr> |
99 </table> |
96 </table> |
|
97 |
100 <h3>Class Methods</h3> |
98 <h3>Class Methods</h3> |
101 |
|
102 <table> |
99 <table> |
103 <tr><td>None</td></tr> |
100 <tr><td>None</td></tr> |
104 </table> |
101 </table> |
|
102 |
105 <h3>Methods</h3> |
103 <h3>Methods</h3> |
106 |
|
107 <table> |
104 <table> |
108 <tr><td>None</td></tr> |
105 <tr><td>None</td></tr> |
109 </table> |
106 </table> |
|
107 |
110 <h3>Static Methods</h3> |
108 <h3>Static Methods</h3> |
111 |
|
112 <table> |
109 <table> |
113 <tr><td>None</td></tr> |
110 <tr><td>None</td></tr> |
114 </table> |
111 </table> |
|
112 |
115 |
113 |
116 <div align="right"><a href="#top">Up</a></div> |
114 <div align="right"><a href="#top">Up</a></div> |
117 <hr /> |
115 <hr /> |
118 <hr /> |
116 <hr /> |
119 <a NAME="_get" ID="_get"></a> |
117 <a NAME="_get" ID="_get"></a> |
124 <hr /> |
122 <hr /> |
125 <hr /> |
123 <hr /> |
126 <a NAME="concatString" ID="concatString"></a> |
124 <a NAME="concatString" ID="concatString"></a> |
127 <h2>concatString</h2> |
125 <h2>concatString</h2> |
128 <b>concatString</b>(<i>node, stop=None</i>) |
126 <b>concatString</b>(<i>node, stop=None</i>) |
129 |
|
130 <p> |
127 <p> |
131 Function to build a string from an ast.BinOp chain. |
128 Function to build a string from an ast.BinOp chain. |
132 </p> |
129 </p> |
133 <p> |
130 <p> |
134 This will build a string from a series of ast.Constant nodes |
131 This will build a string from a series of ast.Constant nodes |
135 wrapped in ast.BinOp nodes. Something like "a" + "b" + "c" or "a %s" % val |
132 wrapped in ast.BinOp nodes. Something like "a" + "b" + "c" or "a %s" % val |
136 etc. The provided node can be any participant in the BinOp chain. |
133 etc. The provided node can be any participant in the BinOp chain. |
137 </p> |
134 </p> |
|
135 |
138 <dl> |
136 <dl> |
139 |
137 |
140 <dt><i>node</i> (ast.BinOp or ast.Constant)</dt> |
138 <dt><i>node</i> (ast.BinOp or ast.Constant)</dt> |
141 <dd> |
139 <dd> |
142 node to be processed |
140 node to be processed |
163 <hr /> |
161 <hr /> |
164 <hr /> |
162 <hr /> |
165 <a NAME="deepgetattr" ID="deepgetattr"></a> |
163 <a NAME="deepgetattr" ID="deepgetattr"></a> |
166 <h2>deepgetattr</h2> |
164 <h2>deepgetattr</h2> |
167 <b>deepgetattr</b>(<i>obj, attr</i>) |
165 <b>deepgetattr</b>(<i>obj, attr</i>) |
168 |
|
169 <p> |
166 <p> |
170 Function to recurs through an attribute chain to get the ultimate value. |
167 Function to recurs through an attribute chain to get the ultimate value. |
171 </p> |
168 </p> |
|
169 |
172 <dl> |
170 <dl> |
173 |
171 |
174 <dt><i>obj</i> (ast.Name or ast.Attribute)</dt> |
172 <dt><i>obj</i> (ast.Name or ast.Attribute)</dt> |
175 <dd> |
173 <dd> |
176 reference to the object to be recursed |
174 reference to the object to be recursed |
196 <hr /> |
194 <hr /> |
197 <hr /> |
195 <hr /> |
198 <a NAME="escapedBytesRepresentation" ID="escapedBytesRepresentation"></a> |
196 <a NAME="escapedBytesRepresentation" ID="escapedBytesRepresentation"></a> |
199 <h2>escapedBytesRepresentation</h2> |
197 <h2>escapedBytesRepresentation</h2> |
200 <b>escapedBytesRepresentation</b>(<i>b</i>) |
198 <b>escapedBytesRepresentation</b>(<i>b</i>) |
201 |
|
202 <p> |
199 <p> |
203 Function to escape bytes for comparison with other strings. |
200 Function to escape bytes for comparison with other strings. |
204 </p> |
201 </p> |
205 <p> |
202 <p> |
206 In practice it turns control characters into acceptable codepoints then |
203 In practice it turns control characters into acceptable codepoints then |
234 <hr /> |
232 <hr /> |
235 <hr /> |
233 <hr /> |
236 <a NAME="getAttrQualName" ID="getAttrQualName"></a> |
234 <a NAME="getAttrQualName" ID="getAttrQualName"></a> |
237 <h2>getAttrQualName</h2> |
235 <h2>getAttrQualName</h2> |
238 <b>getAttrQualName</b>(<i>node, aliases</i>) |
236 <b>getAttrQualName</b>(<i>node, aliases</i>) |
239 |
|
240 <p> |
237 <p> |
241 Function to get a the full name for the attribute node. |
238 Function to get a the full name for the attribute node. |
242 </p> |
239 </p> |
243 <p> |
240 <p> |
244 This will resolve a pseudo-qualified name for the attribute |
241 This will resolve a pseudo-qualified name for the attribute |
247 will not tell you what the name actually refers to. If we |
244 will not tell you what the name actually refers to. If we |
248 encounter a node without a static name we punt with an |
245 encounter a node without a static name we punt with an |
249 empty string. If this encounters something more complex, such as |
246 empty string. If this encounters something more complex, such as |
250 foo.mylist[0](a,b) we just return empty string. |
247 foo.mylist[0](a,b) we just return empty string. |
251 </p> |
248 </p> |
|
249 |
252 <dl> |
250 <dl> |
253 |
251 |
254 <dt><i>node</i> (ast.Attribute)</dt> |
252 <dt><i>node</i> (ast.Attribute)</dt> |
255 <dd> |
253 <dd> |
256 attribute node to be treated |
254 attribute node to be treated |
276 <hr /> |
274 <hr /> |
277 <hr /> |
275 <hr /> |
278 <a NAME="getCallName" ID="getCallName"></a> |
276 <a NAME="getCallName" ID="getCallName"></a> |
279 <h2>getCallName</h2> |
277 <h2>getCallName</h2> |
280 <b>getCallName</b>(<i>node, aliases</i>) |
278 <b>getCallName</b>(<i>node, aliases</i>) |
281 |
|
282 <p> |
279 <p> |
283 Function to extract the call name from an ast.Call node. |
280 Function to extract the call name from an ast.Call node. |
284 </p> |
281 </p> |
|
282 |
285 <dl> |
283 <dl> |
286 |
284 |
287 <dt><i>node</i> (ast.Call)</dt> |
285 <dt><i>node</i> (ast.Call)</dt> |
288 <dd> |
286 <dd> |
289 node to extract information from |
287 node to extract information from |
309 <hr /> |
307 <hr /> |
310 <hr /> |
308 <hr /> |
311 <a NAME="getCalledName" ID="getCalledName"></a> |
309 <a NAME="getCalledName" ID="getCalledName"></a> |
312 <h2>getCalledName</h2> |
310 <h2>getCalledName</h2> |
313 <b>getCalledName</b>(<i>node</i>) |
311 <b>getCalledName</b>(<i>node</i>) |
314 |
|
315 <p> |
312 <p> |
316 Function to get the function name from an ast.Call node. |
313 Function to get the function name from an ast.Call node. |
317 </p> |
314 </p> |
318 <p> |
315 <p> |
319 An ast.Call node representing a method call will present differently to one |
316 An ast.Call node representing a method call will present differently to one |
320 wrapping a function call: thing.call() vs call(). This helper will grab the |
317 wrapping a function call: thing.call() vs call(). This helper will grab the |
321 unqualified call name correctly in either case. |
318 unqualified call name correctly in either case. |
322 </p> |
319 </p> |
|
320 |
323 <dl> |
321 <dl> |
324 |
322 |
325 <dt><i>node</i> (ast.Call)</dt> |
323 <dt><i>node</i> (ast.Call)</dt> |
326 <dd> |
324 <dd> |
327 reference to the call node |
325 reference to the call node |
359 Starting from the right-most directory component look for __init__.py |
356 Starting from the right-most directory component look for __init__.py |
360 in the directory component. If it exists then the directory name is |
357 in the directory component. If it exists then the directory name is |
361 part of the module name. Move left to the subsequent directory |
358 part of the module name. Move left to the subsequent directory |
362 components until a directory is found without __init__.py. |
359 components until a directory is found without __init__.py. |
363 </p> |
360 </p> |
|
361 |
364 <dl> |
362 <dl> |
365 |
363 |
366 <dt><i>path</i> (str)</dt> |
364 <dt><i>path</i> (str)</dt> |
367 <dd> |
365 <dd> |
368 path of the module to be analyzed |
366 path of the module to be analyzed |
391 <hr /> |
389 <hr /> |
392 <hr /> |
390 <hr /> |
393 <a NAME="getQualAttr" ID="getQualAttr"></a> |
391 <a NAME="getQualAttr" ID="getQualAttr"></a> |
394 <h2>getQualAttr</h2> |
392 <h2>getQualAttr</h2> |
395 <b>getQualAttr</b>(<i>node, aliases</i>) |
393 <b>getQualAttr</b>(<i>node, aliases</i>) |
396 |
|
397 <p> |
394 <p> |
398 Function to extract the qualified name from an ast.Attribute node. |
395 Function to extract the qualified name from an ast.Attribute node. |
399 </p> |
396 </p> |
|
397 |
400 <dl> |
398 <dl> |
401 |
399 |
402 <dt><i>node</i> (ast.Attribute)</dt> |
400 <dt><i>node</i> (ast.Attribute)</dt> |
403 <dd> |
401 <dd> |
404 node to extract information from |
402 node to extract information from |
424 <hr /> |
422 <hr /> |
425 <hr /> |
423 <hr /> |
426 <a NAME="linerange" ID="linerange"></a> |
424 <a NAME="linerange" ID="linerange"></a> |
427 <h2>linerange</h2> |
425 <h2>linerange</h2> |
428 <b>linerange</b>(<i>node</i>) |
426 <b>linerange</b>(<i>node</i>) |
429 |
|
430 <p> |
427 <p> |
431 Function to get line number range from a node. |
428 Function to get line number range from a node. |
432 </p> |
429 </p> |
|
430 |
433 <dl> |
431 <dl> |
434 |
432 |
435 <dt><i>node</i> (ast.AST)</dt> |
433 <dt><i>node</i> (ast.AST)</dt> |
436 <dd> |
434 <dd> |
437 node to extract a line range from |
435 node to extract a line range from |
453 <hr /> |
451 <hr /> |
454 <hr /> |
452 <hr /> |
455 <a NAME="linerange_fix" ID="linerange_fix"></a> |
453 <a NAME="linerange_fix" ID="linerange_fix"></a> |
456 <h2>linerange_fix</h2> |
454 <h2>linerange_fix</h2> |
457 <b>linerange_fix</b>(<i>node</i>) |
455 <b>linerange_fix</b>(<i>node</i>) |
458 |
|
459 <p> |
456 <p> |
460 Function to get a line number range working around a known Python bug |
457 Function to get a line number range working around a known Python bug |
461 with multi-line strings. |
458 with multi-line strings. |
462 </p> |
459 </p> |
|
460 |
463 <dl> |
461 <dl> |
464 |
462 |
465 <dt><i>node</i> (ast.AST)</dt> |
463 <dt><i>node</i> (ast.AST)</dt> |
466 <dd> |
464 <dd> |
467 node to extract a line range from |
465 node to extract a line range from |
483 <hr /> |
481 <hr /> |
484 <hr /> |
482 <hr /> |
485 <a NAME="namespacePathJoin" ID="namespacePathJoin"></a> |
483 <a NAME="namespacePathJoin" ID="namespacePathJoin"></a> |
486 <h2>namespacePathJoin</h2> |
484 <h2>namespacePathJoin</h2> |
487 <b>namespacePathJoin</b>(<i>namespace, name</i>) |
485 <b>namespacePathJoin</b>(<i>namespace, name</i>) |
488 |
|
489 <p> |
486 <p> |
490 Function to extend a given namespace path. |
487 Function to extend a given namespace path. |
491 </p> |
488 </p> |
|
489 |
492 <dl> |
490 <dl> |
493 |
491 |
494 <dt><i>namespace</i> (str)</dt> |
492 <dt><i>namespace</i> (str)</dt> |
495 <dd> |
493 <dd> |
496 namespace to be extended |
494 namespace to be extended |
516 <hr /> |
514 <hr /> |
517 <hr /> |
515 <hr /> |
518 <a NAME="namespacePathSplit" ID="namespacePathSplit"></a> |
516 <a NAME="namespacePathSplit" ID="namespacePathSplit"></a> |
519 <h2>namespacePathSplit</h2> |
517 <h2>namespacePathSplit</h2> |
520 <b>namespacePathSplit</b>(<i>path</i>) |
518 <b>namespacePathSplit</b>(<i>path</i>) |
521 |
|
522 <p> |
519 <p> |
523 Function to split a namespace path into a head and tail. |
520 Function to split a namespace path into a head and tail. |
524 </p> |
521 </p> |
525 <p> |
522 <p> |
526 Tail will be the last namespace path component and head will |
523 Tail will be the last namespace path component and head will |
527 be everything leading up to that in the path. This is similar to |
524 be everything leading up to that in the path. This is similar to |
528 os.path.split. |
525 os.path.split. |
529 </p> |
526 </p> |
|
527 |
530 <dl> |
528 <dl> |
531 |
529 |
532 <dt><i>path</i> (str)</dt> |
530 <dt><i>path</i> (str)</dt> |
533 <dd> |
531 <dd> |
534 namespace path to be split |
532 namespace path to be split |