Enterprise-grade API security discovery tool that automatically finds, analyzes, and risk-scores endpoints across your entire microservice architecture
Protect your APIs before they become vulnerabilities - EndPointHawk discovers hidden attack surfaces that traditional security tools miss.
Developed by @rootranjan
π₯ The Hidden API Security Crisis
Modern applications are leaking attack surfaces faster than security teams can discover them. While organizations invest millions in perimeter security, their internal APIs remain invisible and unprotected.
The Reality:
- Unknown endpoints = Unprotected vulnerabilities - Every undiscovered API is a potential breach vector
- Microservice sprawl creates blind spots - 100+ services with 1000+ endpoints impossible to track manually
- Security reviews can't keep up - APIs change faster than security teams can assess them
- Traditional tools miss dynamic routes - Template literals, environment variables, and dynamic routing create invisible endpoints
- No unified view - Security teams struggle to get a complete picture across frameworks and services
Every undiscovered API endpoint is a potential:
- Data breach - Exposing sensitive customer information
- Privilege escalation - Unauthorized access to admin functions
- Service disruption - Attackers targeting critical business functions
- Compliance violation - Regulatory fines and legal consequences
- Reputation damage - Loss of customer trust and business impact
EndPointHawk provides the missing layer of API security intelligence that automatically discovers, analyzes, and risk-scores every endpoint across your entire microservice architecture - before attackers can find them.
We transform invisible attack surfaces into actionable security intelligence.
- 10+ Framework Support: NestJS, Express, FastAPI, Spring Boot, Go, Django, Flask, NextJS, Ruby Rails, Laravel
- Smart Pattern Matching: Regex-based detection with framework-specific optimizations
- Template Resolution: Resolves dynamic routes and environment variables
- Gemini Integration: Advanced semantic analysis of route security
- Risk Scoring: Automated vulnerability assessment (0-100 scale)
- Security Insights: CWE mapping and remediation recommendations
- Multiple Formats: JSON, HTML, CSV, SARIF for security tools
- Rich Dashboards: Interactive reports with risk breakdowns
- Compliance Ready: Enterprise security reporting standards
- Git Integration: Compare API changes between branches/tags/releases
- Smart Author Attribution: Distinguishes between original authors and merge committers
- Line-by-Line Tracking: Each route shows its actual author, not just the last committer
- Directory Comparison: Analyze differences between deployments
- Risk Impact Analysis: Assess security implications of route changes
- Authorship History: Optional complete timeline of all authors who touched each route
- Parallel Processing: Multi-threaded scanning with 2-8 worker threads (3-5x faster)
- Intelligent Caching: In-memory file caching with thread-safe operations
- Optimized File Discovery: Single glob patterns instead of multiple rglob calls (2-3x faster)
- Memory Management: Automatic cache clearing and memory monitoring
- Docker Optimized: Special handling for CI/CD environments with reduced I/O overhead
- Python 3.8 or higher
- pip (Python package installer)
- Git (for comparison features)
# 1. Clone the repository
git clone https://github.com/rootranjan/endpointhawk.git
cd endpointhawk
# 2. Install dependencies
python3 -m pip install -r requirements.txt
# 3. Verify installation
python3 endpointhawk.py --help# 1. Clone the repository
git clone https://github.com/rootranjan/endpointhawk.git
cd endpointhawk
# 2. Create and activate virtual environment
python3 -m venv venv
source venv/bin/activate # macOS/Linux
# venv\Scripts\activate # Windows
# 3. Install dependencies
pip install -r requirements.txt
# 4. Use the tool
python3 endpointhawk.py --help# Install globally (requires sudo/admin)
sudo pip install -e .
endpointhawk --help# Start the web interface
python3 web_cli_bridge.py
# Open in browser: http://localhost:8182# Navigate to your project directory
cd /path/to/your/project
# Run your first scan
python3 /path/to/endpointhawk/endpointhawk.py --repo-path . --frameworks auto
# View results in terminal or check the generated reports# Scan a repository
python3 endpointhawk.py --repo-path /path/to/repo --frameworks auto
# Scan with specific frameworks
python3 endpointhawk.py --repo-path /path/to/repo --frameworks nextjs,express
# Generate different output formats
python3 endpointhawk.py --repo-path /path/to/repo --output-format json,csv,sarif# Start the web interface
python3 web_cli_bridge.py
# Open in browser: http://localhost:8182# Install as package for global access
pip install -e .
endpointhawk --help
endpointhawk-web # Web interfaceIf you see import errors like:
import rich.console could not be resolved
import flask_cors could not be resolved
Solution: Install the dependencies:
python3 -m pip install -r requirements.txt-
"command not found: pip"
- Use
python3 -m pipinstead ofpip - Or install pip:
python3 -m ensurepip --upgrade
- Use
-
Permission errors
- Use
python3 -m pip install --user -r requirements.txt - Or use a virtual environment
- Use
-
Python version issues
- Ensure Python 3.8+ is installed
- Check with:
python3 --version
# Create virtual environment
python3 -m venv venv
# Activate (macOS/Linux)
source venv/bin/activate
# Activate (Windows)
venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Use EndPointHawk
python3 endpointhawk.py --helpclick>=8.0.0- CLI frameworkrich>=13.0.0- Terminal formatting and progress barspydantic>=2.0.0- Data models and validationpyyaml>=6.0- YAML configuration files
flask>=2.3.0- Web frameworkflask-cors>=4.0.0- Cross-origin resource sharing
pyyaml>=6.0- YAML configuration filesschedule>=1.2.0- Task scheduling
google-generativeai>=0.3.0- Google Gemini AI integration
GitPython>=3.1.40- Git repository operationspathspec>=0.11.0- Enhanced gitignore pattern matchingjsondiff>=2.0.0- Enhanced JSON diffing
If you encounter issues:
- Check this troubleshooting guide
- Ensure all dependencies are installed
- Try using a virtual environment
- Check Python version compatibility
- Open an issue on GitHub with error details
# Error: ModuleNotFoundError: No module named 'rich'
# Solution: Install dependencies
python3 -m pip install -r requirements.txt# Error: Permission denied
# Solution: Use virtual environment or --user flag
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt# Error: Python version not supported
# Solution: Check Python version
python3 --version # Should be 3.8+
# Install Python 3.8+ if needed
# macOS: brew install python@3.9
# Ubuntu: sudo apt install python3.9
# Windows: Download from python.org# Error: Repository path not found
# Solution: Use absolute paths or check directory
python3 endpointhawk.py --repo-path /absolute/path/to/repo# Error: Cannot connect to Gemini API
# Solution: Check internet connection and API key
export GEMINI_API_KEY=your_api_key_here
# Or disable AI analysis: --no-ai# Error: Out of memory on large repositories
# Solution: Use memory-optimized mode
python3 endpointhawk.py --repo-path . --performance-mode memory-optimized --max-memory 512# 1. Basic scan of current directory (automatically optimized)
python3 endpointhawk.py --repo-path . --frameworks auto
# 2. Scan with HTML report
python3 endpointhawk.py --repo-path . --output-format html --output-dir ./reports
# 3. Open the HTML report in your browser
open ./reports/endpointhawk_report.html # macOS
# xdg-open ./reports/endpointhawk_report.html # Linux
# start ./reports/endpointhawk_report.html # WindowsPerformance Note: All scans now use parallel processing and intelligent caching for 3-5x faster results!
# Scan with AI analysis and high-risk detection
python3 endpointhawk.py \
--repo-path . \
--use-ai \
--risk-threshold high \
--output-format html,sarif
# Compare API changes between versions
python3 endpointhawk.py \
--repo-path . \
--compare-tags v1.0.0,v2.0.0# Comprehensive analysis with all features
python3 endpointhawk.py \
--repo-path /path/to/your/project \
--use-ai \
--risk-threshold high \
--output-format html,csv,sarif \
--performance-mode fast \
--cache-enabled
# Performance-optimized scan for large repositories
python3 endpointhawk.py \
--repo-path /path/to/your/project \
--performance-mode fast \
--cache-enabled \
--max-workers 8
# Web interface for interactive analysis
python3 web_cli_bridge.py
# Access dashboard at http://localhost:8182EndPointHawk provides powerful comparison capabilities to track API changes across versions, releases, and deployments.
Compare two local directories to identify API changes between different versions or deployments.
# Compare current repository against an older version
python3 endpointhawk.py \
--repo-path /path/to/current/repo \
--compare-dir /path/to/old/version \
--output-format json,html
# Compare two different deployments
python3 endpointhawk.py \
--repo-path /path/to/production/deployment \
--compare-dir /path/to/staging/deployment \
--no-ai \
--output-format jsonStandard Convention (Recommended):
- Source (
--repo-path): Latest/Current version (what you have now) - Target (
--compare-dir): Old/Previous version (what you're comparing against)
Results Interpretation:
- ADDED routes: New endpoints in the latest version
- REMOVED routes: Endpoints that existed in the old version but are no longer available
- MODIFIED routes: Endpoints that changed between versions
Example:
# Current repo (latest) vs Old version (v1.0.0)
python3 endpointhawk.py \
--repo-path /path/to/current/repo \
--compare-dir /path/to/old/repo-v1.0.0
# Results show:
# - 25 ADDED routes (new in latest)
# - 150 REMOVED routes (removed from v1.0.0)
# - 175 HIGH RISK changes (security implications)EndPointHawk provides precise, line-by-line authorship tracking that distinguishes between original authors and merge committers.
Problem Solved:
- Before: All routes showed the last committer (e.g., "John Doe" who merged the PR)
- After: Each route shows its actual author (e.g., "Alice Chen" who wrote the code)
Example Scenario:
# GitLab commit history:
# Commit 707b7703 by Alice Chen - Add user management routes
# Commit a9fdb7c0 by Bob Smith - Add payment processing endpoint
# Both merged by John Doe
# JSON output shows accurate attribution:
{
"new_route": {
"path": "/api/users/management",
"commit_author": "Alice Chen", # Original author
"commit_author_email": "alice.chen@company.com"
},
"new_route": {
"path": "/api/payments/process",
"commit_author": "Bob Smith", # Original author
"commit_author_email": "bob.smith@company.com"
}
}Configuration Options:
# Basic tracking (original authors - default)
python3 endpointhawk.py \
--repo-path /path/to/repo \
--compare-dir /path/to/old/version \
--include-commit-info \
--output-format json
# With complete authorship history
python3 endpointhawk.py \
--repo-path /path/to/repo \
--compare-dir /path/to/old/version \
--include-commit-info \
--output-format json \
--config config-with-history.yamlBenefits:
- β Accurate Attribution: Know exactly who wrote each route
- β Security Accountability: Contact the right developers for security issues
- β Team Insights: Track individual developer contributions
- β Merge Commit Handling: Distinguishes between original authors and merge committers
Compare API changes between different git tags or releases.
# Compare two specific versions
python3 endpointhawk.py \
--repo-path /path/to/repo \
--compare-tags v1.0.0,v2.0.0 \
--output-format json,html
# Compare against a specific tag
python3 endpointhawk.py \
--repo-path /path/to/repo \
--compare-against-tag v1.0.0 \
--output-format jsonCompare API changes between different branches.
# Compare main vs develop branch
python3 endpointhawk.py \
--repo-path /path/to/repo \
--compare-branches main,develop \
--output-format json,html
# Compare feature branch against main
python3 endpointhawk.py \
--repo-path /path/to/repo \
--compare-branches feature/new-api,main \
--output-format json# Filter by framework
python3 endpointhawk.py \
--repo-path /path/to/repo \
--compare-dir /path/to/old/version \
--filter-by "framework=express,nestjs"
# Filter by HTTP method
python3 endpointhawk.py \
--repo-path /path/to/repo \
--compare-dir /path/to/old/version \
--filter-by "method=POST,PUT,DELETE"
# Filter by path pattern
python3 endpointhawk.py \
--repo-path /path/to/repo \
--compare-dir /path/to/old/version \
--filter-by "path=/api/*"
# Combine multiple filters
python3 endpointhawk.py \
--repo-path /path/to/repo \
--compare-dir /path/to/old/version \
--filter-by "framework=express;method=POST,PUT;path=/api/v1/*"# Strict comparison (exact matches only)
python3 endpointhawk.py \
--repo-path /path/to/repo \
--compare-dir /path/to/old/version \
--diff-algorithm strict
# Fuzzy comparison (similar routes)
python3 endpointhawk.py \
--repo-path /path/to/repo \
--compare-dir /path/to/old/version \
--diff-algorithm fuzzy
# Hybrid comparison (recommended)
python3 endpointhawk.py \
--repo-path /path/to/repo \
--compare-dir /path/to/old/version \
--diff-algorithm hybrid# Include file structure changes
python3 endpointhawk.py \
--repo-path /path/to/repo \
--compare-dir /path/to/old/version \
--include-file-changes \
--output-format json,htmlpython3 endpointhawk.py \
--repo-path /path/to/repo \
--compare-dir /path/to/old/version \
--output-format json \
--output-dir ./comparison-reportsJSON Structure:
{
"comparison_summary": {
"source_version": "/path/to/current/repo",
"target_version": "/path/to/old/version",
"comparison_type": "directories",
"route_changes": {
"ADDED": 33,
"REMOVED": 1916,
"MODIFIED": 0
},
"total_route_changes": 1949
},
"changes": [
{
"change_type": "REMOVED",
"risk_impact": "HIGH",
"old_route": {
"path": "/api/users/{id}",
"method": "GET",
"framework": "express",
"risk_level": "HIGH"
}
}
]
}python3 endpointhawk.py \
--repo-path /path/to/repo \
--compare-dir /path/to/old/version \
--output-format html \
--output-dir ./comparison-reports# Audit API changes for security implications
python3 endpointhawk.py \
--repo-path /path/to/production/repo \
--compare-against-tag v1.0.0 \
--risk-threshold high \
--output-format html,json# Plan breaking changes for API consumers
python3 endpointhawk.py \
--repo-path /path/to/repo \
--compare-tags v1.0.0,v2.0.0 \
--output-format html,csv# Assess impact of API changes on integrations
python3 endpointhawk.py \
--repo-path /path/to/new/architecture \
--compare-dir /path/to/legacy/system \
--filter-by "framework=express" \
--output-format json# Track API changes for compliance requirements
python3 endpointhawk.py \
--repo-path /path/to/repo \
--compare-against-tag compliance-baseline \
--output-format sarif,html- Directory Comparison: Requires both directories to exist locally
- Git Comparison: Requires git repository with proper history
- Commit Metadata: Only available for git-based comparisons
- Performance: Large repositories may take significant time
- Memory Usage: Enable caching for repeated comparisons
| Comparison Type | Source | Target | Use Case |
|---|---|---|---|
| Directory | Latest version | Old version | Deployment comparison |
| Git Tags | Newer tag | Older tag | Release comparison |
| Git Branches | Target branch | Source branch | Feature comparison |
| Against Tag | Current state | Specific tag | Baseline comparison |
Standard Convention: Source = Newer/Current, Target = Older/Previous
Create .env file for optional features:
# AI Analysis (Optional)
GEMINI_API_KEY=your_gemini_api_key_here
# GitLab Integration (Optional)
GITLAB_TOKEN=your_gitlab_token_here
GITLAB_URL=https://gitlab.com
# Web Interface
FLASK_ENV=development
SECRET_KEY=your_secret_key_here# Auto-detect frameworks (default)
--frameworks auto
# Specify frameworks explicitly
--frameworks nestjs,express,fastapi,go
# Scan all supported frameworks
--frameworks all# Terminal output (default)
--output-format terminal
# Multiple formats
--output-format json,html,csv,sarif
# Custom output directory
--output-dir ./security-reports# Memory optimization for large repos
--performance-mode memory-optimized --max-memory 2048
# Fast scanning mode
--performance-mode fast --max-workers 8
# Enable intelligent caching
--cache-enabled --cache-cleanup 7
# Parallel processing (automatically enabled)
# Uses 2-8 workers based on repository size
# Small repos: 2 workers, Medium: 4-6 workers, Large: 6-8 workersPerformance Improvements:
- 3-5x faster directory comparison (8+ minutes β 1-3 minutes)
- 2-3x faster file discovery with optimized glob patterns
- 50-70% reduction in I/O operations with intelligent caching
- Automatic optimization based on repository size
Create a config.yaml file for custom settings:
# config.yaml
version: '1.0'
# Organization settings
organization:
organization_name: "My Company"
security_baseline: "standard"
# Enable specific frameworks
frameworks:
enabled_frameworks:
- "nestjs"
- "express"
- "fastapi"
# Security settings
security:
default_risk_threshold: "medium"
enable_ai_analysis: true
# Output settings
output:
default_formats:
- "html"
- "json"Use the configuration:
python3 endpointhawk.py --repo-path . --config config.yaml| Framework | Language | Detection Features | Template Support |
|---|---|---|---|
| NestJS | TypeScript/JavaScript | Controllers, Decorators, Guards | β Variables & Enums |
| Express | JavaScript | Routes, Middleware, Routers | β Template Literals |
| FastAPI | Python | Path Operations, Dependencies | β Path Parameters |
| Spring Boot | Java | Controllers, REST Mappings | β Path Variables |
| Go HTTP | Go | Handlers, Mux Routers | β Route Patterns |
| Django | Python | URLs, Views, Class-Based Views | β URL Patterns |
| Flask | Python | Routes, Blueprints | β Variable Rules |
| NextJS | TypeScript/JavaScript | API Routes, App Router | β Dynamic Routes |
| Ruby Rails | Ruby | Routes, Controllers | β RESTful Routes |
| Laravel | PHP | Routes, Controllers | β Route Parameters |
π¦
EndPointHawk Attack Surface Discovery Complete!
βββββββββββββββββββββββ¬ββββββββββ
β Metric β Count β
βββββββββββββββββββββββΌββββββββββ€
β Total Routes β 1,247 β
β High Risk Routes β 23 β
β Medium Risk Routes β 156 β
β Low Risk Routes β 1,068 β
β Services Found β 12 β
β Frameworks Detected β 4 β
β Scan Duration β 3.2s β
βββββββββββββββββββββββ΄ββββββββββ
π¨ High Risk Routes:
β’ DELETE /admin/users/:id (Unauthenticated admin endpoint)
β’ POST /api/exec (Command execution endpoint)
β’ GET /debug/env (Environment disclosure)
{
"scan_id": "hawk_20240120_143022",
"total_routes": 1247,
"high_risk_routes": 23,
"frameworks_detected": ["nestjs", "express", "fastapi"],
"routes": [
{
"path": "/api/v1/users/:id",
"method": "GET",
"framework": "express",
"authenticated": true,
"risk_score": 25.5,
"security_findings": []
}
]
}EndPointHawk analyzes API routes and endpoints to identify potential security vulnerabilities and risks. Each finding includes a severity level, description, and recommendations for mitigation.
- Missing Authentication (HIGH) - API endpoint lacks authentication mechanisms
- Weak Authentication (MEDIUM) - Authentication mechanism is present but may be weak
- Missing Authorization (HIGH) - Endpoint lacks proper authorization checks
- Missing Input Validation (MEDIUM) - API parameters lack proper validation
- Weak Input Validation (LOW) - Input validation is present but may be insufficient
- Sensitive Data Exposure (HIGH) - Endpoint may expose sensitive information
- Excessive Data Exposure (MEDIUM) - Endpoint returns more data than necessary
- Missing Security Headers (MEDIUM) - API responses lack important security headers
- Missing Rate Limiting (MEDIUM) - API endpoint lacks rate limiting
- Information Disclosure in Errors (MEDIUM) - Error responses may reveal sensitive information
- Insecure Direct Object Reference (HIGH) - API uses predictable resource identifiers
- Missing CSRF Protection (MEDIUM) - API lacks CSRF protection mechanisms
- HIGH - Critical security vulnerabilities requiring immediate attention
- MEDIUM - Moderate security risks to be addressed in reasonable timeframe
- LOW - Minor security concerns for regular maintenance
- Prioritize HIGH severity findings for immediate remediation
- Review MEDIUM severity findings within the next sprint/iteration
- Address LOW severity findings during regular code reviews
- Implement security testing in your CI/CD pipeline
- Regular security audits of your API endpoints
Every contribution to EndPointHawk directly impacts API security worldwide. Whether you're a security researcher, developer, or DevOps engineer, your expertise helps protect thousands of APIs from vulnerabilities.
Your contributions help:
- π Discover hidden attack surfaces in modern microservices
- π¨ Prevent data breaches through early vulnerability detection
- β‘ Accelerate security reviews with automated analysis
- π― Protect real applications used by millions of users
π Complete contributor guide: CONTRIBUTING.md
Most impactful contributions:
- π§ Framework Support - Add detection for new frameworks (Spring Boot, FastAPI, etc.)
- π‘οΈ Security Rules - Enhance vulnerability detection algorithms
- β‘ Performance - Optimize scanning for large enterprise codebases
- π Reporting - Improve security findings and risk assessment
- π Integration - Add support for CI/CD pipelines and security tools
- Framework Detection: Your new detector could secure 1000+ APIs using that framework
- Security Rules: Your vulnerability pattern could prevent the next major breach
- Performance: Your optimization could scan enterprise repos 10x faster
- Documentation: Your guide could help 100+ security teams adopt EndPointHawk
Ready to make a difference? Start with CONTRIBUTING.md π¦
- π CI/CD Integration - Automated security scanning in GitHub Actions, GitLab CI, Jenkins
- π» IDE Extensions - Real-time API discovery in VS Code, IntelliJ, Eclipse
- βΈοΈ Kubernetes Discovery - Runtime API endpoint discovery in containerized environments
- π GraphQL Analysis - Schema and resolver security analysis
- π API Spec Generation - Auto-generate OpenAPI/Swagger documentation
- βοΈ Cloud Integration - AWS API Gateway, Azure APIM, Google Cloud Endpoints
- π€ Advanced AI Models - Custom vulnerability detection and pattern learning
- π Advanced Analytics - Security trend analysis and compliance reporting
- π SSO Integration - Enterprise authentication and role-based access
- π Performance Monitoring - Real-time scanning performance metrics
- π§ Plugin System - Extensible framework for custom detectors
- π± Mobile API Support - iOS/Android API endpoint discovery
- π Multi-language Support - Internationalization for global teams
- π Learning Resources - Interactive tutorials and security best practices
This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0).
- β Free for non-commercial use - Open source, research, education
- β Modification allowed - Fork, modify, improve
- β Distribution allowed - Share with others
β οΈ Commercial use restrictions - Contact for commercial licensing- π Source code disclosure required - Any modifications must be open source
For commercial use, enterprise support, or proprietary integrations, please contact:
- π§ Email: rootranjan+endpointhawk@gmail.com
- π¬ GitHub: @rootranjan
Ranjan Kumar (@rootranjan) is a Security Engineer specializing in API security and attack surface management. With expertise in modern web frameworks and microservice architectures, Ranjan developed EndPointHawk to address the critical gap in automated API security discovery.
Contact & Support:
- π§ Email: rootranjan+endpointhawk@gmail.com
- π¬ GitHub Issues: Create an issue for support
- π Security Reports: SECURITY.md for vulnerability disclosure
EndPointHawk wouldn't be possible without:
- π OWASP Community - For API security research and best practices
- π οΈ Framework Developers - For creating the amazing frameworks we secure
- π§ͺ Security Researchers - For vulnerability research and attack patterns
- π‘ Open Source Contributors - For continuous improvements and feedback
- π’ Enterprise Users - For real-world testing and feature requests
Found a security vulnerability in EndPointHawk? Please report it privately to @rootranjan before public disclosure. See SECURITY.md for our security policy.
EndPointHawk integrates seamlessly with your CI/CD pipeline to provide automated API security scanning. Here are practical examples for different platforms:
# .github/workflows/api-security-scan.yml
name: API Security Scan
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
schedule:
- cron: '0 2 * * *' # Daily at 2 AM
jobs:
api-security:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for git comparison
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install EndPointHawk
run: |
git clone https://github.com/rootranjan/endpointhawk.git
cd endpointhawk
pip install -r requirements.txt
- name: Run API Security Scan
run: |
cd endpointhawk
python3 endpointhawk.py \
--repo-path ../ \
--frameworks auto \
--use-ai \
--risk-threshold medium \
--output-format json,sarif \
--output-dir ./security-reports
- name: Upload SARIF results
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: endpointhawk/security-reports/endpointhawk_report.sarif
- name: Comment PR with findings
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const report = JSON.parse(fs.readFileSync('endpointhawk/security-reports/endpointhawk_report.json', 'utf8'));
const highRiskRoutes = report.routes.filter(r => r.risk_score >= 70);
const mediumRiskRoutes = report.routes.filter(r => r.risk_score >= 40 && r.risk_score < 70);
let comment = `## π¦
EndPointHawk Security Scan Results\n\n`;
comment += `**Total Routes Scanned:** ${report.total_routes}\n`;
comment += `**High Risk Routes:** ${highRiskRoutes.length}\n`;
comment += `**Medium Risk Routes:** ${mediumRiskRoutes.length}\n\n`;
if (highRiskRoutes.length > 0) {
comment += `### π¨ High Risk Routes Found:\n`;
highRiskRoutes.forEach(route => {
comment += `- \`${route.method} ${route.path}\` (Risk: ${route.risk_score})\n`;
});
comment += `\nβ οΈ **Please review these high-risk endpoints before merging.**\n`;
}
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});# .gitlab-ci.yml
stages:
- security
api-security-scan:
stage: security
image: python:3.9-slim
before_script:
- apt-get update && apt-get install -y git
- git clone https://github.com/rootranjan/endpointhawk.git
- cd endpointhawk
- pip install -r requirements.txt
script:
- python3 endpointhawk.py \
--repo-path ../ \
--frameworks auto \
--use-ai \
--risk-threshold medium \
--output-format json,html \
--output-dir ./security-reports
artifacts:
reports:
security: endpointhawk/security-reports/endpointhawk_report.json
paths:
- endpointhawk/security-reports/
expire_in: 30 days
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH// Jenkinsfile
pipeline {
agent any
stages {
stage('API Security Scan') {
steps {
script {
// Checkout code
checkout scm
// Install EndPointHawk
sh '''
git clone https://github.com/rootranjan/endpointhawk.git
cd endpointhawk
pip install -r requirements.txt
'''
// Run security scan
sh '''
cd endpointhawk
python3 endpointhawk.py \
--repo-path ../ \
--frameworks auto \
--use-ai \
--risk-threshold high \
--output-format json,sarif,html \
--output-dir ./security-reports
'''
// Archive results
archiveArtifacts artifacts: 'endpointhawk/security-reports/**/*'
// Parse results for pipeline decision
def report = readJSON file: 'endpointhawk/security-reports/endpointhawk_report.json'
def highRiskCount = report.routes.count { it.risk_score >= 70 }
if (highRiskCount > 0) {
error "Found ${highRiskCount} high-risk API endpoints. Pipeline blocked for security review."
}
}
}
}
}
post {
always {
// Publish security report
publishHTML([
allowMissing: false,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: 'endpointhawk/security-reports',
reportFiles: 'endpointhawk_report.html',
reportName: 'API Security Report'
])
}
}
}# api-security-scan-job.yaml
apiVersion: batch/v1
kind: Job
metadata:
name: api-security-scan
spec:
template:
spec:
containers:
- name: endpointhawk
image: python:3.9-slim
command:
- /bin/bash
- -c
- |
apt-get update && apt-get install -y git
git clone https://github.com/rootranjan/endpointhawk.git
cd endpointhawk
pip install -r requirements.txt
# Clone your repository
git clone $REPO_URL /workspace
cd /workspace
# Run security scan
cd ../endpointhawk
python3 endpointhawk.py \
--repo-path /workspace \
--frameworks auto \
--use-ai \
--risk-threshold medium \
--output-format json,html \
--output-dir ./security-reports
# Upload results to artifact storage
# (Configure based on your setup)
env:
- name: REPO_URL
value: "https://github.com/your-org/your-repo.git"
- name: GEMINI_API_KEY
valueFrom:
secretKeyRef:
name: endpointhawk-secrets
key: gemini-api-key
restartPolicy: Never
backoffLimit: 3# Compare against previous release
python3 endpointhawk.py \
--repo-path . \
--compare-tags v1.0.0,v1.1.0 \
--risk-analysis \
--output-format json,sarif
# Compare against main branch
python3 endpointhawk.py \
--repo-path . \
--compare-branches main,feature/new-api \
--include-file-changes \
--output-format json# Fast scanning for CI/CD environments (automatically optimized)
python3 endpointhawk.py \
--repo-path . \
--performance-mode fast \
--cache-enabled \
--max-workers 4 \
--max-memory 512 \
--output-format jsonAutomatic Optimizations:
- Parallel processing with adaptive worker allocation
- Docker-optimized progress reporting for CI/CD environments
- Memory management with automatic cache clearing
- File discovery optimization for faster scanning
# Use enterprise configuration
python3 endpointhawk.py \
--repo-path . \
--config enterprise-config.yaml \
--enterprise-report security \
--output-format html,json,sarif- Scan on every PR - Catch security issues before merging
- Block high-risk findings - Fail pipeline for critical vulnerabilities
- Generate SARIF reports - Integrate with security tools
- Use caching - Speed up repeated scans
- Set appropriate thresholds - Balance security vs. development speed
- Archive reports - Keep historical security data
- Notify security team - Alert on critical findings
- API Keys: Store
GEMINI_API_KEYas CI/CD secrets - Repository Access: Use appropriate authentication for private repos
- Output Security: Don't expose sensitive findings in public logs
- Rate Limiting: Respect API limits in CI/CD environments
EndPointHawk is optimized for Docker deployment, making it perfect for scanning multiple repositories across different environments.
# Build the Docker image
docker build -t endpointhawk:latest .
# Run a quick scan
docker run --rm -v $(pwd):/workspace endpointhawk:latest \
--repo-path /workspace \
--frameworks auto \
--output-format json,html# Create directory structure
mkdir -p repos reports cache config
# Clone your repositories
git clone https://github.com/your-org/api-service.git repos/api-service
git clone https://github.com/your-org/user-service.git repos/user-service
git clone https://github.com/your-org/payment-service.git repos/payment-service
# Run CLI scan
docker-compose --profile cli up endpointhawk-cli
# Run web interface
docker-compose --profile web up endpointhawk-web# batch-config.json
{
"repositories": [
{
"name": "api-service",
"url": "https://github.com/your-org/api-service.git",
"branch": "main",
"frameworks": ["nestjs", "express"]
},
{
"name": "user-service",
"url": "https://github.com/your-org/user-service.git",
"branch": "develop",
"frameworks": ["fastapi", "django"]
},
{
"name": "payment-service",
"url": "https://github.com/your-org/payment-service.git",
"branch": "main",
"frameworks": ["spring", "go"]
}
],
"scan_config": {
"risk_threshold": "high",
"use_ai": true,
"output_formats": ["json", "html", "sarif"]
}
}# Run batch scan
docker-compose --profile batch up endpointhawk-batch# Run scheduled scans (daily at 2 AM)
docker-compose --profile scheduler up endpointhawk-scheduler
# Custom schedule (every 6 hours)
SCAN_SCHEDULE="0 */6 * * *" docker-compose --profile scheduler up endpointhawk-scheduler# .env file
GEMINI_API_KEY=your_gemini_api_key_here
SECRET_KEY=your_secret_key_here
SCAN_SCHEDULE=0 2 * * * # Daily at 2 AM# Mount repositories
-v ./repos:/workspace:ro
# Mount reports output
-v ./reports:/reports
# Mount cache for performance
-v ./cache:/cache
# Mount custom configurations
-v ./config:/app/config:rodocker run --rm \
-v $(pwd):/workspace \
-v ./reports:/reports \
-v ./cache:/cache \
endpointhawk:latest \
--repo-path /workspace \
--performance-mode fast \
--max-workers 4 \
--max-memory 512 \
--cache-enabled \
--output-format jsondocker run --rm \
-v $(pwd):/workspace \
-v ./reports:/reports \
-v ./cache:/cache \
--memory=1g \
endpointhawk:latest \
--repo-path /workspace \
--performance-mode memory-optimized \
--max-memory 512 \
--output-format json# endpointhawk-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: endpointhawk
spec:
replicas: 1
selector:
matchLabels:
app: endpointhawk
template:
metadata:
labels:
app: endpointhawk
spec:
containers:
- name: endpointhawk
image: endpointhawk:latest
env:
- name: GEMINI_API_KEY
valueFrom:
secretKeyRef:
name: endpointhawk-secrets
key: gemini-api-key
volumeMounts:
- name: repos
mountPath: /workspace
readOnly: true
- name: reports
mountPath: /reports
- name: cache
mountPath: /cache
resources:
requests:
memory: "512Mi"
cpu: "250m"
limits:
memory: "1Gi"
cpu: "500m"
volumes:
- name: repos
persistentVolumeClaim:
claimName: repos-pvc
- name: reports
persistentVolumeClaim:
claimName: reports-pvc
- name: cache
persistentVolumeClaim:
claimName: cache-pvc# Deploy to Docker Swarm
docker stack deploy -c docker-compose.yml endpointhawk
# Scale services
docker service scale endpointhawk_endpointhawk-cli=3- β
Non-root user - Container runs as
endpointhawkuser - β Read-only mounts - Repository mounts are read-only
- β Secrets management - Use Docker secrets for API keys
- β Resource limits - Set memory and CPU limits
- β Multi-stage builds - Optimized image size
- β Volume caching - Persistent cache across runs
- β Parallel scanning - Multiple workers for large repos (2-8 workers)
- β Health checks - Container health monitoring
- β Automatic optimization - 3-5x faster directory comparison
- β Memory management - Automatic cache clearing and monitoring
# Check container health
docker ps --filter "name=endpointhawk"
# View logs
docker logs endpointhawk-cli
# Monitor resource usage
docker stats endpointhawk-clidocker run --rm \
-v $(pwd):/workspace \
-v ./reports:/reports \
endpointhawk:latest \
--repo-path /workspace \
--frameworks auto \
--use-ai \
--risk-threshold high \
--output-format json,html,sarif# Scan all repos in directory
for repo in repos/*; do
docker run --rm \
-v $(pwd)/$repo:/workspace \
-v ./reports:/reports \
-v ./cache:/cache \
endpointhawk:latest \
--repo-path /workspace \
--frameworks auto \
--output-format json,html
done# In your CI/CD pipeline
docker run --rm \
-v $CI_PROJECT_DIR:/workspace \
-v $CI_PROJECT_DIR/reports:/reports \
endpointhawk:latest \
--repo-path /workspace \
--frameworks auto \
--risk-threshold medium \
--output-format json,sarif- Quick Start Guide - Get up and running in minutes
- Installation Guide - Detailed installation instructions
- Usage Examples - Common use cases and examples
- Docker Guide - Containerized deployment and usage
- CI/CD Integration Guide - GitLab CI, GitHub Actions, and Jenkins integration
- Security Findings - Understanding security analysis results
- Contributing Guidelines - How to contribute to the project
π¦ EndPointHawk - Securing APIs, one route at a time
Built with β€οΈ by the security community