Documentation
¶
Overview ¶
Package pathscope checks whether filesystem paths are inside allowed roots.
Index ¶
- Constants
- func EffectiveDirs(workspace string, configDirs []string) ([]string, error)
- func ExtractPathCandidates(payload string) []string
- func NormalizeDir(workspace, requested string) (string, error)
- func Path(workspace string) string
- func RenderPrompt(workspace string, configDirs []string) string
- func RenderText(w io.Writer, report Report)
- func RenderValidationText(w io.Writer, report ValidationReport)
- func Save(workspace string, state State) error
- type Entry
- type PayloadScopeDecision
- type Report
- type State
- type ValidationEntry
- type ValidationReport
Constants ¶
View Source
const FileName = "additional-dirs.json"
Variables ¶
This section is empty.
Functions ¶
func ExtractPathCandidates ¶
ExtractPathCandidates returns conservative path-like operands from a shell or tool payload.
func NormalizeDir ¶
func RenderPrompt ¶
func RenderText ¶
func RenderValidationText ¶
func RenderValidationText(w io.Writer, report ValidationReport)
Types ¶
type PayloadScopeDecision ¶
type PayloadScopeDecision struct {
Allowed bool `json:"allowed"`
Reason string `json:"reason"`
Candidate string `json:"candidate,omitempty"`
Resolved string `json:"resolved,omitempty"`
}
PayloadScopeDecision records whether path-like payload operands stay within the configured workspace scope.
func ValidatePayloadScope ¶
func ValidatePayloadScope(workspace string, additionalDirs []string, payload string, cwd string) PayloadScopeDecision
ValidatePayloadScope validates path-like shell/tool payload operands against the workspace and explicitly allowed additional directories.
type Report ¶
type Report struct {
Kind string `json:"kind"`
Action string `json:"action"`
Workspace string `json:"workspace"`
Total int `json:"total"`
Entries []Entry `json:"entries"`
}
func BuildReport ¶
type State ¶
type ValidationEntry ¶
type ValidationEntry struct {
Input string `json:"input,omitempty"`
Path string `json:"path,omitempty"`
Source string `json:"source,omitempty"`
Valid bool `json:"valid"`
Exists bool `json:"exists"`
IsDir bool `json:"is_dir"`
AlreadyAllowed bool `json:"already_allowed"`
Error string `json:"error,omitempty"`
}
type ValidationReport ¶
Click to show internal directories.
Click to hide internal directories.