Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(env var): check that variable value is not a secret to avoid segfault #218

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions utils/env_var.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand All @@ -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{}

Expand Down
Loading