A comprehensive Golang application for monitoring bug bounty programs from multiple platforms (HackerOne, BugCrowd) and discovering their in-scope assets using Project Discovery's ChaosDB.
- Multi-Platform Support: Integrates with HackerOne and BugCrowd APIs
- Asset Discovery: Uses ChaosDB to discover additional subdomains and assets
- Out-of-Scope Filtering: Automatically filters ChaosDB results against program out-of-scope assets
- Database Storage: PostgreSQL database for persistent storage
- Rate Limiting: Built-in rate limiting to respect API limits
- One-off Scanning: Performs single scans with full state management
- Docker Support: Complete containerization with Docker and Docker Compose
- Comprehensive Testing: Unit, integration, and end-to-end tests
- Health Monitoring: Built-in health checks and monitoring
- Production Ready: Circuit breakers, structured logging, metrics, and error handling
- API Key Rotation: Support for multiple API keys with automatic rotation
- Worker Pools: Concurrent processing for improved performance
- Configuration Validation: Comprehensive validation of all configuration parameters
- Graceful Error Handling: Proper error handling without application crashes
- Circuit Breaker Pattern: Protects against cascading failures from external APIs
- Health Checks: Comprehensive health monitoring for all components
- Recovery Mechanisms: Automatic recovery from transient failures
- Structured Logging: JSON-formatted logs with correlation IDs
- Prometheus Metrics: Comprehensive metrics for monitoring and alerting
- Health Endpoints: Built-in health check endpoints
- Performance Monitoring: Memory usage, goroutine count, and response times
- API Key Rotation: Support for multiple API keys with automatic rotation
- Configuration Validation: Comprehensive validation of all settings
- SSL/TLS Support: Full SSL certificate support for database connections
- Input Validation: Comprehensive input validation and sanitization
- Worker Pools: Concurrent processing for improved performance
- Connection Pooling: Optimized database connection management
- Rate Limiting: Intelligent rate limiting with exponential backoff
- Memory Management: Efficient memory usage with monitoring
Monitor Agent
├── cmd/monitor-agent/ # Application entry point
├── internal/
│ ├── config/ # Configuration management
│ ├── database/ # Database layer and repositories
│ ├── discovery/ # Asset discovery (ChaosDB)
│ ├── metrics/ # Prometheus metrics
│ ├── platforms/ # Platform integrations (HackerOne, BugCrowd)
│ ├── service/ # Business logic layer
│ └── utils/ # Utilities (URL processing, logging, etc.)
├── tests/ # Integration tests
└── docker/ # Docker configuration
- Go 1.21 or later
- PostgreSQL database
- API keys for HackerOne, BugCrowd, and ChaosDB (optional - application will only scan platforms with configured keys)
-
Clone the repository
git clone <repository-url> cd Monitor-Agent
-
Set up environment variables
cp env.example .env # Edit .env with your configuration -
Run the application
# Run a scan (default behavior) go run cmd/monitor-agent/main.go # Or explicitly run a scan go run cmd/monitor-agent/main.go scan # Show statistics go run cmd/monitor-agent/main.go stats # Health check go run cmd/monitor-agent/main.go health
-
Build the image
docker build -f docker/Dockerfile -t monitor-agent . -
Run with Docker Compose
cd docker docker-compose up -d -
Run as one-off container
docker run --env-file .env monitor-agent
DB_HOST: PostgreSQL hostDB_PORT: PostgreSQL port (default: 5432)DB_NAME: Database nameDB_USER: Database userDB_PASSWORD: Database passwordDB_SSL_MODE: SSL mode (disable, require, verify-ca, verify-full)DB_SSL_CERT,DB_SSL_KEY,DB_SSL_ROOT_CERT: SSL certificatesDB_CONNECT_TIMEOUT: Connection timeoutDB_MAX_OPEN_CONNS: Maximum open connectionsDB_MAX_IDLE_CONNS: Maximum idle connectionsDB_CONN_MAX_LIFETIME: Connection max lifetime
HACKERONE_USERNAME: HackerOne username (required with API key)HACKERONE_API_KEY: HackerOne API key (optional)BUGCROWD_API_KEY: BugCrowd API key (optional)CHAOSDB_API_KEY: ChaosDB API key (optional)HACKERONE_RATE_LIMIT: HackerOne rate limit (default: 550)BUGCROWD_RATE_LIMIT: BugCrowd rate limit (default: 55)CHAOSDB_RATE_LIMIT: ChaosDB rate limit (default: 55)
LOG_LEVEL: Log level (debug, info, warn, error, fatal)ENVIRONMENT: Environment (development, staging, production)
HTTP_TIMEOUT: HTTP timeoutHTTP_RETRY_ATTEMPTS: Number of retry attemptsHTTP_RETRY_DELAY: Retry delay
CHAOSDB_BULK_SIZE: Bulk size for ChaosDB requests
HTTPX_ENABLED: Enable HTTPX probe for filtering ChaosDB results (default: true)HTTPX_TIMEOUT: HTTPX probe timeout per domain (default: 15s)HTTPX_TOTAL_TIMEOUT: Total timeout for HTTPX probe operations (default: 30m)HTTPX_CONCURRENCY: Number of concurrent HTTPX probes (default: 100)HTTPX_RATE_LIMIT: HTTPX probe rate limit (default: 100)HTTPX_FOLLOW_REDIRECTS: Follow HTTP redirects (default: true)HTTPX_MAX_REDIRECTS: Maximum number of redirects to follow (default: 3)
PROGRAM_PROCESS_TIMEOUT: Maximum time to process a single program (default: 45m)CHAOS_DISCOVERY_TIMEOUT: Maximum time for ChaosDB discovery and HTTPX probing (default: 30m)
Note: API keys are optional. The application will only scan platforms that have valid API keys configured. If no API keys are provided, the application will start but cannot perform scans.
CIRCUIT_BREAKER_*: Circuit breaker settingsWORKER_POOL_*: Worker pool configurationMETRICS_*: Prometheus metrics settingsLOG_*: Logging configurationHEALTH_CHECK_*: Health check settingsAPI_KEY_ROTATION_*: API key rotation settings
monitor-agentormonitor-agent scan: Perform a scan of all platformsmonitor-agent stats: Show program and asset statisticsmonitor-agent health: Perform health checksmonitor-agent help: Show help information
Since this application performs one-off scans, you can schedule it using:
-
System Cron:
# Add to crontab 0 */6 * * * /path/to/monitor-agent
-
Kubernetes CronJob:
apiVersion: batch/v1 kind: CronJob metadata: name: monitor-agent spec: schedule: "0 */6 * * *" jobTemplate: spec: template: spec: containers: - name: monitor-agent image: monitor-agent:latest restartPolicy: OnFailure
-
Docker with external cron:
# Run every 6 hours 0 */6 * * * docker run --env-file .env monitor-agent
- Fetches public programs and their scope
- Rate limited to 600 requests per minute
- Requires both username and API key for authentication
- Uses Basic Authentication with username:api_key format
- Fetches public programs and their scope
- Rate limited to 60 requests per minute per IP
- Supports API key authentication
- Discovers additional subdomains for domains in scope
- Rate limited to 60 requests per minute per IP
- Supports API key authentication for higher limits
- HTTPX Probe Integration: Automatically filters out non-existent domains using Project Discovery's HTTPX library
- Per-Domain Processing: Each domain is processed individually with immediate HTTPX probing
- Immediate Database Storage: Results are saved to database after each domain's processing
- Sequential Processing: Domains are processed one by one to respect ChaosDB rate limits
- Configurable timeout, concurrency, and rate limiting
- Follows redirects and handles various HTTP status codes
- Only saves domains that actually exist and respond to HTTP requests
- Robust Timeout Handling: 15-second per-domain timeout with graceful fallback
- Crash Prevention: Comprehensive panic recovery and error handling
- Out-of-Scope Filtering: Automatically excludes ChaosDB results that match program out-of-scope assets (URLs and wildcards)
The application follows this optimized flow for asset discovery:
- Program Discovery: Fetch all public programs from configured platforms
- Primary Asset Extraction: Extract domain and wildcard assets from program scope
- Out-of-Scope Asset Collection: Collect out-of-scope assets (URLs and wildcards) for filtering
- Per-Domain ChaosDB Discovery: For each domain, discover subdomains using ChaosDB
- Out-of-Scope Filtering: Filter ChaosDB results against program out-of-scope assets
- Immediate HTTPX Probing: Run concurrent HTTPX probes on filtered subdomains
- Database Storage: Save verified assets to database after each domain's processing
The application uses PostgreSQL with the following main tables:
- programs: Bug bounty programs from various platforms
- assets: In-scope assets (domains, subdomains, URLs)
- scans: Scan history and results
Run the test suite:
# Unit tests
go test ./...
# Integration tests
go test ./tests/integration/...
# With coverage
go test -cover ./...- Clean Architecture: Clear separation of concerns
- Repository Pattern: Database abstraction layer
- Dependency Injection: Easy testing and configuration
- Error Handling: Comprehensive error handling throughout
- Structured Logging: JSON logs with correlation IDs
- Metrics Collection: Prometheus metrics for monitoring
- Health Checks: Comprehensive health monitoring
- Circuit Breakers: Fault tolerance for external APIs
- Set up PostgreSQL database with proper SSL configuration
- Configure API keys for all platforms
- Set appropriate rate limits
- Configure logging and monitoring
- Set up external scheduling (cron, Kubernetes CronJob)
- Configure health checks and alerting
- Set up backup and recovery procedures
The application exposes Prometheus metrics at /metrics and provides health check endpoints. Monitor:
- Scan success/failure rates
- API response times and error rates
- Database connection pool status
- Memory and CPU usage
- Asset discovery rates
- Support for additional bug bounty platforms
- Advanced asset discovery techniques
- Real-time notifications
- Web dashboard for monitoring
- Advanced filtering and search capabilities
- Integration with vulnerability scanners
- Automated reporting and analytics
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
[Add your license information here]