UNPKG

secretshield

Version:

πŸ›‘οΈ SecretShield is a CLI tool that detects API keys and sensitive credentials before you commit code.

239 lines (159 loc) β€’ 5.77 kB
# πŸ”’ SecretShield **Secure your commits before they go public!** `SecretShield` is a powerful, blazing-fast CLI tool to scan your codebase for hardcoded secrets like API keys, tokens, database passwords, and more. Avoid accidental leaks and secure your development workflow in seconds. --- ![npm](https://img.shields.io/npm/v/secretshield?color=blue) ![license](https://img.shields.io/github/license/Arunsinghpundir/secretshield) ![issues](https://img.shields.io/github/issues/Arunsinghpundir/secretshield) ![downloads](https://img.shields.io/npm/dt/secretshield) --- ## πŸš€ Features - πŸ” **Comprehensive scanning** of staged files for sensitive data - 🧠 Detects over **127+ secret patterns** - ⚑ **Fast and efficient** CLI execution - 🎨 **Colorful logs** using Chalk - πŸ”„ Easy integration with Git hooks and CI/CD - πŸ” Prevents accidental commits of secrets --- ## πŸ“¦ Installation You can install SecretShield globally or use it with `npx`. ### Option 1 – Run directly without install: ```bash npx secret-shield ``` ### Option 2 – Install globally: ```bash npm install -g secret-shield ``` ### Option 3 – Install locally (for projects): ```bash npm install --save-dev secret-shield ``` --- ## πŸ› οΈ How to Use Once installed, simply run: ```bash npx secret-shield ``` Or, if installed globally: ```bash secretshield ``` This will scan your **staged files** (those added via `git add`) for any potential secrets. ### Example Output ```bash βœ… SecretShield CLI is working! πŸ” SecretShield scanning staged files... πŸ“‚ Files to scan: [ './.env', './app.js' ] 🚨 Possible secret found in ./app.js at line 12 πŸ”Ž Matched Line: API_KEY="sk_live_1234567890abcdef" ❌ Commit blocked. Secrets detected! ``` --- ## 🧠 Supported Secret Patterns SecretShield currently detects over 127 patterns across multiple categories: ### πŸ”‘ Authentication & Security - βœ… API Keys (Google, Twitter, Facebook, etc.) - βœ… JWT and OAuth Tokens - βœ… 2FA/MFA Secrets - βœ… PGP/GPG Keys - βœ… SSH Private Keys - βœ… SSL Certificates ### ☁️ Cloud Services - βœ… AWS (Access Keys, Secret Keys, Session Tokens) - βœ… Azure (Keys, Secrets, Tokens) - βœ… Google Cloud Platform - βœ… Firebase & Supabase - βœ… Vercel & Netlify - βœ… Digital Ocean, Heroku, Vultr, Linode - βœ… Alibaba Cloud, Oracle Cloud, IBM Cloud ### πŸ’Ύ Database & Storage - βœ… MongoDB, MySQL, PostgreSQL - βœ… Redis, RabbitMQ, Cassandra - βœ… Elasticsearch, Neo4j - βœ… S3, CloudFront, Rackspace - βœ… Backblaze Storage ### πŸ’³ Payment Processing - βœ… Stripe (Secret & Publishable Keys) - βœ… PayPal (Client ID & Secret) - βœ… Square, Braintree, Adyen - βœ… Klarna, Wise ### πŸ“± Social Media & Communication - βœ… Twitter, Facebook, Instagram - βœ… LinkedIn, Discord, Telegram - βœ… Slack, TikTok, Pinterest - βœ… Twitch, Reddit, Snapchat ### πŸ“§ Email Services - βœ… SendGrid, Mailchimp - βœ… Mailgun, Postmark - βœ… Amazon SES, SparkPost - βœ… SMTP Credentials ### πŸ› οΈ DevOps & Infrastructure - βœ… Docker, Kubernetes - βœ… GitHub, GitLab, Bitbucket - βœ… Jenkins, Travis CI, CircleCI - βœ… Ansible Vault, Terraform - βœ… Cloudflare ### πŸ“Š Analytics & Monitoring - βœ… Mixpanel, Segment - βœ… Amplitude, Datadog - βœ… New Relic ### πŸ” Search & Cache - βœ… Algolia, Elastic - βœ… Memcached ### πŸ—ΊοΈ Maps & Location - βœ… Google Maps - βœ… Mapbox, TomTom ### πŸ“ž SMS & Voice - βœ… Twilio (Auth Token, Account SID) - βœ… Nexmo (Vonage) - βœ… Plivo, Sinch ### πŸ”„ Generic Patterns - βœ… Connection Strings - βœ… Credential URLs - βœ… Generic Secrets & Keys - βœ… Private Key Files πŸ”§ You can also **customize the regex** for your org in future versions! --- ## πŸ”„ Git Hook Setup (Optional) Add this to your **pre-commit hook**: ```bash #!/bin/sh npx secret-shield if [ $? -ne 0 ]; then echo "❌ SecretShield blocked your commit!" exit 1 fi ``` Or use tools like [husky](https://github.com/typicode/husky) to integrate it smoothly into your dev workflow. --- ## πŸ›‘οΈ Security If you discover a vulnerability or a false negative, **please do not report it publicly.** Instead, reach out securely: πŸ“§ **[support@decodedev.in](mailto:support@decodedev.in)** --- ## 🚫 Ignoring Specific Lines If you need to ignore a specific line that contains a secret (for example, if it's a test value or a public key), you can add a special comment to that line. SecretShield will skip any line that contains this comment. ### Supported Comment Formats: ```javascript const API_KEY = "test-key-123"; // secretshield: safe to push const DB_PASSWORD = "test-pass-456"; /* secretshield: safe to push */ const SECRET_TOKEN = "test-token-789"; /*secretshield: safe to push */ const AUTH_KEY = "test-auth-012"; //secretshield: safe to push ``` > ⚠️ **Important**: Use this feature carefully and only for legitimate cases where the secret is safe to commit (like test values, public keys, or intentionally public tokens). --- ## πŸ§‘β€πŸ’» Author **Arunq Singh Pundir** [GitHub – @Arunsinghpundir](https://github.com/Arunsinghpundir) --- ## πŸ“ƒ License Licensed under the [MIT License](https://choosealicense.com/licenses/mit/) --- ## 🌟 Support the Project If you find SecretShield useful: - ⭐ Star the repo on [GitHub](https://github.com/Arunsinghpundir/secretShield) - πŸ“’ Share it with your developer friends - πŸ’¬ Suggest improvements or contribute! --- > β€œThe best time to protect secrets was yesterday. The second best time is now.” πŸ”