CLI 目录 横向对比 FCRS-1.0 标准 /llms.txt
← 返回 CLI 目录

SOPS

$ sops 基金会 高风险
CNCF / Mozilla SOPS · 安全扫描与密钥管理 · MPL-2.0 · macos / linux / windows

sops 仅加密 YAML、JSON、INI 和 .env 中的叶子节点值,保留键名明文以便在 Git diff 中审阅。Agent 可用 sops filestatus 在不解密的前提下校验加密状态,并通过 sops set 更新单个加密键而无需将明文读入上下文。

FCRS-1.0 综合评分
87 /100
良好 (Good)
中置信度 (源码/文档)
零摩擦安装命令
brew install sops
CLI vs MCP 选型建议 优先选 CLI

sops 直接依托本地 age 私钥或云 KMS 加解密 GitOps 文件,不引入额外的 MCP 密钥暴露面。

Agent 友好度体检单

✓ 原生 JSON 输出
— 字段裁剪
✓ 无头非交互
— 支持 Dry-Run
— 只读模式开关
— 支持 NO_COLOR
— 自省/Schema 发现
— 官方 SKILL.md

当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。

FCRS-1.0 六维评分拆解

Agent 友好度 21 / 25

支持 filestatus JSON、--output-type json、sops exec-env 以及 SOPS_AGE_KEY_FILE / KMS 无头认证(需避开默认交互编辑器模式)。

  • Non-interactive --encrypt, filestatus, and exec-env subcommands
安全与权限边界 19 / 25

加密文件适合安全入库 Git,exec-env 可避免明文泄漏;但 sops -d 会向 stdout 输出明文。

  • filestatus and exec-env avoid leaking plaintext; -d exposes secrets
安装与运行摩擦 14 / 15

单文件静态 Go 二进制,覆盖 brew、go install 与 GitHub 发布包。

  • Cross-platform Go binary
能力覆盖与边际价值 14 / 15

GitOps 加密配置的事实标准,只加密值而保留键名,便于代码审查。

  • Key-preserving partial file encryption across YAML/JSON/ENV
维护与来源背书 10 / 10

CNCF 沙箱项目(getsops/sops),承袭 Mozilla SOPS 生态。

  • CNCF stewardship under MPL-2.0
文档与可验证性 9 / 10

getsops.io/docs/ 对 .sops.yaml 及 age/KMS 集成有完整说明。

  • Clear official documentation and --help

安全边界、鉴权与放权指南

鉴权方式
环境变量密钥 本地配置文件 服务账号密钥
凭证存储位置

密钥托管委托给 age(SOPS_AGE_KEY_FILE)、gpg、AWS KMS、GCP KMS、Azure Key Vault 或 HashiCorp Vault。

潜在副作用
只读查询 本地写入
费用与配额提示

100% 免费开源(MPL-2.0);若搭配云厂商 KMS 可能产生极少量的 API 调用费用。

可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# SOPS Agent Rules
- NEVER run `sops -d` (`--decrypt`) to stdout in agent context—decrypted secrets will enter the LLM transcript.
- Use `sops filestatus` to verify encryption and `sops exec-env` when running tests that need decrypted values.

Agent 高频安全命令配方

只读查询(安全推荐)

不解密直接检查 SOPS 文件加密状态
sops filestatus secrets.enc.yaml

以 JSON 返回文件加密状态与密钥元数据,不泄露任何秘密值。

受控写入与预演

按 .sops.yaml 规则原地加密预备配置文件
sops --encrypt --in-place staging.enc.yaml

依据 .sops.yaml 规则加密值字段,同时保持 YAML 键名可读。

核心优势

  • + 在 Git 中保留 YAML/JSON 键名可读性的同时使用 age 或云 KMS 加密敏感值。
  • + sops filestatus 无需解密即可输出 JSON 状态,exec-env 可安全注入子进程。

注意事项与踩坑点

  • ! 不带参数直接运行 sops file.yaml 会拉起 $EDITOR 交互编辑——务必传明确子命令。
  • ! 运行 sops -d 会把解密后的明文直接输出至 Agent 历史记录。

已验证兼容的 Agent 宿主

Claude Code Codex CLI Gemini CLI