Skip to content

Commit d28b9af

Browse files
authored
Merge pull request #10791 from asgerf/rb/rails-render-file
Ruby: treat render 'file:' argument as a file system access
2 parents 99b9101 + 7bfb349 commit d28b9af

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,21 @@ module Rails {
7171

7272
/** A render call that does not automatically set the HTTP response body. */
7373
class RenderToCall extends MethodCall instanceof RenderToCallImpl { }
74+
75+
/**
76+
* A `render` call seen as a file system access.
77+
*/
78+
private class RenderAsFileSystemAccess extends FileSystemAccess::Range, DataFlow::CallNode {
79+
RenderAsFileSystemAccess() {
80+
exists(MethodCall call | this.asExpr().getExpr() = call |
81+
call instanceof RenderCall
82+
or
83+
call instanceof RenderToCall
84+
)
85+
}
86+
87+
override DataFlow::Node getAPathArgument() { result = this.getKeywordArgument("file") }
88+
}
7489
}
7590

7691
/**
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* The `rb/path-injection` query now treats the `file:` argument of the Rails `render` method as a sink.

0 commit comments

Comments
 (0)