mirror of
https://github.com/github/codeql.git
synced 2026-05-02 20:25:13 +02:00
Python: Add cherrypy handler function return values as taint sinks.
This commit is contained in:
@@ -6,3 +6,4 @@ import semmle.python.web.twisted.Response
|
||||
import semmle.python.web.bottle.Response
|
||||
import semmle.python.web.turbogears.Response
|
||||
import semmle.python.web.falcon.Response
|
||||
import semmle.python.web.cherrypy.Response
|
||||
|
||||
@@ -13,6 +13,8 @@ class CherryPyExposedFunction extends Function {
|
||||
|
||||
CherryPyExposedFunction() {
|
||||
this.getADecorator().refersTo(CherryPy::expose())
|
||||
or
|
||||
this.getADecorator().(Call).getFunc().refersTo(CherryPy::expose())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
28
python/ql/src/semmle/python/web/cherrypy/Response.qll
Normal file
28
python/ql/src/semmle/python/web/cherrypy/Response.qll
Normal file
@@ -0,0 +1,28 @@
|
||||
import python
|
||||
|
||||
import semmle.python.security.TaintTracking
|
||||
import semmle.python.security.strings.Untrusted
|
||||
import semmle.python.web.Http
|
||||
import semmle.python.web.cherrypy.General
|
||||
|
||||
|
||||
|
||||
class CherryPyExposedFunctionResult extends TaintSink {
|
||||
|
||||
CherryPyExposedFunctionResult() {
|
||||
exists(Return ret |
|
||||
ret.getScope() instanceof CherryPyExposedFunction and
|
||||
ret.getValue().getAFlowNode() = this
|
||||
)
|
||||
}
|
||||
|
||||
override predicate sinks(TaintKind kind) {
|
||||
kind instanceof StringKind
|
||||
}
|
||||
|
||||
override string toString() {
|
||||
result = "cherrypy handler function result"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
3
python/ql/test/library-tests/web/cherrypy/Sinks.expected
Normal file
3
python/ql/test/library-tests/web/cherrypy/Sinks.expected
Normal file
@@ -0,0 +1,3 @@
|
||||
| red.py:8 | Str | externally controlled string |
|
||||
| test.py:11 | BinaryExpr | externally controlled string |
|
||||
| test.py:17 | BinaryExpr | externally controlled string |
|
||||
10
python/ql/test/library-tests/web/cherrypy/Sinks.ql
Normal file
10
python/ql/test/library-tests/web/cherrypy/Sinks.ql
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
import python
|
||||
|
||||
import semmle.python.web.HttpRequest
|
||||
import semmle.python.web.HttpResponse
|
||||
import semmle.python.security.strings.Untrusted
|
||||
|
||||
from TaintSink sink, TaintKind kind
|
||||
where sink.sinks(kind)
|
||||
select sink.getLocation().toString(), sink.(ControlFlowNode).getNode().toString(), kind
|
||||
Reference in New Issue
Block a user