diff options
author | 2022-03-01 11:33:52 -0800 | |
---|---|---|
committer | 2022-03-01 14:33:52 -0500 | |
commit | a1429e1445ecaea07fbb8870c4920087c9bb9b14 (patch) | |
tree | 61cf3d2bd417efa0ba74ab539083f12403f3ea5f /plugin | |
parent | 6c26446bb7105ce82608130a1df18f3fc8a94f33 (diff) | |
download | coredns-a1429e1445ecaea07fbb8870c4920087c9bb9b14.tar.gz coredns-a1429e1445ecaea07fbb8870c4920087c9bb9b14.tar.zst coredns-a1429e1445ecaea07fbb8870c4920087c9bb9b14.zip |
[plugin/rewrite] Refactor to satisfy security scan (#5214)
this PR re-arrange the logic to avoid a false positive DAST scan.
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/rewrite/name.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/plugin/rewrite/name.go b/plugin/rewrite/name.go index e9612839f..73aa171e6 100644 --- a/plugin/rewrite/name.go +++ b/plugin/rewrite/name.go @@ -298,18 +298,19 @@ func newNameRule(nextAction string, args ...string) (Rule, error) { return nil, fmt.Errorf("too few arguments for a name rule") } if len(args) == 2 { - matchType = "exact" + matchType = ExactMatch rewriteQuestionFrom = plugin.Name(args[0]).Normalize() rewriteQuestionTo = plugin.Name(args[1]).Normalize() } if len(args) >= 3 { matchType = strings.ToLower(args[0]) - rewriteQuestionFrom = plugin.Name(args[1]).Normalize() - rewriteQuestionTo = plugin.Name(args[2]).Normalize() - } - if matchType == RegexMatch { - rewriteQuestionFrom = args[1] - rewriteQuestionTo = args[2] + if matchType == RegexMatch { + rewriteQuestionFrom = args[1] + rewriteQuestionTo = args[2] + } else { + rewriteQuestionFrom = plugin.Name(args[1]).Normalize() + rewriteQuestionTo = plugin.Name(args[2]).Normalize() + } } if matchType == ExactMatch || matchType == SuffixMatch { if !hasClosingDot(rewriteQuestionFrom) { |