Skip to content

Commit 710ddb1

Browse files
committed
Ruby: Fix performance of Filter.getAnAction
Only look at the current class and the immediate superclass. This will miss some edge cases but is much faster.
1 parent 2bc7d4e commit 710ddb1

File tree

1 file changed

+6
-5
lines changed
  • ruby/ql/lib/codeql/ruby/frameworks/actioncontroller

1 file changed

+6
-5
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,14 @@ module Filters {
6565
not exists(this.getOnlyArgument()) and
6666
forall(string except | except = this.getExceptArgument() | result.getName() != except)
6767
) and
68+
// This is a simple heuristic and will miss some cases.
6869
(
69-
result = this.getExpr().getEnclosingModule().getAMethod()
70+
// The action is in the same class as this call
71+
result = lookupMethod(this.getExpr().getEnclosingModule().getModule(), _)
7072
or
71-
exists(ModuleBase m |
72-
m.getModule() = this.getExpr().getEnclosingModule().getModule().getADescendent() and
73-
result = m.getAMethod()
74-
)
73+
// or the action is in an immediate subclass of this call
74+
result.getEnclosingModule().getModule().getAnImmediateAncestor() =
75+
this.getExpr().getEnclosingModule().getModule()
7576
)
7677
}
7778

0 commit comments

Comments
 (0)