mirror of
https://github.com/github/codeql.git
synced 2026-05-01 03:35:13 +02:00
JS: better matching of String.prototype.search in js/regex-injection
This commit is contained in:
@@ -69,7 +69,13 @@ module RegExpInjection {
|
||||
mce.getReceiver().analyze().getAType() = TTString() and
|
||||
mce.getMethodName() = methodName |
|
||||
(methodName = "match" and this.asExpr() = mce.getArgument(0) and mce.getNumArgument() = 1) or
|
||||
(methodName = "search" and this.asExpr() = mce.getArgument(0) and mce.getNumArgument() = 1)
|
||||
(
|
||||
methodName = "search" and
|
||||
this.asExpr() = mce.getArgument(0) and
|
||||
mce.getNumArgument() = 1 and
|
||||
// `String.prototype.search` returns a number, so exclude chained accesses
|
||||
not exists(PropAccess p | p.getBase() = mce)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user