File tree Expand file tree Collapse file tree
python/ql/lib/semmle/python Expand file tree Collapse file tree Original file line number Diff line number Diff 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. */
425445module XML {
426446 /**
Original file line number Diff line number Diff 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 ( )
Original file line number Diff line number Diff 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 */
2919deprecated class RegexString extends Regex {
3020 RegexString ( ) { this = RegExpTracking:: regExpSource ( _) .asExpr ( ) }
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ private import semmle.python.regex as Regex
2323DataFlow:: 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/**
You can’t perform that action at this time.
0 commit comments