|
1 | 1 | import python |
2 | | - |
3 | 2 | import semmle.python.security.TaintTracking |
4 | 3 |
|
5 | | -private ClassObject theTurboGearsControllerClass() { |
6 | | - result = ModuleObject::named("tg").attr("TGController") |
7 | | -} |
8 | | - |
9 | | - |
10 | | -ClassObject aTurboGearsControllerClass() { |
11 | | - result.getASuperType() = theTurboGearsControllerClass() |
12 | | -} |
| 4 | +private ClassValue theTurboGearsControllerClass() { result = Value::named("tg.TGController") } |
13 | 5 |
|
| 6 | +ClassValue aTurboGearsControllerClass() { result.getABaseType+() = theTurboGearsControllerClass() } |
14 | 7 |
|
15 | 8 | class TurboGearsControllerMethod extends Function { |
16 | | - |
17 | 9 | ControlFlowNode decorator; |
18 | 10 |
|
19 | 11 | TurboGearsControllerMethod() { |
20 | | - aTurboGearsControllerClass().getPyClass() = this.getScope() and |
| 12 | + aTurboGearsControllerClass().getScope() = this.getScope() and |
21 | 13 | decorator = this.getADecorator().getAFlowNode() and |
22 | 14 | /* Is decorated with @expose() or @expose(path) */ |
23 | 15 | ( |
24 | 16 | decorator.(CallNode).getFunction().(NameNode).getId() = "expose" |
25 | 17 | or |
26 | | - decorator.refersTo(_, ModuleObject::named("tg").attr("expose"), _) |
| 18 | + decorator.pointsTo().getClass() = Value::named("tg.expose") |
27 | 19 | ) |
28 | 20 | } |
29 | 21 |
|
30 | | - private ControlFlowNode templateName() { |
31 | | - result = decorator.(CallNode).getArg(0) |
32 | | - } |
| 22 | + private ControlFlowNode templateName() { result = decorator.(CallNode).getArg(0) } |
33 | 23 |
|
34 | | - predicate isTemplated() { |
35 | | - exists(templateName()) |
36 | | - } |
37 | | - |
38 | | - string getTemplateName() { |
39 | | - exists(StringObject str | |
40 | | - templateName().refersTo(str) and |
41 | | - result = str.getText() |
42 | | - ) |
43 | | - } |
| 24 | + predicate isTemplated() { exists(templateName()) } |
44 | 25 |
|
45 | 26 | Dict getValidationDict() { |
46 | | - exists(Call call, Object dict | |
| 27 | + exists(Call call, Value dict | |
47 | 28 | call = this.getADecorator() and |
48 | 29 | call.getFunc().(Name).getId() = "validate" and |
49 | | - call.getArg(0).refersTo(dict) and |
50 | | - result = dict.getOrigin() |
| 30 | + call.getArg(0).pointsTo(dict, result) |
51 | 31 | ) |
52 | 32 | } |
53 | | - |
54 | 33 | } |
55 | | - |
0 commit comments