MCPcopy Create free account
hub / github.com/ByteYellow/AgentProvenance / cleanRelativeFile

Function cleanRelativeFile

internal/provenance/diff.go:313–325  ·  view source on GitHub ↗
(value string)

Source from the content-addressed store, hash-verified

311}
312
313func 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
327func readRelativeFile(root, rel string) ([]byte, bool, error) {
328 path := filepath.Join(root, rel)

Callers 2

BuildDiffFileFunction · 0.85
BuildBlameFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected