aiwaf 0.1.9.1.2__tar.gz → 0.1.9.1.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.
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/PKG-INFO +223 -2
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/README.md +220 -1
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf/__init__.py +1 -1
- aiwaf-0.1.9.1.4/aiwaf/management/commands/check_dependencies.py +716 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf.egg-info/PKG-INFO +223 -2
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf.egg-info/SOURCES.txt +1 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf.egg-info/requires.txt +2 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/pyproject.toml +4 -2
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/setup.py +3 -1
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/LICENSE +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf/apps.py +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf/blacklist_manager.py +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf/decorators.py +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf/management/__init__.py +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf/management/commands/__init__.py +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf/management/commands/add_exemption.py +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf/management/commands/add_ipexemption.py +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf/management/commands/aiwaf_diagnose.py +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf/management/commands/aiwaf_logging.py +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf/management/commands/aiwaf_reset.py +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf/management/commands/clear_cache.py +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf/management/commands/debug_csv.py +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf/management/commands/detect_and_train.py +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf/management/commands/diagnose_blocking.py +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf/management/commands/regenerate_model.py +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf/management/commands/setup_models.py +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf/management/commands/test_exemption.py +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf/management/commands/test_exemption_fix.py +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf/middleware.py +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf/middleware_logger.py +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf/models.py +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf/resources/model.pkl +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf/storage.py +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf/templatetags/__init__.py +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf/templatetags/aiwaf_tags.py +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf/trainer.py +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf/utils.py +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf.egg-info/dependency_links.txt +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/aiwaf.egg-info/top_level.txt +0 -0
- {aiwaf-0.1.9.1.2 → aiwaf-0.1.9.1.4}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: aiwaf
|
|
3
|
-
Version: 0.1.9.1.
|
|
3
|
+
Version: 0.1.9.1.4
|
|
4
4
|
Summary: AI-powered Web Application Firewall
|
|
5
5
|
Home-page: https://github.com/aayushgauba/aiwaf
|
|
6
6
|
Author: Aayush Gauba
|
|
@@ -14,6 +14,8 @@ Requires-Dist: numpy>=1.21
|
|
|
14
14
|
Requires-Dist: pandas>=1.3
|
|
15
15
|
Requires-Dist: scikit-learn<2.0,>=1.0
|
|
16
16
|
Requires-Dist: joblib>=1.1
|
|
17
|
+
Requires-Dist: packaging>=21.0
|
|
18
|
+
Requires-Dist: requests>=2.25.0
|
|
17
19
|
Dynamic: author
|
|
18
20
|
Dynamic: home-page
|
|
19
21
|
Dynamic: license-file
|
|
@@ -59,7 +61,11 @@ aiwaf/
|
|
|
59
61
|
│ └── dynamic_keywords.json # evolves daily
|
|
60
62
|
├── management/
|
|
61
63
|
│ └── commands/
|
|
62
|
-
│
|
|
64
|
+
│ ├── detect_and_train.py # `python manage.py detect_and_train`
|
|
65
|
+
│ ├── check_dependencies.py # `python manage.py check_dependencies`
|
|
66
|
+
│ ├── add_ipexemption.py # `python manage.py add_ipexemption`
|
|
67
|
+
│ ├── aiwaf_reset.py # `python manage.py aiwaf_reset`
|
|
68
|
+
│ └── aiwaf_logging.py # `python manage.py aiwaf_logging`
|
|
63
69
|
└── LICENSE
|
|
64
70
|
```
|
|
65
71
|
|
|
@@ -104,6 +110,23 @@ aiwaf/
|
|
|
104
110
|
- **Captures response times** for better anomaly detection
|
|
105
111
|
- **Zero configuration** - works out of the box
|
|
106
112
|
|
|
113
|
+
- **Smart Training System**
|
|
114
|
+
AI trainer automatically uses the best available data source:
|
|
115
|
+
- **Primary**: Configured access log files (`AIWAF_ACCESS_LOG`)
|
|
116
|
+
- **Fallback**: Database RequestLog model when files unavailable
|
|
117
|
+
- **Seamless switching** between data sources
|
|
118
|
+
- **Enhanced compatibility** with exemption system
|
|
119
|
+
|
|
120
|
+
- **Dependency Management**
|
|
121
|
+
Built-in dependency checker ensures package compatibility:
|
|
122
|
+
- **Version compatibility** checking (NumPy 2.0 vs pandas, etc.)
|
|
123
|
+
- **Missing dependency** detection
|
|
124
|
+
- **Security vulnerability** scanning
|
|
125
|
+
- **Smart upgrade suggestions** with compatibility validation
|
|
126
|
+
- **Safe automated upgrades** that preserve AIWAF stability
|
|
127
|
+
- **Dry run mode** for testing upgrade plans
|
|
128
|
+
- **Cross-package dependency** analysis and conflict resolution
|
|
129
|
+
|
|
107
130
|
|
|
108
131
|
**Exempt Path & IP Awareness**
|
|
109
132
|
|
|
@@ -189,6 +212,142 @@ python manage.py aiwaf_reset --blacklist-only
|
|
|
189
212
|
python manage.py aiwaf_reset --exemptions-only
|
|
190
213
|
```
|
|
191
214
|
|
|
215
|
+
### Checking Dependencies
|
|
216
|
+
|
|
217
|
+
Check your project's dependencies for updates and compatibility issues:
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
# Basic dependency check
|
|
221
|
+
python manage.py check_dependencies
|
|
222
|
+
|
|
223
|
+
# JSON format output
|
|
224
|
+
python manage.py check_dependencies --format json
|
|
225
|
+
|
|
226
|
+
# Include security vulnerability scanning
|
|
227
|
+
python manage.py check_dependencies --check-security
|
|
228
|
+
|
|
229
|
+
# Dry run - show what would be upgraded
|
|
230
|
+
python manage.py check_dependencies --upgrade --dry-run
|
|
231
|
+
|
|
232
|
+
# Actually upgrade packages safely
|
|
233
|
+
python manage.py check_dependencies --upgrade
|
|
234
|
+
|
|
235
|
+
# Full workflow: check, upgrade, and scan for vulnerabilities
|
|
236
|
+
python manage.py check_dependencies --upgrade --check-security
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
**Core Features:**
|
|
240
|
+
- ✅ **Parses pyproject.toml and requirements.txt**
|
|
241
|
+
- ✅ **Shows current vs latest versions**
|
|
242
|
+
- ✅ **Checks package compatibility** (NumPy 2.0 vs pandas, etc.)
|
|
243
|
+
- ✅ **Detects missing dependencies**
|
|
244
|
+
- ✅ **Security vulnerability scanning** (requires `safety` package)
|
|
245
|
+
- ✅ **Safe package upgrades** (maintains AIWAF stability)
|
|
246
|
+
- ✅ **Dry run mode** for testing upgrade plans
|
|
247
|
+
- ✅ **AIWAF compatibility validation**
|
|
248
|
+
|
|
249
|
+
**Safe Upgrade System:**
|
|
250
|
+
|
|
251
|
+
The upgrade system is designed to maintain AIWAF stability while keeping your packages up to date:
|
|
252
|
+
|
|
253
|
+
| Protection Level | Description | Example |
|
|
254
|
+
|------------------|-------------|---------|
|
|
255
|
+
| 🛡️ **AIWAF Core** | Never upgrades AIWAF itself | Skips `aiwaf` package |
|
|
256
|
+
| 🔒 **Breaking Changes** | Avoids known problematic versions | Blocks NumPy 2.0+ |
|
|
257
|
+
| 🧠 **Smart Constraints** | Respects AIWAF compatibility matrix | pandas ≤ 2.9.99 |
|
|
258
|
+
| 🔍 **Dependency Analysis** | Checks cross-package compatibility | NumPy vs pandas versions |
|
|
259
|
+
|
|
260
|
+
**AIWAF Compatibility Matrix:**
|
|
261
|
+
|
|
262
|
+
| Package | Safe Range | Blocked Versions | Reason |
|
|
263
|
+
|---------|------------|------------------|---------|
|
|
264
|
+
| Django | 3.2+ | None | AIWAF compatible with all Django versions |
|
|
265
|
+
| NumPy | 1.21 - 1.99 | 2.0+ | Avoid breaking changes |
|
|
266
|
+
| pandas | 1.3 - 2.9 | 3.0+ | AIWAF compatibility |
|
|
267
|
+
| scikit-learn | 1.0 - 1.99 | 2.0+ | Model compatibility |
|
|
268
|
+
| joblib | 1.1 - 1.99 | 2.0+ | AIWAF tested range |
|
|
269
|
+
- ✅ **Provides upgrade commands**
|
|
270
|
+
|
|
271
|
+
**Example Output:**
|
|
272
|
+
```
|
|
273
|
+
🔍 Checking project dependencies...
|
|
274
|
+
|
|
275
|
+
📊 Summary: 5 packages checked
|
|
276
|
+
✅ Up to date: 2
|
|
277
|
+
⚠️ Outdated: 2
|
|
278
|
+
❌ Not installed: 0
|
|
279
|
+
|
|
280
|
+
⚠️ OUTDATED PACKAGES:
|
|
281
|
+
────────────────────────────────────────
|
|
282
|
+
📦 pandas 1.3.5 → 2.2.2 (constraint: pandas>=1.3)
|
|
283
|
+
📦 numpy 1.21.0 → 1.26.4 (constraint: numpy>=1.21)
|
|
284
|
+
|
|
285
|
+
🔍 Checking package compatibility...
|
|
286
|
+
✅ All packages appear to be compatible!
|
|
287
|
+
|
|
288
|
+
� Planning safe package upgrades...
|
|
289
|
+
|
|
290
|
+
✅ SAFE UPGRADES PLANNED:
|
|
291
|
+
────────────────────────────────────────
|
|
292
|
+
📦 pandas 1.3.5 → 1.5.3 (Latest: 2.2.2)
|
|
293
|
+
💡 Upgraded to latest safe version (AIWAF constraint: <=1.99.99)
|
|
294
|
+
📦 joblib 1.1.0 → 1.4.2 (Latest: 1.4.2)
|
|
295
|
+
💡 Safe to upgrade to latest version
|
|
296
|
+
|
|
297
|
+
⚠️ UPGRADES BLOCKED FOR STABILITY:
|
|
298
|
+
────────────────────────────────────────
|
|
299
|
+
❌ numpy 1.21.0 ✗ 2.0.1
|
|
300
|
+
🚨 NumPy 2.0+ may cause compatibility issues (max safe: 1.99.99)
|
|
301
|
+
|
|
302
|
+
�💡 To update outdated packages, run:
|
|
303
|
+
pip install --upgrade pandas==1.5.3 joblib
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
**Safe Upgrade System:**
|
|
307
|
+
- 🛡️ **AIWAF Protection**: Never breaks AIWAF functionality
|
|
308
|
+
- 🔍 **Compatibility Validation**: Checks package interdependencies
|
|
309
|
+
- 📊 **Conservative Constraints**: Avoids known problematic versions
|
|
310
|
+
- 🧪 **Dry Run Mode**: Test upgrade plans before execution
|
|
311
|
+
- ⚠️ **Clear Blocking Reasons**: Explains why upgrades are blocked
|
|
312
|
+
|
|
313
|
+
**Recommended Upgrade Workflow:**
|
|
314
|
+
|
|
315
|
+
1. **Check current status:**
|
|
316
|
+
```bash
|
|
317
|
+
python manage.py check_dependencies
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
2. **Preview safe upgrades:**
|
|
321
|
+
```bash
|
|
322
|
+
python manage.py check_dependencies --upgrade --dry-run
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
3. **Execute safe upgrades:**
|
|
326
|
+
```bash
|
|
327
|
+
python manage.py check_dependencies --upgrade
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
4. **Verify after upgrade:**
|
|
331
|
+
```bash
|
|
332
|
+
python manage.py check_dependencies
|
|
333
|
+
python manage.py detect_and_train # Retrain with new packages
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
5. **Test your application:**
|
|
337
|
+
```bash
|
|
338
|
+
python manage.py test # Run your test suite
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
**Upgrade Decision Logic:**
|
|
342
|
+
|
|
343
|
+
The system uses a multi-layer decision process:
|
|
344
|
+
|
|
345
|
+
- **Layer 1**: Skip AIWAF itself (manual upgrade recommended)
|
|
346
|
+
- **Layer 2**: Check AIWAF compatibility constraints
|
|
347
|
+
- **Layer 3**: Analyze cross-package dependencies
|
|
348
|
+
- **Layer 4**: Select highest safe version within constraints
|
|
349
|
+
- **Layer 5**: Execute with error handling and rollback capability
|
|
350
|
+
|
|
192
351
|
This will ensure the IP is never blocked by AI‑WAF. You can also manage exemptions via the Django admin interface.
|
|
193
352
|
|
|
194
353
|
- **Daily Retraining**
|
|
@@ -380,6 +539,68 @@ MIDDLEWARE = [
|
|
|
380
539
|
- Missing migrations: `python manage.py migrate`
|
|
381
540
|
- Import errors: Check `INSTALLED_APPS` includes `'aiwaf'`
|
|
382
541
|
|
|
542
|
+
### **Dependency Upgrade Troubleshooting**
|
|
543
|
+
|
|
544
|
+
**Common Upgrade Scenarios:**
|
|
545
|
+
|
|
546
|
+
1. **NumPy 2.0 Upgrade Blocked:**
|
|
547
|
+
```bash
|
|
548
|
+
# Check pandas compatibility first
|
|
549
|
+
python manage.py check_dependencies --upgrade --dry-run
|
|
550
|
+
|
|
551
|
+
# If pandas < 2.1, upgrade pandas first
|
|
552
|
+
pip install 'pandas>=2.1,<3.0'
|
|
553
|
+
|
|
554
|
+
# Then allow NumPy upgrade
|
|
555
|
+
python manage.py check_dependencies --upgrade
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
2. **All Upgrades Blocked:**
|
|
559
|
+
```bash
|
|
560
|
+
# Check what's blocking upgrades
|
|
561
|
+
python manage.py check_dependencies --upgrade --dry-run
|
|
562
|
+
|
|
563
|
+
# Manual override (use with caution)
|
|
564
|
+
pip install --upgrade package-name
|
|
565
|
+
|
|
566
|
+
# Verify AIWAF still works
|
|
567
|
+
python manage.py detect_and_train
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
3. **Package Conflict After Upgrade:**
|
|
571
|
+
```bash
|
|
572
|
+
# Check current compatibility
|
|
573
|
+
python manage.py check_dependencies
|
|
574
|
+
|
|
575
|
+
# Downgrade to last known good version
|
|
576
|
+
pip install package-name==previous-version
|
|
577
|
+
|
|
578
|
+
# Find safe upgrade path
|
|
579
|
+
python manage.py check_dependencies --upgrade --dry-run
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
4. **AIWAF Model Issues After Upgrade:**
|
|
583
|
+
```bash
|
|
584
|
+
# Regenerate model with new package versions
|
|
585
|
+
python manage.py regenerate_model
|
|
586
|
+
|
|
587
|
+
# Retrain with current environment
|
|
588
|
+
python manage.py detect_and_train
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
**Emergency Rollback:**
|
|
592
|
+
If an upgrade breaks your system:
|
|
593
|
+
```bash
|
|
594
|
+
# Reinstall exact previous versions
|
|
595
|
+
pip install package-name==old-version
|
|
596
|
+
|
|
597
|
+
# Or use requirements.txt backup
|
|
598
|
+
pip install -r requirements.txt.backup
|
|
599
|
+
|
|
600
|
+
# Verify AIWAF functionality
|
|
601
|
+
python manage.py aiwaf_diagnose
|
|
602
|
+
```
|
|
603
|
+
|
|
383
604
|
---
|
|
384
605
|
|
|
385
606
|
## Running Detection & Training
|
|
@@ -38,7 +38,11 @@ aiwaf/
|
|
|
38
38
|
│ └── dynamic_keywords.json # evolves daily
|
|
39
39
|
├── management/
|
|
40
40
|
│ └── commands/
|
|
41
|
-
│
|
|
41
|
+
│ ├── detect_and_train.py # `python manage.py detect_and_train`
|
|
42
|
+
│ ├── check_dependencies.py # `python manage.py check_dependencies`
|
|
43
|
+
│ ├── add_ipexemption.py # `python manage.py add_ipexemption`
|
|
44
|
+
│ ├── aiwaf_reset.py # `python manage.py aiwaf_reset`
|
|
45
|
+
│ └── aiwaf_logging.py # `python manage.py aiwaf_logging`
|
|
42
46
|
└── LICENSE
|
|
43
47
|
```
|
|
44
48
|
|
|
@@ -83,6 +87,23 @@ aiwaf/
|
|
|
83
87
|
- **Captures response times** for better anomaly detection
|
|
84
88
|
- **Zero configuration** - works out of the box
|
|
85
89
|
|
|
90
|
+
- **Smart Training System**
|
|
91
|
+
AI trainer automatically uses the best available data source:
|
|
92
|
+
- **Primary**: Configured access log files (`AIWAF_ACCESS_LOG`)
|
|
93
|
+
- **Fallback**: Database RequestLog model when files unavailable
|
|
94
|
+
- **Seamless switching** between data sources
|
|
95
|
+
- **Enhanced compatibility** with exemption system
|
|
96
|
+
|
|
97
|
+
- **Dependency Management**
|
|
98
|
+
Built-in dependency checker ensures package compatibility:
|
|
99
|
+
- **Version compatibility** checking (NumPy 2.0 vs pandas, etc.)
|
|
100
|
+
- **Missing dependency** detection
|
|
101
|
+
- **Security vulnerability** scanning
|
|
102
|
+
- **Smart upgrade suggestions** with compatibility validation
|
|
103
|
+
- **Safe automated upgrades** that preserve AIWAF stability
|
|
104
|
+
- **Dry run mode** for testing upgrade plans
|
|
105
|
+
- **Cross-package dependency** analysis and conflict resolution
|
|
106
|
+
|
|
86
107
|
|
|
87
108
|
**Exempt Path & IP Awareness**
|
|
88
109
|
|
|
@@ -168,6 +189,142 @@ python manage.py aiwaf_reset --blacklist-only
|
|
|
168
189
|
python manage.py aiwaf_reset --exemptions-only
|
|
169
190
|
```
|
|
170
191
|
|
|
192
|
+
### Checking Dependencies
|
|
193
|
+
|
|
194
|
+
Check your project's dependencies for updates and compatibility issues:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
# Basic dependency check
|
|
198
|
+
python manage.py check_dependencies
|
|
199
|
+
|
|
200
|
+
# JSON format output
|
|
201
|
+
python manage.py check_dependencies --format json
|
|
202
|
+
|
|
203
|
+
# Include security vulnerability scanning
|
|
204
|
+
python manage.py check_dependencies --check-security
|
|
205
|
+
|
|
206
|
+
# Dry run - show what would be upgraded
|
|
207
|
+
python manage.py check_dependencies --upgrade --dry-run
|
|
208
|
+
|
|
209
|
+
# Actually upgrade packages safely
|
|
210
|
+
python manage.py check_dependencies --upgrade
|
|
211
|
+
|
|
212
|
+
# Full workflow: check, upgrade, and scan for vulnerabilities
|
|
213
|
+
python manage.py check_dependencies --upgrade --check-security
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**Core Features:**
|
|
217
|
+
- ✅ **Parses pyproject.toml and requirements.txt**
|
|
218
|
+
- ✅ **Shows current vs latest versions**
|
|
219
|
+
- ✅ **Checks package compatibility** (NumPy 2.0 vs pandas, etc.)
|
|
220
|
+
- ✅ **Detects missing dependencies**
|
|
221
|
+
- ✅ **Security vulnerability scanning** (requires `safety` package)
|
|
222
|
+
- ✅ **Safe package upgrades** (maintains AIWAF stability)
|
|
223
|
+
- ✅ **Dry run mode** for testing upgrade plans
|
|
224
|
+
- ✅ **AIWAF compatibility validation**
|
|
225
|
+
|
|
226
|
+
**Safe Upgrade System:**
|
|
227
|
+
|
|
228
|
+
The upgrade system is designed to maintain AIWAF stability while keeping your packages up to date:
|
|
229
|
+
|
|
230
|
+
| Protection Level | Description | Example |
|
|
231
|
+
|------------------|-------------|---------|
|
|
232
|
+
| 🛡️ **AIWAF Core** | Never upgrades AIWAF itself | Skips `aiwaf` package |
|
|
233
|
+
| 🔒 **Breaking Changes** | Avoids known problematic versions | Blocks NumPy 2.0+ |
|
|
234
|
+
| 🧠 **Smart Constraints** | Respects AIWAF compatibility matrix | pandas ≤ 2.9.99 |
|
|
235
|
+
| 🔍 **Dependency Analysis** | Checks cross-package compatibility | NumPy vs pandas versions |
|
|
236
|
+
|
|
237
|
+
**AIWAF Compatibility Matrix:**
|
|
238
|
+
|
|
239
|
+
| Package | Safe Range | Blocked Versions | Reason |
|
|
240
|
+
|---------|------------|------------------|---------|
|
|
241
|
+
| Django | 3.2+ | None | AIWAF compatible with all Django versions |
|
|
242
|
+
| NumPy | 1.21 - 1.99 | 2.0+ | Avoid breaking changes |
|
|
243
|
+
| pandas | 1.3 - 2.9 | 3.0+ | AIWAF compatibility |
|
|
244
|
+
| scikit-learn | 1.0 - 1.99 | 2.0+ | Model compatibility |
|
|
245
|
+
| joblib | 1.1 - 1.99 | 2.0+ | AIWAF tested range |
|
|
246
|
+
- ✅ **Provides upgrade commands**
|
|
247
|
+
|
|
248
|
+
**Example Output:**
|
|
249
|
+
```
|
|
250
|
+
🔍 Checking project dependencies...
|
|
251
|
+
|
|
252
|
+
📊 Summary: 5 packages checked
|
|
253
|
+
✅ Up to date: 2
|
|
254
|
+
⚠️ Outdated: 2
|
|
255
|
+
❌ Not installed: 0
|
|
256
|
+
|
|
257
|
+
⚠️ OUTDATED PACKAGES:
|
|
258
|
+
────────────────────────────────────────
|
|
259
|
+
📦 pandas 1.3.5 → 2.2.2 (constraint: pandas>=1.3)
|
|
260
|
+
📦 numpy 1.21.0 → 1.26.4 (constraint: numpy>=1.21)
|
|
261
|
+
|
|
262
|
+
🔍 Checking package compatibility...
|
|
263
|
+
✅ All packages appear to be compatible!
|
|
264
|
+
|
|
265
|
+
� Planning safe package upgrades...
|
|
266
|
+
|
|
267
|
+
✅ SAFE UPGRADES PLANNED:
|
|
268
|
+
────────────────────────────────────────
|
|
269
|
+
📦 pandas 1.3.5 → 1.5.3 (Latest: 2.2.2)
|
|
270
|
+
💡 Upgraded to latest safe version (AIWAF constraint: <=1.99.99)
|
|
271
|
+
📦 joblib 1.1.0 → 1.4.2 (Latest: 1.4.2)
|
|
272
|
+
💡 Safe to upgrade to latest version
|
|
273
|
+
|
|
274
|
+
⚠️ UPGRADES BLOCKED FOR STABILITY:
|
|
275
|
+
────────────────────────────────────────
|
|
276
|
+
❌ numpy 1.21.0 ✗ 2.0.1
|
|
277
|
+
🚨 NumPy 2.0+ may cause compatibility issues (max safe: 1.99.99)
|
|
278
|
+
|
|
279
|
+
�💡 To update outdated packages, run:
|
|
280
|
+
pip install --upgrade pandas==1.5.3 joblib
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
**Safe Upgrade System:**
|
|
284
|
+
- 🛡️ **AIWAF Protection**: Never breaks AIWAF functionality
|
|
285
|
+
- 🔍 **Compatibility Validation**: Checks package interdependencies
|
|
286
|
+
- 📊 **Conservative Constraints**: Avoids known problematic versions
|
|
287
|
+
- 🧪 **Dry Run Mode**: Test upgrade plans before execution
|
|
288
|
+
- ⚠️ **Clear Blocking Reasons**: Explains why upgrades are blocked
|
|
289
|
+
|
|
290
|
+
**Recommended Upgrade Workflow:**
|
|
291
|
+
|
|
292
|
+
1. **Check current status:**
|
|
293
|
+
```bash
|
|
294
|
+
python manage.py check_dependencies
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
2. **Preview safe upgrades:**
|
|
298
|
+
```bash
|
|
299
|
+
python manage.py check_dependencies --upgrade --dry-run
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
3. **Execute safe upgrades:**
|
|
303
|
+
```bash
|
|
304
|
+
python manage.py check_dependencies --upgrade
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
4. **Verify after upgrade:**
|
|
308
|
+
```bash
|
|
309
|
+
python manage.py check_dependencies
|
|
310
|
+
python manage.py detect_and_train # Retrain with new packages
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
5. **Test your application:**
|
|
314
|
+
```bash
|
|
315
|
+
python manage.py test # Run your test suite
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
**Upgrade Decision Logic:**
|
|
319
|
+
|
|
320
|
+
The system uses a multi-layer decision process:
|
|
321
|
+
|
|
322
|
+
- **Layer 1**: Skip AIWAF itself (manual upgrade recommended)
|
|
323
|
+
- **Layer 2**: Check AIWAF compatibility constraints
|
|
324
|
+
- **Layer 3**: Analyze cross-package dependencies
|
|
325
|
+
- **Layer 4**: Select highest safe version within constraints
|
|
326
|
+
- **Layer 5**: Execute with error handling and rollback capability
|
|
327
|
+
|
|
171
328
|
This will ensure the IP is never blocked by AI‑WAF. You can also manage exemptions via the Django admin interface.
|
|
172
329
|
|
|
173
330
|
- **Daily Retraining**
|
|
@@ -359,6 +516,68 @@ MIDDLEWARE = [
|
|
|
359
516
|
- Missing migrations: `python manage.py migrate`
|
|
360
517
|
- Import errors: Check `INSTALLED_APPS` includes `'aiwaf'`
|
|
361
518
|
|
|
519
|
+
### **Dependency Upgrade Troubleshooting**
|
|
520
|
+
|
|
521
|
+
**Common Upgrade Scenarios:**
|
|
522
|
+
|
|
523
|
+
1. **NumPy 2.0 Upgrade Blocked:**
|
|
524
|
+
```bash
|
|
525
|
+
# Check pandas compatibility first
|
|
526
|
+
python manage.py check_dependencies --upgrade --dry-run
|
|
527
|
+
|
|
528
|
+
# If pandas < 2.1, upgrade pandas first
|
|
529
|
+
pip install 'pandas>=2.1,<3.0'
|
|
530
|
+
|
|
531
|
+
# Then allow NumPy upgrade
|
|
532
|
+
python manage.py check_dependencies --upgrade
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
2. **All Upgrades Blocked:**
|
|
536
|
+
```bash
|
|
537
|
+
# Check what's blocking upgrades
|
|
538
|
+
python manage.py check_dependencies --upgrade --dry-run
|
|
539
|
+
|
|
540
|
+
# Manual override (use with caution)
|
|
541
|
+
pip install --upgrade package-name
|
|
542
|
+
|
|
543
|
+
# Verify AIWAF still works
|
|
544
|
+
python manage.py detect_and_train
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
3. **Package Conflict After Upgrade:**
|
|
548
|
+
```bash
|
|
549
|
+
# Check current compatibility
|
|
550
|
+
python manage.py check_dependencies
|
|
551
|
+
|
|
552
|
+
# Downgrade to last known good version
|
|
553
|
+
pip install package-name==previous-version
|
|
554
|
+
|
|
555
|
+
# Find safe upgrade path
|
|
556
|
+
python manage.py check_dependencies --upgrade --dry-run
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
4. **AIWAF Model Issues After Upgrade:**
|
|
560
|
+
```bash
|
|
561
|
+
# Regenerate model with new package versions
|
|
562
|
+
python manage.py regenerate_model
|
|
563
|
+
|
|
564
|
+
# Retrain with current environment
|
|
565
|
+
python manage.py detect_and_train
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
**Emergency Rollback:**
|
|
569
|
+
If an upgrade breaks your system:
|
|
570
|
+
```bash
|
|
571
|
+
# Reinstall exact previous versions
|
|
572
|
+
pip install package-name==old-version
|
|
573
|
+
|
|
574
|
+
# Or use requirements.txt backup
|
|
575
|
+
pip install -r requirements.txt.backup
|
|
576
|
+
|
|
577
|
+
# Verify AIWAF functionality
|
|
578
|
+
python manage.py aiwaf_diagnose
|
|
579
|
+
```
|
|
580
|
+
|
|
362
581
|
---
|
|
363
582
|
|
|
364
583
|
## Running Detection & Training
|