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
Markdown
# π 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.




## π 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.β π