(root, currentDir, name string)
| 513 | } |
| 514 | |
| 515 | func 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 | |
| 531 | var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") |
| 532 |
no test coverage detected