Overview
Envark’s scanning engine intelligently traverses your project directory to detect environment variable usage in source code and.env files. The scanner supports multiple programming languages, caches results for performance, and provides detailed usage tracking.
Quick Start
How It Works
The scanning process follows a four-stage pipeline:1. File Discovery
Envark walks your project directory and identifies relevant files:- Source Files:
.js,.ts,.jsx,.tsx,.py,.rb,.go,.php, etc. - Environment Files:
.env,.env.local,.env.development,.env.example, etc. - Configuration Files:
config/, environment-specific configs
Envark automatically skips
node_modules/, .git/, dist/, build/, and other common ignored directories for performance.2. Hash Computation
Before parsing, Envark computes a hash of all discovered files to enable intelligent caching:3. Cache Check
Envark maintains a cache at~/.envark/cache/ to speed up subsequent scans:
Cache Performance Benefits
Cache Performance Benefits
For a typical project:
- First scan: 2-5 seconds
- Cached scan: 50-200ms (10-100x faster)
4. Parse & Extract
For each source file, Envark uses regex-based parsers to detect environment variable access patterns:JavaScript/TypeScript Patterns
Python Patterns
Environment File Patterns
5. Resolution
After extraction, Envark resolves the complete picture for each variable:- Where it’s defined (which .env files)
- Where it’s used (which source files and line numbers)
- Whether it has default values in code
- If it’s documented (.env.example)
- If it’s missing or unused
Scan Options
Configuration
CLI Usage
Filters
Filter scan results to focus on specific issues:- All
- Missing
- Unused
- Risky
- Undocumented
Show everything (default)Returns all discovered environment variables.
Scan Output
Summary Section
- Total: All unique environment variables found
- Defined: Variables with values in .env files
- Missing: Variables used but not defined
- Critical: Variables with critical risk level
Variable Details
- Name: The environment variable identifier
- Risk Level: Security/configuration risk assessment
- Status: ✓ defined, ✗ missing
Detailed View
For more information, use specific commands:Supported Languages
Envark’s scanner detects environment variables in:JavaScript
- Node.js
- React
- Vue.js
- Next.js
- Express
TypeScript
- All JS frameworks
- Deno
- NestJS
- Angular
Python
- Django
- Flask
- FastAPI
- os.getenv
- python-dotenv
Ruby
- Rails
- Sinatra
- ENV[]
Go
- os.Getenv
- godotenv
PHP
- Laravel
- $_ENV
- getenv()
Framework Detection
Envark recognizes framework-specific patterns:Vite/Vite-based Frameworks
Next.js
Create React App
Django
Performance Characteristics
Small Projects
< 100 files
- First scan: ~500ms
- Cached: ~50ms
Medium Projects
100-1000 files
- First scan: 1-3s
- Cached: 100-200ms
Large Projects
1000-5000 files
- First scan: 3-8s
- Cached: 200-500ms
Monorepos
5000+ files
- First scan: 8-20s
- Cached: 500ms-1s
- Consider
--max-files
Ignored Directories
Envark automatically skips these common directories:Custom Ignore Patterns
Custom Ignore Patterns
Add a This works like
.envarkignore file to your project root:.gitignore for scanning.Programmatic Usage
Use the scanner in your own tools:Cache Management
~/.envark/cache/
Troubleshooting
Scan is too slow
Scan is too slow
Solutions:
- Reduce
--max-filesfor huge monorepos - Ensure cache is enabled (default)
- Add
.envarkignoreto skip unnecessary directories - Check for slow disk I/O (network drives, encrypted volumes)
Missing variables in scan
Missing variables in scan
Possible causes:
- Variable accessed using dynamic keys:
process.env[key] - Custom environment loading logic
- Variables loaded from external sources (Vault, AWS Secrets Manager)
- Unsupported language/framework pattern
envark usage <VAR_NAME> to verify detection.False positives
False positives
Common scenarios:
- Commented-out code still detected
- String literals that look like env vars:
"process.env.API_KEY" - Documentation or example code
Implementation Details
The scanner is implemented across multiple modules:src/core/scanner.ts: Main scanning orchestrationsrc/core/parser.ts: Language-specific parserssrc/core/resolver.ts: Variable resolution logicsrc/utils/file-walker.ts: Efficient directory traversalsrc/utils/cache.ts: Caching layer
src/core/scanner.ts:62-134 for the main scan implementation.