Skip to content

Commit 0665c39

Browse files
committed
Refactor GrapeHelperMethod constructor to reuse getHelperSelf to traverse dataflow instead of AST
- add tests to check for nested helpers
1 parent ecd0ce6 commit 0665c39

File tree

4 files changed

+275
-111
lines changed

4 files changed

+275
-111
lines changed

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,12 +291,7 @@ module Grape {
291291
private class GrapeHelperMethod extends Method {
292292
private GrapeApiClass apiClass;
293293

294-
GrapeHelperMethod() {
295-
exists(DataFlow::CallNode helpersCall |
296-
helpersCall = apiClass.getAModuleLevelCall("helpers") and
297-
this.getParent+() = helpersCall.getBlock().asExpr().getExpr()
298-
)
299-
}
294+
GrapeHelperMethod() { this = apiClass.getHelperSelf().getSelfVariable().getDeclaringScope() }
300295

301296
/**
302297
* Gets the API class that contains this helper method.

0 commit comments

Comments
 (0)