🔐 Secret Leak Detector for VS Code
🎯 The Philosophy: Shift-Left Secret ProtectionTraditional secret scanners alert you after code has already reached remote repositories or CI/CD pipelines—when revocation, rotation, and incident reports are already required.
Secret Leak Detector shifts protection directly to the editor & commit boundary:
✨ Key Features1. ⚡ Real-Time In-Editor Diagnostics
2. 🪄 One-Click Quick Fixes (
|
| Credential Type | Provider | Pattern / Format | Risk |
|---|---|---|---|
| AWS Access Key ID | Amazon Web Services | (AKIA\|ASIA\|ABIA\|ACCA)[0-9A-Z]{16} |
CRITICAL |
| AWS Secret Access Key | Amazon Web Services | 40-char high-entropy base64 in AWS context | CRITICAL |
| GitHub Token | GitHub | ghp_, gho_, ghu_, github_pat_ |
CRITICAL |
| OpenAI API Key | OpenAI | sk-proj-[a-zA-Z0-9_-]{48,}, sk-... |
CRITICAL |
| Anthropic API Key | Anthropic | sk-ant-[a-zA-Z0-9_-]{40,} |
CRITICAL |
| Stripe Secret Key | Stripe | sk_live_..., rk_live_..., sk_test_... |
CRITICAL |
| Slack Bot / Webhook | Slack | xox[baprs]-..., hooks.slack.com/services/... |
HIGH |
| Private Keys | Cryptography | -----BEGIN (RSA\|EC\|DSA\|OPENSSH\|PGP) PRIVATE KEY----- |
CRITICAL |
| Database Connection Strings | Databases | (postgres\|mysql\|mongodb\|redis)://user:pass@host/db |
HIGH |
| JSON Web Tokens | Auth / Identity | eyJ... . eyJ... . ... (valid JWT triples) |
HIGH |
| Generic High-Entropy Keys | Any API | Key assignment (apiKey = "...") with entropy > 3.4 |
MEDIUM |
🚀 Installation
Option 1: Install from VSIX (Direct)
- Download or locate
secret-leak-detector-1.0.0.vsix. - Open VS Code.
- Press
Ctrl+Shift+X(orCmd+Shift+X) to open the Extensions View. - Click the
...(Views and More Actions) menu in the top right corner. - Select Install from VSIX... and choose
secret-leak-detector-1.0.0.vsix.
Alternatively, install via terminal:
code --install-extension secret-leak-detector-1.0.0.vsix
Option 2: Run in Extension Development Host (From Source)
- Clone or open the repository in VS Code:
git clone https://github.com/MokuLakshithReddy/Secret_Leak_Detector.git cd Secret_Leak_Detector - Install dependencies:
npm install - Press
F5(or go toRun and Debug➔Run Extension). - A new VS Code window will launch with Secret Leak Detector running live.
- Open
samples/sample-vulnerable-file.jsto see real-time detection in action!
⌨️ Commands
| Command | Title | Description |
|---|---|---|
secret-leak-detector.openDashboard |
Open Security Dashboard | Opens the interactive Webview dashboard |
secret-leak-detector.scanWorkspace |
Scan Workspace for Secrets | Scans all workspace files and aggregates findings |
secret-leak-detector.scanStaged |
Scan Git Staged Changes | Inspects staged diff for credentials before commit |
secret-leak-detector.installGitHook |
Install Pre-Commit Hook | Installs standalone .git/hooks/pre-commit script |
secret-leak-detector.clearFindings |
Clear Findings | Clears active findings and squiggly lines |
⚙️ Configuration Settings
Customize behavior under Settings (Ctrl+,) ➔ Extensions ➔ Secret Leak Detector:
| Setting | Type | Default | Description |
|---|---|---|---|
secretLeakDetector.enableRealtimeScanning |
boolean |
true |
Automatically scan open files as you type/save |
secretLeakDetector.blockGitCommits |
boolean |
true |
Intercept and block commits with staged secrets |
secretLeakDetector.minEntropy |
number |
3.4 |
Shannon entropy threshold for generic secrets |
secretLeakDetector.redactSecrets |
boolean |
true |
Mask credentials in UI and terminal messages |
secretLeakDetector.excludeGlobs |
array |
node_modules, .git, dist, ... |
Paths ignored during full scans |
🧪 Testing & Verification
The extension comes with an automated test suite verifying pattern matching, entropy scoring, redaction, and false-positive prevention:
# Run tests
npm test
# or
node esbuild.js --test && node dist/test-suite.js
Live Demonstration Simulation
To run a complete CLI simulation of the DETECT ➔ BLOCK ➔ FIX ➔ RESCAN ➔ ALLOW lifecycle:
node esbuild.js --demo && node dist/demo-cli.js
📦 Building & Packaging
# Compile and bundle with esbuild
npm run build
# Package into .vsix file
npx @vscode/vsce package
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
Developed with ❤️ by Moku Lakshith Reddy.