mirror of
https://github.com/github/codeql.git
synced 2026-04-29 02:35:15 +02:00
cache isInterpretedAsRegExp
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
import javascript
|
||||
private import semmle.javascript.dataflow.InferredTypes
|
||||
private import semmle.javascript.internal.CachedStages
|
||||
|
||||
/**
|
||||
* An element containing a regular expression term, that is, either
|
||||
@@ -955,7 +956,9 @@ private predicate isUsedAsNonMatchObject(DataFlow::MethodCallNode call) {
|
||||
/**
|
||||
* Holds if `source` may be interpreted as a regular expression.
|
||||
*/
|
||||
cached
|
||||
predicate isInterpretedAsRegExp(DataFlow::Node source) {
|
||||
Stages::Taint::ref() and
|
||||
source.analyze().getAType() = TTString() and
|
||||
(
|
||||
// The first argument to an invocation of `RegExp` (with or without `new`).
|
||||
|
||||
@@ -260,6 +260,8 @@ module Stages {
|
||||
exists(RemoteFlowSource r)
|
||||
or
|
||||
exists(Exports::getALibraryInputParameter())
|
||||
or
|
||||
any(RegExpTerm t).isUsedAsRegExp()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user