(root, currentDir, name string)
| 555 | } |
| 556 | |
| 557 | func 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 | |
| 573 | var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") |
| 574 |
no test coverage detected