- Implemented debug_test_results.py to evaluate WAF test results with detailed request/response logging.
- Created debug_waf.go for logging request details and dumping WAF rules to a file.
- Developed debug_waf.py to extract WAF configuration from Caddy Admin API and test WAF rules with sample requests.
- Added sample_rules.json containing test rules for WAF evaluation.
- Configured test.caddyfile for local testing of WAF with defined rules and logging.
- Enhanced test_anomalythreshold.py to validate anomaly threshold behavior with comprehensive test cases and detailed output.
- Introducing custom types `RuleID` and `HitCount` for better type safety in rule management and hit tracking.
- Refactoring the `loadRules` function to `rules.go` for code reusability and maintainability, and using this function in the main module.
- Implementing type checks on rule hit stats.
- Adding geoip nil reader check in shutdown.
- Improving logging in various areas to aid debugging.
- Log file name when reloading rules.
- Added a buffered channel and background worker for asynchronous logging.
- Modified `logRequest` to queue log entries instead of writing synchronously.
- Updated `Provision` and `Shutdown` to start and stop the logging worker.
- Improved performance by reducing logging overhead in high-traffic scenarios.
- Added graceful shutdown to ensure all logs are written before exiting.
- Added short-circuit mechanism to stop rule evaluation early if a blocking decision is made.
- Replaced `map[string]struct{}` with `*CIDRTrie` for efficient IP blacklist storage and lookups.
- Improved performance by avoiding unnecessary rule evaluations and optimizing CIDR range checks.
- Updated `processRuleMatch`, `handlePhase`, and `loadIPBlacklistIntoMap` to support the new optimizations.
fix: update blockRequest calls to include reason, ruleID, and matchedValue
- Updated all calls to `blockRequest` to include required parameters: `reason`, `ruleID`, and `matchedValue`.
- Fixed argument mismatches by replacing incorrect `zap.String` usage with actual string values.
- Enhanced logging for blocked requests to include detailed context (reason, rule ID, and matched value).
- Ensured compatibility with updated `response.go` changes.
This resolves compilation errors and improves logging for blocked requests.