aiwaf 0.1.0__tar.gz → 0.1.2__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.2/PKG-INFO ADDED
@@ -0,0 +1,187 @@
1
+ Metadata-Version: 2.4
2
+ Name: aiwaf
3
+ Version: 0.1.2
4
+ Summary: AI-powered Web Application Firewall
5
+ Author: Aayush Gauba
6
+ Author-email: Aayush Gauba <gauba.aayush@gmail.com>
7
+ License: MIT
8
+ Requires-Python: >=3.8
9
+ Description-Content-Type: text/markdown
10
+ Dynamic: author
11
+
12
+ # AI‑WAF
13
+
14
+ > A self-learning, Django-friendly Web Application Firewall
15
+ > with rate-limiting, anomaly detection, honeypots, UUID-tamper protection, and daily retraining.
16
+
17
+ ---
18
+
19
+ ## Package Structure
20
+
21
+ ```
22
+ aiwaf/
23
+ ├── __init__.py
24
+ ├── blacklist_manager.py
25
+ ├── middleware.py
26
+ ├── trainer.py # exposes detect_and_train()
27
+ ├── utils.py
28
+ ├── template_tags/
29
+ │ └── aiwaf_tags.py
30
+ ├── resources/
31
+ │ └── model.pkl # pre-trained base model
32
+ ├── management/
33
+ │ └── commands/
34
+ │ └── detect_and_train.py # python manage.py detect_and_train
35
+ └── LICENSE
36
+ ```
37
+
38
+ ---
39
+
40
+ ## Features
41
+
42
+ - **IP Blocklist**
43
+ Automatically blocks suspicious IPs; optionally backed by CSV or Django model.
44
+
45
+ - **Rate Limiting**
46
+ Sliding window logic blocks IPs exceeding a threshold of requests per second.
47
+
48
+ - **AI Anomaly Detection**
49
+ IsolationForest trained on real logs with features like:
50
+ - Path length
51
+ - Keyword hits
52
+ - Response time
53
+ - Status code index
54
+ - Burst count
55
+ - Total 404s
56
+
57
+ - **Honeypot Field**
58
+ Hidden form field that bots are likely to fill — if triggered, the IP is blocked.
59
+
60
+ - **UUID Tampering Protection**
61
+ Detects if someone is probing by injecting random/nonexistent UUIDs into URLs.
62
+
63
+ - **Daily Retraining**
64
+ A single command retrains your model every day based on your logs.
65
+
66
+ ---
67
+
68
+ ## Installation
69
+
70
+ Install locally or from PyPI:
71
+
72
+ ```bash
73
+ pip install aiwaf
74
+ ```
75
+
76
+ Or for local dev:
77
+
78
+ ```bash
79
+ git clone https://github.com/aayushgauba/aiwaf.git
80
+ cd aiwaf
81
+ pip install -e .
82
+ ```
83
+
84
+ ---
85
+
86
+ ## ⚙️ Configuration (`settings.py`)
87
+
88
+ ```python
89
+ INSTALLED_APPS += [
90
+ "aiwaf",
91
+ ]
92
+
93
+ # Required
94
+ AIWAF_ACCESS_LOG = "/var/log/nginx/access.log"
95
+
96
+ # Optional (defaults included)
97
+ AIWAF_MODEL_PATH = BASE_DIR / "aiwaf" / "resources" / "model.pkl"
98
+ AIWAF_MALICIOUS_KEYWORDS = [".php", "xmlrpc", "wp-", ".env", ".git", ".bak", "conflg", "shell", "filemanager"]
99
+ AIWAF_STATUS_CODES = ["200", "403", "404", "500"]
100
+ AIWAF_HONEYPOT_FIELD = "hp_field"
101
+ ```
102
+
103
+ ---
104
+
105
+ ## Middleware Setup
106
+
107
+ Add to `MIDDLEWARE` in order:
108
+
109
+ ```python
110
+ MIDDLEWARE = [
111
+ "aiwaf.middleware.IPBlockMiddleware",
112
+ "aiwaf.middleware.RateLimitMiddleware",
113
+ "aiwaf.middleware.AIAnomalyMiddleware",
114
+ "aiwaf.middleware.HoneypotMiddleware",
115
+ "aiwaf.middleware.UUIDTamperMiddleware",
116
+ ...
117
+ ]
118
+ ```
119
+
120
+ ---
121
+
122
+ ## Honeypot Field (in template)
123
+
124
+ ```html
125
+ {% load aiwaf_tags %}
126
+
127
+ <form method="post">
128
+ {% csrf_token %}
129
+ {% honeypot_field %}
130
+ <!-- other fields -->
131
+ </form>
132
+ ```
133
+
134
+ The hidden field will be `<input type="hidden" name="hp_field">`.
135
+ If it’s ever filled → IP gets blocked.
136
+
137
+ ---
138
+
139
+ ## Run Detection + Training
140
+
141
+ ```bash
142
+ python manage.py detect_and_train
143
+ ```
144
+
145
+ What it does:
146
+
147
+ - Reads logs (supports `.gz` and rotated logs).
148
+ - Detects excessive 404s (≥6) → instant block.
149
+ - Builds feature vectors from logs.
150
+ - Trains IsolationForest and saves `model.pkl`.
151
+
152
+ Schedule it to run daily via `cron`, `Celery beat`, or systemd timer.
153
+
154
+ ---
155
+
156
+ ## How It Works (Simplified)
157
+
158
+ | Middleware | Functionality |
159
+ |------------------------|--------------------------------------------------------------|
160
+ | IPBlockMiddleware | Blocks requests from known blacklisted IPs |
161
+ | RateLimitMiddleware | Blocks flooders (>20/10s) and blacklists them (>10/10s) |
162
+ | AIAnomalyMiddleware | Uses ML to detect suspicious behavior in request patterns |
163
+ | HoneypotMiddleware | Detects bots filling hidden inputs in forms |
164
+ | UUIDTamperMiddleware | Detects guessing/probing by checking invalid UUID access |
165
+
166
+ ---
167
+
168
+ ## Development Roadmap
169
+
170
+ - [ ] Add CSV blocklist fallback
171
+ - [ ] Admin dashboard integration
172
+ - [ ] Auto-pruning of old block entries
173
+ - [ ] Real-time log streaming compatibility
174
+ - [ ] Docker/Helm deployment guide
175
+
176
+ ---
177
+
178
+ ## License
179
+
180
+ This project is licensed under the **MIT License** — see `LICENSE` for details.
181
+
182
+ ---
183
+
184
+ ## Credits
185
+
186
+ **AIWAF** by [Aayush Gauba](https://github.com/aayushgauba)
187
+ > "Let your firewall learn and evolve with your logs. Make your site a fortress."
@@ -0,0 +1,187 @@
1
+ Metadata-Version: 2.4
2
+ Name: aiwaf
3
+ Version: 0.1.2
4
+ Summary: AI-powered Web Application Firewall
5
+ Author: Aayush Gauba
6
+ Author-email: Aayush Gauba <gauba.aayush@gmail.com>
7
+ License: MIT
8
+ Requires-Python: >=3.8
9
+ Description-Content-Type: text/markdown
10
+ Dynamic: author
11
+
12
+ # AI‑WAF
13
+
14
+ > A self-learning, Django-friendly Web Application Firewall
15
+ > with rate-limiting, anomaly detection, honeypots, UUID-tamper protection, and daily retraining.
16
+
17
+ ---
18
+
19
+ ## Package Structure
20
+
21
+ ```
22
+ aiwaf/
23
+ ├── __init__.py
24
+ ├── blacklist_manager.py
25
+ ├── middleware.py
26
+ ├── trainer.py # exposes detect_and_train()
27
+ ├── utils.py
28
+ ├── template_tags/
29
+ │ └── aiwaf_tags.py
30
+ ├── resources/
31
+ │ └── model.pkl # pre-trained base model
32
+ ├── management/
33
+ │ └── commands/
34
+ │ └── detect_and_train.py # python manage.py detect_and_train
35
+ └── LICENSE
36
+ ```
37
+
38
+ ---
39
+
40
+ ## Features
41
+
42
+ - **IP Blocklist**
43
+ Automatically blocks suspicious IPs; optionally backed by CSV or Django model.
44
+
45
+ - **Rate Limiting**
46
+ Sliding window logic blocks IPs exceeding a threshold of requests per second.
47
+
48
+ - **AI Anomaly Detection**
49
+ IsolationForest trained on real logs with features like:
50
+ - Path length
51
+ - Keyword hits
52
+ - Response time
53
+ - Status code index
54
+ - Burst count
55
+ - Total 404s
56
+
57
+ - **Honeypot Field**
58
+ Hidden form field that bots are likely to fill — if triggered, the IP is blocked.
59
+
60
+ - **UUID Tampering Protection**
61
+ Detects if someone is probing by injecting random/nonexistent UUIDs into URLs.
62
+
63
+ - **Daily Retraining**
64
+ A single command retrains your model every day based on your logs.
65
+
66
+ ---
67
+
68
+ ## Installation
69
+
70
+ Install locally or from PyPI:
71
+
72
+ ```bash
73
+ pip install aiwaf
74
+ ```
75
+
76
+ Or for local dev:
77
+
78
+ ```bash
79
+ git clone https://github.com/aayushgauba/aiwaf.git
80
+ cd aiwaf
81
+ pip install -e .
82
+ ```
83
+
84
+ ---
85
+
86
+ ## ⚙️ Configuration (`settings.py`)
87
+
88
+ ```python
89
+ INSTALLED_APPS += [
90
+ "aiwaf",
91
+ ]
92
+
93
+ # Required
94
+ AIWAF_ACCESS_LOG = "/var/log/nginx/access.log"
95
+
96
+ # Optional (defaults included)
97
+ AIWAF_MODEL_PATH = BASE_DIR / "aiwaf" / "resources" / "model.pkl"
98
+ AIWAF_MALICIOUS_KEYWORDS = [".php", "xmlrpc", "wp-", ".env", ".git", ".bak", "conflg", "shell", "filemanager"]
99
+ AIWAF_STATUS_CODES = ["200", "403", "404", "500"]
100
+ AIWAF_HONEYPOT_FIELD = "hp_field"
101
+ ```
102
+
103
+ ---
104
+
105
+ ## Middleware Setup
106
+
107
+ Add to `MIDDLEWARE` in order:
108
+
109
+ ```python
110
+ MIDDLEWARE = [
111
+ "aiwaf.middleware.IPBlockMiddleware",
112
+ "aiwaf.middleware.RateLimitMiddleware",
113
+ "aiwaf.middleware.AIAnomalyMiddleware",
114
+ "aiwaf.middleware.HoneypotMiddleware",
115
+ "aiwaf.middleware.UUIDTamperMiddleware",
116
+ ...
117
+ ]
118
+ ```
119
+
120
+ ---
121
+
122
+ ## Honeypot Field (in template)
123
+
124
+ ```html
125
+ {% load aiwaf_tags %}
126
+
127
+ <form method="post">
128
+ {% csrf_token %}
129
+ {% honeypot_field %}
130
+ <!-- other fields -->
131
+ </form>
132
+ ```
133
+
134
+ The hidden field will be `<input type="hidden" name="hp_field">`.
135
+ If it’s ever filled → IP gets blocked.
136
+
137
+ ---
138
+
139
+ ## Run Detection + Training
140
+
141
+ ```bash
142
+ python manage.py detect_and_train
143
+ ```
144
+
145
+ What it does:
146
+
147
+ - Reads logs (supports `.gz` and rotated logs).
148
+ - Detects excessive 404s (≥6) → instant block.
149
+ - Builds feature vectors from logs.
150
+ - Trains IsolationForest and saves `model.pkl`.
151
+
152
+ Schedule it to run daily via `cron`, `Celery beat`, or systemd timer.
153
+
154
+ ---
155
+
156
+ ## How It Works (Simplified)
157
+
158
+ | Middleware | Functionality |
159
+ |------------------------|--------------------------------------------------------------|
160
+ | IPBlockMiddleware | Blocks requests from known blacklisted IPs |
161
+ | RateLimitMiddleware | Blocks flooders (>20/10s) and blacklists them (>10/10s) |
162
+ | AIAnomalyMiddleware | Uses ML to detect suspicious behavior in request patterns |
163
+ | HoneypotMiddleware | Detects bots filling hidden inputs in forms |
164
+ | UUIDTamperMiddleware | Detects guessing/probing by checking invalid UUID access |
165
+
166
+ ---
167
+
168
+ ## Development Roadmap
169
+
170
+ - [ ] Add CSV blocklist fallback
171
+ - [ ] Admin dashboard integration
172
+ - [ ] Auto-pruning of old block entries
173
+ - [ ] Real-time log streaming compatibility
174
+ - [ ] Docker/Helm deployment guide
175
+
176
+ ---
177
+
178
+ ## License
179
+
180
+ This project is licensed under the **MIT License** — see `LICENSE` for details.
181
+
182
+ ---
183
+
184
+ ## Credits
185
+
186
+ **AIWAF** by [Aayush Gauba](https://github.com/aayushgauba)
187
+ > "Let your firewall learn and evolve with your logs. Make your site a fortress."
@@ -1,4 +1,5 @@
1
1
  README.md
2
+ pyproject.toml
2
3
  setup.py
3
4
  aiwaf/__init__.py
4
5
  aiwaf/apps.py
@@ -11,8 +12,6 @@ aiwaf/utils.py
11
12
  aiwaf.egg-info/PKG-INFO
12
13
  aiwaf.egg-info/SOURCES.txt
13
14
  aiwaf.egg-info/dependency_links.txt
14
- aiwaf.egg-info/entry_points.txt
15
- aiwaf.egg-info/requires.txt
16
15
  aiwaf.egg-info/top_level.txt
17
16
  aiwaf/management/__init__.py
18
17
  aiwaf/management/commands/__init__.py
@@ -0,0 +1,9 @@
1
+ [project]
2
+ name = "aiwaf"
3
+ version = "0.1.2"
4
+ description = "AI-powered Web Application Firewall"
5
+ readme = "README.md"
6
+ requires-python = ">=3.8"
7
+ license = {text = "MIT"}
8
+ authors = [{ name = "Aayush Gauba", email = "gauba.aayush@gmail.com" }]
9
+ dependencies = [ ]
@@ -1,9 +1,15 @@
1
1
  from setuptools import setup, find_packages
2
+ from pathlib import Path
3
+
4
+ this_directory = Path(__file__).parent
5
+ long_description = (this_directory / "README.md").read_text(encoding="utf-8")
2
6
 
3
7
  setup(
4
8
  name="aiwaf",
5
- version="0.1.0",
9
+ version="0.1.2",
6
10
  description="AI‑driven pluggable Web Application Firewall for Django (CSV or DB storage)",
11
+ long_description=long_description,
12
+ long_description_content_type="text/markdown", # <- required for markdown support
7
13
  author="Aayush Gauba",
8
14
  packages=find_packages(),
9
15
  package_data={
aiwaf-0.1.0/PKG-INFO DELETED
@@ -1,13 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: aiwaf
3
- Version: 0.1.0
4
- Summary: AI‑driven pluggable Web Application Firewall for Django (CSV or DB storage)
5
- Author: Aayush Gauba
6
- Requires-Dist: django>=3.0
7
- Requires-Dist: scikit-learn
8
- Requires-Dist: numpy
9
- Requires-Dist: pandas
10
- Requires-Dist: joblib
11
- Dynamic: author
12
- Dynamic: requires-dist
13
- Dynamic: summary
@@ -1,13 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: aiwaf
3
- Version: 0.1.0
4
- Summary: AI‑driven pluggable Web Application Firewall for Django (CSV or DB storage)
5
- Author: Aayush Gauba
6
- Requires-Dist: django>=3.0
7
- Requires-Dist: scikit-learn
8
- Requires-Dist: numpy
9
- Requires-Dist: pandas
10
- Requires-Dist: joblib
11
- Dynamic: author
12
- Dynamic: requires-dist
13
- Dynamic: summary
@@ -1,2 +0,0 @@
1
- [console_scripts]
2
- aiwaf-detect = aiwaf.trainer:detect_and_train
@@ -1,5 +0,0 @@
1
- django>=3.0
2
- scikit-learn
3
- numpy
4
- pandas
5
- joblib
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes