(value string)
| 311 | } |
| 312 | |
| 313 | func cleanRelativeFile(value string) (string, error) { |
| 314 | if strings.TrimSpace(value) == "" { |
| 315 | return "", fmt.Errorf("--file is required") |
| 316 | } |
| 317 | if filepath.IsAbs(value) { |
| 318 | return "", fmt.Errorf("--file must be workspace-relative") |
| 319 | } |
| 320 | clean := filepath.Clean(value) |
| 321 | if clean == "." || clean == ".." || strings.HasPrefix(clean, ".."+string(filepath.Separator)) { |
| 322 | return "", fmt.Errorf("--file escapes workspace") |
| 323 | } |
| 324 | return clean, nil |
| 325 | } |
| 326 | |
| 327 | func readRelativeFile(root, rel string) ([]byte, bool, error) { |
| 328 | path := filepath.Join(root, rel) |
no outgoing calls
no test coverage detected