From 271ea49b09c5f865ae3584ad191a7e508d00a9f4 Mon Sep 17 00:00:00 2001 From: Alex Ott Date: Mon, 12 Dec 2022 16:33:55 +0100 Subject: [PATCH] Exporter: explicitly normalize variable names (#1835) Otherwise, variable name may contain dots & other characters when secrets/secret scopes are containing them --- exporter/context.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/exporter/context.go b/exporter/context.go index ecdf522994..1b5afdea9b 100644 --- a/exporter/context.go +++ b/exporter/context.go @@ -95,6 +95,11 @@ var nameFixes = []regexFix{ {regexp.MustCompile(`[_]{2,}`), "_"}, } +// less aggressive name normalization +var simpleNameFixes = []regexFix{ + {nameNormalizationRegex, "_"}, +} + var workspaceConfKeys = map[string]any{ "enableIpAccessLists": false, "enableTokensConfig": false, @@ -555,8 +560,8 @@ func (ic *importContext) dataToHcl(i importable, path []string, } for _, r := range i.Depends { if r.Path == pathString && r.Variable { - // sensitive fields are moved to variable depends - raw = i.Name(ic, d) + // sensitive fields are moved to variable depends, variable name is normalized + raw = ic.regexFix(i.Name(ic, d), simpleNameFixes) ok = true } }