From 3e6a96d21b51a2ea03792df78430accc57f11252 Mon Sep 17 00:00:00 2001 From: Sauyon Lee Date: Wed, 19 Feb 2020 13:04:16 -0800 Subject: [PATCH] IncompleteHostnameRegexp: Use a reluctant regexp This should help make results more comprehensible by including the maximal string after an unescaped dot. --- ql/src/Security/CWE-020/IncompleteHostnameRegexp.ql | 5 +++-- .../IncompleteHostnameRegexp.expected | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ql/src/Security/CWE-020/IncompleteHostnameRegexp.ql b/ql/src/Security/CWE-020/IncompleteHostnameRegexp.ql index a9109e6a5ca..8aa7dae4c27 100644 --- a/ql/src/Security/CWE-020/IncompleteHostnameRegexp.ql +++ b/ql/src/Security/CWE-020/IncompleteHostnameRegexp.ql @@ -20,8 +20,9 @@ import DataFlow::PathGraph */ bindingset[pattern] predicate isIncompleteHostNameRegexpPattern(string pattern, string hostPart) { - hostPart = pattern - .regexpCapture("(?i).*" + + hostPart = + pattern + .regexpCapture("(?i).*?" + // an unescaped single `.` "(?