.env, SSH keys, the SDK, and system files — and follow symlinks so a harmless.txt → .env link is still blocked.
How It Works
Quick Start
1
Simple Usage
Protected-path checks apply automatically when using
praisonai code tools:2
With Configuration
Inspect protection before a write:
How It Works
is_protected() and get_protection_reason() in praisonai.security.protected guard write_file, append_to_file, search_replace, apply_diff, and multiedit. They also drive the file-discovery tools glob_files, glob_directories, and grep_search. Both resolve symlinks (os.path.realpath) before matching, so a same-directory symlink to a protected file is checked by its real target, not its name.
Protected targets include environment files, .git/, SSH keys, ~/.aws/, /etc/passwd, praisonaiagents/, and audit.jsonl.
How it applies to each tool
Protection means refuse-write, skip-read, or hide depending on the tool.multiedit (in praisonai.tools.multiedit) refuses protected files even when they sit inside the workspace root, returning: "Refusing to edit protected path: <reason>". grep_search (in praisonai.tools.grep_tool) skips protected files during its scan, and glob_files / glob_directories (in praisonai.tools.glob_tool) filter protected paths out of their results. See File Tool Workspace Confinement for how these tools also honour PRAISONAI_WORKSPACE.
Symlinks are resolved before matching — a symlink to a protected file is protected.The protected-path check runs before workspace confinement — both apply to every write. See Code Editing → Workspace Security. Blocked calls return:is_protected()andget_protection_reason()callos.path.realpath()on the input first, so a same-directoryharmless.txt → .envsymlink is blocked as.env(PR #3616).
Configuration Options
Symlink-safe writes
write_file, append_to_file, apply_diff, and search_replace resolve symlinks before both the protection check and the write. A same-directory symlink like harmless.txt → .env is refused with the same reason as .env itself, and a symlink that changes target between the check and the write cannot redirect an approved edit into a protected file.
Best Practices
Never disable in production
Never disable in production
Protected-path checks are a safety default — extend
extra_protected only after review.Use praisonai code tools
Use praisonai code tools
Protection is enforced in
praisonai.code.tools, not the core FileTools class.Check before custom tools
Check before custom tools
Call
is_protected() in custom write tools that bypass the built-in guards.Keep secrets out of prompts
Keep secrets out of prompts
Even with protection, avoid passing
.env contents into agent context.Related
Security Overview
Full security feature matrix
Shell Tools
Dangerous command protection
File Tool Workspace Confinement
Confine glob/grep/multiedit to a workspace root

