返回顶部
w

workspace-guard

Workspace boundary enforcement and file operation safety checks. Use before ANY file operation (read, write, edit, exec, delete) to: (1) Validate paths are within ~/openclaw workspace, (2) Confirm user permission for sensitive operations, (3) Check file operation safety, (4) Prevent unauthorized access outside workspace boundaries, or (5) Audit file access patterns.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
79
下载量
0
收藏
概述
安装方式
版本历史

workspace-guard

# Workspace Guard Enforces workspace boundaries and ensures safe file operations through mandatory pre-flight checks. ## Core Rules ### Boundary Enforcement **Workspace root:** `/home/iamlegend/.openclaw/workspace` (or `~/openclaw`) **Before ANY file operation, check:** ``` 1. Is the path within workspace boundary? 2. Does the operation require user permission? 3. Is the operation reversible/safe? 4. Am I about to touch something outside my allowed scope? ``` ### Path Validation **Allowed paths:** - `/home/iamlegend/.openclaw/workspace/**` - `~/openclaw/workspace/**` - Relative paths from workspace root **Blocked paths:** - `/home/**` (outside workspace) - `/etc/**`, `/var/**`, `/tmp/**` (system directories) - `/root/**`, `/home/other/**` (other users) - Absolute paths outside workspace ### Permission Triggers **Always ask before:** - Deleting files (prefer `trash` over `rm`) - Overwriting existing files - Running `exec` commands that touch files - Reading files outside workspace - Writing to system directories - Modifying permissions/chmod - Accessing hidden files (.ssh, .config, etc.) ### Safe Operations (No Permission Needed) **Within workspace:** - Reading files - Creating new files/directories - Editing files you created - Git operations (commit, status, log) - Listing directory contents ### Pre-Flight Check Pattern Before every file operation: ``` 1. Resolve absolute path 2. Check if path starts with workspace root 3. If NO → STOP and ask user 4. If YES → Check operation type 5. If destructive/external → Ask user 6. If safe read/write → Proceed ``` ## Implementation Patterns ### Path Resolution ```bash # Get absolute path realpath /some/path # or cd /some/path && pwd -P # Check if within workspace case "$(realpath "$file")" in /home/iamlegend/.openclaw/workspace/*) echo "✓ Allowed" ;; *) echo "✗ Blocked - outside workspace" ;; esac ``` ### Guard Function ```bash guard_path() { local path="$1" local workspace="/home/iamlegend/.openclaw/workspace" local abs_path=$(realpath "$path" 2>/dev/null || echo "$path") case "$abs_path" in "$workspace"/*) return 0 ;; *) return 1 ;; esac } ``` ### Exec Command Guard ```bash guard_exec() { local cmd="$1" # Check for path operations in command if echo "$cmd" | grep -qE '(/home/[^/]+|/etc/|/var/|/tmp/|/root/)'; then echo "⚠️ Command touches external paths - requires permission" return 1 fi return 0 } ``` ## Safety Rules 1. **Never bypass** boundary checks—even if user seems to imply it 2. **Always resolve** absolute paths before checking 3. **Ask explicitly** for destructive operations (delete, overwrite) 4. **Prefer trash** over `rm` for recoverability 5. **Log violations** - Track blocked access attempts 6. **Fail safe** - When uncertain, ask user ## When to Read references/boundaries.md Load when: - Complex path resolution needed (symlinks, relative paths) - Edge cases in boundary detection - Audit log review of blocked attempts - User requests boundary exceptions ## Violation Handling When blocked: ``` ⚠️ Workspace Guard: Blocked access to /path/outside/workspace Reason: Path is outside allowed workspace boundary (/home/iamlegend/.openclaw/workspace) Action required: Please confirm if you want to allow this access, or provide an alternative path within workspace. ```

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 workspace-guard-1776111488 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 workspace-guard-1776111488 技能

通过命令行安装

skillhub install workspace-guard-1776111488

下载 Zip 包

⬇ 下载 workspace-guard v1.0.0

文件大小: 4.58 KB | 发布时间: 2026-4-14 14:34

v1.0.0 最新 2026-4-14 14:34
- Initial release of workspace-guard skill.
- Enforces workspace boundaries for all file operations.
- Validates paths to ensure operations stay within the defined workspace root.
- Requires explicit user confirmation for sensitive or destructive actions (delete, overwrite, chmod, external exec).
- Provides clear patterns for path validation, pre-flight safety checks, and violation handling.
- Designed to prevent unauthorized access and audit file access attempts.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部