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

Method workspacePath

internal/computerapi/service.go:221–231  ·  view source on GitHub ↗
(workspaceRoot, requested string)

Source from the content-addressed store, hash-verified

219}
220
221func (s Service) workspacePath(workspaceRoot, requested string) (string, error) {
222 trimmed := strings.TrimPrefix(requested, "/workspace")
223 trimmed = strings.TrimPrefix(trimmed, "/")
224 hostPath := filepath.Join(workspaceRoot, trimmed)
225 cleanRoot := filepath.Clean(workspaceRoot)
226 cleanPath := filepath.Clean(hostPath)
227 if cleanPath != cleanRoot && !strings.HasPrefix(cleanPath, cleanRoot+string(os.PathSeparator)) {
228 return "", fmt.Errorf("path escapes workspace: %s", requested)
229 }
230 return cleanPath, nil
231}
232
233func (s Service) recordEvent(event security.Event, payload map[string]any) (security.DecisionRecord, error) {
234 payload["recorded_at"] = time.Now().UTC().Format(time.RFC3339Nano)

Callers 3

ReadFileMethod · 0.95
WriteFileMethod · 0.95
ExportArtifactMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected