Skip to content

Commit 2e47462

Browse files
committed
redact all the things
1 parent 64be25f commit 2e47462

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

support/support.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,9 @@ func Run(ctx context.Context, d *Deps) (*Bundle, error) {
355355
// sanitizeEnv modifies kvs in place and erases the values of keys containing
356356
// the strings "secret", "token", or "pass"
357357
func sanitizeEnv(kvs map[string]string) {
358-
for k := range kvs {
359-
kl := strings.ToLower(k)
360-
if strings.Contains(kl, "secret") || strings.Contains(kl, "token") || strings.Contains(kl, "pass") {
361-
kvs[k] = ""
358+
for k, v := range kvs {
359+
if v != "" {
360+
kvs[k] = "***REDACTED***"
362361
}
363362
}
364363
}

support/support_test.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"context"
66
"io"
77
"net/http"
8-
"strings"
98
"testing"
109
"time"
1110

@@ -148,10 +147,7 @@ func assertSanitizedWorkspace(t *testing.T, ws codersdk.Workspace) {
148147
for _, res := range ws.LatestBuild.Resources {
149148
for _, agt := range res.Agents {
150149
for k, v := range agt.EnvironmentVariables {
151-
kl := strings.ToLower(k)
152-
if strings.Contains(kl, "secret") || strings.Contains(kl, "token") || strings.Contains(kl, "pass") {
153-
assert.Empty(t, v, "environment variable %q not sanitized", k)
154-
}
150+
assert.Equal(t, "***REDACTED***", v, "environment variable %q not sanitized", k)
155151
}
156152
}
157153
}

0 commit comments

Comments
 (0)