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

Function sandboxFilePath

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

Source from the content-addressed store, hash-verified

513}
514
515func sandboxFilePath(root, currentDir, name string) (string, error) {
516 if filepath.IsAbs(name) {
517 return "", errors.New("path must be relative to the testscript sandbox")
518 }
519
520 outputPath := filepath.Clean(filepath.Join(currentDir, name))
521 relativePath, err := filepath.Rel(root, outputPath)
522 if err != nil {
523 return "", err
524 }
525 if relativePath == ".." || strings.HasPrefix(relativePath, ".."+string(filepath.Separator)) {
526 return "", errors.New("path must stay within the testscript sandbox")
527 }
528 return outputPath, nil
529}
530
531var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
532

Callers 2

TestSandboxFilePathFunction · 0.85
sharedCmdsFunction · 0.85

Calls 2

JoinMethod · 0.80
CleanMethod · 0.45

Tested by

no test coverage detected