Skip to content

Commit 889d971

Browse files
committed
Ruby: Refactor getFilterCallable
Try to force a join with the filter argument string first, to reduce tuple counts.
1 parent 2590682 commit 889d971

File tree

1 file changed

+9
-3
lines changed
  • ruby/ql/lib/codeql/ruby/frameworks/actioncontroller

1 file changed

+9
-3
lines changed

ruby/ql/lib/codeql/ruby/frameworks/actioncontroller/Filters.qll

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ module Filters {
104104

105105
StringlikeLiteralCfgNode getFilterArgument() { result = this.getPositionalArgument(_) }
106106

107+
string getFilterArgumentName() {
108+
result = this.getFilterArgument().getConstantValue().getStringlikeValue()
109+
}
110+
107111
/**
108112
* Gets the callable that implements the filter with name `name`.
109113
* This currently only finds methods in the local class or superclass.
@@ -122,8 +126,8 @@ module Filters {
122126
* end
123127
* ```
124128
*/
125-
Callable getFilterCallable(string name) {
126-
result.(MethodBase).getName() = name and
129+
Callable getAFilterCallable() {
130+
this.getFilterArgumentName() = result.(MethodBase).getName() and
127131
result.getEnclosingModule().getModule() =
128132
this.getExpr().getEnclosingModule().getModule().getAnAncestor()
129133
}
@@ -321,7 +325,9 @@ module Filters {
321325

322326
string getFilterName() { result = this.getConstantValue().getStringlikeValue() }
323327

324-
Callable getFilterCallable() { result = call.getFilterCallable(this.getFilterName()) }
328+
Callable getFilterCallable() {
329+
result = call.getAFilterCallable() and result.(MethodBase).getName() = this.getFilterName()
330+
}
325331

326332
ActionControllerActionMethod getAnAction() { result = call.getAnAction() }
327333
}

0 commit comments

Comments
 (0)