|
| 1 | +import python |
| 2 | +import semmle.python.web.Http |
| 3 | + |
| 4 | +module CherryPy { |
| 5 | + |
| 6 | + FunctionObject expose() { |
| 7 | + result = ModuleObject::named("cherrypy").attr("expose") |
| 8 | + } |
| 9 | + |
| 10 | +} |
| 11 | + |
| 12 | +class CherryPyExposedFunction extends Function { |
| 13 | + |
| 14 | + CherryPyExposedFunction() { |
| 15 | + this.getADecorator().refersTo(CherryPy::expose()) |
| 16 | + or |
| 17 | + this.getADecorator().(Call).getFunc().refersTo(CherryPy::expose()) |
| 18 | + } |
| 19 | + |
| 20 | +} |
| 21 | + |
| 22 | +class CherryPyRoute extends CallNode { |
| 23 | + |
| 24 | + CherryPyRoute() { |
| 25 | + /* cherrypy.quickstart(root, script_name, config) */ |
| 26 | + ModuleObject::named("cherrypy").attr("quickstart").(FunctionObject).getACall() = this |
| 27 | + or |
| 28 | + /* cherrypy.tree.mount(root, script_name, config) */ |
| 29 | + this.getFunction().(AttrNode).getObject("mount").refersTo(ModuleObject::named("cherrypy").attr("tree")) |
| 30 | + } |
| 31 | + |
| 32 | + ClassObject getAppClass() { |
| 33 | + this.getArg(0).refersTo(_, result, _) |
| 34 | + or |
| 35 | + this.getArgByName("root").refersTo(_, result, _) |
| 36 | + } |
| 37 | + |
| 38 | + string getPath() { |
| 39 | + exists(StringObject path | |
| 40 | + result = path.getText() |
| 41 | + | |
| 42 | + this.getArg(1).refersTo(path) |
| 43 | + or |
| 44 | + this.getArgByName("script_name").refersTo(path) |
| 45 | + ) |
| 46 | + } |
| 47 | + |
| 48 | + Object getConfig() { |
| 49 | + this.getArg(2).refersTo(_, result, _) |
| 50 | + or |
| 51 | + this.getArgByName("config").refersTo(_, result, _) |
| 52 | + } |
| 53 | + |
| 54 | +} |
| 55 | + |
| 56 | + |
0 commit comments