File tree Expand file tree Collapse file tree
src/experimental/manually-check-http-verb
test/query-tests/experimental/manually-check-http-verb Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,7 +18,15 @@ import codeql.ruby.frameworks.ActionController
1818class Request extends DataFlow:: CallNode {
1919 Request ( ) {
2020 this .getMethodName ( ) = "request" and
21- this .asExpr ( ) .getExpr ( ) instanceof ActionControllerActionMethod
21+ this .asExpr ( ) .getExpr ( ) .getEnclosingMethod ( ) instanceof ActionControllerActionMethod
22+ }
23+ }
24+
25+ // `request.env`
26+ class RequestEnvMethod extends DataFlow:: CallNode {
27+ RequestEnvMethod ( ) {
28+ this .getMethodName ( ) = "env" and
29+ any ( Request r ) .flowsTo ( this .getReceiver ( ) )
2230 }
2331}
2432
Original file line number Diff line number Diff line change @@ -8,35 +8,40 @@ def example_action
88
99 # Should find
1010 def other_action
11- if request . env [ 'REQUEST_METHOD' ] == "GET"
11+ method = request . env [ 'REQUEST_METHOD' ]
12+ if method == "GET"
1213 Resource . find ( id : params [ :id ] )
1314 end
1415 end
1516
1617 # Should find
1718 def foo
18- if request . request_method == "GET"
19+ method = request . request_method
20+ if method == "GET"
1921 Resource . find ( id : params [ :id ] )
2022 end
2123 end
2224
2325 # Should find
2426 def bar
25- if request . method == "GET"
27+ method = request . method
28+ if method == "GET"
2629 Resource . find ( id : params [ :id ] )
2730 end
2831 end
2932
3033 # Should find
3134 def baz
32- if request . raw_request_method == "GET"
35+ method = request . raw_request_method
36+ if method == "GET"
3337 Resource . find ( id : params [ :id ] )
3438 end
3539 end
3640
3741 # Should find
3842 def foobarbaz
39- if request . request_method_symbol == :GET
43+ method = request . request_method_symbol
44+ if method == :GET
4045 Resource . find ( id : params [ :id ] )
4146 end
4247 end
You can’t perform that action at this time.
0 commit comments