Skip to content

Commit a40fdf7

Browse files
committed
Python: Deprecate old web modeling
1 parent e9b496b commit a40fdf7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+173
-159
lines changed

python/ql/lib/semmle/python/web/Http.qll

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import semmle.python.security.strings.External
44
import HttpConstants
55

66
/** Generic taint source from a http request */
7-
abstract class HttpRequestTaintSource extends TaintSource { }
7+
abstract deprecated class HttpRequestTaintSource extends TaintSource { }
88

99
/**
1010
* Taint kind representing the WSGI environment.
1111
* As specified in PEP 3333. https://www.python.org/dev/peps/pep-3333/#environ-variables
1212
*/
13-
class WsgiEnvironment extends TaintKind {
13+
deprecated class WsgiEnvironment extends TaintKind {
1414
WsgiEnvironment() { this = "wsgi.environment" }
1515

1616
override TaintKind getTaintForFlowStep(ControlFlowNode fromnode, ControlFlowNode tonode) {
@@ -43,7 +43,7 @@ class WsgiEnvironment extends TaintKind {
4343
* A standard morsel object from a HTTP request, a value in a cookie,
4444
* typically an instance of `http.cookies.Morsel`
4545
*/
46-
class UntrustedMorsel extends TaintKind {
46+
deprecated class UntrustedMorsel extends TaintKind {
4747
UntrustedMorsel() { this = "http.Morsel" }
4848

4949
override TaintKind getTaintOfAttribute(string name) {
@@ -53,7 +53,7 @@ class UntrustedMorsel extends TaintKind {
5353
}
5454

5555
/** A standard cookie object from a HTTP request, typically an instance of `http.cookies.SimpleCookie` */
56-
class UntrustedCookie extends TaintKind {
56+
deprecated class UntrustedCookie extends TaintKind {
5757
UntrustedCookie() { this = "http.Cookie" }
5858

5959
override TaintKind getTaintForFlowStep(ControlFlowNode fromnode, ControlFlowNode tonode) {
@@ -62,7 +62,7 @@ class UntrustedCookie extends TaintKind {
6262
}
6363
}
6464

65-
abstract class CookieOperation extends @py_flow_node {
65+
abstract deprecated class CookieOperation extends @py_flow_node {
6666
/** Gets a textual representation of this element. */
6767
abstract string toString();
6868

@@ -71,20 +71,20 @@ abstract class CookieOperation extends @py_flow_node {
7171
abstract ControlFlowNode getValue();
7272
}
7373

74-
abstract class CookieGet extends CookieOperation { }
74+
abstract deprecated class CookieGet extends CookieOperation { }
7575

76-
abstract class CookieSet extends CookieOperation { }
76+
abstract deprecated class CookieSet extends CookieOperation { }
7777

7878
/** Generic taint sink in a http response */
79-
abstract class HttpResponseTaintSink extends TaintSink {
79+
abstract deprecated class HttpResponseTaintSink extends TaintSink {
8080
override predicate sinks(TaintKind kind) { kind instanceof ExternalStringKind }
8181
}
8282

83-
abstract class HttpRedirectTaintSink extends TaintSink {
83+
abstract deprecated class HttpRedirectTaintSink extends TaintSink {
8484
override predicate sinks(TaintKind kind) { kind instanceof ExternalStringKind }
8585
}
8686

87-
module Client {
87+
deprecated module Client {
8888
// TODO: user-input in other than URL:
8989
// - `data`, `json` for `requests.post`
9090
// - `body` for `HTTPConnection.request`
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/** Gets an HTTP verb, in upper case */
2-
string httpVerb() { result in ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"] }
2+
deprecated string httpVerb() {
3+
result in ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"]
4+
}
35

46
/** Gets an HTTP verb, in lower case */
5-
string httpVerbLower() { result = httpVerb().toLowerCase() }
7+
deprecated string httpVerbLower() { result = httpVerb().toLowerCase() }

python/ql/lib/semmle/python/web/bottle/General.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ import semmle.python.web.Http
33
import semmle.python.types.Extensions
44

55
/** The bottle module */
6-
ModuleValue theBottleModule() { result = Module::named("bottle") }
6+
deprecated ModuleValue theBottleModule() { result = Module::named("bottle") }
77

88
/** The bottle.Bottle class */
9-
ClassValue theBottleClass() { result = theBottleModule().attr("Bottle") }
9+
deprecated ClassValue theBottleClass() { result = theBottleModule().attr("Bottle") }
1010

1111
/**
1212
* Holds if `route` is routed to `func`
1313
* by decorating `func` with `app.route(route)` or `route(route)`
1414
*/
15-
predicate bottle_route(CallNode route_call, ControlFlowNode route, Function func) {
15+
deprecated predicate bottle_route(CallNode route_call, ControlFlowNode route, Function func) {
1616
exists(CallNode decorator_call, string name |
1717
route_call.getFunction().(AttrNode).getObject(name).pointsTo().getClass() = theBottleClass() or
1818
route_call.getFunction().pointsTo(theBottleModule().attr(name))
@@ -24,7 +24,7 @@ predicate bottle_route(CallNode route_call, ControlFlowNode route, Function func
2424
)
2525
}
2626

27-
class BottleRoute extends ControlFlowNode {
27+
deprecated class BottleRoute extends ControlFlowNode {
2828
BottleRoute() { bottle_route(this, _, _) }
2929

3030
string getUrl() {

python/ql/lib/semmle/python/web/bottle/Redirect.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import semmle.python.dataflow.TaintTracking
99
import semmle.python.security.strings.Basic
1010
import semmle.python.web.bottle.General
1111

12-
FunctionValue bottle_redirect() { result = theBottleModule().attr("redirect") }
12+
deprecated FunctionValue bottle_redirect() { result = theBottleModule().attr("redirect") }
1313

1414
/**
1515
* Represents an argument to the `bottle.redirect` function.
1616
*/
17-
class BottleRedirect extends TaintSink {
17+
deprecated class BottleRedirect extends TaintSink {
1818
override string toString() { result = "bottle.redirect" }
1919

2020
BottleRedirect() {

python/ql/lib/semmle/python/web/bottle/Request.qll

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import semmle.python.security.strings.External
44
import semmle.python.web.Http
55
import semmle.python.web.bottle.General
66

7-
private Value theBottleRequestObject() { result = theBottleModule().attr("request") }
7+
deprecated private Value theBottleRequestObject() { result = theBottleModule().attr("request") }
88

9-
class BottleRequestKind extends TaintKind {
9+
deprecated class BottleRequestKind extends TaintKind {
1010
BottleRequestKind() { this = "bottle.request" }
1111

1212
override TaintKind getTaintOfAttribute(string name) {
@@ -21,13 +21,13 @@ class BottleRequestKind extends TaintKind {
2121
}
2222
}
2323

24-
private class RequestSource extends HttpRequestTaintSource {
24+
deprecated private class RequestSource extends HttpRequestTaintSource {
2525
RequestSource() { this.(ControlFlowNode).pointsTo(theBottleRequestObject()) }
2626

2727
override predicate isSourceOf(TaintKind kind) { kind instanceof BottleRequestKind }
2828
}
2929

30-
class BottleFormsDict extends TaintKind {
30+
deprecated class BottleFormsDict extends TaintKind {
3131
BottleFormsDict() { this = "bottle.FormsDict" }
3232

3333
override TaintKind getTaintForFlowStep(ControlFlowNode fromnode, ControlFlowNode tonode) {
@@ -48,7 +48,7 @@ class BottleFormsDict extends TaintKind {
4848
}
4949
}
5050

51-
class FileUpload extends TaintKind {
51+
deprecated class FileUpload extends TaintKind {
5252
FileUpload() { this = "bottle.FileUpload" }
5353

5454
override TaintKind getTaintOfAttribute(string name) {
@@ -60,7 +60,7 @@ class FileUpload extends TaintKind {
6060
}
6161
}
6262

63-
class UntrustedFile extends TaintKind {
63+
deprecated class UntrustedFile extends TaintKind {
6464
UntrustedFile() { this = "Untrusted file" }
6565
}
6666

@@ -69,7 +69,7 @@ class UntrustedFile extends TaintKind {
6969
// Move UntrustedFile to shared location
7070
//
7171
/** Parameter to a bottle request handler function */
72-
class BottleRequestParameter extends HttpRequestTaintSource {
72+
deprecated class BottleRequestParameter extends HttpRequestTaintSource {
7373
BottleRequestParameter() {
7474
exists(BottleRoute route | route.getANamedArgument() = this.(ControlFlowNode).getNode())
7575
}

python/ql/lib/semmle/python/web/bottle/Response.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import semmle.python.web.bottle.General
99
* This isn't really a "taint", but we use the value tracking machinery to
1010
* track the flow of response objects.
1111
*/
12-
class BottleResponse extends TaintKind {
12+
deprecated class BottleResponse extends TaintKind {
1313
BottleResponse() { this = "bottle.response" }
1414
}
1515

16-
private Value theBottleResponseObject() { result = theBottleModule().attr("response") }
16+
deprecated private Value theBottleResponseObject() { result = theBottleModule().attr("response") }
1717

18-
class BottleResponseBodyAssignment extends HttpResponseTaintSink {
18+
deprecated class BottleResponseBodyAssignment extends HttpResponseTaintSink {
1919
BottleResponseBodyAssignment() {
2020
exists(DefinitionNode lhs |
2121
lhs.getValue() = this and
@@ -26,7 +26,7 @@ class BottleResponseBodyAssignment extends HttpResponseTaintSink {
2626
override predicate sinks(TaintKind kind) { kind instanceof StringKind }
2727
}
2828

29-
class BottleHandlerFunctionResult extends HttpResponseTaintSink {
29+
deprecated class BottleHandlerFunctionResult extends HttpResponseTaintSink {
3030
BottleHandlerFunctionResult() {
3131
exists(BottleRoute route, Return ret |
3232
ret.getScope() = route.getFunction() and
@@ -39,7 +39,7 @@ class BottleHandlerFunctionResult extends HttpResponseTaintSink {
3939
override string toString() { result = "bottle handler function result" }
4040
}
4141

42-
class BottleCookieSet extends CookieSet, CallNode {
42+
deprecated class BottleCookieSet extends CookieSet, CallNode {
4343
BottleCookieSet() {
4444
any(BottleResponse r).taints(this.getFunction().(AttrNode).getObject("set_cookie"))
4545
}

python/ql/lib/semmle/python/web/cherrypy/General.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import python
22
import semmle.python.web.Http
33

4-
module CherryPy {
4+
deprecated module CherryPy {
55
FunctionValue expose() { result = Value::named("cherrypy.expose") }
66
}
77

8-
class CherryPyExposedFunction extends Function {
8+
deprecated class CherryPyExposedFunction extends Function {
99
CherryPyExposedFunction() {
1010
this.getADecorator().pointsTo(CherryPy::expose())
1111
or
1212
this.getADecorator().(Call).getFunc().pointsTo(CherryPy::expose())
1313
}
1414
}
1515

16-
class CherryPyRoute extends CallNode {
16+
deprecated class CherryPyRoute extends CallNode {
1717
CherryPyRoute() {
1818
/* cherrypy.quickstart(root, script_name, config) */
1919
Value::named("cherrypy.quickstart").(FunctionValue).getACall() = this

python/ql/lib/semmle/python/web/cherrypy/Request.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import semmle.python.web.Http
55
import semmle.python.web.cherrypy.General
66

77
/** The cherrypy.request local-proxy object */
8-
class CherryPyRequest extends TaintKind {
8+
deprecated class CherryPyRequest extends TaintKind {
99
CherryPyRequest() { this = "cherrypy.request" }
1010

1111
override TaintKind getTaintOfAttribute(string name) {
@@ -20,7 +20,7 @@ class CherryPyRequest extends TaintKind {
2020
}
2121
}
2222

23-
class CherryPyExposedFunctionParameter extends HttpRequestTaintSource {
23+
deprecated class CherryPyExposedFunctionParameter extends HttpRequestTaintSource {
2424
CherryPyExposedFunctionParameter() {
2525
exists(Parameter p |
2626
p = any(CherryPyExposedFunction f).getAnArg() and
@@ -34,7 +34,7 @@ class CherryPyExposedFunctionParameter extends HttpRequestTaintSource {
3434
override predicate isSourceOf(TaintKind kind) { kind instanceof ExternalStringKind }
3535
}
3636

37-
class CherryPyRequestSource extends HttpRequestTaintSource {
37+
deprecated class CherryPyRequestSource extends HttpRequestTaintSource {
3838
CherryPyRequestSource() { this.(ControlFlowNode).pointsTo(Value::named("cherrypy.request")) }
3939

4040
override predicate isSourceOf(TaintKind kind) { kind instanceof CherryPyRequest }

python/ql/lib/semmle/python/web/cherrypy/Response.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import semmle.python.security.strings.Untrusted
44
import semmle.python.web.Http
55
import semmle.python.web.cherrypy.General
66

7-
class CherryPyExposedFunctionResult extends HttpResponseTaintSink {
7+
deprecated class CherryPyExposedFunctionResult extends HttpResponseTaintSink {
88
CherryPyExposedFunctionResult() {
99
exists(Return ret |
1010
ret.getScope() instanceof CherryPyExposedFunction and

python/ql/lib/semmle/python/web/client/Requests.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import python
77
private import semmle.python.web.Http
88

9-
class RequestsHttpRequest extends Client::HttpRequest, CallNode {
9+
deprecated class RequestsHttpRequest extends Client::HttpRequest, CallNode {
1010
CallableValue func;
1111
string method;
1212

0 commit comments

Comments
 (0)