Skip to content

Commit e80ff4e

Browse files
committed
Ruby: Fix tests and qldoc
1 parent 071517c commit e80ff4e

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

ruby/ql/lib/codeql/ruby/frameworks/Sinatra.qll

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,9 @@ module Sinatra {
169169
}
170170

171171
/**
172-
* A summary for accessing a local variable in an ERB template.
173-
* This is the second half of the modelling of the flow from the `locals` keyword argument to variables in the ERB template.
172+
* A summary for accessing a local variable in an ERB template.
173+
* This is the second half of the modeling of the flow from the `locals`
174+
* keyword argument to variables in the ERB template.
174175
* The first half is modeled by `ErbLocalsSummary`.
175176
*/
176177
private class ErbLocalsAccessSummary extends SummarizedCallable {
@@ -233,14 +234,14 @@ module Sinatra {
233234
}
234235

235236
/**
236-
* `before` filters run before the route handler.
237+
* A class for Sinatra `before` filters. These run before the route handler.
237238
*/
238239
class BeforeFilter extends Filter {
239240
BeforeFilter() { this.getMethodName() = "before" }
240241
}
241242

242243
/**
243-
* `after` filters run after the route handler.
244+
* A class for Sinatra `after` filters. These run after the route handler.
244245
*/
245246
class AfterFilter extends Filter {
246247
AfterFilter() { this.getMethodName() = "after" }

ruby/ql/test/library-tests/frameworks/sinatra/Flow.expected

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,19 @@ edges
66
| app.rb:75:12:75:24 | ...[...] : | app.rb:75:5:75:8 | [post] self [@foo] : |
77
| app.rb:76:32:76:35 | @foo : | views/index.erb:2:10:2:12 | call to foo |
88
| app.rb:76:32:76:35 | self [@foo] : | app.rb:76:32:76:35 | @foo : |
9+
| app.rb:95:10:95:14 | self [@user] : | app.rb:95:10:95:14 | @user |
10+
| app.rb:103:5:103:9 | [post] self [@user] : | app.rb:95:10:95:14 | self [@user] : |
11+
| app.rb:103:13:103:22 | call to source : | app.rb:103:5:103:9 | [post] self [@user] : |
912
nodes
1013
| app.rb:75:5:75:8 | [post] self [@foo] : | semmle.label | [post] self [@foo] : |
1114
| app.rb:75:12:75:17 | call to params : | semmle.label | call to params : |
1215
| app.rb:75:12:75:24 | ...[...] : | semmle.label | ...[...] : |
1316
| app.rb:76:32:76:35 | @foo : | semmle.label | @foo : |
1417
| app.rb:76:32:76:35 | self [@foo] : | semmle.label | self [@foo] : |
18+
| app.rb:95:10:95:14 | @user | semmle.label | @user |
19+
| app.rb:95:10:95:14 | self [@user] : | semmle.label | self [@user] : |
20+
| app.rb:103:5:103:9 | [post] self [@user] : | semmle.label | [post] self [@user] : |
21+
| app.rb:103:13:103:22 | call to source : | semmle.label | call to source : |
1522
| views/index.erb:2:10:2:12 | call to foo | semmle.label | call to foo |
1623
subpaths
1724
#select

ruby/ql/test/library-tests/frameworks/sinatra/Flow.ql

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ import PathGraph
88
import codeql.ruby.frameworks.Sinatra
99
import codeql.ruby.Concepts
1010

11-
from DataFlow::PathNode source, DataFlow::PathNode sink, DefaultTaintFlowConf conf
11+
class SinatraConf extends DefaultTaintFlowConf {
12+
override predicate isSource(DataFlow::Node source) {
13+
source instanceof Http::Server::RequestInputAccess::Range
14+
}
15+
}
16+
17+
from DataFlow::PathNode source, DataFlow::PathNode sink, SinatraConf conf
1218
where conf.hasFlowPath(source, sink)
1319
select sink, source, sink, "$@", source, source.toString()

ruby/ql/test/library-tests/frameworks/sinatra/app.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class MyApp < Sinatra::Base
9292
end
9393

9494
get "/home" do
95-
sink @user # $ hasTaintFlow=a
95+
sink @user # $ hasValueFlow=a
9696
end
9797

9898
after do

0 commit comments

Comments
 (0)