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

Method readFile

pkg/tools/builtin/filesystem/filesystem.go:690–699  ·  view source on GitHub ↗

readFile is a TOCTOU-safe equivalent of [os.ReadFile] for paths that the allow-list contains. When no rooted access is available it falls back to the plain [os.ReadFile]. Callers MUST pass a path that has already been validated by [resolveAndCheckPath].

(resolved string)

Source from the content-addressed store, hash-verified

688// the plain [os.ReadFile]. Callers MUST pass a path that has already been
689// validated by [resolveAndCheckPath].
690func (t *ToolSet) readFile(resolved string) ([]byte, error) {
691 root, rel, err := t.rootedAccess(resolved)
692 if err != nil {
693 return nil, err
694 }
695 if root != nil {
696 return root.ReadFile(rel)
697 }
698 return os.ReadFile(resolved)
699}
700
701// writeFile is a TOCTOU-safe equivalent of [os.WriteFile]. See [readFile]
702// for the contract. The call is rejected by the kernel when any component

Callers 6

handleEditFileMethod · 0.95
handleReadFileMethod · 0.95
readImageFileMethod · 0.95

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 2

rootedAccessMethod · 0.95
ReadFileMethod · 0.80