|
16 | 16 | // If you already did article includes book, there should be no problem. |
17 | 17 | import ruby |
18 | 18 | private import codeql.ruby.AST |
| 19 | +import codeql.ruby.ast.internal.Constant |
19 | 20 | import codeql.ruby.Concepts |
20 | 21 | import codeql.ruby.frameworks.ActiveRecord |
21 | 22 | private import codeql.ruby.TaintTracking |
@@ -84,12 +85,14 @@ DataFlow::Node guardForLoopControl(ConditionalExpr cond, Stmt control) { |
84 | 85 |
|
85 | 86 | from LoopingCall loop, DataFlow::CallNode call |
86 | 87 | where |
87 | | - // TODO: Filter loops over constants |
| 88 | + // Filter loops over constants |
| 89 | + not isArrayConstant(loop.getReceiver().asExpr(), _) and |
| 90 | + // Filter tests |
88 | 91 | not call.getLocation().getFile().getAbsolutePath().matches("%test%") and |
89 | | - // not call = any(PluckCall p).chaines() and |
| 92 | + not call = any(PluckCall p).chaines() and |
90 | 93 | not usedInLoopControlGuard(call, _) and |
91 | 94 | happensInInnermostLoop(loop, call) and |
92 | | - call instanceof ActiveRecordModelFinderCall and |
93 | | - not call.getMethodName() in ["new", "create"] //and |
94 | | -// call.getLocation().getFile().getAbsolutePath().matches("%app/models/stafftools/%") |
| 95 | + (call instanceof ActiveRecordModelFinderCall or call instanceof PluckCall) and |
| 96 | + not call.getMethodName() in ["new", "create"] and |
| 97 | + call.getLocation().getFile().getAbsolutePath().matches(["%app/models/s%", "%app/models/e%"]) |
95 | 98 | select call, "This call happens inside $@, and could be hoisted.", loop, "this loop" |
0 commit comments