← 返回
未分类 中文

Env Config Validator

Validate .env files against schemas, compare environments (dev vs prod), detect common mistakes (trailing spaces, placeholders, invalid ports, missing protoc...
校验 .env 文件,匹配 schema,比较环境(dev 与 prod),检测尾部空格、占位符、无效端口、缺失 protoc 等常见错误
charlie-morrison
未分类 clawhub v1.0.1 1 版本 99768.5 Key: 无需
★ 0
Stars
📥 431
下载
💾 1
安装
1
版本
#latest

概述

Env Config Validator

Validate .env files, compare environments, detect common mistakes, and enforce schemas.

Quick Start

# Validate with auto-detected common checks
python3 scripts/validate_env.py .env

# Validate against a schema
python3 scripts/validate_env.py .env --schema env-schema.json

# Compare dev vs prod
python3 scripts/validate_env.py --diff .env.development .env.production

# Generate schema from existing .env
python3 scripts/validate_env.py --generate-schema .env -o env-schema.json

# JSON output for CI
python3 scripts/validate_env.py .env --output json --severity error

Common Checks (Auto-Detected)

The validator automatically detects these issues without a schema:

CheckSeverityWhat it catches
----------------------------------
Trailing whitespacewarningInvisible chars causing bugs
Unquoted spaceswarningValues with spaces not wrapped in quotes
Placeholderserrorchange_me, TODO, xxx, your_* values
Empty valuesinfoDefined but blank variables
Double-nested quoteswarning""value"" quoting errors
URL missing protocolwarningURL vars without http(s)://
Port out of rangeerrorPort > 65535 or < 1
Short secretswarningSECRET/PASSWORD/KEY < 8 chars
Inconsistent booleansinfoyes/1 instead of true/false
Mixed case keysinfosome_Var instead of SOME_VAR
Inline commentswarningvalue # comment (not all parsers support)
Duplicate keyswarningSame variable defined twice

Options

FlagDefaultDescription
----------------------------
--schemaJSON schema file for type/required validation
--diff FILE FILECompare two env files
--generate-schemaAuto-generate schema from .env file
--outputtextOutput format: text, json, markdown
-ostdoutOutput file path
--ignoreSkip specific check IDs (repeatable)
--severityinfoMinimum severity: error, warning, info

Exit Codes

  • 0 — No issues (or only info)
  • 1 — Warnings found (or diff has differences)
  • 2 — Errors found

Workflow

Pre-deploy Validation

  1. Generate schema from working .env: --generate-schema .env -o schema.json
  2. Add schema to repo, validate in CI: validate_env.py .env --schema schema.json --severity error
  3. Diff staging vs prod: --diff .env.staging .env.production

Audit Existing Project

  1. Run validate_env.py .env to find common mistakes
  2. Fix errors and warnings
  3. Generate schema for future validation

References

  • schema-format.md — Full JSON schema specification, supported types, field reference

版本历史

共 1 个版本

  • v1.0.1 当前
    2026-05-07 04:24 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

Pyproject Toml Validator

charlie-morrison
依据 PEP 517/621 规则校验 pyproject.toml 文件,验证项目元数据、构建系统和工具配置,并提供详细报告。
★ 0 📥 458

Stylelint Config Validator

charlie-morrison
校验 Stylelint 配置文件,检查错误、已弃用规则、配置结构、插件、extends 和 overrides,并输出文本或 JSON 结果。
★ 0 📥 446

Site Health Monitor

charlie-morrison
监控网站可用性、SSL证书到期、响应时间、HTTP错误和内容变更,生成健康报告并在检测到问题时发送告警。
★ 0 📥 445