feat: add varlock scan command for sensitive value leak detection#316
feat: add varlock scan command for sensitive value leak detection#316
varlock scan command for sensitive value leak detection#316Conversation
|
Implements a new `varlock scan` CLI command that scans files for plaintext secrets. Can be wired up as a pre-commit git hook. Features: - Detects PEM private keys, AWS Access Key IDs, GitHub tokens, Slack tokens, and URLs with embedded credentials - Default: scans non-git-ignored files (using git ls-files with -z) - --staged: only scans staged files (for pre-commit hooks) - --include-ignored: scans all files including git-ignored ones - --path / -p: specify directory to scan - Exits with code 1 when secrets are found - Skips binary files and common build/dependency directories - Uses null-byte separated git output to handle unusual filenames Co-authored-by: theoephraim <1158956+theoephraim@users.noreply.github.com>
varlock scan command for plaintext secret detection
|
@copilot - the point of this is that we know the actual secret values to look for and dont have to resort to looking for patterns like other tools do. We should resolve the config and then look for any sensitive values. |
Instead of regex pattern matching, the scan command now: 1. Loads the varlock config via loadVarlockEnvGraph() 2. Resolves all config values 3. Collects all items where isSensitive=true with non-empty string values 4. Scans files for those actual literal values This means zero false positives and works for any type of secret, not just well-known patterns. Reports the env var key name when a leak is found. Co-authored-by: theoephraim <1158956+theoephraim@users.noreply.github.com>
Reworked in f82dd70. The scan command now loads the varlock config via |
varlock scan command for plaintext secret detectionvarlock scan command for sensitive value leak detection
|
Looks good to me at first glance. We may want some sort of skip pattern to explicitly exclude files outside of the staged/ignored affordances we already have. But that might be overkill too. |
Adds a new
varlock scanCLI command that scans files to ensure none of your resolved sensitive config values appear in plaintext. Designed to be wired up as a git pre-commit hook.Rather than relying on generic regex patterns like other secret scanners,
varlock scanloads your varlock config, resolves all values, and then searches files for the actual literal values of items marked@sensitive. This means zero false positives and works for any type of secret — not just well-known formats.Command options
--staged— only scan staged files (primary git hook use case)--include-ignored— scan all files, including git-ignored ones (default skips ignored files viagit ls-files -z)--path / -p— path to a specific.envfile or directory ending with/to use as the schema entry point (default: cwd)Exit code
1when sensitive values are found in plaintext, making it drop-in compatible with git hooks.How it works
loadVarlockEnvGraph()@sensitiveis set and the resolved value is a non-empty stringBinary files (null bytes, common binary extensions) and build/dependency directories (
node_modules,dist,.next, etc.) are skipped automatically.Git hook setup
Sample output
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.