11import python
2-
32import semmle.python.security.TaintTracking
43import semmle.python.security.strings.Basic
54import semmle.python.web.Http
65import semmle.python.web.cherrypy.General
76
87/** The cherrypy.request local-proxy object */
98class CherryPyRequest extends TaintKind {
10-
11- CherryPyRequest ( ) {
12- this = "cherrypy.request"
13- }
9+ CherryPyRequest ( ) { this = "cherrypy.request" }
1410
1511 override TaintKind getTaintOfAttribute ( string name ) {
1612 name = "params" and result instanceof ExternalStringDictKind
@@ -19,20 +15,17 @@ class CherryPyRequest extends TaintKind {
1915 }
2016
2117 override TaintKind getTaintOfMethodResult ( string name ) {
22- (
23- name = "getHeader" or
24- name = "getCookie" or
25- name = "getUser" or
26- name = "getPassword"
27- ) and
28- result instanceof ExternalStringKind
18+ (
19+ name = "getHeader" or
20+ name = "getCookie" or
21+ name = "getUser" or
22+ name = "getPassword"
23+ ) and
24+ result instanceof ExternalStringKind
2925 }
30-
3126}
3227
33-
3428class CherryPyExposedFunctionParameter extends TaintSource {
35-
3629 CherryPyExposedFunctionParameter ( ) {
3730 exists ( Parameter p |
3831 p = any ( CherryPyExposedFunction f ) .getAnArg ( ) and
@@ -41,29 +34,13 @@ class CherryPyExposedFunctionParameter extends TaintSource {
4134 )
4235 }
4336
44- override string toString ( ) {
45- result = "CherryPy handler function parameter"
46- }
47-
48- override predicate isSourceOf ( TaintKind kind ) {
49- kind instanceof ExternalStringKind
50- }
37+ override string toString ( ) { result = "CherryPy handler function parameter" }
5138
39+ override predicate isSourceOf ( TaintKind kind ) { kind instanceof ExternalStringKind }
5240}
5341
5442class CherryPyRequestSource extends TaintSource {
43+ CherryPyRequestSource ( ) { this .( ControlFlowNode ) .pointsTo ( Value:: named ( "cherrypy.request" ) ) }
5544
56- CherryPyRequestSource ( ) {
57- this .( ControlFlowNode ) .refersTo ( ModuleObject:: named ( "cherrypy" ) .attr ( "request" ) )
58- }
59-
60- override predicate isSourceOf ( TaintKind kind ) {
61- kind instanceof CherryPyRequest
62- }
63-
45+ override predicate isSourceOf ( TaintKind kind ) { kind instanceof CherryPyRequest }
6446}
65-
66-
67-
68-
69-
0 commit comments