Skip to content

Commit 13459c8

Browse files
committed
Ruby: add Regexp.compile as sink for regexp injection query
1 parent 4b42c44 commit 13459c8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

ruby/ql/lib/codeql/ruby/security/performance/RegExpInjectionCustomizations.qll

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,16 @@ module RegExpInjection {
4848
}
4949

5050
/**
51-
* The first argument of a call to `Regexp.new`, considered as a flow sink.
51+
* The first argument of a call to `Regexp.new` or `Regexp.compile`,
52+
* considered as a flow sink.
5253
*/
5354
class ConstructedRegExpAsSink extends Sink {
5455
ConstructedRegExpAsSink() {
55-
this =
56-
API::getTopLevelMember("Regexp").getAnInstantiation().(DataFlow::CallNode).getArgument(0)
56+
exists(API::Node regexp, DataFlow::CallNode callNode |
57+
regexp = API::getTopLevelMember("Regexp") and
58+
(callNode = regexp.getAnInstantiation() or callNode = regexp.getAMethodCall("compile")) and
59+
this = callNode.getArgument(0)
60+
)
5761
}
5862
}
5963

0 commit comments

Comments
 (0)