mirror of
https://github.com/github/codeql.git
synced 2026-07-31 15:33:00 +02:00
Note that we are currently still implementing what Ruby thinks a regex is. This is not correct as C++ by default uses a variant of ECMAScript regexes. We will address this in the follow-up commits.
33 lines
852 B
Plaintext
33 lines
852 B
Plaintext
/**
|
|
* @kind graph
|
|
*/
|
|
|
|
import semmle.code.cpp.regex.internal.ParseRegExp
|
|
import semmle.code.cpp.regex.RegexTreeView
|
|
|
|
// Stop gap for missing flow configs
|
|
class RegExpTest extends RegExp {
|
|
RegExpTest() { any() }
|
|
}
|
|
|
|
query predicate nodes(RegExpTerm n, string attr, string val) {
|
|
attr = "semmle.label" and
|
|
val = "[" + concat(n.getAPrimaryQlClass(), ", ") + "] " + n.toString()
|
|
or
|
|
attr = "semmle.order" and
|
|
val =
|
|
any(int i |
|
|
n =
|
|
rank[i](RegExpTerm t, string fp, int sl, int sc, int el, int ec |
|
|
t.hasLocationInfo(fp, sl, sc, el, ec)
|
|
|
|
|
t order by fp, sl, sc, el, ec, t.toString()
|
|
)
|
|
).toString()
|
|
}
|
|
|
|
query predicate edges(RegExpTerm pred, RegExpTerm succ, string attr, string val) {
|
|
attr in ["semmle.label", "semmle.order"] and
|
|
val = any(int i | succ = pred.getChild(i)).toString()
|
|
}
|