Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9ff0baf

Browse files
authored
fix(support): also sanitize agent environment (#12615)
1 parent6f0ba5b commit9ff0baf

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

‎support/support.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ func AgentInfo(ctx context.Context, client *codersdk.Client, log slog.Logger, ag
298298
iferr!=nil {
299299
returnxerrors.Errorf("fetch workspace agent: %w",err)
300300
}
301+
sanitizeEnv(agt.EnvironmentVariables)
301302
a.Agent=&agt
302303
returnnil
303304
})

‎support/support_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ func TestRun(t *testing.T) {
7373
assertNotNilNotEmpty(t,bun.Workspace.TemplateFileBase64,"workspace template file should be present")
7474
require.NotNil(t,bun.Workspace.Parameters,"workspace parameters should be present")
7575
assertNotNilNotEmpty(t,bun.Agent.Agent,"agent should be present")
76+
assertSanitizedAgent(t,*bun.Agent.Agent)
7677
assertNotNilNotEmpty(t,bun.Agent.ListeningPorts,"agent listening ports should be present")
7778
assertNotNilNotEmpty(t,bun.Agent.Logs,"agent logs should be present")
7879
assertNotNilNotEmpty(t,bun.Agent.AgentMagicsockHTML,"agent magicsock should be present")
@@ -163,13 +164,18 @@ func assertSanitizedWorkspace(t *testing.T, ws codersdk.Workspace) {
163164
t.Helper()
164165
for_,res:=rangews.LatestBuild.Resources {
165166
for_,agt:=rangeres.Agents {
166-
fork,v:=rangeagt.EnvironmentVariables {
167-
assert.Equal(t,"***REDACTED***",v,"environment variable %q not sanitized",k)
168-
}
167+
assertSanitizedAgent(t,agt)
169168
}
170169
}
171170
}
172171

172+
funcassertSanitizedAgent(t*testing.T,agt codersdk.WorkspaceAgent) {
173+
t.Helper()
174+
fork,v:=rangeagt.EnvironmentVariables {
175+
assert.Equal(t,"***REDACTED***",v,"agent %q environment variable %q not sanitized",agt.Name,k)
176+
}
177+
}
178+
173179
funcsetupWorkspaceAndAgent(ctx context.Context,t*testing.T,client*codersdk.Client,db database.Store,user codersdk.CreateFirstUserResponse) (codersdk.Workspace, codersdk.WorkspaceAgent) {
174180
// This is a valid zip file
175181
zipBytes:=make([]byte,22)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp