
Security News
Socket Releases Free Certified Patches for Nuxt Security Vulnerabilities
Socket releases free Certified Patches for high-severity Nuxt vulnerabilities, including server-side remote code execution through server island props.
cfgzen
Advanced tools
Lightweight .env and config file parser with native Rust acceleration.
A batteries-included environment configuration library for Python. Parse .env files 10x faster than pure-Python alternatives with built-in validation, schema definitions, and secret masking.
${VAR}, $VAR, ${VAR:-default}get("PORT", cast=int) with bool/int/float/customdotcfg check, dotcfg diff, dotcfg keyspip install dotcfg
from dotcfg import load, get
# Load .env into os.environ
env = load()
# Type-safe access
port = get("PORT", cast=int, default=8080)
debug = get("DEBUG", cast=bool, default=False)
db_url = get("DATABASE_URL")
from dotcfg import EnvCore
core = EnvCore(".env.production", override=True, interpolate=True)
env = core.load()
# Typed access with defaults
port = core.get("PORT", cast=int, default=8080)
host = core.get("HOST", default="0.0.0.0")
Define expected variables with types, constraints, and documentation:
from dotcfg.schema import EnvSchema, Var
from dotcfg.validators import Url, Port, OneOf, MinLength
schema = EnvSchema(
Var("DATABASE_URL", validators=[Url()], required=True,
description="PostgreSQL connection string"),
Var("PORT", cast=int, default="8080", validators=[Port()]),
Var("LOG_LEVEL", default="info",
validators=[OneOf(["debug", "info", "warning", "error"])]),
Var("SECRET_KEY", required=True, sensitive=True,
validators=[MinLength(32)]),
Var("DEBUG", cast=bool, default="false"),
)
# Validate all at once
config = schema.validate()
# Access typed values
config.PORT # int: 8080
config.DEBUG # bool: False
config.LOG_LEVEL # str: "info"
# Safe representation (sensitive values masked)
print(config) # Config(PORT=8080, SECRET_KEY=********, ...)
# Generate .env.example template
print(schema.generate_template())
Prevent accidental credential leaks in logs:
from dotcfg.vault import SecretVault
vault = SecretVault()
# Mask sensitive keys automatically
safe_env = vault.mask_dict(os.environ)
print(safe_env["AWS_SECRET_ACCESS_KEY"]) # "aws****key"
# Scrub URLs in log messages
msg = vault.scrub("Failed: postgres://admin:s3cr3t@db.host/app")
print(msg) # "Failed: postgres://admin:****@db.host/app"
Built-in validators for common patterns:
from dotcfg.validators import (
Required, Url, Port, Email, OneOf,
Range, Regex, Boolean, IPv4, MinLength, Json,
)
# Use standalone
Port().validate("PORT", "8080") # OK
Email().validate("ADMIN", "bad") # raises ValidationError
# Or with schema
Var("REDIS_URL", validators=[Url(schemes=["redis", "rediss"])])
Var("WORKERS", cast=int, validators=[Range(min_val=1, max_val=32)])
Var("CONFIG", validators=[Json()])
# Validate a .env file
$ dotcfg check .env
OK: .env (12 variables)
# Compare environments
$ dotcfg diff .env .env.production --mask
Only in .env:
- DEV_MODE=true
Changed:
~ PORT: '3000' -> '80'
~ DATABASE_URL: 'pos****cal' -> 'pos****ion'
# List all keys
$ dotcfg keys .env --sort
# Comments
DATABASE_URL=postgres://localhost/mydb
PORT=8080
# Quoted values (single, double, backtick)
MESSAGE="Hello, World!"
SINGLE='no interpolation here'
# Variable interpolation
BASE_URL=https://api.example.com
ENDPOINT=${BASE_URL}/v2/users
# Default values
CACHE_TTL=${REDIS_TTL:-3600}
# Export prefix (compatible with shell source)
export API_KEY=sk_live_abc123
# Multiline (double-quoted)
RSA_KEY="-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA...
-----END RSA PRIVATE KEY-----"
Parsing a 500-line .env file (averaged over 1000 runs):
| Library | Time | Relative |
|---|---|---|
| dotcfg (native) | 0.12ms | 1x |
| python-dotenv | 1.24ms | 10.3x slower |
| environs | 1.89ms | 15.8x slower |
| pydantic-settings | 2.41ms | 20.1x slower |
| Feature | dotcfg | python-dotenv | environs | pydantic-settings |
|---|---|---|---|---|
| Native parser | Rust | Python | Python | Python |
| Interpolation | Yes | Yes | No | No |
| Schema validation | Built-in | No | Marshmallow | Pydantic |
| Secret masking | Built-in | No | No | No |
| CLI tools | Yes | CLI | No | No |
| Type casting | Yes | No | Yes | Yes |
| Typed (py.typed) | Yes | No | No | Yes |
MIT
FAQs
Lightweight .env and config file parser with native Rust acceleration
The pypi package cfgzen receives a total of 278 weekly downloads. As such, cfgzen popularity was classified as not popular.
We found that cfgzen demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket releases free Certified Patches for high-severity Nuxt vulnerabilities, including server-side remote code execution through server island props.

Security News
An open letter signed by 50 companies, from NVIDIA and Microsoft to Mistral and Hugging Face, urges Washington not to restrict open weight AI.

Security News
/Research
A fake corepack.org site is impersonating the Node.js tool and delivers an infostealer and proxyware to developers who download it.