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

Function sandboxFilePath

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

Source from the content-addressed store, hash-verified

1241}
1242
1243func sandboxFilePath(root, currentDir, name string) (string, error) {
1244 if filepath.IsAbs(name) {
1245 return "", errors.New("path must be relative to the testscript sandbox")
1246 }
1247
1248 outputPath := filepath.Clean(filepath.Join(currentDir, name))
1249 relativePath, err := filepath.Rel(root, outputPath)
1250 if err != nil {
1251 return "", err
1252 }
1253 if relativePath == ".." || strings.HasPrefix(relativePath, ".."+string(filepath.Separator)) {
1254 return "", errors.New("path must stay within the testscript sandbox")
1255 }
1256 return outputPath, nil
1257}
1258
1259var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
1260

Callers 2

TestSandboxFilePathFunction · 0.85
sharedCmdsFunction · 0.85

Calls 2

JoinMethod · 0.80
CleanMethod · 0.45

Tested by

no test coverage detected