Skip to content

Commit 6cc82d4

Browse files
committed
Fix LinkToCallArgumentAsSink matching when link_to is passed a block
1 parent 200c8f2 commit 6cc82d4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,12 @@ private class ActionViewRenderToCall extends ActionViewContextCall, RenderToCall
145145
class LinkToCall extends ActionViewContextCall {
146146
LinkToCall() { this.getMethodName() = "link_to" }
147147

148-
// TODO: the path can also be specified through other optional arguments
149-
Expr getPathArgument() { result = this.getArgument(1) }
148+
Expr getPathArgument() {
149+
// When `link_to` is called with a block, it uses the first argument as the
150+
// path, and otherwise the second argument.
151+
exists(this.getBlock()) and result = this.getArgument(0)
152+
or
153+
not exists(this.getBlock()) and result = this.getArgument(1)
154+
}
150155
}
151156
// TODO: model flow in/out of template files properly,

0 commit comments

Comments
 (0)