You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP β†’
Socket
Book a DemoInstallSign in
Socket

secret-hunter

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

secret-hunter

A powerful CLI tool to scan your codebase for exposed API keys, secrets, and sensitive information

1.0.9
latest
Source
npmnpm
Version published
Weekly downloads
14
-87.93%
Maintainers
1
Weekly downloads
Β 
Created
Source

πŸ” Secret Hunter

Lightning-fast secret detection for secure development

A powerful CLI tool that scans your codebase for exposed API keys, secrets, and sensitive information with zero configuration required.

npm version npm downloads license build status

GitHub stars GitHub forks GitHub issues GitHub pull requests

Installation β€’ Usage β€’ Features β€’ Detection β€’ Contributing




πŸ”₯ Features

FeatureDescription
⚑ Lightning FastScans thousands of files in seconds with optimized algorithms
🎯 Smart DetectionAI-powered pattern matching with minimal false positives
πŸ” ComprehensiveDetects API keys, tokens, database URLs, private keys and more
πŸ“Š Rich ReportsBeautiful CLI output with file locations and security recommendations
πŸ›‘οΈ Zero ConfigWorks out of the box with intelligent defaults - no setup required
πŸ“ Smart FilteringAutomatically ignores irrelevant files and directories
🎨 Beautiful UIColorized output with progress indicators and clear formatting

πŸ“¦ Installation

Choose your preferred installation method:

npm install -g secret-hunter

Using Yarn

yarn global add secret-hunter

Using npx (No Installation Required)

npx secret-hunter

From Source

git clone https://github.com/itsAnuragsingh/secret-hunter.git
cd secret-hunter
npm install
npm link

🎬 Usage

Quick Start

# Navigate to your project directory
cd your-project

# Run the scanner
secret-hunter

Example Output

πŸ” Starting secret scan...
Found 1,247 files to scan
Scanning for secrets...

♂️ SECRET HUNTER REPORT
==================================================

πŸ“Š SCAN SUMMARY
------------------------------
πŸ“ Total files scanned: 1,247
🚨 Total secrets found: 3
πŸ“„ Files with secrets: 2
πŸ” Secret types found: 2

🚨 DETAILED FINDINGS
------------------------------

πŸ“ File 1: src/config/database.js
────────────────────────────────────────────────────────────
  1. MongoDB Connection String
     Line: 12
     Code: const dbUrl = "mongodb://user:password@localhost:27017/myapp"

πŸ“ File 2: .env.example
────────────────────────────────────────────────────────────
  1. OpenAI API Key
     Line: 5
     Code: OPENAI_API_KEY=sk-1234567890abcdef...

  2. Stripe Secret Key
     Line: 8
     Code: STRIPE_SECRET_KEY=sk_live_1234567890abcdef...

πŸ’‘ RECOMMENDATIONS
------------------------------
1. Remove hardcoded secrets from your code
2. Use environment variables (.env files)
3. Add .env to your .gitignore
4. Use secret management tools for production

==================================================
�️‍♂️ Scan completed successfully!

πŸ” What secret-hunter Detects

πŸ”‘ API Keys & Tokens
  • OpenAI API Keys (sk-...)
  • Google API Keys (AIza...)
  • Anthropic API Keys (sk-ant-...)
  • GitHub Personal Access Tokens (ghp_...)
  • Discord Bot Tokens
  • JWT Tokens
  • Bearer Tokens
  • Generic API Keys
☁️ Cloud Services
  • AWS Access Keys (AKIA...)
  • AWS Secret Keys
  • Azure Storage Keys
  • Google Cloud Service Keys
  • Stripe API Keys (Live & Test)
  • Heroku API Keys
πŸ—„οΈ Database Connections
  • MongoDB Connection Strings
  • MySQL Connection Strings
  • PostgreSQL Connection Strings
  • Redis Connection Strings
  • Database URLs with credentials
πŸ“§ Communication Services
  • Twilio Account SIDs
  • SendGrid API Keys
  • Mailgun API Keys
  • Slack Bot Tokens
πŸ” Security & Cryptographic Keys
  • RSA Private Keys
  • OpenSSH Private Keys
  • DSA Private Keys
  • EC Private Keys
  • Generic Private Keys

πŸ› οΈ Advanced Usage

πŸ”’ Pre-commit Hook (Prevent Secrets from Being Committed)

What it does: Automatically scans your code before every Git commit. If secrets are found, it blocks the commit.

Setup Instructions:

  • Create the hook file:

    # Navigate to your project
    cd your-project
    
    # Create the pre-commit hook
    touch .git/hooks/pre-commit
    chmod +x .git/hooks/pre-commit
    
  • Add this content to .git/hooks/pre-commit:

    #!/bin/sh
    echo "πŸ” Scanning for secrets before commit..."
    secret-hunter
    if [ $? -ne 0 ]; then
        echo "❌ Secrets detected! Please remove them before committing."
        exit 1
    fi
    echo "βœ… No secrets found. Commit allowed."
    

How it works: Every time you run git commit, it will automatically scan your code first!

πŸ“Š Community & Support

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Maintained by Anurag Singh Β· LinkedIn Β· Twitter/X

⭐ Star this repository if it helped you secure your codebase!

Built with ❀️ for developers who care about security


Secret Hunter - Making secure development accessible to everyone

Keywords

security

FAQs

Package last updated on 07 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts