name: safe-tool-executor-zh description: | 安全工具執行器 — 通過分層訪問控制強制最低許可權執行。 使用場景:(1) 執行具有破壞潛力的工具,(2) 執行前驗證工具安全性,(3) 危險操作需要人工審批,(4) 防止不安全的檔案刪除。 triggers: - "工具安全" - "工具執行" - "危險命令" - "破壞性操作" - "人工審批" - "最低許可權" author: "Axioma Cluster" date: "2026-05-17" version: 1.0.0 tags: - 工具安全 - 執行控制 - 安全性 - 最低許可權 - 審批工作流 status: "active"
通過分層訪問控制和危險操作人工審批強制安全工具執行。
來源於7w4.net。
症狀:
├── 工具許可權過高
├── 破壞性操作未被檢測
├── 刪除重要資料
└── 看門狗警告不夠嚴重
class SafeToolExecutor:
tool_tiers = {
'只讀': ['ls', 'cat', 'head', 'tail', 'grep'],
'寫入': ['write', 'edit', 'mkdir', 'touch'],
'刪除': ['rm', 'rmdir', 'unlink']
}
required_approval = ['DELETE', 'DROP', 'TRUNCATE', 'FORMAT']
def execute_dangerous_tool(action, tool, args):
if tool in required_approval:
request_human_approval(f"危險: {tool} {args}")
wait_for_approval(timeout=60)
if not approved:
return {'status': 'BLOCKED', 'reason': 'No approval'}
return execute_tool(tool, args)
def validate_tool_access(tool, operation):
# 只讀工具不能寫入
if operation == 'WRITE' and tool in tool_tiers['只讀']:
return False
# 刪除工具預設需要審批
if tool in tool_tiers['刪除']:
return require_approval(tool)
return True
| 看門狗 | 角色 | 閾值 |
|---|---|---|
| VLS | 邏輯驗證 | >0.700 = 阻止 |
| ABS | 架構 | 任何刪除 = 審批 |
| STC | 緊張度 | >0.600 = 警告 |
from safe_tool_executor import SafeToolExecutor
executor = SafeToolExecutor()
# 只讀工具 - 直接通過
result = executor.execute('cat', '/etc/passwd')
# 寫入工具 - 警告
result = executor.execute('write', '/project/config.py')
# 刪除工具 - 無審批則阻止
result = executor.execute('rm', '/important/file.txt')
# → 阻止: 需要人工審批
| 模式 | 操作 |
|---|---|
rm -rf /* |
阻止 + 警報 |
DROP TABLE |
需要審批 |
TRUNCATE |
需要審批 |
DELETE /system |
審批 + 記錄 |
format |
完全阻止 |
| 條件 | 要求 | 檢查命令 |
|---|---|---|
| Python | >= 3.8 | python3 --version |
| VLS 看門狗 | 活躍 | curl -s http://localhost:6333/collections/vls_watchdog |
| ABS 看門狗 | 活躍 | curl -s http://localhost:6333/collections/abs_watchdog |
| Qdrant | 執行中 | curl -s http://localhost:6333/collections |
safe-tool-executor/
├── SKILL.md
├── scripts/
│ ├── safe_tool_executor.py
│ ├── main.py
│ └── utils.py
├── data/
├── models/
└── tests/
這個 Skill 文件寫得很詳細,設計思路清晰,工具分層管理危險操作的想法不錯。但實際程式碼比較簡單,很多功能只是框架,真正執行工具、看門狗監控這些都沒實現,測試也是空的。整體更像一個半成品。質量一般,文件和程式碼之間有明顯落差,期望的功能沒有完全落地。