MCPcopy Index your code
hub / github.com/docker/docker-agent / resolveAndCheckPath

Method resolveAndCheckPath

pkg/tools/builtin/filesystem/filesystem.go:635–655  ·  view source on GitHub ↗

resolveAndCheckPath is the canonical entry point used by every filesystem handler that operates on a user-supplied path. It resolves the path against the working directory and validates the result against the allow- and deny-lists. The returned string is the on-disk path the handler should pass to t

(path string)

Source from the content-addressed store, hash-verified

633// - On GOOS=windows, [*os.Root] additionally rejects reserved device
634// names (NUL, COM1, …), which is a strengthening, not a weakening.
635func (t *ToolSet) resolveAndCheckPath(path string) (string, error) {
636 if t.sandboxBroken {
637 return "", errors.New("filesystem toolset is disabled due to invalid allow/deny list configuration")
638 }
639
640 resolved := t.resolvePath(path)
641 if t.allowList == nil && t.denyList == nil {
642 return resolved, nil
643 }
644 realPath, err := resolveRealPath(resolved)
645 if err != nil {
646 return "", fmt.Errorf("resolving %q: %w", path, err)
647 }
648 if t.denyList != nil && t.denyList.contains(realPath) {
649 return "", fmt.Errorf("path %q is inside a denied directory (%s)", path, t.denyList.describe())
650 }
651 if t.allowList != nil && !t.allowList.contains(realPath) {
652 return "", fmt.Errorf("path %q is outside the allowed directories (%s)", path, t.allowList.describe())
653 }
654 return resolved, nil
655}
656
657// rootedAccess returns the [*os.Root] handle and rooted (slash-separated)
658// name for resolved when the allow-list is configured.

Implementers 15

StartableToolSetpkg/tools/startable.go
fakeToolSetpkg/tools/named_test.go
stubDescriberpkg/tools/startable_test.go
stubToolSetpkg/tools/startable_test.go
flappyToolSetpkg/tools/startable_test.go
listFlappyToolSetpkg/tools/startable_test.go
reportingToolSetpkg/tools/startable_test.go
reportingStartOnlyToolSetpkg/tools/startable_test.go
recoveryFailingToolSetpkg/tools/startable_test.go
codeModeToolpkg/tools/codemode/codemode.go
testToolSetpkg/tools/codemode/codemode_test.go
Toolsetpkg/tools/a2a/a2a.go

Calls 5

resolvePathMethod · 0.95
resolveRealPathFunction · 0.85
describeMethod · 0.65
NewMethod · 0.45
containsMethod · 0.45