(root, currentDir, name string)
| 1241 | } |
| 1242 | |
| 1243 | func 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 | |
| 1259 | var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") |
| 1260 |
no test coverage detected