Skip to content

Commit 7c44c37

Browse files
committed
Python: Autoformat (4 spaces) pyramid library
1 parent 4463b30 commit 7c44c37

File tree

4 files changed

+18
-53
lines changed

4 files changed

+18
-53
lines changed
Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
/** Provides class representing the `pyramid.redirect` function.
1+
/**
2+
* Provides class representing the `pyramid.redirect` function.
23
* This module is intended to be imported into a taint-tracking query
34
* to extend `TaintSink`.
45
*/
5-
import python
66

7+
import python
78
import semmle.python.security.TaintTracking
89
import semmle.python.security.strings.Basic
910
import semmle.python.web.Http
1011

1112
private ClassValue redirectClass() {
12-
exists(ModuleValue ex |
13-
ex.getName() = "pyramid.httpexceptions" |
13+
exists(ModuleValue ex | ex.getName() = "pyramid.httpexceptions" |
1414
ex.attr("HTTPFound") = result
1515
or
1616
ex.attr("HTTPTemporaryRedirect") = result
@@ -21,19 +21,13 @@ private ClassValue redirectClass() {
2121
* Represents an argument to the `tornado.redirect` function.
2222
*/
2323
class PyramidRedirect extends HttpRedirectTaintSink {
24-
25-
override string toString() {
26-
result = "pyramid.redirect"
27-
}
24+
override string toString() { result = "pyramid.redirect" }
2825

2926
PyramidRedirect() {
30-
exists(CallNode call |
31-
call.getFunction().pointsTo(redirectClass())
32-
|
27+
exists(CallNode call | call.getFunction().pointsTo(redirectClass()) |
3328
call.getArg(0) = this
3429
or
3530
call.getArgByName("location") = this
3631
)
3732
}
38-
3933
}
Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,25 @@
11
import python
2-
32
import semmle.python.security.TaintTracking
43
import semmle.python.web.Http
54
private import semmle.python.web.webob.Request
65
private import semmle.python.web.pyramid.View
76

87
class PyramidRequest extends BaseWebobRequest {
8+
PyramidRequest() { this = "pyramid.request" }
99

10-
PyramidRequest() {
11-
this = "pyramid.request"
12-
}
13-
14-
override ClassValue getType() {
15-
result = Value::named("pyramid.request.Request")
16-
}
17-
10+
override ClassValue getType() { result = Value::named("pyramid.request.Request") }
1811
}
1912

2013
/** Source of pyramid request objects */
2114
class PyramidViewArgument extends TaintSource {
22-
2315
PyramidViewArgument() {
2416
exists(Function view_func |
2517
is_pyramid_view_function(view_func) and
2618
this.(ControlFlowNode).getNode() = view_func.getArg(0)
2719
)
2820
}
2921

30-
override predicate isSourceOf(TaintKind kind) {
31-
kind instanceof PyramidRequest
32-
}
33-
34-
override string toString() {
35-
result = "pyramid.view.argument"
36-
}
22+
override predicate isSourceOf(TaintKind kind) { kind instanceof PyramidRequest }
3723

24+
override string toString() { result = "pyramid.view.argument" }
3825
}
39-
Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,28 @@
11
import python
2-
3-
42
import semmle.python.security.TaintTracking
53
import semmle.python.security.strings.Basic
64
import semmle.python.web.Http
7-
85
private import semmle.python.web.pyramid.View
96
private import semmle.python.web.Http
107

11-
/** A pyramid response, which is vulnerable to any sort of
12-
* http response malice. */
8+
/**
9+
* A pyramid response, which is vulnerable to any sort of
10+
* http response malice.
11+
*/
1312
class PyramidRoutedResponse extends HttpResponseTaintSink {
14-
1513
PyramidRoutedResponse() {
1614
exists(PyFunctionObject view |
1715
is_pyramid_view_function(view.getFunction()) and
1816
this = view.getAReturnedNode()
1917
)
2018
}
2119

22-
override predicate sinks(TaintKind kind) {
23-
kind instanceof StringKind
24-
}
25-
26-
override string toString() {
27-
result = "pyramid.routed.response"
28-
}
20+
override predicate sinks(TaintKind kind) { kind instanceof StringKind }
2921

22+
override string toString() { result = "pyramid.routed.response" }
3023
}
3124

32-
3325
class PyramidCookieSet extends CookieSet, CallNode {
34-
3526
PyramidCookieSet() {
3627
exists(ControlFlowNode f |
3728
f = this.getFunction().(AttrNode).getObject("set_cookie") and
@@ -44,5 +35,4 @@ class PyramidCookieSet extends CookieSet, CallNode {
4435
override ControlFlowNode getKey() { result = this.getArg(0) }
4536

4637
override ControlFlowNode getValue() { result = this.getArg(1) }
47-
4838
}
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
import python
22

3-
ModuleValue thePyramidViewModule() {
4-
result.getName() = "pyramid.view"
5-
}
3+
ModuleValue thePyramidViewModule() { result.getName() = "pyramid.view" }
64

7-
Value thePyramidViewConfig() {
8-
result = thePyramidViewModule().attr("view_config")
9-
}
5+
Value thePyramidViewConfig() { result = thePyramidViewModule().attr("view_config") }
106

117
predicate is_pyramid_view_function(Function func) {
128
func.getADecorator().pointsTo().getClass() = thePyramidViewConfig()
139
}
14-

0 commit comments

Comments
 (0)