aiwaf 0.1.9.2.4__py3-none-any.whl → 0.1.9.2.6__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 CHANGED
@@ -1,6 +1,6 @@
1
1
  default_app_config = "aiwaf.apps.AiwafConfig"
2
2
 
3
- __version__ = "0.1.9.2.4"
3
+ __version__ = "0.1.9.2.6"
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
aiwaf/middleware.py CHANGED
@@ -587,10 +587,20 @@ class AIAnomalyMiddleware(MiddlewareMixin):
587
587
  data = [d for d in data if now - d[0] < self.WINDOW]
588
588
  cache.set(key, data, timeout=self.WINDOW)
589
589
 
590
- keyword_store = get_keyword_store()
591
- for seg in re.split(r"\W+", request.path.lower()):
592
- if len(seg) > 3:
593
- keyword_store.add_keyword(seg)
590
+ # Only learn keywords from 404 responses (not found) on non-existent paths
591
+ # This prevents learning from 403 (blocked IPs accessing legitimate paths) or other error codes
592
+ if (response.status_code == 404 and not known_path and not is_exempt_path(request.path)):
593
+ keyword_store = get_keyword_store()
594
+ # Get legitimate keywords to avoid learning them
595
+ from .trainer import get_legitimate_keywords
596
+ legitimate_keywords = get_legitimate_keywords()
597
+
598
+ for seg in re.split(r"\W+", request.path.lower()):
599
+ if (len(seg) > 3 and
600
+ seg not in STATIC_KW and # Don't re-learn static keywords
601
+ seg not in legitimate_keywords and # Don't learn legitimate keywords
602
+ self._is_malicious_context(request, seg)): # Only learn in malicious context
603
+ keyword_store.add_keyword(seg)
594
604
 
595
605
  return response
596
606
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aiwaf
3
- Version: 0.1.9.2.4
3
+ Version: 0.1.9.2.6
4
4
  Summary: AI-powered Web Application Firewall
5
5
  Home-page: https://github.com/aayushgauba/aiwaf
6
6
  Author: Aayush Gauba
@@ -1,8 +1,8 @@
1
- aiwaf/__init__.py,sha256=dd7iB2QMRRoAnHCazKFantX-94j0ZZzF91cXNQXynwU,220
1
+ aiwaf/__init__.py,sha256=vgc-dT-AtR3_k84Wpmujg4ZRwl6EuU7IR2_KW2B0tBU,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
5
- aiwaf/middleware.py,sha256=uUDHipAk1FBgw8B7VGRfbM8JgxQYC4rkVm_Igvwr4EU,31125
5
+ aiwaf/middleware.py,sha256=cpxOI6W45A6qRa9Ulk1StqCTSJjCoBx387FegZB0iMA,31889
6
6
  aiwaf/middleware_logger.py,sha256=LWZVDAnjh6CGESirA8eMbhGgJKB7lVDGRQqVroH95Lo,4742
7
7
  aiwaf/models.py,sha256=vQxgY19BDVMjoO903UNrTZC1pNoLltMU6wbyWPoAEns,2719
8
8
  aiwaf/storage.py,sha256=5ImrZMRn3u7HNsPH0fDjWhDrD2tgG2IHVnOXtLz0fk4,10253
@@ -29,8 +29,8 @@ aiwaf/management/commands/test_exemption_fix.py,sha256=ngyGaHUCmQQ6y--6j4q1viZJt
29
29
  aiwaf/resources/model.pkl,sha256=5t6h9BX8yoh2xct85MXOO60jdlWyg1APskUOW0jZE1Y,1288265
30
30
  aiwaf/templatetags/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
31
  aiwaf/templatetags/aiwaf_tags.py,sha256=XXfb7Tl4DjU3Sc40GbqdaqOEtKTUKELBEk58u83wBNw,357
32
- aiwaf-0.1.9.2.4.dist-info/licenses/LICENSE,sha256=Ir8PX4dxgAcdB0wqNPIkw84fzIIRKE75NoUil9RX0QU,1069
33
- aiwaf-0.1.9.2.4.dist-info/METADATA,sha256=kxzp7zWpy5ig93vGyai9wtbcTuq5DSX7bDjNsMliTkg,26824
34
- aiwaf-0.1.9.2.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
35
- aiwaf-0.1.9.2.4.dist-info/top_level.txt,sha256=kU6EyjobT6UPCxuWpI_BvcHDG0I2tMgKaPlWzVxe2xI,6
36
- aiwaf-0.1.9.2.4.dist-info/RECORD,,
32
+ aiwaf-0.1.9.2.6.dist-info/licenses/LICENSE,sha256=Ir8PX4dxgAcdB0wqNPIkw84fzIIRKE75NoUil9RX0QU,1069
33
+ aiwaf-0.1.9.2.6.dist-info/METADATA,sha256=iaCG43PeSHGu16Jawzelh5Qi0PoGysvi_BYfWFIcvbA,26824
34
+ aiwaf-0.1.9.2.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
35
+ aiwaf-0.1.9.2.6.dist-info/top_level.txt,sha256=kU6EyjobT6UPCxuWpI_BvcHDG0I2tMgKaPlWzVxe2xI,6
36
+ aiwaf-0.1.9.2.6.dist-info/RECORD,,