зеркало из https://github.com/github/codeql.git
JS: refactor `IncompleteHostnameRegExp::regexp` to RegExp.qll
This commit is contained in:
Родитель
79406f8387
Коммит
98ae2597bb
|
@ -12,38 +12,6 @@
|
|||
|
||||
import javascript
|
||||
|
||||
/**
|
||||
* Gets a node whose value may flow (inter-procedurally) to a position where it is interpreted
|
||||
* as a regular expression.
|
||||
*/
|
||||
DataFlow::Node regExpSource(DataFlow::Node re, DataFlow::TypeBackTracker t) {
|
||||
t.start() and
|
||||
re = result and
|
||||
isInterpretedAsRegExp(result)
|
||||
or
|
||||
exists(DataFlow::TypeBackTracker t2, DataFlow::Node succ | succ = regExpSource(re, t2) |
|
||||
t2 = t.smallstep(result, succ)
|
||||
or
|
||||
any(TaintTracking::AdditionalTaintStep dts).step(result, succ) and
|
||||
t = t2
|
||||
)
|
||||
}
|
||||
|
||||
DataFlow::Node regExpSource(DataFlow::Node re) {
|
||||
result = regExpSource(re, DataFlow::TypeBackTracker::end())
|
||||
}
|
||||
|
||||
/** Holds if `re` is a regular expression with value `pattern`. */
|
||||
predicate regexp(DataFlow::Node re, string pattern, string kind, DataFlow::Node aux) {
|
||||
re.asExpr().(RegExpLiteral).getValue() = pattern and
|
||||
kind = "regular expression" and
|
||||
aux = re
|
||||
or
|
||||
re = regExpSource(aux) and
|
||||
pattern = re.getStringValue() and
|
||||
kind = "string, which is used as a regular expression $@,"
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `pattern` is a regular expression pattern for URLs with a host matched by `hostPart`,
|
||||
* and `pattern` contains a subtle mistake that allows it to match unexpected hosts.
|
||||
|
|
|
@ -404,3 +404,39 @@ module RegExpPatterns {
|
|||
result = "(?:com|org|edu|gov|uk|net|io)(?![a-z0-9])"
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a node whose value may flow (inter-procedurally) to a position where it is interpreted
|
||||
* as a regular expression.
|
||||
*/
|
||||
private DataFlow::Node regExpSource(DataFlow::Node re, DataFlow::TypeBackTracker t) {
|
||||
t.start() and
|
||||
re = result and
|
||||
isInterpretedAsRegExp(result)
|
||||
or
|
||||
exists(DataFlow::TypeBackTracker t2, DataFlow::Node succ | succ = regExpSource(re, t2) |
|
||||
t2 = t.smallstep(result, succ)
|
||||
or
|
||||
any(TaintTracking::AdditionalTaintStep dts).step(result, succ) and
|
||||
t = t2
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a node whose value may flow (inter-procedurally) to a position where it is interpreted
|
||||
* as a regular expression.
|
||||
*/
|
||||
private DataFlow::Node regExpSource(DataFlow::Node re) {
|
||||
result = regExpSource(re, DataFlow::TypeBackTracker::end())
|
||||
}
|
||||
|
||||
/** Holds if `re` is a regular expression with value `pattern`. */
|
||||
predicate regexp(DataFlow::Node re, string pattern, string kind, DataFlow::Node aux) {
|
||||
re.asExpr().(RegExpLiteral).getValue() = pattern and
|
||||
kind = "regular expression" and
|
||||
aux = re
|
||||
or
|
||||
re = regExpSource(aux) and
|
||||
pattern = re.getStringValue() and
|
||||
kind = "string, which is used as a regular expression $@,"
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче