aiwaf 0.1.9.3.2__tar.gz → 0.1.9.3.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of aiwaf might be problematic. Click here for more details.

Files changed (82) hide show
  1. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/PKG-INFO +46 -5
  2. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/README.md +45 -4
  3. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/__init__.py +1 -1
  4. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/middleware.py +391 -104
  5. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf.egg-info/PKG-INFO +46 -5
  6. aiwaf-0.1.9.3.4/aiwaf.egg-info/SOURCES.txt +79 -0
  7. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/pyproject.toml +1 -1
  8. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/setup.py +1 -1
  9. aiwaf-0.1.9.3.4/tests/test_404_only_learning_django.py +60 -0
  10. aiwaf-0.1.9.3.4/tests/test_aiwaf_reset_django.py +76 -0
  11. aiwaf-0.1.9.3.4/tests/test_basic_import_django.py +126 -0
  12. aiwaf-0.1.9.3.4/tests/test_conservative_path_validation_django.py +47 -0
  13. aiwaf-0.1.9.3.4/tests/test_csv_simple_django.py +48 -0
  14. aiwaf-0.1.9.3.4/tests/test_edge_case_fix_demo_django.py +61 -0
  15. aiwaf-0.1.9.3.4/tests/test_exemption_simple_django.py +49 -0
  16. aiwaf-0.1.9.3.4/tests/test_header_validation_django.py +68 -0
  17. aiwaf-0.1.9.3.4/tests/test_honeypot_enhancements_django.py +75 -0
  18. aiwaf-0.1.9.3.4/tests/test_import_fix_django.py +48 -0
  19. aiwaf-0.1.9.3.4/tests/test_improved_path_validation_django.py +47 -0
  20. aiwaf-0.1.9.3.4/tests/test_include_path_edge_case_django.py +61 -0
  21. aiwaf-0.1.9.3.4/tests/test_keyword_persistence_django.py +48 -0
  22. aiwaf-0.1.9.3.4/tests/test_keyword_protection_django.py +65 -0
  23. aiwaf-0.1.9.3.4/tests/test_keyword_storage_debug_django.py +61 -0
  24. aiwaf-0.1.9.3.4/tests/test_live_web_app_django.py +62 -0
  25. aiwaf-0.1.9.3.4/tests/test_malicious_keywords_fix_django.py +47 -0
  26. aiwaf-0.1.9.3.4/tests/test_method_validation_django.py +170 -0
  27. aiwaf-0.1.9.3.4/tests/test_method_validation_simple_django.py +63 -0
  28. aiwaf-0.1.9.3.4/tests/test_middleware_enhanced_validation_django.py +47 -0
  29. aiwaf-0.1.9.3.4/tests/test_middleware_learning_fix_django.py +60 -0
  30. aiwaf-0.1.9.3.4/tests/test_middleware_logger_django.py +48 -0
  31. aiwaf-0.1.9.3.4/tests/test_middleware_protection_django.py +92 -0
  32. aiwaf-0.1.9.3.4/tests/test_path_validation_flaw_django.py +47 -0
  33. aiwaf-0.1.9.3.4/tests/test_rate_limiting_django.py +48 -0
  34. aiwaf-0.1.9.3.4/tests/test_rate_limiting_pure_logic_django.py +48 -0
  35. aiwaf-0.1.9.3.4/tests/test_real_world_headers_django.py +51 -0
  36. aiwaf-0.1.9.3.4/tests/test_route_keyword_extraction_django.py +60 -0
  37. aiwaf-0.1.9.3.4/tests/test_route_protection_simple_django.py +60 -0
  38. aiwaf-0.1.9.3.4/tests/test_settings.py +165 -0
  39. aiwaf-0.1.9.3.4/tests/test_simplified_honeypot_django.py +52 -0
  40. aiwaf-0.1.9.3.4/tests/test_status_summary.py +86 -0
  41. aiwaf-0.1.9.3.4/tests/test_storage_fix_django.py +61 -0
  42. aiwaf-0.1.9.3.4/tests/test_storage_simple_django.py +48 -0
  43. aiwaf-0.1.9.3.4/tests/test_trainer_enhancements_django.py +78 -0
  44. aiwaf-0.1.9.3.4/tests/test_trainer_functions_django.py +94 -0
  45. aiwaf-0.1.9.3.4/tests/test_unified_keyword_logic_django.py +86 -0
  46. aiwaf-0.1.9.3.4/tests/test_urls.py +28 -0
  47. aiwaf-0.1.9.3.4/tests/test_view_method_detection_django.py +73 -0
  48. aiwaf-0.1.9.3.2/aiwaf.egg-info/SOURCES.txt +0 -40
  49. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/LICENSE +0 -0
  50. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/apps.py +0 -0
  51. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/blacklist_manager.py +0 -0
  52. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/decorators.py +0 -0
  53. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/management/__init__.py +0 -0
  54. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/management/commands/__init__.py +0 -0
  55. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/management/commands/add_exemption.py +0 -0
  56. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/management/commands/add_ipexemption.py +0 -0
  57. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/management/commands/aiwaf_diagnose.py +0 -0
  58. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/management/commands/aiwaf_list.py +0 -0
  59. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/management/commands/aiwaf_logging.py +0 -0
  60. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/management/commands/aiwaf_reset.py +0 -0
  61. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/management/commands/check_dependencies.py +0 -0
  62. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/management/commands/clear_blacklist.py +0 -0
  63. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/management/commands/clear_cache.py +0 -0
  64. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/management/commands/debug_csv.py +0 -0
  65. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/management/commands/detect_and_train.py +0 -0
  66. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/management/commands/diagnose_blocking.py +0 -0
  67. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/management/commands/regenerate_model.py +0 -0
  68. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/management/commands/setup_models.py +0 -0
  69. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/management/commands/test_exemption.py +0 -0
  70. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/management/commands/test_exemption_fix.py +0 -0
  71. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/middleware_logger.py +0 -0
  72. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/models.py +0 -0
  73. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/resources/model.pkl +0 -0
  74. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/storage.py +0 -0
  75. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/templatetags/__init__.py +0 -0
  76. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/templatetags/aiwaf_tags.py +0 -0
  77. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/trainer.py +0 -0
  78. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf/utils.py +0 -0
  79. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf.egg-info/dependency_links.txt +0 -0
  80. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf.egg-info/requires.txt +0 -0
  81. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/aiwaf.egg-info/top_level.txt +0 -0
  82. {aiwaf-0.1.9.3.2 → aiwaf-0.1.9.3.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aiwaf
3
- Version: 0.1.9.3.2
3
+ Version: 0.1.9.3.4
4
4
  Summary: AI-powered Web Application Firewall
5
5
  Home-page: https://github.com/aayushgauba/aiwaf
6
6
  Author: Aayush Gauba
@@ -34,6 +34,7 @@ Dynamic: requires-python
34
34
  - ✅ **Enhanced Configuration** - `AIWAF_ALLOWED_PATH_KEYWORDS` and `AIWAF_EXEMPT_KEYWORDS`
35
35
  - ✅ **Comprehensive HTTP Method Validation** - Blocks GET→POST-only, POST→GET-only, unsupported REST methods
36
36
  - ✅ **Enhanced Honeypot Protection** - POST validation & 4-minute page timeout with smart reload detection
37
+ - ✅ **HTTP Header Validation** - Comprehensive bot detection via header analysis and quality scoring
37
38
 
38
39
  ---
39
40
 
@@ -113,6 +114,50 @@ aiwaf/
113
114
  - **File‑Extension Probing Detection**
114
115
  Tracks repeated 404s on common extensions (e.g. `.php`, `.asp`) and blocks IPs.
115
116
 
117
+ - **🆕 HTTP Header Validation**
118
+ Advanced header analysis to detect bots and malicious requests:
119
+ - **Missing Required Headers** - Blocks requests without User-Agent or Accept headers
120
+ - **Suspicious User-Agents** - Detects curl, wget, python-requests, automated tools
121
+ - **Header Quality Scoring** - Calculates realism score based on browser-standard headers
122
+ - **Legitimate Bot Whitelist** - Allows Googlebot, Bingbot, and other search engines
123
+ - **Header Combination Analysis** - Detects impossible combinations (HTTP/2 + old browsers)
124
+ - **Static File Exemption** - Skips validation for CSS, JS, images
125
+
126
+ ## 🛡️ Header Validation Middleware Features
127
+
128
+ The **HeaderValidationMiddleware** provides advanced bot detection through HTTP header analysis:
129
+
130
+ ### **What it detects:**
131
+ - **Missing Headers**: Requests without standard browser headers
132
+ - **Suspicious User-Agents**: WordPress scanners, exploit tools, basic scrapers
133
+ - **Bot-like Patterns**: Low header diversity, missing Accept headers
134
+ - **Quality Scoring**: 0-11 point system based on header completeness
135
+
136
+ ### **What it allows:**
137
+ - **Legitimate Browsers**: Chrome, Firefox, Safari, Edge with full headers
138
+ - **Search Engine Bots**: Google, Bing, DuckDuckGo, Yandex crawlers
139
+ - **API Clients**: Properly identified with good headers
140
+ - **Static Files**: CSS, JS, images (automatically exempted)
141
+
142
+ ### **Real-world effectiveness:**
143
+ ```
144
+ ✅ Blocks: WordPress scanners, exploit bots, basic scrapers
145
+ ✅ Allows: Real browsers, legitimate bots, API clients
146
+ ✅ Quality Score: 10/11 = Legitimate, 2/11 = Suspicious bot
147
+ ```
148
+
149
+ ### **Testing header validation:**
150
+ ```bash
151
+ # Test with curl (will be blocked - low quality headers)
152
+ curl http://yoursite.com/
153
+
154
+ # Test with browser (will be allowed - high quality headers)
155
+ # Visit site normally in Chrome/Firefox
156
+
157
+ # Check logs for header validation blocks
158
+ python manage.py aiwaf_logging --recent
159
+ ```
160
+
116
161
  - **Enhanced Timing-Based Honeypot**
117
162
  Advanced GET→POST timing analysis with comprehensive HTTP method validation:
118
163
  - Submit forms faster than `AIWAF_MIN_FORM_TIME` seconds (default: 1 second)
@@ -859,7 +904,3 @@ This project is licensed under the **MIT License**. See the [LICENSE](LICENSE) f
859
904
 
860
905
  ---
861
906
 
862
- ## Credits
863
-
864
- **AI‑WAF** by [Aayush Gauba](https://github.com/aayushgauba)
865
- > "Let your firewall learn and evolve — keep your site a fortress." your Django `INSTALLED_APPS` to avoid setup errors.
@@ -11,6 +11,7 @@
11
11
  - ✅ **Enhanced Configuration** - `AIWAF_ALLOWED_PATH_KEYWORDS` and `AIWAF_EXEMPT_KEYWORDS`
12
12
  - ✅ **Comprehensive HTTP Method Validation** - Blocks GET→POST-only, POST→GET-only, unsupported REST methods
13
13
  - ✅ **Enhanced Honeypot Protection** - POST validation & 4-minute page timeout with smart reload detection
14
+ - ✅ **HTTP Header Validation** - Comprehensive bot detection via header analysis and quality scoring
14
15
 
15
16
  ---
16
17
 
@@ -90,6 +91,50 @@ aiwaf/
90
91
  - **File‑Extension Probing Detection**
91
92
  Tracks repeated 404s on common extensions (e.g. `.php`, `.asp`) and blocks IPs.
92
93
 
94
+ - **🆕 HTTP Header Validation**
95
+ Advanced header analysis to detect bots and malicious requests:
96
+ - **Missing Required Headers** - Blocks requests without User-Agent or Accept headers
97
+ - **Suspicious User-Agents** - Detects curl, wget, python-requests, automated tools
98
+ - **Header Quality Scoring** - Calculates realism score based on browser-standard headers
99
+ - **Legitimate Bot Whitelist** - Allows Googlebot, Bingbot, and other search engines
100
+ - **Header Combination Analysis** - Detects impossible combinations (HTTP/2 + old browsers)
101
+ - **Static File Exemption** - Skips validation for CSS, JS, images
102
+
103
+ ## 🛡️ Header Validation Middleware Features
104
+
105
+ The **HeaderValidationMiddleware** provides advanced bot detection through HTTP header analysis:
106
+
107
+ ### **What it detects:**
108
+ - **Missing Headers**: Requests without standard browser headers
109
+ - **Suspicious User-Agents**: WordPress scanners, exploit tools, basic scrapers
110
+ - **Bot-like Patterns**: Low header diversity, missing Accept headers
111
+ - **Quality Scoring**: 0-11 point system based on header completeness
112
+
113
+ ### **What it allows:**
114
+ - **Legitimate Browsers**: Chrome, Firefox, Safari, Edge with full headers
115
+ - **Search Engine Bots**: Google, Bing, DuckDuckGo, Yandex crawlers
116
+ - **API Clients**: Properly identified with good headers
117
+ - **Static Files**: CSS, JS, images (automatically exempted)
118
+
119
+ ### **Real-world effectiveness:**
120
+ ```
121
+ ✅ Blocks: WordPress scanners, exploit bots, basic scrapers
122
+ ✅ Allows: Real browsers, legitimate bots, API clients
123
+ ✅ Quality Score: 10/11 = Legitimate, 2/11 = Suspicious bot
124
+ ```
125
+
126
+ ### **Testing header validation:**
127
+ ```bash
128
+ # Test with curl (will be blocked - low quality headers)
129
+ curl http://yoursite.com/
130
+
131
+ # Test with browser (will be allowed - high quality headers)
132
+ # Visit site normally in Chrome/Firefox
133
+
134
+ # Check logs for header validation blocks
135
+ python manage.py aiwaf_logging --recent
136
+ ```
137
+
93
138
  - **Enhanced Timing-Based Honeypot**
94
139
  Advanced GET→POST timing analysis with comprehensive HTTP method validation:
95
140
  - Submit forms faster than `AIWAF_MIN_FORM_TIME` seconds (default: 1 second)
@@ -836,7 +881,3 @@ This project is licensed under the **MIT License**. See the [LICENSE](LICENSE) f
836
881
 
837
882
  ---
838
883
 
839
- ## Credits
840
-
841
- **AI‑WAF** by [Aayush Gauba](https://github.com/aayushgauba)
842
- > "Let your firewall learn and evolve — keep your site a fortress." your Django `INSTALLED_APPS` to avoid setup errors.
@@ -1,6 +1,6 @@
1
1
  default_app_config = "aiwaf.apps.AiwafConfig"
2
2
 
3
- __version__ = "0.1.9.3.2"
3
+ __version__ = "0.1.9.3.3"
4
4
 
5
5
  # Note: Middleware classes are available from aiwaf.middleware
6
6
  # Import them only when needed to avoid circular imports during Django app loading