mirror of
https://github.com/github/codeql.git
synced 2026-07-07 20:45:28 +02:00
Do not flag strings that have dots escaped in IncompleteHostnameRegExp.
This commit is contained in:
@@ -12,7 +12,19 @@ private import codeql.regex.HostnameRegexp as Shared
|
||||
module Impl implements Shared::HostnameRegexpSig<TreeImpl> {
|
||||
class DataFlowNode = JS::DataFlow::Node;
|
||||
|
||||
class RegExpPatternSource = RegExp::RegExpPatternSource;
|
||||
class RegExpPatternSource extends JS::DataFlow::Node instanceof RegExp::RegExpPatternSource {
|
||||
RegExpPatternSource() {
|
||||
not super.escapes(_)
|
||||
}
|
||||
|
||||
RegExp::RegExpTerm getRegExpTerm() {
|
||||
result = super.getRegExpTerm()
|
||||
}
|
||||
|
||||
JS::DataFlow::Node getAParse() {
|
||||
result = super.getAParse()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
import Shared::Make<TreeImpl, Impl>
|
||||
|
||||
@@ -57,4 +57,9 @@
|
||||
/^http:\/\/(..|...)\.example\.com\/index\.html/; // OK, wildcards are intentional
|
||||
/^http:\/\/.\.example\.com\/index\.html/; // OK, the wildcard is intentional
|
||||
/^(foo.example\.com|whatever)$/; // kinda OK - one disjunction doesn't even look like a hostname
|
||||
|
||||
function makeHostnameRegExp(hostname) {
|
||||
return new RegExp(`^https://${hostname.replace(/[\.\\]/g, '\\$&')}$`);
|
||||
}
|
||||
makeHostnameRegExp('test.example.com'); // OK
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user