MCPcopy Create free account
hub / github.com/cli/cli / sandboxFilePath

Function sandboxFilePath

acceptance/acceptance_test.go:557–571  ·  view source on GitHub ↗
(root, currentDir, name string)

Source from the content-addressed store, hash-verified

555}
556
557func sandboxFilePath(root, currentDir, name string) (string, error) {
558 if filepath.IsAbs(name) {
559 return "", errors.New("path must be relative to the testscript sandbox")
560 }
561
562 outputPath := filepath.Clean(filepath.Join(currentDir, name))
563 relativePath, err := filepath.Rel(root, outputPath)
564 if err != nil {
565 return "", err
566 }
567 if relativePath == ".." || strings.HasPrefix(relativePath, ".."+string(filepath.Separator)) {
568 return "", errors.New("path must stay within the testscript sandbox")
569 }
570 return outputPath, nil
571}
572
573var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
574

Callers 2

TestSandboxFilePathFunction · 0.85
sharedCmdsFunction · 0.85

Calls 2

JoinMethod · 0.80
CleanMethod · 0.45

Tested by

no test coverage detected