Skip to main content

Overview

Create an envtrap.json file in your project root (next to package.json) to customise envtrap’s behaviour. All fields are optional — envtrap ships with safe, production-ready defaults. envtrap validates this file on every envtrap run and prints warnings for any invalid fields. You can also validate it manually with envtrap check.

Full Schema with Defaults


channels

Type: object
Default: see above
Sets the enforcement mode for each interception channel independently. Each key accepts one of three string values:

Channel Keys

Example — set all channels to warn-only for development:
Example — disable a specific channel:
Setting a channel to "off" fully disables monitoring for that attack surface. Only use this if you are certain no leaks are possible through that channel.

exclusions

Type: object

exclusions.domains

Type: string[]
Default: []
A list of fully-qualified domain names that are allowed to bypass network scanning entirely. Requests to these domains are forwarded directly through the MITM proxy without inspecting headers, body, or URL. Use this for your own known API endpoints where you intentionally send credentials:
Only add domains you explicitly own or fully trust. envtrap matches the exact hostname — subdomains like evil.api.stripe.com are not covered by adding api.stripe.com.

exclusions.paths

Type: string[]
Default: []
A list of glob patterns for source file paths. If an intercepted operation (dns lookup, subprocess spawn, stdout write) originates from a file that matches one of these patterns — resolved via call stack inspection — the detection is suppressed. Common use case: suppress alerts from your own test files that intentionally use mock secrets:
Glob matching rules:
  • * matches any sequence of characters except /
  • ** matches any sequence of characters including /
  • Patterns without a leading / or **/ are automatically prefixed with **/ to match anywhere in the path
Path exclusions apply to stdout, stderr, child_process, and dns channels. They do not apply to the network channel (the MITM proxy has no access to call stack information).

entropy

Type: object Controls the Shannon entropy threshold used to screen process.env and .env values as secret candidates at startup.

entropy.threshold

Type: number
Default: 3.5
Range: 0 to 8
Minimum Shannon entropy score a string must have to be registered as an active secret. Higher values are stricter (fewer false positives, might miss low-entropy secrets).

entropy.minLength

Type: number
Default: 12
Minimum character length a value must have before entropy is evaluated. Values shorter than this are always dropped, regardless of entropy score.
These settings also control the high-entropy DNS tunneling detection threshold inside hooks.mjs.

quiet

Type: boolean
Default: false
When true, suppresses all real-time output from envtrap:
  • No startup banner
  • No per-leak alert blocks
  • No warn() / info() lines
Only the run summary (printed after child exits) and .envtrap-report.json are still produced. Can also be set via the --quiet CLI flag.

logFile

Type: string | null
Default: null
Path (relative to the current working directory, or absolute) to a file where envtrap appends structured JSONL events as each leak is detected — one JSON object per line. The log directory is created automatically if it does not exist. Can also be set via the --log-file <path> CLI flag.
Each JSONL line has the following shape:

Validation

envtrap validates envtrap.json on every startup and prints warnings for any issues without crashing. Run envtrap check to validate explicitly:
Valid output:
Invalid output: