Documentation
¶
Index ¶
- func CheckSensitiveFile(m *ignore.SensitiveMatcher, path string, isDir bool) (bool, string, error)
- func DescribeFlags(flagged []string) string
- func DescribeRedactions(hits []string) string
- func IsBlockedByIdentity(set []os.FileInfo, info os.FileInfo) bool
- func RedactToolOutput(output string) (string, []string)
- func SensitiveIdentitySet(root string, m *ignore.SensitiveMatcher) []os.FileInfo
- func ValidatePath(workspaceRoot, requestedPath string) (string, error)
- type ApprovalGate
- func (g *ApprovalGate) IsAutoApproved(toolName string) bool
- func (g *ApprovalGate) IsDenied(toolName string) bool
- func (g *ApprovalGate) RequestApproval(toolName string, args json.RawMessage, preview string) (bool, error)
- func (g *ApprovalGate) SetInputReader(r *bufio.Reader)
- func (g *ApprovalGate) SetPermissions(autoApprove, deny []string)
- func (g *ApprovalGate) WrapExecution(ctx context.Context, tool Tool, args json.RawMessage) (Result, error)
- type CodeSearchTool
- type FilePatchTool
- type FileReadTool
- type FileWriteTool
- type Preview
- type Previewer
- type Registry
- type Result
- type ShellExecTool
- type ShellGuard
- type Tool
- type ToolSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckSensitiveFile ¶ added in v0.7.0
CheckSensitiveFile rejects normalisation tricks, then applies ignore and case-folded sensitive checks.
func DescribeFlags ¶ added in v0.5.0
DescribeFlags renders the advisory warnings shown in the approval preview.
func DescribeRedactions ¶ added in v0.5.0
DescribeRedactions renders a note listing which secret patterns were masked.
func IsBlockedByIdentity ¶ added in v0.7.0
IsBlockedByIdentity reports whether info is SameFile-equal to any entry in set.
func RedactToolOutput ¶ added in v0.7.0
RedactToolOutput masks credential-shaped values unconditionally. SECURITY: it is the transcript boundary.
func SensitiveIdentitySet ¶ added in v0.7.0
func SensitiveIdentitySet(root string, m *ignore.SensitiveMatcher) []os.FileInfo
SensitiveIdentitySet returns FileInfo of blocked files. SECURITY: hardlink aliases match by identity. Callers filter candidates by identity instead of by name.
func ValidatePath ¶ added in v0.4.0
ValidatePath ensures the requested path resolves inside the workspace root. Returns the absolute path.
Types ¶
type ApprovalGate ¶
type ApprovalGate struct {
OnPresent func(toolName string, args json.RawMessage, preview string) (bool, error)
// contains filtered or unexported fields
}
func NewApprovalGate ¶
func NewApprovalGate() *ApprovalGate
func NewApprovalGateWithPermissions ¶ added in v0.2.0
func NewApprovalGateWithPermissions(autoApprove, deny []string) *ApprovalGate
func (*ApprovalGate) IsAutoApproved ¶ added in v0.2.0
func (g *ApprovalGate) IsAutoApproved(toolName string) bool
func (*ApprovalGate) IsDenied ¶ added in v0.2.0
func (g *ApprovalGate) IsDenied(toolName string) bool
func (*ApprovalGate) RequestApproval ¶
func (g *ApprovalGate) RequestApproval(toolName string, args json.RawMessage, preview string) (bool, error)
func (*ApprovalGate) SetInputReader ¶ added in v0.5.0
func (g *ApprovalGate) SetInputReader(r *bufio.Reader)
SetInputReader makes the gate read answers from r. Callers sharing the stream must pass their reader.
func (*ApprovalGate) SetPermissions ¶ added in v0.2.0
func (g *ApprovalGate) SetPermissions(autoApprove, deny []string)
func (*ApprovalGate) WrapExecution ¶
func (g *ApprovalGate) WrapExecution(ctx context.Context, tool Tool, args json.RawMessage) (Result, error)
WrapExecution runs preview → approval → execute. Denied operations never call Execute.
type CodeSearchTool ¶ added in v0.4.0
type CodeSearchTool struct {
IgnoreMatcher ignore.Matcher
SensitiveMatcher *ignore.SensitiveMatcher
WorkspaceRoot string
}
CodeSearchTool searches for patterns across workspace files.
func (*CodeSearchTool) Execute ¶ added in v0.4.0
func (c *CodeSearchTool) Execute(ctx context.Context, args json.RawMessage) (Result, error)
func (*CodeSearchTool) RequiresApproval ¶ added in v0.4.0
func (c *CodeSearchTool) RequiresApproval() bool
func (*CodeSearchTool) Spec ¶ added in v0.4.0
func (c *CodeSearchTool) Spec() ToolSpec
type FilePatchTool ¶
type FilePatchTool struct {
IgnoreMatcher ignore.Matcher
SensitiveMatcher *ignore.SensitiveMatcher
WorkspaceRoot string
OnModified func(path string)
}
func (*FilePatchTool) Execute ¶
func (f *FilePatchTool) Execute(ctx context.Context, args json.RawMessage) (Result, error)
Execute applies the patch. Called only after approval.
func (*FilePatchTool) Preview ¶ added in v0.4.0
func (f *FilePatchTool) Preview(ctx context.Context, args json.RawMessage) (Preview, error)
Preview shows a diff preview without modifying files.
func (*FilePatchTool) RequiresApproval ¶
func (f *FilePatchTool) RequiresApproval() bool
func (*FilePatchTool) Spec ¶
func (f *FilePatchTool) Spec() ToolSpec
type FileReadTool ¶
type FileReadTool struct {
IgnoreMatcher ignore.Matcher
SensitiveMatcher *ignore.SensitiveMatcher
WorkspaceRoot string
}
func (*FileReadTool) Execute ¶
func (f *FileReadTool) Execute(ctx context.Context, args json.RawMessage) (Result, error)
func (*FileReadTool) RequiresApproval ¶
func (f *FileReadTool) RequiresApproval() bool
func (*FileReadTool) Spec ¶
func (f *FileReadTool) Spec() ToolSpec
type FileWriteTool ¶
type FileWriteTool struct {
IgnoreMatcher ignore.Matcher
SensitiveMatcher *ignore.SensitiveMatcher
WorkspaceRoot string
OnModified func(path string)
}
func (*FileWriteTool) Execute ¶
func (f *FileWriteTool) Execute(ctx context.Context, args json.RawMessage) (Result, error)
Execute writes the file. Called only after approval.
func (*FileWriteTool) Preview ¶ added in v0.4.0
func (f *FileWriteTool) Preview(ctx context.Context, args json.RawMessage) (Preview, error)
Preview shows a diff preview without modifying files.
func (*FileWriteTool) RequiresApproval ¶
func (f *FileWriteTool) RequiresApproval() bool
func (*FileWriteTool) Spec ¶
func (f *FileWriteTool) Spec() ToolSpec
type Preview ¶ added in v0.4.0
type Preview struct {
Description string `json:"description,omitempty"`
Diff string `json:"diff,omitempty"`
Command string `json:"command,omitempty"`
WorkDir string `json:"work_dir,omitempty"`
}
Preview contains the information shown to the user before approval.
type Previewer ¶ added in v0.4.0
Previewer optionally provides a preview for approval before execution.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry() *Registry
type Result ¶
type ShellExecTool ¶
type ShellExecTool struct {
Timeout time.Duration
WorkspaceRoot string
MaxOutputBytes int
// Guard redacts secrets and warns about sensitive paths in previews. May be nil.
Guard *ShellGuard
}
func (*ShellExecTool) Execute ¶
func (s *ShellExecTool) Execute(ctx context.Context, args json.RawMessage) (Result, error)
func (*ShellExecTool) Preview ¶ added in v0.4.0
func (s *ShellExecTool) Preview(ctx context.Context, args json.RawMessage) (Preview, error)
Preview returns command execution metadata without running the command.
func (*ShellExecTool) RequiresApproval ¶
func (s *ShellExecTool) RequiresApproval() bool
func (*ShellExecTool) Spec ¶
func (s *ShellExecTool) Spec() ToolSpec
type ShellGuard ¶ added in v0.5.0
type ShellGuard struct {
// SensitiveMatcher flags sensitive paths. May be nil; redaction still applies.
SensitiveMatcher *ignore.SensitiveMatcher
// RedactSecretOutput enables redaction of secret-shaped values in output.
RedactSecretOutput bool
}
ShellGuard redacts secrets from shell output and warns about sensitive paths. It does not sandbox the shell. SECURITY: file tools stay confined via ValidatePath; the shell is advisory-only.
func (*ShellGuard) FlagSensitivePaths ¶ added in v0.5.0
func (g *ShellGuard) FlagSensitivePaths(command string) []string
FlagSensitivePaths returns sensitive paths referenced by a command for the approval preview. Advisory only.
func (*ShellGuard) RedactSecrets ¶ added in v0.5.0
func (g *ShellGuard) RedactSecrets(output string) (string, []string)
RedactSecrets masks secret-shaped values. With redaction disabled the text is unchanged.