Skip to content

Commit fd9c1e4

Browse files
committed
Ruby: filter out obvious module 'prepend' calls
1 parent 00e52ad commit fd9c1e4

File tree

1 file changed

+6
-1
lines changed
  • ruby/ql/lib/codeql/ruby/frameworks/core

1 file changed

+6
-1
lines changed

ruby/ql/lib/codeql/ruby/frameworks/core/Array.qll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,12 @@ module Array {
11421142
this = mc.getMethodName() + "(" + mc.getNumberOfArguments() + ")"
11431143
}
11441144

1145-
override MethodCall getACallSimple() { result = mc }
1145+
override MethodCall getACallSimple() {
1146+
result = mc and
1147+
// Filter out obvious 'prepend' calls in a module scope
1148+
// Including such calls is mostly harmless but also easy to filter out
1149+
not result.getReceiver().(SelfVariableAccess).getCfgScope() instanceof ModuleBase
1150+
}
11461151

11471152
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
11481153
exists(int num | num = mc.getNumberOfArguments() and preservesValue = true |

0 commit comments

Comments
 (0)