Documentation
¶
Index ¶
- Variables
- func CheckDangerousRemovalPath(path string, cwd string) error
- func FormatNotFoundError(path string, workingDir string) error
- func GetAbsolutePath(path string) (string, error)
- func GetFileReadIgnorePatterns(_ context.Context) []string
- func GetVCSDirectoriesToExclude() []string
- func HasSuspiciousPattern(path string) bool
- func IsBlockedDevicePath(filePath string) bool
- func IsDangerousDirectory(path string) bool
- func IsDangerousFile(path string) bool
- func IsInWorkingDirectory(path, workingDir string) bool
- func IsPathWithin(base, path string) (bool, error)
- func IsUNCPath(path string) bool
- func Plural(count int) string
- func RipgrepNotFoundError() error
- func SuggestPathUnderCwd(requestedPath string, workingDir string) (string, error)
- func ValidateFilePath(filePath, operation string) error
- func ValidatePathExists(path string) error
- func ValidatePathIsDirectory(path string) error
- func ValidateSensitivePath(absolutePath, toolName, content string) error
- func ValidateUNCPathSecurity(path string) error
- type GitDiff
Constants ¶
This section is empty.
Variables ¶
var DangerousDirectories = []string{
".git",
".vscode",
".idea",
".claude",
".openclaude",
".ssh",
".aws",
".gcp",
".azure",
".gnupg",
}
DangerousDirectories are directories that should never be auto-edited. Aligned with OpenClaude's DANGEROUS_DIRECTORIES (filesystem.ts:527-534).
var DangerousFiles = []string{
".bashrc",
".bash_profile",
".zshrc",
".zprofile",
".profile",
".bash_logout",
".gitconfig",
".gitmodules",
"authorized_keys",
"known_hosts",
"id_rsa",
"id_ed25519",
"id_ecdsa",
".env",
".env.local",
".env.production",
".env.staging",
".envrc",
".netrc",
".npmrc",
".yarnrc",
".pypirc",
"credentials",
"config",
".mcp.json",
".claude.json",
".ripgreprc",
".travis.yml",
}
DangerousFiles are files that should never be auto-edited. Aligned with OpenClaude's DANGEROUS_FILES (filesystem.ts:516-525).
Functions ¶
func CheckDangerousRemovalPath ¶
CheckDangerousRemovalPath checks if a removal path is dangerous. Aligned with OpenClaude's checkDangerousRemovalPaths (pathValidation.ts:331-367).
func FormatNotFoundError ¶
FormatNotFoundError formats a helpful "not found" error with optional suggestion
func GetAbsolutePath ¶
GetAbsolutePath returns the real absolute path with symlinks resolved. If the path doesn't exist, the parent is resolved to prevent escape.
func GetFileReadIgnorePatterns ¶
GetFileReadIgnorePatterns returns patterns to ignore during file reads.
func GetVCSDirectoriesToExclude ¶
func GetVCSDirectoriesToExclude() []string
GetVCSDirectoriesToExclude returns VCS directories to exclude from searches.
func HasSuspiciousPattern ¶
HasSuspiciousPattern checks if a path has suspicious patterns that could bypass safety checks. Aligned with OpenClaude's Windows path patterns (pathValidation.ts:546-611).
func IsBlockedDevicePath ¶
IsBlockedDevicePath reports whether filePath is (or is under) a blocked device node.
func IsDangerousDirectory ¶
IsDangerousDirectory checks if a path is in or points to a dangerous directory.
func IsDangerousFile ¶
IsDangerousFile checks if a file path points to a dangerous file.
func IsInWorkingDirectory ¶
IsInWorkingDirectory checks if a path is within the working directory after resolving all symlinks to prevent escape attacks.
func IsPathWithin ¶
IsPathWithin checks if a path is within a base directory (after symlink resolution).
func IsUNCPath ¶
IsUNCPath reports whether path is a UNC/network path (\\server\share or //server/share). These can leak NTLM credentials on Windows and are blocked unconditionally.
func RipgrepNotFoundError ¶
func RipgrepNotFoundError() error
RipgrepNotFoundError returns a clear, OS-specific error when ripgrep is missing.
func SuggestPathUnderCwd ¶
SuggestPathUnderCwd suggests a corrected path if the requested path exists under the parent of the current working directory but not under cwd itself. This helps users who accidentally type paths like "../project/file.go" when they mean "file.go" (assuming the file exists in both locations).
IMPORTANT: This function only suggests if the requested path DOES NOT exist. If the requested path exists, no suggestion is made even if a similar file exists under cwd.
func ValidateFilePath ¶
ValidateFilePath rejects device paths and path-traversal sequences. operation is a short label used in error messages (e.g. "writing", "editing").
func ValidatePathExists ¶
ValidatePathExists checks if a path exists
func ValidatePathIsDirectory ¶
ValidatePathIsDirectory checks if a path exists and is a directory
func ValidateSensitivePath ¶
ValidateSensitivePath rejects edits to credential / settings files that would leave them in an unsafe state. toolName is used in error messages.
func ValidateUNCPathSecurity ¶
ValidateUNCPathSecurity returns an error when path is a UNC/network path.
Types ¶
type GitDiff ¶
type GitDiff struct {
Filename string `json:"filename"`
Status string `json:"status"`
Additions int `json:"additions"`
Deletions int `json:"deletions"`
Changes int `json:"changes"`
Patch string `json:"patch"`
}
GitDiff holds a minimal summary of git changes for a file.
func ComputeGitDiff ¶
ComputeGitDiff computes a git diff summary for absolutePath. Returns (diff, true) when inside a git repo; (nil, false) otherwise.