MCPcopy Index your code
hub / github.com/coder/coder / ensurePlanPathResolvesToItself

Function ensurePlanPathResolvesToItself

coderd/x/chatd/chattool/planpathresolve.go:15–41  ·  view source on GitHub ↗
(
	ctx context.Context,
	conn workspacesdk.AgentConn,
	planPath string,
)

Source from the content-addressed store, hash-verified

13)
14
15func ensurePlanPathResolvesToItself(
16 ctx context.Context,
17 conn workspacesdk.AgentConn,
18 planPath string,
19) error {
20 if conn == nil {
21 return xerrors.New("workspace connection is required")
22 }
23
24 normalizedPlanPath := normalizeWorkspacePath(planPath)
25 resolvedPath, err := conn.ResolvePath(ctx, planPath)
26 if err != nil {
27 if resolvePathUnsupported(err) {
28 // Older workspace agents do not expose /resolve-path yet. Keep
29 // plan turns working during rolling upgrades, even though they
30 // cannot enforce the symlink guard until the agent is upgraded.
31 return nil
32 }
33 return xerrors.Errorf("resolve plan path: %w", err)
34 }
35 resolvedPath = normalizeWorkspacePath(resolvedPath)
36 if resolvedPath != normalizedPlanPath {
37 return xerrors.New(symlinkedPlanPathMessage(normalizedPlanPath, resolvedPath))
38 }
39
40 return nil
41}
42
43func resolvePathUnsupported(err error) bool {
44 var statusErr interface{ StatusCode() int }

Callers 2

EditFilesFunction · 0.85
WriteFileFunction · 0.85

Calls 6

normalizeWorkspacePathFunction · 0.85
resolvePathUnsupportedFunction · 0.85
symlinkedPlanPathMessageFunction · 0.85
NewMethod · 0.65
ResolvePathMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected