Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
redact all the things
  • Loading branch information
johnstcn committed Mar 12, 2024
commit da0fb1e360472bbf88137cbbf45008b800cb575e
7 changes: 3 additions & 4 deletions support/support.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,9 @@ func Run(ctx context.Context, d *Deps) (*Bundle, error) {
// sanitizeEnv modifies kvs in place and erases the values of keys containing
// the strings "secret", "token", or "pass"
func sanitizeEnv(kvs map[string]string) {
for k := range kvs {
kl := strings.ToLower(k)
if strings.Contains(kl, "secret") || strings.Contains(kl, "token") || strings.Contains(kl, "pass") {
kvs[k] = ""
for k, v := range kvs {
if v != "" {
kvs[k] = "***REDACTED***"
}
}
}
6 changes: 1 addition & 5 deletions support/support_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"io"
"net/http"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -148,10 +147,7 @@ func assertSanitizedWorkspace(t *testing.T, ws codersdk.Workspace) {
for _, res := range ws.LatestBuild.Resources {
for _, agt := range res.Agents {
for k, v := range agt.EnvironmentVariables {
kl := strings.ToLower(k)
if strings.Contains(kl, "secret") || strings.Contains(kl, "token") || strings.Contains(kl, "pass") {
assert.Empty(t, v, "environment variable %q not sanitized", k)
}
assert.Equal(t, "***REDACTED***", v, "environment variable %q not sanitized", k)
}
}
}
Expand Down