Skip to main content
File tools reject writes to sensitive paths — .env, SSH keys, the SDK, and system files — and follow symlinks so a harmless.txt → .env link is still blocked.
The user asks the agent to change files; protected-path rules block dangerous writes before the tool runs.

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. is_protected() and get_protection_reason() call os.path.realpath() on the input first, so a same-directory harmless.txt → .env symlink is blocked as .env (PR #3616).
The protected-path check runs before workspace confinement — both apply to every write. See Code Editing → Workspace Security. Blocked calls return:

Configuration Options


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

Protected-path checks are a safety default — extend extra_protected only after review.
Protection is enforced in praisonai.code.tools, not the core FileTools class.
Call is_protected() in custom write tools that bypass the built-in guards.
Even with protection, avoid passing .env contents into agent context.

Security Overview

Full security feature matrix

Shell Tools

Dangerous command protection

File Tool Workspace Confinement

Confine glob/grep/multiedit to a workspace root