aiwaf 1.1.4 → 1.1.5

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.
package/README.md CHANGED
@@ -39,22 +39,21 @@ the supported Redis backends when sharing limits across workers.
39
39
 
40
40
  Each package is versioned and released independently.
41
41
 
42
- Python 1.1.6, Rust/Python 0.2.5, Node.js 1.1.4, WASM 0.2.4, and Java 1.3.4 are local release candidates; see the
43
- [upgrade notes](docs/releases/2026-10-elv2.md).
42
+ Python 1.1.8, Rust/Python 0.2.7, Node.js 1.1.5, WASM 0.2.5, and Java 1.3.5 are local source targets. See the package table below and [CHANGELOG](CHANGELOG.md) for release changes.
44
43
 
45
44
  | Runtime | Package | Repository version | Primary use |
46
45
  | --- | --- | ---: | --- |
47
- | Python | [`aiwaf`](https://pypi.org/project/aiwaf/) | `1.1.6` | Django, Flask, and FastAPI protection |
48
- | Node.js | [`aiwaf`](https://www.npmjs.com/package/aiwaf) | `1.1.4` | Express and Node framework middleware |
49
- | Rust/Python | [`aiwaf-rust`](https://pypi.org/project/aiwaf-rust/) | `0.2.5` | Native Python acceleration and JSON model inference |
50
- | WebAssembly | [`aiwaf-wasm`](https://www.npmjs.com/package/aiwaf-wasm) | `0.2.4` | Rust detection and model primitives for JavaScript |
51
- | Java | `io.github.aiwaf-project:aiwaf-java` | `1.3.4` | Spring MVC and Jakarta Servlet protection |
46
+ | Python | [`aiwaf`](https://pypi.org/project/aiwaf/) | `1.1.8` | Django, Flask, and FastAPI protection |
47
+ | Node.js | [`aiwaf`](https://www.npmjs.com/package/aiwaf) | `1.1.5` | Express and Node framework middleware |
48
+ | Rust/Python | [`aiwaf-rust`](https://pypi.org/project/aiwaf-rust/) | `0.2.7` | Native Python acceleration and JSON model inference |
49
+ | WebAssembly | [`aiwaf-wasm`](https://www.npmjs.com/package/aiwaf-wasm) | `0.2.5` | Rust detection and model primitives for JavaScript |
50
+ | Java | `io.github.aiwaf-project:aiwaf-java` | `1.3.5` | Spring MVC and Jakarta Servlet protection |
52
51
 
53
52
  Supported framework integrations include Django, Flask, FastAPI, Express, Fastify, Hapi, Koa, NestJS, Next.js API routes, AdonisJS, Sails.js, Spring MVC, and Jakarta Servlet.
54
53
 
55
54
  ## What AIWAF provides
56
55
 
57
- - IP blacklist, exemption, reputation, expiry, and progressive-block handling
56
+ - IP blocklist, exemption, reputation, expiry, and progressive-block handling
58
57
  - Sliding-window rate limiting and flood detection
59
58
  - Header, method, request-size, content-type, and parameter validation
60
59
  - Static and learned malicious keyword detection
@@ -79,7 +78,6 @@ The runtimes share policy intent and training feature names, but their framework
79
78
  │ └── crates/aiwaf_wasm/ WebAssembly bindings
80
79
  ├── java/ Java 17 package
81
80
  ├── tests/ Python integration and parity tests
82
- ├── benchmarks/ Python middleware benchmarks
83
81
  ├── examples/ Focused Python examples
84
82
  ├── .github/workflows/ Tests, security checks, and releases
85
83
  ├── README.md Canonical project documentation
@@ -97,7 +95,7 @@ pip install "aiwaf[django]"
97
95
  pip install "aiwaf[flask]"
98
96
  pip install "aiwaf[fastapi]"
99
97
 
100
- # Backward-compatible alias; Python 1.1.6 already installs aiwaf-rust
98
+ # Backward-compatible alias; Python 1.1.8 already installs aiwaf-rust
101
99
  pip install "aiwaf[rust]"
102
100
 
103
101
  # Node.js middleware
@@ -107,13 +105,13 @@ npm install aiwaf
107
105
  npm install aiwaf-wasm
108
106
  ```
109
107
 
110
- Java 1.3.4, after it is published to Maven Central:
108
+ Java 1.3.5, after it is published to Maven Central:
111
109
 
112
110
  ```xml
113
111
  <dependency>
114
112
  <groupId>io.github.aiwaf-project</groupId>
115
113
  <artifactId>aiwaf-java</artifactId>
116
- <version>1.3.4</version>
114
+ <version>1.3.5</version>
117
115
  </dependency>
118
116
  ```
119
117
 
@@ -121,7 +119,7 @@ Java 1.3.4, after it is published to Maven Central:
121
119
 
122
120
  The Python package requires Python 3.10 or newer. Framework dependencies are optional, so install only the extra needed by the application.
123
121
 
124
- Python 1.1.6 requires `aiwaf-rust>=0.2.5`; the `rust` extra remains an installation
122
+ Python 1.1.8 requires `aiwaf-rust>=0.2.7`; the `rust` extra remains an installation
125
123
  alias. Publish the matching Rust wheel with `NativeCSVPipeline` support before
126
124
  the Python release. The Rust release workflow builds Linux x86_64/aarch64,
127
125
  musl x86_64, macOS x86_64/arm64 and Windows x86_64 wheels and checks the native
@@ -136,7 +134,7 @@ Install it **instead of the existing eight-middleware chain**. The existing
136
134
  they do not switch automatically to this pipeline.
137
135
 
138
136
  Rust owns the immutable configuration, enforcement order, SQL and keyword
139
- inspection, geo and blacklist decisions, rate buckets, form timing state, UUID
137
+ inspection, geo and blocklist decisions, rate buckets, form timing state, UUID
140
138
  scores, anomaly inference/history, keyword learning and CSV logging. Python
141
139
  supplies framework routing/authentication facts, obtains GeoIP country data,
142
140
  buffers a bounded body prefix and constructs responses. Each request crosses
@@ -185,17 +183,20 @@ Common profile keys and defaults:
185
183
  | Setting | Default / meaning |
186
184
  | --- | --- |
187
185
  | `enabled` | All eight names: `geo_block`, `ip_keyword_block`, `rate_limit`, `ai_anomaly`, `honeypot`, `uuid_tamper`, `header_validation`, `logging` |
188
- | `data_dir` | `aiwaf_data`; policy CSVs use the shared whitelist/blacklist/keyword/geo/path schemas |
186
+ | `data_dir` | `aiwaf_data`; policy CSVs use the shared allowlist/blocklist/keyword/geo/path schemas |
189
187
  | `exempt_paths`, `exempt_ips` | `/health`, `/robots.txt`, `/sitemap.xml`; empty IP list. Paths are literal, case-insensitive prefixes, not globs. Stored path exemptions use the same literal-prefix rule |
190
188
  | `sql_mode`, `max_bytes` | `block`, `65536`; `off` supported, `monitor` rejected. Structured JSON/form bodies and nested escaped strings are inspected with bounded traversal |
191
189
  | `learning`, `top_n` | `True`, `10`; presence keywords use a sorted, stable subset instead of Python set iteration order |
192
190
  | `static_keywords`, `legitimate_keywords`, `exempt_keywords`, `safe_prefixes` | Native policy defaults or explicit arrays; set route-specific safe vocabulary in the profile |
193
191
  | `geo_allow`, `geo_block` | Empty lists; includes stored blocked countries. Unknown country remains allowed |
194
192
  | `rate_backend`, `rate_key_mode` | `memory`, `ip_path`; `csv` shares buckets across workers; `ip` aggregates paths. Redis is rejected |
195
- | `rate_window`, `rate_max`, `rate_flood` | `10`, `20`, `40`; throttle at 429, flood at 403 with blacklist persistence |
196
- | `soft_block_blacklist`, `ip_blocking`, `block_duration` | `False`, `True`, reputation-based duration; explicit seconds or nonpositive permanent duration |
197
- | `honeypot_backend` | `csv`; shared, persistent form timestamps in `pipeline_state.csv`. Optional `memory` uses a Rust map local to one engine/worker |
198
- | `min_form_time`, `max_page_time`, `skip_authenticated` | `1.0`, `240`, `True`; same timing policy for both honeypot backends |
193
+ | `rate_window`, `rate_max`, `rate_flood` | `10`, `20`, `40`; throttle at 429, flood at 403 with blocklist persistence |
194
+ | `soft_block_blocklist`, `ip_blocking`, `block_duration` | `False`, `True`, reputation-based duration; explicit seconds or nonpositive permanent duration |
195
+ | `honeypot_backend` | Django defaults to `django_cache`; Flask/FastAPI and direct construction default to `csv`. Optional `memory` is local to one engine; `redis` and `cache` delegate timestamp I/O while Rust enforces timing |
196
+ | `honeypot_cache_alias` | Django-only; `default`. Uses the named `CACHES` entry for honeypot timestamps, not other policy or rate state |
197
+ | `honeypot_redis_url` | Required for `honeypot_backend="redis"`; stripped before native profile serialization. `rediss://` requires redis-py |
198
+ | `honeypot_cache_namespace` | Redis/custom cache key prefix, default `aiwaf:native:honeypot:v1`; use the same value across workers and a distinct value for unrelated applications |
199
+ | `min_form_time`, `max_page_time`, `skip_authenticated` | `1.0`, `240`, `True`; native Rust applies the timing policy |
199
200
  | `uuid_score_enabled`, `uuid_window`, `uuid_threshold` | `True`, `60`, `5`; weights: `uuid_malformed_weight=5`, `uuid_not_found_weight=1`, `uuid_success_decay=2` |
200
201
  | `required_headers`, `header_min_score` | `HTTP_USER_AGENT` and `HTTP_ACCEPT`, `3`; empty required list disables required-header/quality checks, retains safety caps |
201
202
  | `anomaly_window`, `anomaly_keywords` | `60`, standard anomaly vocabulary; history/scoring is held in Rust per worker |
@@ -214,26 +215,98 @@ timestamps in an expiring map and evaluates/clears POST timing atomically,
214
215
  avoiding a durable CSV rewrite on each GET. Timing state is isolated per engine,
215
216
  is not shared across workers and resets on restart. Backend switches do not
216
217
  transfer timestamps automatically. Keep `csv` for shared or persistent timing;
217
- CSV writes remain immediately synced. Blacklist, keyword, geo and whitelist
218
+ CSV writes remain immediately synced. Blocklist, keyword, geo and allowlist
218
219
  policy files and immediate request logging keep their configured CSV behavior.
219
220
 
220
- A second matched WSL benchmark compared these two timing backends with all
221
- eight stages enabled. Three alternating runs of 300 requests per mode/framework
222
- measured the following added overhead after subtracting framework-only latency:
221
+ ### Flask and FastAPI native honeypot cache
223
222
 
224
- | Framework | CSV timing, AI off | Memory timing, AI off | CSV timing, AI on | Memory timing, AI on |
225
- | --- | ---: | ---: | ---: | ---: |
226
- | Flask | 3.74 ms | 0.83 ms | 3.66 ms | 0.97 ms |
227
- | Django | 3.67 ms | 0.91 ms | 4.02 ms | 0.83 ms |
228
- | FastAPI | 3.78 ms | 0.78 ms | 3.70 ms | 0.92 ms |
223
+ Both native adapters accept Redis or a supplied synchronous cache. CSV remains
224
+ their default. This changes honeypot timestamp storage only; other policies and
225
+ rate-limit backends retain their configured behavior.
229
226
 
230
- All 13,500 measured requests returned 200 and both protected modes blocked the
231
- SQL/PHP probes. These are medians of per-run mean server times for a synthetic
232
- one-client workload with immediate logging, 80% GET / 20% JSON POST, 30 fields
233
- and a seeded 100-tree Rust model when AI is enabled. The performance comparison
234
- does not remove the persistence and cross-worker differences between backends.
235
- Reproduce memory mode with `--pipeline --honeypot-backend memory` in the HTTP
236
- benchmark harness; the default remains `--honeypot-backend csv`.
227
+ ```python
228
+ import os
229
+ from aiwaf.flask.csv_pipeline import NativeAIWAF
230
+
231
+ profile = {
232
+ "data_dir": "aiwaf_data",
233
+ "honeypot_backend": "redis",
234
+ "honeypot_redis_url": os.environ["AIWAF_REDIS_URL"],
235
+ "honeypot_cache_namespace": "myapp:honeypot:v1",
236
+ }
237
+ NativeAIWAF(app, config=profile) # Flask
238
+
239
+ # FastAPI alternative:
240
+ # from aiwaf.fast.csv_pipeline import NativeAIWAFMiddleware
241
+ # app.add_middleware(NativeAIWAFMiddleware, config=profile)
242
+ ```
243
+
244
+ For an existing Flask-Caching instance or another compatible object, select
245
+ `honeypot_backend="cache"` and pass `honeypot_cache=cache` to either native adapter.
246
+ The contract is `get(key)` returning a stored value or `None`, and
247
+ `set(key, value, timeout=seconds)` returning success or `None`. Explicit `False`
248
+ means failure. Methods must be synchronous, preserve a timestamp/expiry pair,
249
+ honor TTL, and propagate storage errors. Disable any ignored-error option;
250
+ no-op cache backends are unsuitable. Custom adapters must translate their own
251
+ cache's TTL argument if it differs. A local cache still isolates workers.
252
+
253
+ Rust retains timing decisions, exemptions and logical expiry. Entries have a
254
+ 300-second TTL; misses/evictions permit the POST timing check, while exceptions,
255
+ invalid records and failed writes return generic HTTP 503. Expired-page POSTs
256
+ return 409 until a new GET or TTL expiry, without deleting a concurrent refresh.
257
+ FastAPI offloads the cache-backed native request check to its worker thread pool
258
+ so synchronous network I/O does not block the event loop. Pool saturation and
259
+ cache latency still affect request latency. Existing CSV/memory timing behavior
260
+ and the legacy middleware chain are unchanged.
261
+
262
+ To exercise independent workers against a dedicated test Redis instance, set
263
+ `AIWAF_TEST_REDIS_URL` and run
264
+ `python -m pytest tests/integration/test_native_honeypot_cache.py`.
265
+
266
+ ### Django native honeypot cache
267
+
268
+ Starting with Python 1.1.7 / aiwaf-rust 0.2.6, Django's native middleware uses
269
+ the existing Django cache for honeypot GET timestamps by default. Rust calls a
270
+ small Python storage adapter; form timing, logical expiry, exemptions and block
271
+ decisions remain native. Other policies retain their configured CSV storage.
272
+
273
+ ```python
274
+ AIWAF_CSV_PIPELINE = {
275
+ "data_dir": "aiwaf_data",
276
+ "honeypot_cache_alias": "default", # optional; uses CACHES["default"]
277
+ }
278
+ ```
279
+
280
+ Use a shared Django cache backend for cross-worker timing. For example, Django's
281
+ built-in Redis cache can be configured as follows (install its Redis Python
282
+ driver and configure the URL for your deployment):
283
+
284
+ ```python
285
+ CACHES = {
286
+ "default": {
287
+ "BACKEND": "django.core.cache.backends.redis.RedisCache",
288
+ "LOCATION": "redis://127.0.0.1:6379/1",
289
+ "KEY_PREFIX": "my-service",
290
+ },
291
+ }
292
+ ```
293
+
294
+ LocMemCache remains supported with a startup warning: it is worker-local and
295
+ resets on restart. DummyCache is rejected when the honeypot stage is enabled.
296
+ Configured ignored cache errors are rejected; runtime read/write failures,
297
+ failed writes and invalid timestamp records produce generic HTTP 503, without
298
+ silently selecting memory or CSV. Cache methods must be synchronous.
299
+
300
+ Timestamp entries use a 300-second TTL and bounded, hashed client-IP keys under
301
+ Django's key prefix/version. Expired-page POSTs return 409 until a fresh GET or
302
+ TTL expiry. The pipeline does not delete an expired snapshot, so it cannot erase
303
+ a concurrent GET refresh. As before, no timestamp means the timing check allows
304
+ the POST; cache outages are distinguished from misses. Backends can evict entries
305
+ before their TTL. Changing backends does not migrate existing timestamps.
306
+
307
+ Set `"honeypot_backend": "csv"` explicitly to retain shared filesystem timing,
308
+ or `"memory"` for the per-engine Rust map. Install the matching native extension
309
+ before upgrading Django workers. Flask and FastAPI defaults are unchanged.
237
310
 
238
311
  Flask/FastAPI accept synchronous `country_lookup(ip)` and
239
312
  `authenticated(request)` callbacks for adapter facts. Default GeoIP uses the
@@ -251,30 +324,6 @@ available. Session/route handlers, response construction, GeoIP lookup and legac
251
324
  custom integrations still execute in Python; the whole Python package has not
252
325
  been rewritten in Rust.
253
326
 
254
- Measure this path with `scripts/benchmark_release_http.py --pipeline`, alongside
255
- the existing chain and `--plain` framework baseline. Native execution and both
256
- SQL/PHP protection probes are checked by the harness; the benchmark report
257
- records workload details and subtracts the framework baseline for added overhead.
258
-
259
- Matched WSL tests of the complete pipeline (three alternating runs of 300
260
- requests per framework/mode, one client, all eight stages and immediate CSV
261
- logging) measured the following **added overhead**, after subtracting the same
262
- framework-only baseline. The comparison is against the current legacy chain.
263
-
264
- | Framework | Current chain, AI off | Native pipeline, AI off | Current chain, AI on | Native pipeline, AI on |
265
- | --- | ---: | ---: | ---: | ---: |
266
- | Flask | 10.60 ms | 3.77 ms | 14.53 ms | 3.56 ms |
267
- | Django | 14.18 ms | 3.52 ms | 18.98 ms | 3.66 ms |
268
- | FastAPI | 11.83 ms | 3.52 ms | 12.21 ms | 3.67 ms |
269
-
270
- These are medians of per-run mean server times. Native and legacy run ranges
271
- were separated in all six protected comparisons. All 13,500 measured requests
272
- returned 200 and both protected modes blocked SQL/PHP probes. The AI fixture
273
- used a seeded 100-tree Rust forest and 200 initial history records per client.
274
- The dedicated profile, storage layout and adapter semantics differ from some
275
- legacy configurations; this is a synthetic comparison of the documented modes,
276
- not a production latency guarantee or a drop-in migration result.
277
-
278
327
  ### Flask
279
328
 
280
329
  ```python
@@ -433,7 +482,7 @@ the new capabilities. Older extensions retain the compatible Python fallback.
433
482
 
434
483
  - **CSV storage:** bounded snapshot caches and indexed IP/key lookups avoid repeated
435
484
  parsing and copying entire tables into Python. Native readers validate file
436
- metadata and use shared OS locks; mutations use exclusive locks. Blacklist
485
+ metadata and use shared OS locks; mutations use exclusive locks. Blocklist
437
486
  reputation updates, keyword increments/removals, exemptions, audit entries, and
438
487
  geo-list changes use atomic transactions. Unchanged policy rows skip rewriting
439
488
  and disk synchronization. Changed policy writes still synchronize to disk.
@@ -441,7 +490,7 @@ the new capabilities. Older extensions retain the compatible Python fallback.
441
490
  signatures, geo decisions, rate-window filtering, form timing, UUID format
442
491
  validation, reputation scoring, wildcard/CIDR exemptions, and longest-prefix
443
492
  route plans. Flask CSV keyword retrieval, evaluation, and learning share one
444
- native call. SQL checks and blacklist updates retain their existing order;
493
+ native call. SQL checks and blocklist updates retain their existing order;
445
494
  custom evaluators and unsupported Unicode behavior use the Python adapter.
446
495
  - **Exemption reuse:** Flask reuses CSV exemption results within a request and
447
496
  checks file identity, size, timestamps, and configuration before each reuse.
@@ -519,17 +568,10 @@ extra policy input. ORM-only Django operation remains separate. FastAPI geo
519
568
  middleware honors its `use_rust` option, passed from the application's Rust flags.
520
569
  Dynamic-only FastAPI policy and custom getters/evaluators retain their fallback
521
570
  path. Native reads respect TTLs and observe updates/removals; disabled native geo
522
- reads refresh the Python CSV snapshot. Exemptions and blacklist writes still run
571
+ reads refresh the Python CSV snapshot. Exemptions and blocklist writes still run
523
572
  at their original stages. Rebuild the extension from this checkout to test these
524
573
  unpublished capabilities.
525
574
 
526
- Run `python scripts/benchmark_native_request_batches.py` for the focused comparison.
527
- Three alternating Windows runs of 500 checks measured 100-field SQL inspection at
528
- 0.650 ms combined versus 0.989 ms previous, and the CSV geo binding at 0.286 ms
529
- versus 0.367 ms. Early SQL rejection measured 0.067 ms versus 0.066 ms. These
530
- isolated, warmed checks exclude the complete middleware chain, networking, model
531
- scoring, and concurrent load.
532
-
533
575
  ### Request-time anomaly acceleration (development)
534
576
 
535
577
  With a matching rebuilt extension and a real Rust Isolation Forest, Flask and
@@ -554,16 +596,6 @@ building a dictionary per historical record. No native process-local object is
554
596
  stored in Django's cache. These changes do not introduce model auto-reload or
555
597
  shared histories for Flask/FastAPI.
556
598
 
557
- Run `python scripts/benchmark_anomaly_runtime.py` to compare the previous bridge,
558
- tuple analysis, and native histories with a real seeded forest. Five alternating
559
- Windows runs of 300 evaluations, a 100-tree forest, and 200 prior requests measured
560
- anomalous evaluation at 0.175 ms versus 0.486 ms (2.78x) and benign evaluation at
561
- 0.040 ms versus 0.146 ms (3.61x). The same WSL benchmark measured anomalous
562
- evaluation at 0.178 ms versus 0.533 ms (2.99x) and benign evaluation at
563
- 0.036 ms versus 0.126 ms (3.46x). These isolated engine timings exclude networking,
564
- CSV writes, real route-resolution costs, the full middleware chain, and concurrent
565
- load. They are not deployed-site speedup claims.
566
-
567
599
  Further request-path refinements use the existing native CSV log writer for
568
600
  Flask/FastAPI anomaly training logs when supported. Each row is flushed before
569
601
  returning; there is no background queue. `AIWAF_CSV_LOG_FSYNC=True` additionally
@@ -581,15 +613,7 @@ worker performs no background cleanup. Django continues to use cache timeouts.
581
613
  Rust recent-behavior analysis now counts symmetric ten-second bursts with a
582
614
  linear sweep after sorting finite timestamps, replacing two binary searches per
583
615
  record. Non-finite timestamps retain the established search path. This shared-core
584
- change also applies to the WASM recent-behavior API. Run
585
- `python scripts/benchmark_request_refinements.py` for isolated logging, route, and
586
- burst-analysis timings; these do not measure deployed-site throughput.
587
- With five runs of 300 operations in WSL, immediate CSV writes measured 0.030 ms
588
- versus 0.173 ms, repeated route checks 0.0175 ms versus 0.0266 ms, and analysis of
589
- 1,000 history records 0.663 ms versus 0.787 ms. The route comparison uses the
590
- previous implementation with its exception import corrected; burst timings
591
- include Python-to-Rust tuple conversion. These benchmarks use local files and
592
- synthetic inputs, without concurrent load.
616
+ change also applies to the WASM recent-behavior API.
593
617
 
594
618
  ### Python operations
595
619
 
@@ -604,26 +628,17 @@ rebuild the profile; CSV state remains live. Flask/FastAPI can use one native ca
604
628
  for supported query requests. Django keeps SQL inspection before route resolution,
605
629
  then uses the compiled keyword/CSV stage with the resolved route facts.
606
630
 
607
- Framework extraction, body buffering/replay, exemptions, blacklist enforcement,
631
+ Framework extraction, body buffering/replay, exemptions, blocklist enforcement,
608
632
  rate limits, honeypot/UUID hooks, header enforcement, and response processing keep
609
633
  their existing positions. Structured SQL bodies, Unicode paths/decoding, monitor
610
634
  mode, custom policy/storage hooks, custom Django converters, older extensions,
611
635
  and dynamic-keyword subsets whose ranking requires Python retain the established
612
636
  path. The engine does not replace the whole eight-middleware chain.
613
637
 
614
- Three alternating WSL runs of 300 requests through the full chain, at concurrency
615
- one with AI scoring off, observed server-time medians of 12.88 to 12.46 ms for
616
- Flask, 16.09 to 15.60 ms for Django, and 13.41 to 13.17 ms for FastAPI. Run ranges
617
- overlapped; these do not establish a dependable speedup. The opt-in default avoids
618
- assuming that fewer boundaries alone remove the remaining request cost. Compare
619
- `scripts/benchmark_release_http.py` with and without `--engine` using identical
620
- dependencies and traffic. `--plain` measures an endpoint without AIWAF, and the
621
- harness reports server processing time separately from HTTP latency.
622
-
623
638
  ```bash
624
639
  # Auto-detected CLI (one supported framework installed)
625
640
  aiwaf --help
626
- aiwaf blacklist migrate
641
+ aiwaf blocklist migrate
627
642
  aiwaf status
628
643
 
629
644
  # Django management commands
@@ -833,7 +848,7 @@ All eight stages are enabled by default. Native defaults include:
833
848
  | `exempt_paths`, `exempt_ips` | `/health`, `/robots.txt`, `/sitemap.xml`; no IPs; literal case-insensitive path prefixes |
834
849
  | `sql_mode`, `max_bytes` | `block`, `65536`; `off` supported, monitor rejected; bounded nested JSON/form values and double URL decoding |
835
850
  | `static_keywords`, `dynamic_keywords`, `legitimate_keywords`, `learning` | Native vocabulary, empty dynamic set, legitimate exact route names, `true`; learned probe segments capped at 4096 |
836
- | `geo_allow`, `geo_block`, `blacklist` | Empty; blacklist maps IP to Unix expiry seconds (`0` permanent) |
851
+ | `geo_allow`, `geo_block`, `blocklist` | Empty; blocklist maps IP to Unix expiry seconds (`0` permanent) |
837
852
  | `rate_window`, `rate_max`, `rate_flood`, `rate_key_mode` | `10` seconds, `20`, `40`, `ip_path`; `ip` also supported |
838
853
  | `min_form_time`, `max_page_time`, `skip_authenticated`, `honeypot_field` | `1.0`, `240` seconds, `true`, empty field; local Rust timing state |
839
854
  | `allowed_methods`, `uuid_prefix`, `uuid_window`, `uuid_threshold` | Empty method restriction, `/user/`, `60` seconds, `5` repeated UUID 404s; malformed UUID denied immediately |
@@ -885,23 +900,7 @@ installed before enforcement; required middleware overrides decorator exemptions
885
900
  while profile-level exemptions remain global. Next integration is Node API routes,
886
901
  not Edge/Fetch middleware.
887
902
 
888
- Run `npm run test:native` in `js/` against the built WASM package and
889
- `node scripts/benchmark_js_pipeline.js` for full HTTP comparisons. The benchmark
890
- subtracts bare Express server processing latency and includes synchronous response
891
- finalization/logging. Its legacy comparison uses SQLite policy lookups and JSONL
892
- logging, while native uses Rust state and CSV output; this is an integration
893
- comparison with different persistence/policy semantics, not a pure language test.
894
-
895
- The matched Windows HTTP benchmark (Node v22.18.0, Express 4.22.1) measured:
896
-
897
- | Mode | Server processing | Added overhead |
898
- | --- | ---: | ---: |
899
- | Express only | 0.37 ms | 0.00 ms |
900
- | Legacy, AI off | 3.86 ms | 3.48 ms |
901
- | Native, AI off | 0.60 ms | 0.22 ms |
902
- | Native, AI on | 0.64 ms | 0.27 ms |
903
-
904
- Server samples include synchronous finalization and immediate logging. Overhead subtracts the matched bare Express baseline; figures are medians of per-run means. Legacy uses SQLite policy lookups and one immediate JSONL append; native uses Rust state and one immediate CSV append. These stores/policies have different persistence semantics, so this is an integration comparison, not a pure Rust-versus-JavaScript equivalence test. GeoIP is an unknown-country fixture, not a real database lookup. Synthetic local latency does not establish production throughput or latency.
903
+ Run `npm run test:native` in `js/` against the built WASM package to validate the native integrations.
905
904
 
906
905
  ### JavaScript training and operations
907
906
 
@@ -910,8 +909,8 @@ cd js
910
909
 
911
910
  AIWAF_ACCESS_LOG=/path/to/access.log npm run train
912
911
  npm run aiwaf -- status
913
- npm run aiwaf -- list blacklist
914
- npm run aiwaf -- add blacklist 203.0.113.9 "manual block"
912
+ npm run aiwaf -- list blocklist
913
+ npm run aiwaf -- add blocklist 203.0.113.9 "manual block"
915
914
  npm run aiwaf -- add ip-exemption 203.0.113.10 "trusted monitor"
916
915
  npm run aiwaf -- geo summary
917
916
  npm run aiwaf -- model info
@@ -1028,7 +1027,7 @@ cp -R ../licenses crates/aiwaf_wasm/pkg/
1028
1027
 
1029
1028
  ## Java package
1030
1029
 
1031
- AIWAF Java 1.3.4 targets Java 17, Spring Framework 7.0, and Jakarta Servlet 6.1. It is a native Java implementation and does not load the Rust library.
1030
+ AIWAF Java 1.3.5 targets Java 17, Spring Framework 7.0, and Jakarta Servlet 6.1. It is a native Java implementation and does not load the Rust library.
1032
1031
 
1033
1032
  ### Core engine
1034
1033
 
@@ -1117,7 +1116,7 @@ UUID protection uses Python-compatible weighted signals: malformed input, valid
1117
1116
  Generate a route manifest from the live Spring application rather than supplying controller methods manually:
1118
1117
 
1119
1118
  ```bash
1120
- java -cp "your-app.jar:aiwaf-java-1.3.4.jar" \
1119
+ java -cp "your-app.jar:aiwaf-java-1.3.5.jar" \
1121
1120
  com.aiwaf.cli.AiwafConsole init \
1122
1121
  --app com.example.Application \
1123
1122
  --output .aiwaf/paths.json
@@ -1154,9 +1153,9 @@ The generic servlet filter uses request-time evaluation. Spring applications sho
1154
1153
  | Storage | `storageBackend`, `storageFilePath`, `storageRedisUrl`, `storageKeyPrefix`, `storageRedisFailureMode`, Redis timeout and pool limits |
1155
1154
  | Telemetry | `observabilityEnabled` |
1156
1155
 
1157
- GeoIP uses the bundled MMDB through the native Java reader; it does not require the external `mmdblookup` executable. A valid `X-Country` value is accepted only from a peer in `trustedProxyCidrs`; otherwise AIWAF resolves the client address itself. Default blacklist calls use Python-compatible reputation scoring and temporary escalation (15 minutes, 1 hour, then 24 hours). Use `BlacklistManager.blockPermanent(ip, reason)` for an explicit permanent administrative block.
1156
+ GeoIP uses the bundled MMDB through the native Java reader; it does not require the external `mmdblookup` executable. A valid `X-Country` value is accepted only from a peer in `trustedProxyCidrs`; otherwise AIWAF resolves the client address itself. Default blocklist calls use Python-compatible reputation scoring and temporary escalation (15 minutes, 1 hour, then 24 hours). Use `BlocklistManager.blockPermanent(ip, reason)` for an explicit permanent administrative block.
1158
1157
 
1159
- `storageBackend="redis"` makes rate-limit buckets, honeypot timing, weighted UUID scores, recent-request anomaly state, blacklist data, exemptions, geo policy, and learned keywords visible to every application instance using the same key prefix. Redis enforcement updates use atomic server-side scripts. Memory, file, CSV, and SQLite engines keep request state isolated per `AiwafEngine`; constructing another engine no longer replaces an existing engine's stores. The static `RuntimeStorage` and `BlacklistManager` methods remain compatibility facades for command-line and administrative code.
1158
+ `storageBackend="redis"` makes rate-limit buckets, honeypot timing, weighted UUID scores, recent-request anomaly state, blocklist data, exemptions, geo policy, and learned keywords visible to every application instance using the same key prefix. Redis enforcement updates use atomic server-side scripts. Memory, file, CSV, and SQLite engines keep request state isolated per `AiwafEngine`; constructing another engine no longer replaces an existing engine's stores. The static `RuntimeStorage` and `BlocklistManager` methods remain compatibility facades for command-line and administrative code.
1160
1159
 
1161
1160
  The Java 1.3 Redis backend supports **standalone Redis only**. Sentinel and Cluster configurations are rejected during validation instead of silently operating with incomplete semantics. `fail_closed` is the default: an unavailable Redis instance prevents startup or raises a request-path storage failure, which results in the application denying availability rather than bypassing protection. `fail_open` permits startup and returns non-blocking enforcement fallbacks while Redis is unavailable; failed mutations return `false` at the `StorageBackend` boundary. Connection, socket, pool size, and pool wait limits are bounded and configurable. `RedisStorage.diagnostics()` reports operation/failure counts, latency, and live pool utilization.
1162
1161
 
@@ -1199,13 +1198,13 @@ Replaying old logs cannot extend an active block or recreate one after expiry
1199
1198
  or manual removal. Fresh traffic must independently satisfy the blocking rules.
1200
1199
 
1201
1200
  CLI listing filters expired blocks for display without rewriting its snapshot
1202
- back to the blacklist. This prevents concurrent training updates from being
1201
+ back to the blocklist. This prevents concurrent training updates from being
1203
1202
  erased by an older cleanup snapshot. Default first blocks last 900 seconds.
1204
1203
 
1205
- Keep the receipt file across restarts, log rotation, and blacklist clearing.
1204
+ Keep the receipt file across restarts, log rotation, and blocklist clearing.
1206
1205
  Receipts do not expire and grow with the distinct requests used in block
1207
1206
  decisions. `AIWAF_TRAINING_STATE_DIR` can select a durable shared directory;
1208
- trainers sharing a blacklist must also share this directory. Missing native
1207
+ trainers sharing a blocklist must also share this directory. Missing native
1209
1208
  capabilities or corrupt receipt state stop training visibly. A crash between
1210
1209
  writing a block and committing its receipt can still require recovery; the two
1211
1210
  writes are not a single transaction.
@@ -1220,9 +1219,9 @@ disappearing before its expiry.
1220
1219
  Node.js 1.1.4 with aiwaf-wasm 0.2.4 uses the same Rust receipt algorithm as
1221
1220
  Python. The shared trainer applies this protection across JavaScript framework
1222
1221
  adapters. The WASM `NativeTrainingEvidence` API hashes and filters evidence;
1223
- Node persists `node_training_evidence.json` in the blacklist CSV directory, or
1222
+ Node persists `node_training_evidence.json` in the blocklist CSV directory, or
1224
1223
  the directory selected by `AIWAF_TRAINING_STATE_DIR`. Preserve this file across
1225
- expiry, unblocking, blacklist clearing, and log rotation. Sharing a blacklist
1224
+ expiry, unblocking, blocklist clearing, and log rotation. Sharing a blocklist
1226
1225
  also requires sharing the evidence directory. Model fitting and keyword learning
1227
1226
  still use full history; 404 and anomaly enforcement use fresh evidence only.
1228
1227
  Log records without a valid stable timestamp are excluded from training.
@@ -1239,15 +1238,15 @@ storage errors. Programmatic callers can await `require('aiwaf/train')()`.
1239
1238
  Publish the matching WASM package before the Node package; `test:wasm-real`
1240
1239
  checks receipt restoration against the installed dependency, not just a fixture.
1241
1240
 
1242
- Java's `train-model` operation fits and saves a model without adding blacklist
1241
+ Java's `train-model` operation fits and saves a model without adding blocklist
1243
1242
  entries. Servlet and Spring use that shared Java core. Retraining alone therefore
1244
1243
  cannot extend or recreate their runtime blocks; a regression test verifies this.
1245
1244
 
1246
- Blacklist expiry is also protected against concurrent updates. Node request
1245
+ Blocklist expiry is also protected against concurrent updates. Node request
1247
1246
  checks and listings do not delete expired snapshots. Explicit cleanup checks
1248
1247
  expiry in the database DELETE, or inside the CSV mutation lock after reading
1249
- the current rows. CSV blacklist writers use the same lock and atomically replace
1250
- the file. A crashed writer can leave `<blacklist CSV path>.lock`; stop its owner
1248
+ the current rows. CSV blocklist writers use the same lock and atomically replace
1249
+ the file. A crashed writer can leave `<blocklist CSV path>.lock`; stop its owner
1251
1250
  before removing that lock directory. Lock acquisition times out after 60 seconds
1252
1251
  and reports an error rather than proceeding without protection.
1253
1252
 
@@ -1286,7 +1285,7 @@ Do not train directly on unreviewed sensitive request bodies or authentication h
1286
1285
 
1287
1286
  - Configure the application to trust forwarding headers only from known proxy CIDRs.
1288
1287
  - Configure the outermost proxy to overwrite client-supplied forwarding headers.
1289
- - Use Redis, a database, or another shared backend when multiple workers must share rate-limit, blacklist, or exemption state.
1288
+ - Use Redis, a database, or another shared backend when multiple workers must share rate-limit, blocklist, or exemption state.
1290
1289
  - Keep health checks, static assets, and trusted webhook routes explicitly scoped instead of disabling protection globally.
1291
1290
  - Start anomaly detection in observe-only or conservative mode and tune it with representative normal traffic.
1292
1291
  - Rotate logs and exclude secrets, authorization headers, cookies, and personal data.
@@ -1342,67 +1341,17 @@ pytest -q rust/tests/test_python_api.py
1342
1341
  mvn -f java/pom.xml test
1343
1342
  ```
1344
1343
 
1345
- ### Benchmark
1346
-
1347
- The in-process Flask benchmark compares a baseline app, `auto` middleware selection, and the full middleware chain:
1348
-
1349
- ```bash
1350
- python -m benchmarks.benchmark_auto_middleware
1351
- python -m benchmarks.benchmark_auto_middleware --path-rules 250
1352
- python -m benchmarks.benchmark_auto_middleware --requests 200 --rounds 3 --warmup 50
1353
- ```
1354
-
1355
- Use the same machine, environment, request count, and background load when comparing results. These measurements exclude network and production-server overhead.
1356
-
1357
- The latest native optimization measurements used three alternating runs. Timestamp
1358
- and feature/model tests used 10,000 synthetic records; the model test used a
1359
- 20-tree forest and compared the previous Rust-feature/Python-matrix path with
1360
- retained native features.
1361
-
1362
- | Scoped workload | Windows speedup | WSL Linux speedup |
1363
- | --- | ---: | ---: |
1364
- | Unique Apache timestamp parsing | 4.57× | 3.65× |
1365
- | Feature extraction + Rust fit/predict boundary | 1.55× | 1.35× |
1366
-
1367
- Native ISO parsing was slower on both platforms, so it remains optional. An
1368
- offline Windows Flask test-client workload with IP/keyword enforcement and CSV
1369
- logging measured 5.95 ms/request native versus 9.18 ms/request Python (1.54×),
1370
- using 100 initial blacklist rows and 20 requests per trial. These measurements
1371
- exclude networking, production-server overhead, and concurrent request load;
1372
- they do not establish a complete training or deployed-site speedup.
1373
-
1374
- Reproduce the focused measurements and concurrency smoke check locally:
1375
-
1376
- ```bash
1377
- python scripts/benchmark_native_training_boundary.py
1378
- python scripts/benchmark_native_csv_training.py
1379
- python scripts/benchmark_native_csv_workloads.py
1380
- python scripts/benchmark_csv_request_reuse.py
1381
- python scripts/profile_csv_logging.py
1382
- python scripts/check_csv_release_concurrency.py
1383
- ```
1384
-
1385
- Validation of the development changes passed 282 Django tests, 134 FastAPI tests
1386
- (one skipped), and 247 Flask/core optimization tests in separate processes.
1387
- Coverage includes timestamp fallbacks, gzip/quoted CSV, seeded model parity,
1388
- chunk equivalence, concurrent mutations, no-op writes, and log rotation/reopening.
1389
- An installed-wheel Linux smoke check with four processes retained all 160 access
1390
- rows and 80 blacklist entries. Local wheels were checked on Windows Python 3.13
1391
- and WSL Python 3.10; the locally built Linux wheel requires glibc 2.34 or newer.
1392
- The complete supported platform/version matrix and production load validation
1393
- remain release checks.
1394
-
1395
1344
  ## Release automation
1396
1345
 
1397
1346
  Release versions and tags must match the relevant manifest.
1398
1347
 
1399
1348
  | Package | Manifest | Tag | Workflow |
1400
1349
  | --- | --- | --- | --- |
1401
- | Python `aiwaf` | `pyproject.toml` | `python-v1.1.6` | `python-publish.yml` |
1402
- | npm `aiwaf` | `js/package.json` | `js-v1.1.4` | `npm-publish.yml` |
1403
- | PyPI `aiwaf-rust` | `rust/pyproject.toml` + `rust/Cargo.toml` | `rust-v0.2.5` | `rust-publish.yml` |
1404
- | npm `aiwaf-wasm` | `rust/crates/aiwaf_wasm/Cargo.toml` | `wasm-v0.2.4` | `wasm-publish.yml` |
1405
- | Maven `aiwaf-java` | `java/pom.xml` | `java-v1.3.4` | `java-publish.yml` |
1350
+ | Python `aiwaf` | `pyproject.toml` | `python-v1.1.8` | `python-publish.yml` |
1351
+ | npm `aiwaf` | `js/package.json` | `js-v1.1.5` | `npm-publish.yml` |
1352
+ | PyPI `aiwaf-rust` | `rust/pyproject.toml` + `rust/Cargo.toml` | `rust-v0.2.7` | `rust-publish.yml` |
1353
+ | npm `aiwaf-wasm` | `rust/crates/aiwaf_wasm/Cargo.toml` | `wasm-v0.2.5` | `wasm-publish.yml` |
1354
+ | Maven `aiwaf-java` | `java/pom.xml` | `java-v1.3.5` | `java-publish.yml` |
1406
1355
 
1407
1356
  Python and Rust publish to PyPI with trusted publishing. The npm workflows use npm trusted publishing and stage packages for approval. Configure the trusted publisher with organization `aiwaf-project`, repository `aiwaf`, the exact workflow filename, and the environment used by that workflow.
1408
1357
 
@@ -1410,8 +1359,8 @@ Java publishing uses the protected `maven-publish` environment plus `GPG_PRIVATE
1410
1359
 
1411
1360
  Registry releases are immutable. Increment the relevant manifest version before publishing another release.
1412
1361
 
1413
- For the replay fix, publish `aiwaf-rust 0.2.5` before Python `aiwaf 1.1.6`, and
1414
- `aiwaf-wasm 0.2.4` before npm `aiwaf 1.1.4`. After WASM publication, refresh the
1362
+ For this release, publish `aiwaf-rust 0.2.7` before Python `aiwaf 1.1.8`, and
1363
+ `aiwaf-wasm 0.2.5` before npm `aiwaf 1.1.5`. After WASM publication, refresh the
1415
1364
  npm lockfile against the registry to record the actual companion checksum, then
1416
1365
  run `npm ci` and the release checks. The prepared future WASM lock entry has no
1417
1366
  integrity checksum; it cannot be installed until that package is published.
@@ -1438,6 +1387,8 @@ Original AIWAF project code in this checkout uses the unmodified [Elastic Licens
1438
1387
 
1439
1388
  This migration applies to this checkout and future releases expressly distributed under ELv2. Previously distributed MIT copies retain their permissions; version numbers do not retroactively change their license. Do not republish an existing version with new licensing terms. Independently versioned packages record their license in their release artifacts.
1440
1389
 
1390
+ Initial ELv2 release boundaries are Python/Node.js `1.1.2`, Rust/Python and WASM `0.2.2`, and Java `1.3.3`. Earlier MIT distributions retain their MIT permissions.
1391
+
1441
1392
  Retained MIT contributions keep their rights and notices in [licenses/MIT.txt](licenses/MIT.txt). The bundled IPinfo Lite database is provided by [IPinfo](https://ipinfo.io/) under [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/); ELv2 restrictions do not apply to that data. Package metadata uses an `AND` expression where separately licensed components are included; this does not offer a choice to license the entire package under MIT. Dependencies retain their respective terms.
1442
1393
 
1443
1394
  Redistributions must include the applicable LICENSE, NOTICE, and licenses/ files. See [NOTICE](NOTICE) for historical rights, contributor notices, and attribution.