Skip to content

Commit

Permalink
fix(env var): check that variable value is not a secret to avoid segf…
Browse files Browse the repository at this point in the history
…ault
  • Loading branch information
erebe committed Nov 28, 2023
1 parent 90afaf6 commit b422402
Showing 1 changed file with 10 additions and 2 deletions.
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

0 comments on commit b422402

Please sign in to comment.