engine: redact dynamic secrets (e.g. #NewSecret)

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi 2022-01-07 11:57:48 -08:00
parent 5f840723e2
commit a61291a887

View File

@ -213,8 +213,10 @@ func (c *Client) logSolveStatus(ctx context.Context, pctx *plancontext.Context,
}
// Just like sprintf, but redacts secrets automatically
secrets := pctx.Secrets.List()
secureSprintf := func(format string, a ...interface{}) string {
// Load a fresh copy of secrets (since they can be dynamically added).
secrets := pctx.Secrets.List()
s := fmt.Sprintf(format, a...)
for _, secret := range secrets {
s = strings.ReplaceAll(s, secret.PlainText(), "***")