(path string)
| 58 | } |
| 59 | |
| 60 | func validateGitRelPath(path string) error { |
| 61 | if path == "" { |
| 62 | return fmt.Errorf("git path cannot be empty") |
| 63 | } |
| 64 | if filepath.IsAbs(path) { |
| 65 | return fmt.Errorf("git path must be relative: %q", path) |
| 66 | } |
| 67 | if strings.Contains(path, "\x00") { |
| 68 | return fmt.Errorf("git path contains NUL: %q", path) |
| 69 | } |
| 70 | cleaned := filepath.Clean(path) |
| 71 | if cleaned == ".." || strings.HasPrefix(cleaned, ".."+string(filepath.Separator)) { |
| 72 | return fmt.Errorf("git path escapes repository: %q", path) |
| 73 | } |
| 74 | return nil |
| 75 | } |
| 76 | |
| 77 | // validateCommit checks if the given commit reference exists in the repository |
| 78 | func validateCommit(repoPath, commitID string) error { |
no outgoing calls
no test coverage detected