Skip to content

Commit a632508

Browse files
committed
Merge remote-tracking branch 'origin/main' into jjs/prebuilds-agent-reinit
2 parents 7e45919 + 799a0ba commit a632508

File tree

11 files changed

+172
-139
lines changed

11 files changed

+172
-139
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ jobs:
188188
189189
# Check for any typos
190190
- name: Check for typos
191-
uses: crate-ci/typos@b1a1ef3893ff35ade0cfa71523852a49bfd05d19 # v1.31.1
191+
uses: crate-ci/typos@0f0ccba9ed1df83948f0c15026e4f5ccfce46109 # v1.32.0
192192
with:
193193
config: .github/workflows/typos.toml
194194

.github/workflows/dependabot.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
steps:
2424
- name: Dependabot metadata
2525
id: metadata
26-
uses: dependabot/fetch-metadata@d7267f607e9d3fb96fc2fbe83e0af444713e90b7 # v2.3.0
26+
uses: dependabot/fetch-metadata@08eff52bf64351f401fb50d4972fa95b9f2c2d1b # v2.4.0
2727
with:
2828
github-token: "${{ secrets.GITHUB_TOKEN }}"
2929

.github/workflows/docs-ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: Setup Node
2929
uses: ./.github/actions/setup-node
3030

31-
- uses: tj-actions/changed-files@5426ecc3f5c2b10effaefbd374f0abdc6a571b2f # v45.0.7
31+
- uses: tj-actions/changed-files@480f49412651059a414a6a5c96887abb1877de8a # v45.0.7
3232
id: changed-files
3333
with:
3434
files: |

.github/workflows/scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ jobs:
4747

4848
# Upload the results to GitHub's code scanning dashboard.
4949
- name: "Upload to code-scanning"
50-
uses: github/codeql-action/upload-sarif@28deaeda66b76a05916b6923827895f2b14ab387 # v3.28.16
50+
uses: github/codeql-action/upload-sarif@60168efe1c415ce0f5521ea06d5c2062adbeed1b # v3.28.17
5151
with:
5252
sarif_file: results.sarif

.github/workflows/security.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
uses: ./.github/actions/setup-go
3939

4040
- name: Initialize CodeQL
41-
uses: github/codeql-action/init@28deaeda66b76a05916b6923827895f2b14ab387 # v3.28.16
41+
uses: github/codeql-action/init@60168efe1c415ce0f5521ea06d5c2062adbeed1b # v3.28.17
4242
with:
4343
languages: go, javascript
4444

@@ -48,7 +48,7 @@ jobs:
4848
rm Makefile
4949
5050
- name: Perform CodeQL Analysis
51-
uses: github/codeql-action/analyze@28deaeda66b76a05916b6923827895f2b14ab387 # v3.28.16
51+
uses: github/codeql-action/analyze@60168efe1c415ce0f5521ea06d5c2062adbeed1b # v3.28.17
5252

5353
- name: Send Slack notification on failure
5454
if: ${{ failure() }}
@@ -150,7 +150,7 @@ jobs:
150150
severity: "CRITICAL,HIGH"
151151

152152
- name: Upload Trivy scan results to GitHub Security tab
153-
uses: github/codeql-action/upload-sarif@28deaeda66b76a05916b6923827895f2b14ab387 # v3.28.16
153+
uses: github/codeql-action/upload-sarif@60168efe1c415ce0f5521ea06d5c2062adbeed1b # v3.28.17
154154
with:
155155
sarif_file: trivy-results.sarif
156156
category: "Trivy"

