This application is a Flask-based API that generates synthetic secrets and API keys for testing purposes. It provides deterministic secret generation across multiple endpoints, making it perfect for testing secret scanning tools like GitLeaks and other security scanners.
- Introduction
- Pre-Requisites
- Installation
- Running the Application
- API Endpoints
- Testing with Keploy
- Wrapping Up
🔐 Dive into the world of synthetic secret generation and see how seamlessly Keploy integrates with Flask for API testing. This application generates realistic-looking secrets for various cloud providers and services in a deterministic way, making it perfect for security testing workflows! 🎢
- Python 3.7+ installed on your system
- pip (Python package installer)
- Install WSL (
wsl --install) forWindows.
First, navigate to the project directory and setup python virtual environment
python3 -m venv venv
source venv/bin/activateInstall the required Python packages:
pip install -r requirements.txt curl --silent -O -L https://keploy.io/install.sh && source install.shStart the Flask application:
python main.pyThe server will start on http://localhost:8000
The application provides the following endpoints:
curl -s http://localhost:8000/healthGet secrets from /secret1:
curl -s http://localhost:8000/secret1Get secrets from /secret2:
curl -s http://localhost:8000/secret2Get secrets from /secret3:
curl -s http://localhost:8000/secret3Each endpoint returns a deeply nested JSON payload containing various types of synthetic secrets including:
- AWS Access Keys and Secret Keys
- GitHub Personal Access Tokens
- Slack Webhook URLs
- Stripe Live Keys
- Google API Keys
- MongoDB URIs
- PostgreSQL URLs
- And many more...
Capture test cases by recording API interactions:
keploy record -c "python main.py"Make some API calls to generate test cases. You can use curl, Postman, or any HTTP client:
Make GET requests to all secret endpoints:
curl -s http://localhost:8000/secret1
curl -s http://localhost:8000/secret2
curl -s http://localhost:8000/secret3You will now see a folder named keploy with your recorded tests.
Execute the recorded tests:
keploy test -c "python main.py"- Deterministic Generation: All secrets are generated deterministically using fixed seeds
- Realistic Format: Secrets follow the actual format patterns of real services
- Multiple Providers: Supports AWS, GitHub, Slack, Stripe, Google, MongoDB, PostgreSQL, and more
- Nested Payloads: Returns complex, deeply nested JSON structures
- Testing Ready: Perfect for security scanner testing and API testing workflows
Congrats on exploring the Flask Secret Generator API! You've seen how Keploy can seamlessly integrate with Flask applications for comprehensive API testing. This tool is perfect for testing secret scanning tools and security workflows without exposing real credentials.
Happy coding! ✨👩💻👨💻✨

