mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
move RegExpInterpretation into Concepts.qll
This commit is contained in:
@@ -421,6 +421,26 @@ module RegexExecution {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A node that is not a regular expression literal, but is used in places that
|
||||
* may interpret it as one. Instances of this class are typically strings that
|
||||
* flow to method calls like `re.compile`.
|
||||
*
|
||||
* Extend this class to refine existing API models. If you want to model new APIs,
|
||||
* extend `RegExpInterpretation::Range` instead.
|
||||
*/
|
||||
class RegExpInterpretation extends DataFlow::Node instanceof RegExpInterpretation::Range { }
|
||||
|
||||
/** Provides a class for modeling regular expression interpretations. */
|
||||
module RegExpInterpretation {
|
||||
/**
|
||||
* A node that is not a regular expression literal, but is used in places that
|
||||
* may interpret it as one. Instances of this class are typically strings that
|
||||
* flow to method calls like `re.compile`.
|
||||
*/
|
||||
abstract class Range extends DataFlow::Node { }
|
||||
}
|
||||
|
||||
/** Provides classes for modeling XML-related APIs. */
|
||||
module XML {
|
||||
/**
|
||||
|
||||
@@ -3015,13 +3015,11 @@ private module StdlibPrivate {
|
||||
override string getKind() { result = Escaping::getRegexKind() }
|
||||
}
|
||||
|
||||
private import semmle.python.regex as Regex
|
||||
|
||||
/**
|
||||
* A node interpreted as a regular expression.
|
||||
* Speficically nodes where string values are interpreted as regular expressions.
|
||||
*/
|
||||
class StdLibRegExpInterpretation extends Regex::RegExpInterpretation::Range {
|
||||
private class StdLibRegExpInterpretation extends RegExpInterpretation::Range {
|
||||
StdLibRegExpInterpretation() {
|
||||
this =
|
||||
API::moduleImport("re").getMember("compile").getACall().getParameter(0, "pattern").asSink()
|
||||
|
||||
@@ -15,16 +15,6 @@ RegExpTerm getTermForExecution(Concepts::RegexExecution exec) {
|
||||
)
|
||||
}
|
||||
|
||||
/** Provides a class for modeling regular expression interpretations. */
|
||||
module RegExpInterpretation {
|
||||
/**
|
||||
* A node that is not a regular expression literal, but is used in places that
|
||||
* may interpret it as one. Instances of this class are typically strings that
|
||||
* flow to method calls like `re.compile`.
|
||||
*/
|
||||
abstract class Range extends DataFlow::Node { }
|
||||
}
|
||||
|
||||
/** A StrConst used as a regular expression */
|
||||
deprecated class RegexString extends Regex {
|
||||
RegexString() { this = RegExpTracking::regExpSource(_).asExpr() }
|
||||
|
||||
@@ -24,7 +24,7 @@ private module FindRegexMode {
|
||||
sink = call.(Concepts::RegexExecution).getRegex()
|
||||
or
|
||||
call.getArg(_) = sink and
|
||||
sink instanceof RegExpInterpretation::Range
|
||||
sink instanceof Concepts::RegExpInterpretation::Range
|
||||
|
|
||||
exists(DataFlow::CallCfgNode callNode |
|
||||
call = callNode and
|
||||
|
||||
@@ -23,7 +23,7 @@ private import semmle.python.regex as Regex
|
||||
DataFlow::Node regSink() {
|
||||
result = any(Concepts::RegexExecution exec).getRegex()
|
||||
or
|
||||
result instanceof Regex::RegExpInterpretation::Range
|
||||
result instanceof Concepts::RegExpInterpretation
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user