aiwaf 0.1.9.1.0__py3-none-any.whl → 0.1.9.1.1__py3-none-any.whl
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/__init__.py +1 -1
- aiwaf/trainer.py +5 -6
- {aiwaf-0.1.9.1.0.dist-info → aiwaf-0.1.9.1.1.dist-info}/METADATA +1 -1
- {aiwaf-0.1.9.1.0.dist-info → aiwaf-0.1.9.1.1.dist-info}/RECORD +7 -7
- {aiwaf-0.1.9.1.0.dist-info → aiwaf-0.1.9.1.1.dist-info}/WHEEL +0 -0
- {aiwaf-0.1.9.1.0.dist-info → aiwaf-0.1.9.1.1.dist-info}/licenses/LICENSE +0 -0
- {aiwaf-0.1.9.1.0.dist-info → aiwaf-0.1.9.1.1.dist-info}/top_level.txt +0 -0
aiwaf/__init__.py
CHANGED
aiwaf/trainer.py
CHANGED
|
@@ -15,6 +15,7 @@ from django.apps import apps
|
|
|
15
15
|
from django.db.models import F
|
|
16
16
|
from .utils import is_exempt_path
|
|
17
17
|
from .storage import get_blacklist_store, get_exemption_store, get_keyword_store
|
|
18
|
+
from .blacklist_manager import BlacklistManager
|
|
18
19
|
|
|
19
20
|
# ─────────── Configuration ───────────
|
|
20
21
|
LOG_PATH = getattr(settings, 'AIWAF_ACCESS_LOG', None)
|
|
@@ -102,13 +103,12 @@ def _parse(line: str) -> dict | None:
|
|
|
102
103
|
def train() -> None:
|
|
103
104
|
remove_exempt_keywords()
|
|
104
105
|
|
|
105
|
-
# Remove any IPs in IPExemption from the blacklist using
|
|
106
|
+
# Remove any IPs in IPExemption from the blacklist using BlacklistManager
|
|
106
107
|
exemption_store = get_exemption_store()
|
|
107
|
-
blacklist_store = get_blacklist_store()
|
|
108
108
|
|
|
109
109
|
exempted_ips = [entry['ip_address'] for entry in exemption_store.get_all()]
|
|
110
110
|
for ip in exempted_ips:
|
|
111
|
-
|
|
111
|
+
BlacklistManager.unblock(ip)
|
|
112
112
|
|
|
113
113
|
raw_lines = _read_all_logs()
|
|
114
114
|
if not raw_lines:
|
|
@@ -141,8 +141,7 @@ def train() -> None:
|
|
|
141
141
|
|
|
142
142
|
# Don't block if majority of 404s are on login paths
|
|
143
143
|
if count > login_404s: # More non-login 404s than login 404s
|
|
144
|
-
|
|
145
|
-
blacklist_store.add_ip(ip, f"Excessive 404s (≥6 non-login, {count}/{total_404s})")
|
|
144
|
+
BlacklistManager.block(ip, f"Excessive 404s (≥6 non-login, {count}/{total_404s})")
|
|
146
145
|
|
|
147
146
|
feature_dicts = []
|
|
148
147
|
for r in parsed:
|
|
@@ -239,7 +238,7 @@ def train() -> None:
|
|
|
239
238
|
continue
|
|
240
239
|
|
|
241
240
|
# Block if it shows clear signs of malicious behavior
|
|
242
|
-
|
|
241
|
+
BlacklistManager.block(ip, f"AI anomaly + suspicious patterns (kw:{avg_kw_hits:.1f}, 404s:{max_404s}, burst:{avg_burst:.1f})")
|
|
243
242
|
blocked_count += 1
|
|
244
243
|
print(f" - {ip}: Blocked for suspicious behavior (kw:{avg_kw_hits:.1f}, 404s:{max_404s}, burst:{avg_burst:.1f})")
|
|
245
244
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
aiwaf/__init__.py,sha256=
|
|
1
|
+
aiwaf/__init__.py,sha256=rnt-v3alYPo9DW-fh1U85gKTOLaMHNZIUrLlWSlFkUc,220
|
|
2
2
|
aiwaf/apps.py,sha256=nCez-Ptlv2kaEk5HenA8b1pATz1VfhrHP1344gwcY1A,142
|
|
3
3
|
aiwaf/blacklist_manager.py,sha256=LYCeKFB-7e_C6Bg2WeFJWFIIQlrfRMPuGp30ivrnhQY,1196
|
|
4
4
|
aiwaf/decorators.py,sha256=IUKOdM_gdroffImRZep1g1wT6gNqD10zGwcp28hsJCs,825
|
|
@@ -6,7 +6,7 @@ aiwaf/middleware.py,sha256=4Ox0pUdB7rMT1Sw5XHO6-udQrfqyF9VGdkkkgLioRJ0,12470
|
|
|
6
6
|
aiwaf/middleware_logger.py,sha256=LWZVDAnjh6CGESirA8eMbhGgJKB7lVDGRQqVroH95Lo,4742
|
|
7
7
|
aiwaf/models.py,sha256=vQxgY19BDVMjoO903UNrTZC1pNoLltMU6wbyWPoAEns,2719
|
|
8
8
|
aiwaf/storage.py,sha256=HYSnis7S8ETsos_NxWkd05OoiHXMhIWQy8FcFTqO4vk,8408
|
|
9
|
-
aiwaf/trainer.py,sha256=
|
|
9
|
+
aiwaf/trainer.py,sha256=btRoim-Iak6jHTVO1Q1BCFIAhkjM9h-s92dFFMfAYjw,9152
|
|
10
10
|
aiwaf/utils.py,sha256=BJk5vJCYdGPl_4QQiknjhCbkzv5HZCXgFcBJDMJpHok,3390
|
|
11
11
|
aiwaf/management/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
12
|
aiwaf/management/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -26,8 +26,8 @@ aiwaf/management/commands/test_exemption_fix.py,sha256=ngyGaHUCmQQ6y--6j4q1viZJt
|
|
|
26
26
|
aiwaf/resources/model.pkl,sha256=5t6h9BX8yoh2xct85MXOO60jdlWyg1APskUOW0jZE1Y,1288265
|
|
27
27
|
aiwaf/templatetags/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
28
28
|
aiwaf/templatetags/aiwaf_tags.py,sha256=XXfb7Tl4DjU3Sc40GbqdaqOEtKTUKELBEk58u83wBNw,357
|
|
29
|
-
aiwaf-0.1.9.1.
|
|
30
|
-
aiwaf-0.1.9.1.
|
|
31
|
-
aiwaf-0.1.9.1.
|
|
32
|
-
aiwaf-0.1.9.1.
|
|
33
|
-
aiwaf-0.1.9.1.
|
|
29
|
+
aiwaf-0.1.9.1.1.dist-info/licenses/LICENSE,sha256=Ir8PX4dxgAcdB0wqNPIkw84fzIIRKE75NoUil9RX0QU,1069
|
|
30
|
+
aiwaf-0.1.9.1.1.dist-info/METADATA,sha256=ii4UbtfMHxo6bERH_ZMxRmtOkPl3BjyaBSCgifMwGJA,13763
|
|
31
|
+
aiwaf-0.1.9.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
32
|
+
aiwaf-0.1.9.1.1.dist-info/top_level.txt,sha256=kU6EyjobT6UPCxuWpI_BvcHDG0I2tMgKaPlWzVxe2xI,6
|
|
33
|
+
aiwaf-0.1.9.1.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|