agent/agent.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,8 @@ func (a *agent) handleManifest(manifestOK *checkpoint) func(ctx context.Context,
10911091
if err != nil {
10921092
return xerrors.Errorf("expand directory: %w", err)
10931093
}
1094+
// Normalize all devcontainer paths by making them absolute.
1095+
manifest.Devcontainers = agentcontainers.ExpandAllDevcontainerPaths(a.logger, expandPathToAbs, manifest.Devcontainers)
10941096
subsys, err := agentsdk.ProtoFromSubsystems(a.subsystems)
10951097
if err != nil {
10961098
a.logger.Critical(ctx, "failed to convert subsystems", slog.Error(err))
@@ -1133,7 +1135,7 @@ func (a *agent) handleManifest(manifestOK *checkpoint) func(ctx context.Context,
11331135
)
11341136
if a.experimentalDevcontainersEnabled {
11351137
var dcScripts []codersdk.WorkspaceAgentScript
1136-
scripts, dcScripts = agentcontainers.ExtractAndInitializeDevcontainerScripts(a.logger, expandPathToAbs, manifest.Devcontainers, scripts)
1138+
scripts, dcScripts = agentcontainers.ExtractAndInitializeDevcontainerScripts(manifest.Devcontainers, scripts)
11371139
// See ExtractAndInitializeDevcontainerScripts for motivation
11381140
// behind running dcScripts as post start scripts.
11391141
scriptRunnerOpts = append(scriptRunnerOpts, agentscripts.WithPostStartScripts(dcScripts...))

agent/agent_test.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,8 +1998,9 @@ func TestAgent_ReconnectingPTYContainer(t *testing.T) {
19981998
// You can run it manually as follows:
19991999
//
20002000
// CODER_TEST_USE_DOCKER=1 go test -count=1 ./agent -run TestAgent_DevcontainerAutostart
2001+
//
2002+
//nolint:paralleltest // This test sets an environment variable.
20012003
func TestAgent_DevcontainerAutostart(t *testing.T) {
2002-
t.Parallel()
20032004
if os.Getenv("CODER_TEST_USE_DOCKER") != "1" {
20042005
t.Skip("Set CODER_TEST_USE_DOCKER=1 to run this test")
20052006
}
@@ -2012,9 +2013,12 @@ func TestAgent_DevcontainerAutostart(t *testing.T) {
20122013

20132014
// Prepare temporary devcontainer for test (mywork).
20142015
devcontainerID := uuid.New()
2015-
tempWorkspaceFolder := t.TempDir()
2016-
tempWorkspaceFolder = filepath.Join(tempWorkspaceFolder, "mywork")
2016+
tmpdir := t.TempDir()
2017+
t.Setenv("HOME", tmpdir)
2018+
tempWorkspaceFolder := filepath.Join(tmpdir, "mywork")
2019+
unexpandedWorkspaceFolder := filepath.Join("~", "mywork")
20172020
t.Logf("Workspace folder: %s", tempWorkspaceFolder)
2021+
t.Logf("Unexpanded workspace folder: %s", unexpandedWorkspaceFolder)
20182022
devcontainerPath := filepath.Join(tempWorkspaceFolder, ".devcontainer")
20192023
err = os.MkdirAll(devcontainerPath, 0o755)
20202024
require.NoError(t, err, "create devcontainer directory")
@@ -2031,9 +2035,10 @@ func TestAgent_DevcontainerAutostart(t *testing.T) {
20312035
// is expected to be prepared by the provisioner normally.
20322036
Devcontainers: []codersdk.WorkspaceAgentDevcontainer{
20332037
{
2034-
ID: devcontainerID,
2035-
Name: "test",
2036-
WorkspaceFolder: tempWorkspaceFolder,
2038+
ID: devcontainerID,
2039+
Name: "test",
2040+
// Use an unexpanded path to test the expansion.
2041+
WorkspaceFolder: unexpandedWorkspaceFolder,
20372042
},
20382043
},
20392044
Scripts: []codersdk.WorkspaceAgentScript{

agent/agentcontainers/devcontainer.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ devcontainer up %s
3636
// initialize the workspace (e.g. git clone, npm install, etc). This is
3737
// important if e.g. a Coder module to install @devcontainer/cli is used.
3838
func ExtractAndInitializeDevcontainerScripts(
39-
logger slog.Logger,
40-
expandPath func(string) (string, error),
4139
devcontainers []codersdk.WorkspaceAgentDevcontainer,
4240
scripts []codersdk.WorkspaceAgentScript,
4341
) (filteredScripts []codersdk.WorkspaceAgentScript, devcontainerScripts []codersdk.WorkspaceAgentScript) {
@@ -47,7 +45,6 @@ ScriptLoop:
4745
// The devcontainer scripts match the devcontainer ID for
4846
// identification.
4947
if script.ID == dc.ID {
50-
dc = expandDevcontainerPaths(logger, expandPath, dc)
5148
devcontainerScripts = append(devcontainerScripts, devcontainerStartupScript(dc, script))
5249
continue ScriptLoop
5350
}
@@ -75,6 +72,17 @@ func devcontainerStartupScript(dc codersdk.WorkspaceAgentDevcontainer, script co
7572
return script
7673
}
7774

75+
// ExpandAllDevcontainerPaths expands all devcontainer paths in the given
76+
// devcontainers. This is required by the devcontainer CLI, which requires
77+
// absolute paths for the workspace folder and config path.
78+
func ExpandAllDevcontainerPaths(logger slog.Logger, expandPath func(string) (string, error), devcontainers []codersdk.WorkspaceAgentDevcontainer) []codersdk.WorkspaceAgentDevcontainer {
79+
expanded := make([]codersdk.WorkspaceAgentDevcontainer, 0, len(devcontainers))
80+
for _, dc := range devcontainers {
81+
expanded = append(expanded, expandDevcontainerPaths(logger, expandPath, dc))
82+
}
83+
return expanded
84+
}
85+
7886
func expandDevcontainerPaths(logger slog.Logger, expandPath func(string) (string, error), dc codersdk.WorkspaceAgentDevcontainer) codersdk.WorkspaceAgentDevcontainer {
7987
logger = logger.With(slog.F("devcontainer", dc.Name), slog.F("workspace_folder", dc.WorkspaceFolder), slog.F("config_path", dc.ConfigPath))
8088

agent/agentcontainers/devcontainer_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,7 @@ func TestExtractAndInitializeDevcontainerScripts(t *testing.T) {
242242
}
243243
}
244244
gotFilteredScripts, gotDevcontainerScripts := agentcontainers.ExtractAndInitializeDevcontainerScripts(
245-
logger,
246-
tt.args.expandPath,
247-
tt.args.devcontainers,
245+
agentcontainers.ExpandAllDevcontainerPaths(logger, tt.args.expandPath, tt.args.devcontainers),
248246
tt.args.scripts,
249247
)
250248

go.mod

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ require (
158158
github.com/mocktools/go-smtp-mock/v2 v2.4.0
159159
github.com/muesli/termenv v0.16.0
160160
github.com/natefinch/atomic v1.0.1
161-
github.com/open-policy-agent/opa v1.3.0
161+
github.com/open-policy-agent/opa v1.4.2
162162
github.com/ory/dockertest/v3 v3.12.0
163163
github.com/pion/udp v0.1.4
164164
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
@@ -181,7 +181,7 @@ require (
181181
github.com/tidwall/gjson v1.18.0
182182
github.com/u-root/u-root v0.14.0
183183
github.com/unrolled/secure v1.17.0
184-
github.com/valyala/fasthttp v1.61.0
184+
github.com/valyala/fasthttp v1.62.0
185185
github.com/wagslane/go-password-validator v0.3.0
186186
github.com/zclconf/go-cty-yaml v1.1.0
187187
go.mozilla.org/pkcs7 v0.9.0
@@ -195,21 +195,21 @@ require (
195195
go.uber.org/goleak v1.3.1-0.20240429205332-517bace7cc29
196196
go.uber.org/mock v0.5.0
197197
go4.org/netipx v0.0.0-20230728180743-ad4cb58a6516
198-
golang.org/x/crypto v0.37.0
199-
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8
198+
golang.org/x/crypto v0.38.0
199+
golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac
200200
golang.org/x/mod v0.24.0
201-
golang.org/x/net v0.39.0
201+
golang.org/x/net v0.40.0
202202
golang.org/x/oauth2 v0.29.0
203-
golang.org/x/sync v0.13.0
204-
golang.org/x/sys v0.32.0
205-
golang.org/x/term v0.31.0
206-
golang.org/x/text v0.24.0 // indirect
203+
golang.org/x/sync v0.14.0
204+
golang.org/x/sys v0.33.0
205+
golang.org/x/term v0.32.0
206+
golang.org/x/text v0.25.0 // indirect
207207
golang.org/x/tools v0.32.0
208208
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da
209209
google.golang.org/api v0.231.0
210210
google.golang.org/grpc v1.72.0
211211
google.golang.org/protobuf v1.36.6
212-
gopkg.in/DataDog/dd-trace-go.v1 v1.72.1
212+
gopkg.in/DataDog/dd-trace-go.v1 v1.73.0
213213
gopkg.in/natefinch/lumberjack.v2 v2.2.1
214214
gopkg.in/yaml.v3 v3.0.1
215215
gvisor.dev/gvisor v0.0.0-20240509041132-65b30f7869dc
@@ -227,20 +227,20 @@ require (
227227
filippo.io/edwards25519 v1.1.0 // indirect
228228
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
229229
github.com/DataDog/appsec-internal-go v1.9.0 // indirect
230-
github.com/DataDog/datadog-agent/pkg/obfuscate v0.58.0 // indirect
231-
github.com/DataDog/datadog-agent/pkg/proto v0.58.0 // indirect
232-
github.com/DataDog/datadog-agent/pkg/remoteconfig/state v0.58.0 // indirect
233-
github.com/DataDog/datadog-agent/pkg/trace v0.58.0 // indirect
234-
github.com/DataDog/datadog-agent/pkg/util/log v0.58.0 // indirect
235-
github.com/DataDog/datadog-agent/pkg/util/scrubber v0.58.0 // indirect
236-
github.com/DataDog/datadog-go/v5 v5.5.0 // indirect
237-
github.com/DataDog/go-libddwaf/v3 v3.5.1 // indirect
230+
github.com/DataDog/datadog-agent/pkg/obfuscate v0.64.0-rc.1 // indirect
231+
github.com/DataDog/datadog-agent/pkg/proto v0.64.0-rc.1 // indirect
232+
github.com/DataDog/datadog-agent/pkg/remoteconfig/state v0.64.0-rc.1 // indirect
233+
github.com/DataDog/datadog-agent/pkg/trace v0.64.0-rc.1 // indirect
234+
github.com/DataDog/datadog-agent/pkg/util/log v0.64.0-rc.1 // indirect
235+
github.com/DataDog/datadog-agent/pkg/util/scrubber v0.64.0-rc.1 // indirect
236+
github.com/DataDog/datadog-go/v5 v5.6.0 // indirect
237+
github.com/DataDog/go-libddwaf/v3 v3.5.3 // indirect
238238
github.com/DataDog/go-runtime-metrics-internal v0.0.4-0.20241206090539-a14610dc22b6 // indirect
239-
github.com/DataDog/go-sqllexer v0.0.14 // indirect
239+
github.com/DataDog/go-sqllexer v0.1.0 // indirect
240240
github.com/DataDog/go-tuf v1.1.0-0.5.2 // indirect
241241
github.com/DataDog/gostackparse v0.7.0 // indirect
242-
github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.20.0 // indirect
243-
github.com/DataDog/sketches-go v1.4.5 // indirect
242+
github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.26.0 // indirect
243+
github.com/DataDog/sketches-go v1.4.7 // indirect
244244
github.com/KyleBanks/depth v1.2.1 // indirect
245245
github.com/Microsoft/go-winio v0.6.2 // indirect
246246
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
@@ -323,7 +323,7 @@ require (
323323
github.com/google/btree v1.1.2 // indirect
324324
github.com/google/go-querystring v1.1.0 // indirect
325325
github.com/google/nftables v0.2.0 // indirect
326-
github.com/google/pprof v0.0.0-20240409012703-83162a5b38cd // indirect
326+
github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db // indirect
327327
github.com/google/s2a-go v0.1.9 // indirect
328328
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
329329
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
@@ -392,7 +392,7 @@ require (
392392
github.com/opencontainers/runc v1.2.3 // indirect
393393
github.com/outcaste-io/ristretto v0.2.3 // indirect
394394
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
395-
github.com/philhofer/fwd v1.1.3-0.20240612014219-fbbf4953d986 // indirect
395+
github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c // indirect
396396
github.com/pierrec/lz4/v4 v4.1.18 // indirect
397397
github.com/pion/transport/v2 v2.2.10 // indirect
398398
github.com/pion/transport/v3 v3.0.7 // indirect
@@ -407,8 +407,6 @@ require (
407407
github.com/ryanuber/go-glob v1.0.0 // indirect
408408
github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b // indirect
409409
github.com/secure-systems-lab/go-securesystemslib v0.9.0 // indirect
410-
github.com/shirou/gopsutil/v3 v3.24.4 // indirect
411-
github.com/shoenig/go-m1cpu v0.1.6 // indirect
412410
github.com/sirupsen/logrus v1.9.3 // indirect
413411
github.com/spaolacci/murmur3 v1.1.0 // indirect
414412
github.com/spf13/cast v1.7.1 // indirect
@@ -426,9 +424,9 @@ require (
426424
github.com/tdewolff/test v1.0.11-0.20240106005702-7de5f7df4739 // indirect
427425
github.com/tidwall/match v1.1.1 // indirect
428426
github.com/tidwall/pretty v1.2.1 // indirect
429-
github.com/tinylib/msgp v1.2.1 // indirect
430-
github.com/tklauser/go-sysconf v0.3.13 // indirect
431-
github.com/tklauser/numcpus v0.7.0 // indirect
427+
github.com/tinylib/msgp v1.2.5 // indirect
428+
github.com/tklauser/go-sysconf v0.3.14 // indirect
429+
github.com/tklauser/numcpus v0.8.0 // indirect
432430
github.com/u-root/uio v0.0.0-20240209044354-b3d14b93376a // indirect
433431
github.com/vishvananda/netlink v1.2.1-beta.2 // indirect
434432
github.com/vishvananda/netns v0.0.4 // indirect
@@ -447,11 +445,10 @@ require (
447445
github.com/zclconf/go-cty v1.16.2
448446
github.com/zeebo/errs v1.4.0 // indirect
449447
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
450-
go.opentelemetry.io/collector/component v0.104.0 // indirect
451-
go.opentelemetry.io/collector/config/configtelemetry v0.104.0 // indirect
452-
go.opentelemetry.io/collector/pdata v1.11.0 // indirect
453-
go.opentelemetry.io/collector/pdata/pprofile v0.104.0 // indirect
454-
go.opentelemetry.io/collector/semconv v0.104.0 // indirect
448+
go.opentelemetry.io/collector/component v0.120.0 // indirect
449+
go.opentelemetry.io/collector/pdata v1.26.0 // indirect
450+
go.opentelemetry.io/collector/pdata/pprofile v0.120.0 // indirect
451+
go.opentelemetry.io/collector/semconv v0.120.0 // indirect
455452
go.opentelemetry.io/contrib v1.19.0 // indirect
456453
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 // indirect
457454
go.opentelemetry.io/otel/metric v1.35.0 // indirect
@@ -491,7 +488,7 @@ require (
491488
github.com/coder/preview v0.0.2-0.20250509141204-fc9484dbe506
492489
github.com/fsnotify/fsnotify v1.9.0
493490
github.com/kylecarbs/aisdk-go v0.0.8
494-
github.com/mark3labs/mcp-go v0.25.0
491+
github.com/mark3labs/mcp-go v0.27.0
495492
github.com/openai/openai-go v0.1.0-beta.10
496493
google.golang.org/genai v0.7.0
497494
)
@@ -502,6 +499,8 @@ require (
502499
cloud.google.com/go/iam v1.4.0 // indirect
503500
cloud.google.com/go/monitoring v1.24.0 // indirect
504501
cloud.google.com/go/storage v1.50.0 // indirect
502+
github.com/DataDog/datadog-agent/comp/core/tagger/origindetection v0.64.0-rc.1 // indirect
503+
github.com/DataDog/datadog-agent/pkg/version v0.64.0-rc.1 // indirect
505504
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.26.0 // indirect
506505
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.50.0 // indirect
507506
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.50.0 // indirect
@@ -511,6 +510,7 @@ require (
511510
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
512511
github.com/charmbracelet/x/exp/slice v0.0.0-20250327172914-2fdc97757edf // indirect
513512
github.com/cncf/xds/go v0.0.0-20250121191232-2f005788dc42 // indirect
513+
github.com/dgryski/go-farm v0.0.0-20240924180020-3414d57e47da // indirect
514514
github.com/envoyproxy/go-control-plane/envoy v1.32.4 // indirect
515515
github.com/envoyproxy/protoc-gen-validate v1.2.1 // indirect
516516
github.com/gorilla/websocket v1.5.3 // indirect
@@ -519,6 +519,7 @@ require (
519519
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
520520
github.com/moby/sys/user v0.3.0 // indirect
521521
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
522+
github.com/puzpuzpuz/xsync/v3 v3.5.1 // indirect
522523
github.com/samber/lo v1.49.1 // indirect
523524
github.com/spiffe/go-spiffe/v2 v2.5.0 // indirect
524525
github.com/tidwall/sjson v1.2.5 // indirect

0 commit comments

Comments
 (0)