Skip to content

Commit 36cc7b5

Browse files
committed
Fix CompiledRegex
1 parent 35f1c45 commit 36cc7b5

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

  • python/ql/src/experimental/semmle/python/frameworks

python/ql/src/experimental/semmle/python/frameworks/Stdlib.qll

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ private module Re {
3131

3232
override DataFlow::Node getRegexNode() { result = regexNode }
3333

34+
// pending obj.this discussion
3435
override DataFlow::CallCfgNode getRegexMethod() { result = regexMethod }
3536
}
3637

@@ -39,13 +40,13 @@ private module Re {
3940
DataFlow::CallCfgNode regexMethod;
4041

4142
CompiledRegex() {
42-
exists(DataFlow::CallCfgNode patternCall, DirectRegex reMethod |
43-
this = reMethod and
43+
exists(DataFlow::CallCfgNode patternCall, DataFlow::AttrRead reMethod |
44+
this.getFunction() = reMethod and
4445
patternCall = API::moduleImport("re").getMember("compile").getACall() and
45-
patternCall = reMethod.(DataFlow::AttrRead).getObject().getALocalSource() and
46+
patternCall = reMethod.getObject().getALocalSource() and
47+
reMethod.getAttributeName() instanceof ReMethods and
4648
regexNode = patternCall.getArg(0) and
47-
// regexMethod is *not* worked out outside class instanciation because `CompiledRegex` focuses on re.compile(pattern).ReMethod
48-
regexMethod = reMethod.getRegexMethod()
49+
regexMethod = this
4950
)
5051
}
5152

0 commit comments

Comments
 (0)