Skip to content

Commit a7f733a

Browse files
committed
move RegExpInterpretation into Concepts.qll
1 parent 2fad406 commit a7f733a

File tree

5 files changed

+23
-15
lines changed

5 files changed

+23
-15
lines changed

python/ql/lib/semmle/python/Concepts.qll

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,26 @@ module RegexExecution {
421421
}
422422
}
423423

424+
/**
425+
* A node that is not a regular expression literal, but is used in places that
426+
* may interpret it as one. Instances of this class are typically strings that
427+
* flow to method calls like `re.compile`.
428+
*
429+
* Extend this class to refine existing API models. If you want to model new APIs,
430+
* extend `RegExpInterpretation::Range` instead.
431+
*/
432+
class RegExpInterpretation extends DataFlow::Node instanceof RegExpInterpretation::Range { }
433+
434+
/** Provides a class for modeling regular expression interpretations. */
435+
module RegExpInterpretation {
436+
/**
437+
* A node that is not a regular expression literal, but is used in places that
438+
* may interpret it as one. Instances of this class are typically strings that
439+
* flow to method calls like `re.compile`.
440+
*/
441+
abstract class Range extends DataFlow::Node { }
442+
}
443+
424444
/** Provides classes for modeling XML-related APIs. */
425445
module XML {
426446
/**

python/ql/lib/semmle/python/frameworks/Stdlib.qll

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3015,13 +3015,11 @@ private module StdlibPrivate {
30153015
override string getKind() { result = Escaping::getRegexKind() }
30163016
}
30173017

3018-
private import semmle.python.regex as Regex
3019-
30203018
/**
30213019
* A node interpreted as a regular expression.
30223020
* Speficically nodes where string values are interpreted as regular expressions.
30233021
*/
3024-
class StdLibRegExpInterpretation extends Regex::RegExpInterpretation::Range {
3022+
private class StdLibRegExpInterpretation extends RegExpInterpretation::Range {
30253023
StdLibRegExpInterpretation() {
30263024
this =
30273025
API::moduleImport("re").getMember("compile").getACall().getParameter(0, "pattern").asSink()

python/ql/lib/semmle/python/regex.qll

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,6 @@ RegExpTerm getTermForExecution(Concepts::RegexExecution exec) {
1515
)
1616
}
1717

18-
/** Provides a class for modeling regular expression interpretations. */
19-
module RegExpInterpretation {
20-
/**
21-
* A node that is not a regular expression literal, but is used in places that
22-
* may interpret it as one. Instances of this class are typically strings that
23-
* flow to method calls like `re.compile`.
24-
*/
25-
abstract class Range extends DataFlow::Node { }
26-
}
27-
2818
/** A StrConst used as a regular expression */
2919
deprecated class RegexString extends Regex {
3020
RegexString() { this = RegExpTracking::regExpSource(_).asExpr() }

python/ql/lib/semmle/python/regexp/internal/ParseRegExp.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ private module FindRegexMode {
2424
sink = call.(Concepts::RegexExecution).getRegex()
2525
or
2626
call.getArg(_) = sink and
27-
sink instanceof RegExpInterpretation::Range
27+
sink instanceof Concepts::RegExpInterpretation::Range
2828
|
2929
exists(DataFlow::CallCfgNode callNode |
3030
call = callNode and

python/ql/lib/semmle/python/regexp/internal/RegExpTracking.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ private import semmle.python.regex as Regex
2323
DataFlow::Node regSink() {
2424
result = any(Concepts::RegexExecution exec).getRegex()
2525
or
26-
result instanceof Regex::RegExpInterpretation::Range
26+
result instanceof Concepts::RegExpInterpretation
2727
}
2828

2929
/**

0 commit comments

Comments
 (0)