From 1cfad846c8a5eec56f43921ab83c78ab985ce785 Mon Sep 17 00:00:00 2001 From: Chris Smowton Date: Tue, 29 Sep 2020 16:36:07 +0100 Subject: [PATCH] Improve variable names in example code These were inherited from the JS version of the example, which concerns HTML. --- ql/src/Security/CWE-020/SuspiciousCharacterInRegexp.go | 4 ++-- ql/src/Security/CWE-020/SuspiciousCharacterInRegexpGood.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ql/src/Security/CWE-020/SuspiciousCharacterInRegexp.go b/ql/src/Security/CWE-020/SuspiciousCharacterInRegexp.go index 6df71046833..0a4b8a90794 100644 --- a/ql/src/Security/CWE-020/SuspiciousCharacterInRegexp.go +++ b/ql/src/Security/CWE-020/SuspiciousCharacterInRegexp.go @@ -3,8 +3,8 @@ package main import "regexp" func broken(hostNames []byte) string { - var htmlRe = regexp.MustCompile("\bforbidden.host.org") - if htmlRe.Match(hostNames) { + var hostRe = regexp.MustCompile("\bforbidden.host.org") + if hostRe.Match(hostNames) { return "Must not target forbidden.host.org" } else { // This will be reached even if hostNames is exactly "forbidden.host.org", diff --git a/ql/src/Security/CWE-020/SuspiciousCharacterInRegexpGood.go b/ql/src/Security/CWE-020/SuspiciousCharacterInRegexpGood.go index c66f0068c41..a311e66af8d 100644 --- a/ql/src/Security/CWE-020/SuspiciousCharacterInRegexpGood.go +++ b/ql/src/Security/CWE-020/SuspiciousCharacterInRegexpGood.go @@ -3,8 +3,8 @@ package main import "regexp" func fixed(hostNames []byte) string { - var htmlRe = regexp.MustCompile("\\bforbidden.host.org") - if htmlRe.Match(hostNames) { + var hostRe = regexp.MustCompile("\\bforbidden.host.org") + if hostRe.Match(hostNames) { return "Must not target forbidden.host.org" } else { // hostNames definitely doesn't contain a word "forbidden.host.org", as "\\b"