Initial implementation of the OPEN-2 epic: a .NET 10 YARP edge that decides from what the upstream answered. Design (docs/ARCHITECTURE.md, tracker authority 4c9de3f6): - one short-circuit point, ordered: always-pass prefixes -> allowlist -> operator block (301) -> engine ban (403 + Retry-After) -> geo (451) - a post-response observer feeds a consecutive-refusal streak; N refusals in M minutes ban for BanDuration; 5xx alerts and never bans - provenance on the block row, so clearing engine bans cannot touch an operator's entries; the toggle is Off/Observe/Enforce and changes no rows - inherited protections from the reference deployment: one durable write per source per 30s, LRU-bounded streak map, no DB on the request path Verification: 36 unit + 14 integration tests, plus scripts/smoke.sh (19 assertions against a running edge and a real upstream, including the distroless --healthcheck mode). Findings worth keeping (documented in docs/ARCHITECTURE.md): - ctx.RequestAborted silently cancelled the ban write, because the observer runs after the response is written - SQLite cannot translate DateTimeOffset comparisons; timestamps are stored as integers there and stay timestamptz on PostgreSQL - CIDR masking order silently widened prefixes (198.51.100.24/19 -> /16) - an empty string in appsettings.json defeats the env fallback (?? on "") - concurrent ban writes raced into the unique index and lost evidence Also moves the unrelated 2026-09-30 inference benchmarks out of the project root into research/.
40 lines
1.4 KiB
YAML
40 lines
1.4 KiB
YAML
# The edge in front of an application it knows nothing about. That is the
|
|
# point: openwaf decides on what the upstream answered, so the upstream can be
|
|
# anything. `upstream` here is nginx purely so the compose file demonstrates a
|
|
# ban with nothing but curl.
|
|
#
|
|
# Before starting: set OPENWAF_ADMIN_TOKEN. Without it the admin API is closed
|
|
# (404), which is the safe default, not a misconfiguration.
|
|
services:
|
|
edge:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
ports:
|
|
- "8080:8080"
|
|
environment:
|
|
OPENWAF_ADMIN_TOKEN: ${OPENWAF_ADMIN_TOKEN:?set OPENWAF_ADMIN_TOKEN before starting}
|
|
OpenWaf__Policy__Mode: Enforce
|
|
OpenWaf__Policy__StreakThreshold: "10"
|
|
OpenWaf__Policy__StreakWindow: "00:05:00"
|
|
OpenWaf__Policy__BanDuration: "01:00:00"
|
|
# Only turn this on when the edge sits behind a proxy you control and
|
|
# whose address you have allowlisted. If X-Forwarded-For is
|
|
# attacker-controlled, every request gets a fresh source key and no
|
|
# streak ever matures.
|
|
OpenWaf__Policy__TrustProxyHeaders: "false"
|
|
ReverseProxy__Clusters__upstream__Destinations__upstream1__Address: "http://upstream:80/"
|
|
volumes:
|
|
- openwaf-data:/app/data
|
|
- openwaf-geoip:/app/geoip
|
|
depends_on:
|
|
- upstream
|
|
|
|
upstream:
|
|
image: nginx:alpine
|
|
restart: unless-stopped
|
|
|
|
volumes:
|
|
openwaf-data:
|
|
openwaf-geoip:
|