Merge pull request #12543 from erik-krogh/reg-perf

ReDoS: restrict the edges considered in polynomial-redos for complex regular expressions
This commit is contained in:
Erik Krogh Kristensen
2023-03-20 15:48:35 +01:00
committed by GitHub
5 changed files with 72 additions and 39 deletions

View File

@@ -140,7 +140,11 @@ string mode_from_node(DataFlow::Node node) { node = re_flag_tracker(result) }
/** A StrConst used as a regular expression */
abstract class RegexString extends Expr {
RegexString() { (this instanceof Bytes or this instanceof Unicode) }
RegexString() {
(this instanceof Bytes or this instanceof Unicode) and
// is part of the user code
exists(this.getLocation().getFile().getRelativePath())
}
/**
* Helper predicate for `char_set_start(int start, int end)`.