Skip to content

Commit 8bc8342

Browse files
committed
Py:don't parse regular expressions in system-code
1 parent be8f04a commit 8bc8342

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,11 @@ string mode_from_node(DataFlow::Node node) { node = re_flag_tracker(result) }
140140

141141
/** A StrConst used as a regular expression */
142142
abstract class RegexString extends Expr {
143-
RegexString() { (this instanceof Bytes or this instanceof Unicode) }
143+
RegexString() {
144+
(this instanceof Bytes or this instanceof Unicode) and
145+
// is part of the user code
146+
exists(this.getLocation().getFile().getRelativePath())
147+
}
144148

145149
/**
146150
* Helper predicate for `char_set_start(int start, int end)`.

0 commit comments

Comments
 (0)