Overview
Envark’s risk analysis engine evaluates environment variables for security vulnerabilities, configuration issues, and best practice violations. It uses a multi-factor scoring system to classify risks and provides actionable recommendations.Risk Levels
Envark classifies issues into five severity levels:Critical
Score: 5Immediate security threats or application-breaking issues:
- Variables used in code with no definition
- Hardcoded secrets in committed files
- Exposed credentials
High
Score: 4Serious security risks requiring urgent attention:
- Secrets in potentially committed .env files
- Weak encryption keys
- Missing required variables with no defaults
Medium
Score: 3Configuration issues that should be addressed:
- Variables with conflicting values across files
- Multiple usages with no default value
- Placeholder values in production
- Inconsistent naming patterns
Low
Score: 1-2Minor issues and improvements:
- Undocumented variables
- Dead variables (defined but unused)
- Empty values
- Poor naming conventions
Info
Score: 0Informational findings with no risk:
- Well-configured variables
- Properly documented settings
- Following best practices
Risk Scoring Algorithm
Envark calculates a risk score (0-5) using multiple factors:Score to Risk Level Mapping
Issue Types
Envark detects nine distinct issue types:- MISSING
- EXPOSED
- DUPLICATE
- PLACEHOLDER_VALUE
- INCONSISTENT
- NO_DEFAULT
- UNDOCUMENTED
- DEAD
- EMPTY_VALUE
Severity: CriticalVariable is used in code but not defined anywhere.Risk: Application will receive
undefined, potentially causing runtime errors or security issues.Recommendation: Add the variable to your .env file or provide a default value in code.Secret Detection
Envark uses pattern matching to identify potential secrets:Detected Secret Patterns
API Keys
- API_KEY
- OPENAI_KEY
- STRIPE_KEY
- GOOGLE_API_KEY
Passwords
- PASSWORD
- DB_PASSWORD
- ADMIN_PASS
- USER_PASSWORD
Tokens
- ACCESS_TOKEN
- JWT_TOKEN
- REFRESH_TOKEN
- AUTH_TOKEN
Secrets
- SECRET
- JWT_SECRET
- SESSION_SECRET
- WEBHOOK_SECRET
Private Keys
- PRIVATE_KEY
- SSH_KEY
- SIGNING_KEY
- ENCRYPTION_KEY
Credentials
- CREDENTIALS
- AWS_CREDENTIALS
- DB_CREDENTIALS
- AUTH_CREDENTIALS
Running Risk Analysis
CLI Command
TUI Command
Output Format
Analysis Result Structure
Recommendations Engine
For each variable, Envark generates contextual recommendations:Example Recommendations
For Missing Variables
For Missing Variables
- Add
DATABASE_URLto your .env file - Provide a default value in code
- Create a config validation module
- Document required environment variables
For Exposed Secrets
For Exposed Secrets
- Move to
.env.local(git-ignored) - Use environment-specific files
- Implement secret rotation
- Consider using AWS Secrets Manager or HashiCorp Vault
- Review git history for leaked credentials
For Inconsistent Naming
For Inconsistent Naming
- Standardize to
DATABASE_URLacross all files - Create a naming convention guide
- Use a linter to enforce patterns
- Migrate old variable names gradually
Filtering Results
By Risk Level
By Issue Type
AI-Enhanced Analysis
When an AI provider is configured, Envark can provide deeper insights:- Your specific framework (Next.js, Django, etc.)
- Industry-specific security practices
- Common vulnerability patterns
- Best practices for your tech stack
Best Practices
Regular Scanning
Run
envark risk regularly, especially before deployments.Fix Critical First
Address Critical and High issues before Medium and Low.
Document Decisions
If you intentionally ignore an issue, document why in comments.
Use CI/CD Integration
Add Envark to your CI pipeline to catch issues early.
CI/CD Integration
Programmatic Usage
Implementation Reference
The risk analysis engine is implemented in:src/core/analyzer.ts: Main analysis logic (lines 99-365)src/core/resolver.ts: Variable resolution and deduplicationsrc/tools/get_env_risk.ts: CLI tool interface
src/core/analyzer.ts:295-365 for the complete analysis algorithm.