diff --git a/javascript/ql/src/Security/CWE-020/IncompleteHostnameRegExp.qhelp b/javascript/ql/src/Security/CWE-020/IncompleteHostnameRegExp.qhelp index d6b4f279728..0b2b7369bc1 100644 --- a/javascript/ql/src/Security/CWE-020/IncompleteHostnameRegExp.qhelp +++ b/javascript/ql/src/Security/CWE-020/IncompleteHostnameRegExp.qhelp @@ -8,7 +8,7 @@ Sanitizing untrusted URLs is an important technique for preventing attacks such as request forgeries and malicious - redirections. Usually, this is done by checking that the host of a URL + redirections. Often, this is done by checking that the host of a URL is in a set of allowed hosts.

@@ -56,7 +56,7 @@ an attacker-controlled domain such as wwwXexample.com. Address this vulnerability by escaping . - appropriately: let regex =/(www|beta|)\.example\.com/. + appropriately: let regex = /(www|beta|)\.example\.com/.

diff --git a/javascript/ql/src/Security/CWE-020/IncompleteHostnameRegExp.ql b/javascript/ql/src/Security/CWE-020/IncompleteHostnameRegExp.ql index 49344ee8fec..abe6d76d6f0 100644 --- a/javascript/ql/src/Security/CWE-020/IncompleteHostnameRegExp.ql +++ b/javascript/ql/src/Security/CWE-020/IncompleteHostnameRegExp.ql @@ -12,28 +12,25 @@ import javascript -module IncompleteHostnameRegExpTracking { +/** + * A taint tracking configuration for incomplete hostname regular expressions sources. + */ +class Configuration extends TaintTracking::Configuration { + Configuration() { this = "IncompleteHostnameRegExpTracking" } - /** - * A taint tracking configuration for incomplete hostname regular expressions sources. - */ - class Configuration extends TaintTracking::Configuration { - Configuration() { this = "IncompleteHostnameRegExpTracking" } - - override - predicate isSource(DataFlow::Node source) { - isIncompleteHostNameRegExpPattern(source.asExpr().getStringValue(), _) - } - - override - predicate isSink(DataFlow::Node sink) { - isInterpretedAsRegExp(sink) - } + override + predicate isSource(DataFlow::Node source) { + isIncompleteHostNameRegExpPattern(source.asExpr().getStringValue(), _) + } + override + predicate isSink(DataFlow::Node sink) { + isInterpretedAsRegExp(sink) } } + /** * Holds if `pattern` is a regular expression pattern for URLs with a host matched by `hostPart`, * and `pattern` contains a subtle mistake that allows it to match unexpected hosts. @@ -45,7 +42,7 @@ predicate isIncompleteHostNameRegExpPattern(string pattern, string hostPart) { // an unescaped single `.` "(?> + result = "com|org|edu|gov|uk|net|io" + } +} \ No newline at end of file