360 Secure SkillHub
360 安全技能中心

RedHat File Operations

该技能可在MCP环境执行安全文件操作,涵盖读写、更新、删除、移动、复制等,自带路径校验防范非法访问,默认对破坏性操作自动创建备份确保可逆。适用于需编辑磁盘文件、保障修改安全、避免误操作的场景。输入需指定操作类型与路径,可选内容、备份设置等;输出返回操作详情、受影响路径、备份路径及结果状态。

mzfshark
mzfshark
热度 37.63
最近更新 2026-05-11 17:45:41
分类:效率依赖:读写文件 / MCP 服务应用场景:工作流 / 任务管理

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add axodus-file-operations
Metadata
name
file-operations
description
Perform safe, auditable file operations with path validation and backups.
metadata
{"author":"RedHat Dev","version":"1.0.0","owner":"RedHat Dev Agent","category":"execution"}

SKILL: file-operations

Purpose

Perform safe, auditable file operations (read/write/update/delete/move/copy) in an MCP-enabled environment with path validation and backups.

When to Use

  • Any task requires editing files on disk.
  • You need to ensure changes are safe and reversible.
  • You must avoid accidental overwrites or destructive operations.

Inputs

  • operation (required, enum: read|write|update|delete|move|copy).
  • paths (required, object):
    • source (optional, string)
    • target (optional, string)
    • targets (optional, string[])
  • content (optional, string): for write/update.
  • backup (optional, boolean, default: true for overwrite/delete).
  • constraints (optional, string[]): e.g., “only within workspace”.

Steps

  1. Resolve absolute paths and normalize.
  2. Validate scope:
    • operation stays inside the intended workspace root(s)
    • block path traversal/suspicious targets
  3. Preflight:
    • confirm existence for read/update/delete
    • confirm non-existence (or allow overwrite explicitly) for write/move
  4. If overwrite/delete and backup=true, create a backup copy (timestamped).
  5. Execute the operation with explicit reporting (what changed).
  6. Post-validate:
    • file exists where expected
    • content/diff matches expectation

Validation

  • Operation is reversible when possible (backup exists for destructive actions).
  • The final target path is verified before execution.
  • The operation result is explicitly reported (not silent).

Output

operation: "<operation>"
affected: ["<path>"]
backup_paths: ["<path>"]
result: "success|blocked|failed"
notes: ["..."]

Safety Rules

  • Never delete or overwrite recursively without explicit user confirmation.
  • Never operate on computed paths without printing the resolved final paths first.
  • Prefer patch-based updates over full-file rewrites when possible.

Example

Update a config file:

  • operation: update
  • paths: { target: "apps/api/.env.example" }
  • Validation: backup created; diff is minimal; file still parses.