Quick Summary
- What: A pre-commit hook that scans for .env files and secret patterns, then publicly shames you before you make security mistakes.
The Problem: Your .env File Is Basically a Public Diary
Let's be honest: the .env file is where secrets go to die. It starts innocently enough—a database password here, an API key there. Then you add your Stripe secret key, your AWS credentials, your grandmother's cookie recipe (encrypted, of course), and before you know it, you've created a digital treasure map for every script kiddie on the internet.
The absurdity reaches peak levels when you consider the aftermath. You commit, you push, you realize your mistake approximately 2.7 seconds later. What follows is a ritual so predictable it could be choreographed:
- Panic-sweat activates
- Frantic git history rewriting that makes you question your entire understanding of version control
- Rotating 17 different API keys while praying to the tech gods
- Sending that "Hey team, just updating some credentials for security reasons 😇" message
- Pretending you didn't just expose your entire infrastructure because you were too lazy to add .env to .gitignore
It's like watching someone repeatedly touch a hot stove while saying "This time will be different!" The only thing more embarrassing than committing secrets is the elaborate dance we do to pretend it never happened.
The Solution: Public Humiliation as a Service
Enter .env Secret Shamer, the tool that treats your security hygiene with the same gentle respect as a drill sergeant inspecting a messy barracks. I built this because frankly, we've tried nice. We've tried .gitignore templates. We've tried stern warnings in READMEs. None of it works. What we need is shame—beautiful, constructive, public shame.
Here's how it works: the tool installs as a pre-commit hook that scans for .env files and common secret patterns (API keys, passwords, tokens—you know, the digital crown jewels). When it finds something suspicious, it doesn't just fail silently. Oh no. It prints messages so embarrassing you'll think twice before making the same mistake again.
Think of it as a combination security guard and sarcastic friend who says things like "Really? You were going to commit THAT?" right before you make a terrible life decision. The humor is the spoonful of sugar that makes the security medicine go down.
How to Use It: Embrace the Shame
Installation is straightforward because even tools that roast you should be easy to use:
# Clone the repository
git clone https://github.com/BoopyCode/env-secret-shamer.git
cd env-secret-shamer
# Install the pre-commit hook
./install.sh
Now, every time you try to commit, the shamer springs into action. Here's a taste of what you'll see when you attempt to commit something you shouldn't:
# Example output when you try to commit secrets
🚨 SECRET SHAMER ACTIVATED 🚨
Found .env file in commit. Really? In 2024?
Detected potential AWS key: AKIAIOSFODNN7EXAMPLE
Is this your idea of "security best practices"?
Commit rejected. Go fix your life choices.
The beauty is in the details. Check out this snippet from the main detection logic:
def shame_secrets(file_content):
"""Roast the user for their terrible security choices"""
patterns = {
'AWS_KEY': r'AKIA[0-9A-Z]{16}',
'PASSWORD': r'password\s*=\s*[^\s]+',
'API_KEY': r'api[_-]?key\s*=\s*[^\s]+',
}
for secret_type, pattern in patterns.items():
if re.search(pattern, file_content, re.IGNORECASE):
print(f"\n🔍 Found {secret_type} in your .env file")
print(f" Do you also leave your house keys in the mailbox?")
return False
return True
See the full source and all its glorious roasts on GitHub.
Key Features: Your Personal Security Comedy Club
- Pre-commit hook that scans for .env files: Catches you before you embarrass yourself publicly. It's like having a friend who grabs your phone when you're drunk-texting.
- Detects common secret patterns: API keys, passwords, tokens—all the things you definitely shouldn't share with 8 billion strangers on the internet.
- Prints embarrassing messages about your security hygiene: From gentle teasing to full-on roasting, the feedback is designed to make you actually remember to be careful.
- Customizable shame levels: Feeling fragile? Tone down the sarcasm. Need tough love? Crank it to "drill sergeant."
- Open source and free: Because security shouldn't be a luxury, and neither should public humiliation.
Conclusion: Stop Pretending, Start Preventing
At the end of the day, .env Secret Shamer isn't just about funny error messages. It's about breaking the cycle of "oops I did it again" that plagues our industry. Every minute spent rotating compromised keys is a minute not spent building cool stuff. Every security breach from a committed .env file is a story that starts with "So I was being lazy..."
The tool works because it taps into our most powerful motivator: not wanting to look stupid. It's the digital equivalent of your mom catching you with your hand in the cookie jar. That moment of shame creates a memory that sticks, and that memory prevents future mistakes.
So go ahead. Install it. Let it roast you. Embrace the shame. Your future self—and your company's security team—will thank you. And if nothing else, at least you'll have funny commit rejection messages to screenshot and share on Twitter.
Try it out: https://github.com/BoopyCode/env-secret-shamer
Remember: Your secrets deserve better than a public GitHub repository. They deserve to be shamed in private, like proper secrets should be.
💬 Discussion
Add a Comment