From b4224025df20cd889d9fcaab6816b553457bb5d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=A3rebe=20-=20Romain=20GERARD?= Date: Tue, 28 Nov 2023 09:47:42 +0100 Subject: [PATCH] fix(env var): check that variable value is not a secret to avoid segfault --- utils/env_var.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/utils/env_var.go b/utils/env_var.go index aaeaa07a..38664e76 100644 --- a/utils/env_var.go +++ b/utils/env_var.go @@ -904,14 +904,14 @@ FirstLoop: // where v is an Alias, we should interpolate the value of the parent key for _, x := range variables { if v.AliasParentKey != nil && *v.AliasParentKey == x.Key { - finalValue = insertAtIndex(valueWithoutInterpolation, *x.Value, startIndex) + finalValue = insertAtIndex(valueWithoutInterpolation, getValueOrDefault(x.Value), startIndex) continue FirstLoop } } } // work only if the key is a secret or an environment variable - finalValue = insertAtIndex(valueWithoutInterpolation, *v.Value, startIndex) + finalValue = insertAtIndex(valueWithoutInterpolation, getValueOrDefault(v.Value), startIndex) break } } @@ -923,6 +923,14 @@ FirstLoop: return &finalValue } +func getValueOrDefault(value *string) string { + if value == nil { + return "xxx secret xxx" + } else { + return *value + } +} + func GetEnvVarJsonOutput(variables []EnvVarLineOutput) string { var results []interface{}