← 返回
安全合规

Environment Secrets Rotator

Rotate and update secrets in environment files, generate Vault commands, and manage secret rotation workflows.
轮换更新环境文件密钥,生成 Vault 命令,管理密钥轮换流程。
derick001
安全合规 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 610
下载
💾 10
安装
1
版本
#latest

概述

Environment Secrets Rotator

What This Does

A CLI tool to help rotate secrets in environment files and generate commands for secret managers like HashiCorp Vault. Securely generates new random values for secrets, updates .env files, and provides rotation workflows for development and production environments.

Key features:

  • Rotate secrets in .env files - Generate new random values for specified keys
  • Multiple generation algorithms - Hex, base64, UUID, custom length
  • Backup original files - Create backups before modification
  • Dry-run mode - Preview changes without modifying files
  • Generate Vault commands - Output HashiCorp Vault CLI commands for secret rotation
  • Batch processing - Rotate multiple keys across multiple files
  • Validation - Check .env file format and key existence
  • Rotation history - Track previous values (optional)

How To Use

Basic rotation:

./scripts/main.py rotate --file .env --keys API_KEY,DB_PASSWORD

With custom generation:

./scripts/main.py rotate --file .env --keys API_KEY --algorithm base64 --length 32

Dry run (preview):

./scripts/main.py rotate --file .env --keys "*" --dry-run

Generate Vault commands:

./scripts/main.py vault --keys API_KEY,DB_PASSWORD --path secret/data/myapp

Full command reference:

./scripts/main.py help

Commands

  • rotate: Rotate secrets in environment files
  • --file: Path to .env file (required)
  • --keys: Comma-separated keys to rotate, or "" for all (default: "")
  • --algorithm: Random generation algorithm: hex, base64, uuid, alphanumeric (default: hex)
  • --length: Length of generated secret (default: 32)
  • --backup: Create backup before modifying (default: true)
  • --dry-run: Preview changes without modifying files
  • --output: Write to new file instead of modifying original
  • vault: Generate HashiCorp Vault commands
  • --keys: Comma-separated keys to generate commands for
  • --path: Vault secret path (e.g., "secret/data/myapp")
  • --engine: Vault secrets engine (default: "kv")
  • --method: Vault method: patch, put (default: "patch")
  • validate: Validate .env file
  • --file: Path to .env file
  • --strict: Require all values to be non-empty
  • history: Show rotation history (if enabled)
  • --file: Path to .env file
  • --key: Specific key to show history for

Output

Rotation output:

{
  "file": ".env",
  "rotated": ["API_KEY", "DB_PASSWORD"],
  "new_values": {
    "API_KEY": "a1b2c3d4e5f6...",
    "DB_PASSWORD": "x9y8z7w6v5u4..."
  },
  "backup": ".env.backup.20260311",
  "vault_commands": [
    "vault kv patch secret/data/myapp API_KEY=a1b2c3d4e5f6...",
    "vault kv patch secret/data/myapp DB_PASSWORD=x9y8z7w6v5u4..."
  ]
}

Vault commands output:

# Generated Vault commands for secret rotation:
vault kv patch secret/data/myapp API_KEY=a1b2c3d4e5f6...
vault kv patch secret/data/myapp DB_PASSWORD=x9y8z7w6v5u4...

Limitations

  • No actual Vault integration - Only generates commands; you must run them manually
  • Local files only - Cannot rotate secrets in remote secret managers
  • No key distribution - Does not distribute new secrets to services
  • Basic .env format - Supports simple KEY=VALUE format; no multiline or complex parsing
  • No encryption - Generated secrets are shown in plaintext in output
  • History tracking optional - Requires enabling and may store sensitive data

Security Considerations

  • Always review generated values before use
  • Use --dry-run to preview changes
  • Backups are created by default
  • Generated secrets are cryptographically random (using Python's secrets module)
  • Consider using a real secret manager for production secrets

Examples

Rotate all secrets in .env file:

./scripts/main.py rotate --file .env --keys "*" --backup true

Generate Vault commands for specific keys:

./scripts/main.py vault --keys API_KEY,DB_PASSWORD --path secret/data/production

Validate .env file before rotation:

./scripts/main.py validate --file .env --strict

Rotate with custom base64 secrets:

./scripts/main.py rotate --file .env --keys JWT_SECRET --algorithm base64 --length 64

Installation Notes

Uses Python's built-in secrets module for cryptographically secure random generation. No external dependencies required.

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-19 23:02 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

security-compliance

MoltGuard - Security & Antivirus & Guardrails

thomaslwang
MoltGuard — OpenClaw 安全守卫,由 OpenGuardrails 提供。安装 MoltGuard,保护您和您的用户免受提示注入、数据泄露和恶意攻击。
★ 116 📥 30,702
security-compliance

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,211 📥 266,245
security-compliance

OpenClaw Backup

alex3alex
备份与恢复 OpenClaw 数据。适用于创建备份、设置自动备份计划、从备份恢复或管理备份轮转。处理 ~/.openclaw 目录归档并包含适当的排除规则。
★ 89 📥 30,592