File tree Expand file tree Collapse file tree 5 files changed +23
-15
lines changed
python/ql/lib/semmle/python Expand file tree Collapse file tree 5 files changed +23
-15
lines changed Original file line number Diff line number Diff line change @@ -421,6 +421,26 @@ module RegexExecution {
421
421
}
422
422
}
423
423
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
+
424
444
/** Provides classes for modeling XML-related APIs. */
425
445
module XML {
426
446
/**
Original file line number Diff line number Diff line change @@ -3015,13 +3015,11 @@ private module StdlibPrivate {
3015
3015
override string getKind ( ) { result = Escaping:: getRegexKind ( ) }
3016
3016
}
3017
3017
3018
- private import semmle.python.regex as Regex
3019
-
3020
3018
/**
3021
3019
* A node interpreted as a regular expression.
3022
3020
* Speficically nodes where string values are interpreted as regular expressions.
3023
3021
*/
3024
- class StdLibRegExpInterpretation extends Regex :: RegExpInterpretation:: Range {
3022
+ private class StdLibRegExpInterpretation extends RegExpInterpretation:: Range {
3025
3023
StdLibRegExpInterpretation ( ) {
3026
3024
this =
3027
3025
API:: moduleImport ( "re" ) .getMember ( "compile" ) .getACall ( ) .getParameter ( 0 , "pattern" ) .asSink ( )
Original file line number Diff line number Diff line change @@ -15,16 +15,6 @@ RegExpTerm getTermForExecution(Concepts::RegexExecution exec) {
15
15
)
16
16
}
17
17
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
-
28
18
/** A StrConst used as a regular expression */
29
19
deprecated class RegexString extends Regex {
30
20
RegexString ( ) { this = RegExpTracking:: regExpSource ( _) .asExpr ( ) }
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ private module FindRegexMode {
24
24
sink = call .( Concepts:: RegexExecution ) .getRegex ( )
25
25
or
26
26
call .getArg ( _) = sink and
27
- sink instanceof RegExpInterpretation:: Range
27
+ sink instanceof Concepts :: RegExpInterpretation:: Range
28
28
|
29
29
exists ( DataFlow:: CallCfgNode callNode |
30
30
call = callNode and
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ private import semmle.python.regex as Regex
23
23
DataFlow:: Node regSink ( ) {
24
24
result = any ( Concepts:: RegexExecution exec ) .getRegex ( )
25
25
or
26
- result instanceof Regex :: RegExpInterpretation:: Range
26
+ result instanceof Concepts :: RegExpInterpretation
27
27
}
28
28
29
29
/**
You can’t perform that action at this time.
0 commit comments