11# Security Header Analyzer
22
33[ ![ Python] ( https://img.shields.io/badge/Python-3.8%2B-blue.svg )] ( https://www.python.org/downloads/ )
4- [ ![ Tests] ( https://img.shields.io/badge/tests-478 %20passing-success.svg )] ( https://github.com/itheCreator1/security-header-analyzer/actions )
5- [ ![ Coverage] ( https://img.shields.io/badge/coverage-96 %25-brightgreen.svg )] ( https://github.com/itheCreator1/security-header-analyzer )
4+ [ ![ Tests] ( https://img.shields.io/badge/tests-494 %20passing-success.svg )] ( https://github.com/itheCreator1/security-header-analyzer/actions )
5+ [ ![ Coverage] ( https://img.shields.io/badge/coverage-97 %25-brightgreen.svg )] ( https://github.com/itheCreator1/security-header-analyzer )
66[ ![ License] ( https://img.shields.io/badge/license-MIT-green.svg )] ( LICENSE )
77
88A lightweight Python CLI tool that fetches and analyzes HTTP security headers according to Mozilla and OWASP best practices. This tool is designed for developers, penetration testers, and system administrators who want a quick, reliable way to evaluate the security posture of a website's HTTP response headers.
99
1010## 🚀 Features
1111
1212* ** 15 Security Header Analyzers** : HSTS, CSP, X-Frame-Options, X-Content-Type-Options, Referrer-Policy, Set-Cookie, Cache-Control, Expect-CT, Permissions-Policy, COEP, COOP, CORP, X-XSS-Protection, X-Download-Options, X-Permitted-Cross-Domain-Policies
13- * ** SSRF Protection** : Built-in safeguards against Server-Side Request Forgery attacks
14- * ** Multiple Output Formats** : Human-readable text or JSON for automation
13+ * ** Enhanced SSRF Protection** : Multi-layer validation including intermediate redirect checks and DNS rebinding prevention
14+ * ** Automatic Retry Logic** : Exponential backoff for 429/503 errors and transient network failures
15+ * ** Robust Error Handling** : Graceful handling of malformed CSP policies, analyzer failures, and edge cases
16+ * ** Multiple Output Formats** : Human-readable text or JSON with schema versioning for automation
1517* ** Severity Classification** : Issues categorized as Critical, High, Medium, or Low
16- * ** 96 % Test Coverage** : 478 comprehensive tests ensuring reliability
17- * ** Type Safety** : Full type hints with mypy support
18+ * ** 97 % Test Coverage** : 494 comprehensive tests ensuring reliability
19+ * ** Type Safety** : Full type hints with mypy support and runtime validation
1820* ** CI/CD Ready** : Easy integration with GitHub Actions, GitLab CI, Jenkins
1921* ** Extensible** : Add new header analyzers with minimal code changes
2022
@@ -44,16 +46,39 @@ Run the analyzer from the command line:
4446python -m sha https://example.com
4547```
4648
47- ### Useful options
49+ ### Command-Line Options
4850
4951```
50- --json Outputs results in JSON format
51- --timeout 10 Sets request timeout
52- --no-redirects Disables following HTTP redirects
53- --user-agent "MyBot" Uses a custom User-Agent
54- --debug Shows verbose debug logs
52+ --json Output results in JSON format (with schema version)
53+ --timeout SECONDS Request timeout (1-300 seconds, default: 10)
54+ --no-redirects Disable following HTTP redirects
55+ --max-redirects N Maximum redirects to follow (default: 5)
56+ --user-agent STRING Custom User-Agent string
57+ -v, --verbose Enable verbose output with detailed progress
58+ -q, --quiet Suppress all output except errors and final report
59+ --debug Show full error tracebacks
60+ --version Show version information
5561```
5662
63+ ### Advanced Features
64+
65+ ** Automatic Retry with Exponential Backoff:**
66+ The tool automatically retries failed requests with exponential backoff for:
67+ - HTTP 429 (Too Many Requests) - respects Retry-After header
68+ - HTTP 503 (Service Unavailable) - respects Retry-After header
69+ - Transient network errors (timeouts, connection failures)
70+
71+ ** Enhanced SSRF Protection:**
72+ - Pre-request DNS validation
73+ - Post-redirect DNS rebinding checks
74+ - Intermediate redirect validation (all redirects in chain)
75+ - Private IP range blocking (IPv4 and IPv6)
76+
77+ ** Robust Error Handling:**
78+ - Malformed CSP policies are parsed gracefully with detailed error messages
79+ - Analyzer failures are caught and reported without stopping analysis
80+ - HTTP errors with headers still allow partial analysis
81+
5782## 📖 Documentation
5883
5984- ** [ Architecture Guide] ( docs/architecture-overview.md ) ** - System design, components, and extensibility
@@ -78,7 +103,7 @@ security-header-analyzer/
78103│ ├── reporter.py # Report generation (text/JSON)
79104│ ├── config.py # Configuration and exceptions
80105│ └── analyzers/ # Individual header analyzers (15 total)
81- ├── tests/ # Comprehensive test suite (478 tests, 96 % coverage)
106+ ├── tests/ # Comprehensive test suite (494 tests, 97 % coverage)
82107├── docs/ # Documentation
83108└── .github/ # CI/CD workflows
84109```
0 commit comments