main
10
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
7c5e1ef230 |
the edge gains a schema step a compiled binary can run, and NativeAOT gets a measured verdict
ci / lint the workflow and the shell (push) Successful in 10s
geo-freshness / the pinned geo database vs the vendor (push) Successful in 5s
ci / the operator page in a real browser (push) Successful in 3m42s
ci / build, test, smoke (push) Failing after 2m6s
ci / build the image and smoke it (push) Successful in 5m7s
The Dockerfile said "why not NativeAOT" on the authority of another repo's
Dockerfile. That claim is now this repo's own, and it is a measurement.
What was built to find out:
* Persistence/Schema/schema.sqlite.sql — the model's DDL, generated by
`dotnet ef dbcontext script`, embedded in the binary and read by
Persistence/EmbeddedSchema.cs. A NativeAOT build cannot ask EF to build a
model at run time, and EnsureCreated and GenerateCreateScript both go through
the design-time model, so the schema step has nowhere to get its SQL from.
OPENWAF_SCHEMA=script is the fourth strategy: same provider-shaped
statements, produced at build time instead of at start-up. The schema-script
CI step regenerates the file and fails the run when the committed copy is not
what the current model produces (5652 bytes today).
* SchemaUpgrader.ModelTables asks the runtime model, per entity type. The
design-time one is refused outright under NativeAOT, and GetRelationalModel()
on the runtime model of a compiled model throws
"The annotation 'Relational:DefaultMappings' cannot be added because an
annotation with the same name already exists on the object EntityType:
CountryRule" — building a compiled model's relational model a second time
collides with itself.
* The persistence layer's queries were rewritten into the shape EF's query
precompiler accepts: captured parameters copied to locals, conditional
IQueryable composition written as literal chains, aggregates that take a
predicate given their own Where. 40 of them were refused before that.
* dotnet-ef and EF Core moved 10.0.0 -> 10.0.12, because 10.0.0's design package
ships no build host and `--precompile-queries` cannot load a project without it.
What the measurement says, from scripts/aot-probe.sh on osx-arm64: the AOT build
compiles (48,797,072-byte native binary, 10 IL warnings, 0 errors), starts, and
creates all 12 tables from the DDL it carries. Then it never serves. EF refuses
every query at run time ("Query wasn't precompiled and dynamic code isn't
supported with NativeAOT"), and the precompiler that would fix that is not
usable on this model: after all 40 refusals were cleared it emitted 14
declarations with dots in the identifier
(`var openWaf.Domain.Security.BlockEntryPrimaryKeyProperties = …`) — 28 CS1002
and CS1003 errors, one per entity materialisation — with or without --nativeaot.
The refusals themselves trace to dotnet/efcore#35887, #38030 and #35494; the fix
landed in the 12.0-preview1 milestone, not in any 10.0.x.
Two things were not kept, and why:
* The atomic alert-queue claim and the claim release were rewritten as raw SQL
to dodge the precompiler's ExecuteUpdate failures. Reverted: with the
statement written as SQL, DateTimeOffset reaches sqlite as a provider
parameter instead of through the property's own mapping, the reclaim
comparison stops matching, and
AlertPushQueueTests.A_delivery_owed_by_a_process_that_stopped_is_owed_by_the_next_one
fails with the row still owed. A correctness risk here buys nothing when the
AOT build is blocked further along anyway.
* --nativeaot on the compiled model: its unsafe accessors do not compile
(CS1503 in BlockEntryEntityType.cs). The plain compiled model is what is
committed.
The compose gate's two escalation-count scenes also stopped being a coin toss.
They slept a fixed 2 s and then counted; on a loaded host the same tree read 3
rows once and 1 the next, and the assertion is about a settled number either
way. They now wait for three equal reads, bounded. The scene count is unchanged
at 368.
Gates at this commit: build 0 warnings / 0 errors, unit 378/378, integration
405/405, schema-script ok, smoke 256/0, compose-smoke 368/0, README counts
match (256, 368), lint clean (actionlint 1.7.12, shellcheck 0.11.0).
Not verified: the AOT image on linux-x64 — the probe ran on osx-arm64, and the
ILC failure mode that ends the attempt is a codegen bug in EF, not a
platform-specific one, but that is an inference rather than a measurement.
|
||
|
|
848ec1a82a |
an operator can ban a range, not only an address
A scanner rotating through a rented /29 used to cost one row and one write per address: POST /admin-api/blocks answered "not an IP address" for a CIDR while the allowlist control beside it accepted one, and the config export could not carry the operator's answer either. A CIDR now has its own table and is enforced by containment. The rulings: - One list, two shapes. GET /admin-api/blocks merges address rows and range rows and says which is which with `kind`; DELETE ?key= takes the CIDR as it was typed; ?source=engine still cannot reach an operator's range, while ?source=operator clears both operator shapes. - Containment is checked on the raw peer address, the same field the allowlist is matched on, after the exact operator block and before the engine's own ban. The verdict stays block_operator, so nothing downstream had to learn a new reason; the decision trace names the range that answered, and an allow entry still outranks a range. - What is written is normalised before it is stored: 203.0.113.37/28 is stored as 203.0.113.32/28, a /32 or /128 is stored as the bare address it already was, and the full-width prefix is refused on meaning rather than on form — "0.0.0.0/0" covers every address there is, including the one this was written from; that is a shutdown, not a ban on a source. - A request pays for the number of distinct prefix lengths, not for the number of ranges: the index buckets by prefix and asks a set for the request address masked to it, most specific first, and an expired row does not stop the search for a broader live one. - Export carries ranges in the blocks section and import lands them idempotently, so an edge's decisions survive the move. /state counts them apart from address blocks, and the console prints the shape beside the row. What the run caught: - BlockRow read Range?.Field ?? Entry!.Field. The two rows are mutually exclusive, so a range with no expiry, reason or redirect — the common case — dereferenced the row that is not there and GET /admin-api/blocks answered 500. - NetworkBanIndex filed a row under "a.b.c.d/24" while the lookup compared a masked address with no prefix, so no range ever matched: ten unit tests red before the bucket key was fixed to the network address alone. - smoke and compose both wrote their JSON bodies with escaped quotes straight inside a command substitution, which truncates the body and answers 400 — the hazard this file's own header warns about. The payloads are variables now. - Scene ordering in smoke: the range scene clears the engine's list wholesale, which took the expired scanner row a later scene asserts on. It runs after those scenes now, and says why in the file. - Test-side, worth keeping: 203.0.113.37/28 is not the network 203.0.113.16/28 names, so an assertion that writes one and expects the other is testing the mask, not the match. build 0 warnings / 0 errors, unit 334/334, integration 312/312 in 31 s, console 105 assertions 0 failed, smoke passed 137 failed 0, compose 285 passed 0 failed against the built image at 262 MB. Refs OPEN-66. |
||
|
|
6664f94b22 |
an operator's decisions move to another edge in one call
An operator running several edges types every rule several times: blocks, allowlist, request rules, country rules and the policy overrides have their own endpoints one row at a time, and nothing moved them as a set. A new deployment starts empty, and a change that turns out wrong has nothing to be restored from. This is the multi-instance finding one level up from the shared streak store: SharedStreaks shares the counters, nothing shared the decisions.
GET /admin-api/export answers one document — version, exportedAt, edgeId, per-section counts, the policy section, and blocks / allowlist / rules / country rules. Only live rows; rules keep their evaluation order; and the document names how many engine bans it left behind, because "0 blocks" and "0 operator blocks, 7 engine bans left behind" are different sentences. A ban the engine earned is a claim about this edge's own traffic, so enforcing it where that traffic was never seen is a decision nobody made.
POST /admin-api/import is additive and idempotent: it never deletes a row the document does not mention — a transfer that silently clears a fleet's exemptions is worse than one that duplicates a block — a live row for the same source is reported as already there rather than rewritten, and expiry travels as an instant, so a block that expires in ten minutes where it came from expires in ten minutes here. Per-section counts (added / alreadyThere / skippedExpired / rejected) and a rejected[] list named by section and index; an unknown version, an oversize body or a malformed document writes nothing at all; a storage failure answers 503 with the report, because "it failed" and "it added 41 of 60" must not collapse into one sentence.
What the run caught, in order: (1) a unit assert used "203.0.113" as the invalid address and passed for the wrong reason — IPAddress.TryParse accepts it as 203.0.113.0, so the assert now names 203.0.113.999. (2) Two smoke asserts were wrong rather than the product: a helper printed a Python boolean where the gate compares text, and a blocks delete was asserted as 204 when the endpoint answers 200 with {"deleted":n}. (3) The metrics-as-a-number test could pass its wait on a cache refreshed between an enqueue and its first attempt — pending > 0 was true a moment before attempts > 0 could be — so the wait now requires both numbers. (4) A real defect, not a test one: the alert notifier left the rows it had claimed claimed when the process stopped, so the next process waited out the five-minute reclaim window to deliver an alert that was already owed. It now releases what it holds on the way out, and the reclaim window is back to being what it is for — a process that was killed and cannot say anything.
Gates on this tree: build 0 warnings / 0 errors, unit 285/285, integration 257/257 in 23s, smoke 82 passed / 0 failed (14 new), image 262 MB, compose-smoke 243 passed / 0 failed with 0 containers left behind (11 new, against the shipped image).
Refs OPEN-61.
|
||
|
|
5cf93ef0fd |
a source that asks too often is stopped, even when the origin keeps answering
Every defence this edge had reads something that already happened: the status the application answered, the country the address sits in, a list a human wrote. A source asking for a cheap path two hundred times a minute produces no refusal, so no streak matures, no path rule names it, and the origin serves all two hundred. The only signal is the count, and a count has to be kept while the requests are arriving — which is why this pillar is the one piece of live state on the request path, and why it runs after the ordered decision instead of inside it. `rateMode` off|observe|enforce, `rateLimitPerWindow`, `rateWindowSeconds` (policy_settings, so no schema change). Off is the default: a limit nobody wrote is a defence nobody asked for, and a false positive here locks out a whole office behind one address. `observe` counts and raises one `rate_breach` alert per source per window. `enforce` answers the request that crosses with 429 + Retry-After — the surplus never reaches the origin — and writes an engine ban, so the stop outlives the window, is shared with the other edges and survives a restart; from then on the answer is the ban's own 403. One breach, one alert, one ban write per source per window: a flood is exactly the traffic that turns a per-request durable write into the thing that takes the database down. Exempt by construction rather than by a second copy of the precedence rules: the counter runs only on a plain Pass, so an always-pass prefix, an allowlisted address, a matched rule, a block or a geo refusal never reaches it. The budget counts exactly the requests that would have cost the origin. Costs, stated rather than hidden: the counter is per process, so N edges allow N times the budget (the same trade `SharedStreaks` made for the streak, at a round trip per request instead of per observed response); the window is fixed, not sliding, so the worst sustained rate is twice the limit across one boundary — a sliding counter needs one entry per request, which is a map that grows at attack rate. Two things the run caught rather than the design assumed: * The guard wrote the 429 and then called next() anyway, so YARP answered "the request cannot be forwarded, the response has already started". The pillar now says whether the request may go through. * `StreakTracker.Configure` was called by nobody outside its own tests, so `maxTrackedSources` bounded nothing in a running edge — the map grew to the built-in 10000 whatever the operator had asked for. Both maps are configured at warm-up and on a policy write now. And the smoke gate was not testing what its first line says. The edge was started from the repository root, where there is no appsettings.json, so it loaded no ReverseProxy section at all, logged "Request reached the end of the middleware pipeline without being handled by application code" for every request, and answered 404 for a path the upstream was serving with 200. Every assertion in the file expects a 404 or a refusal, so the gate kept passing on an edge that never proxied anything. Naming the content root fixes it; the streak scene also waits for the ban row to exist before asking the wire whether it is enforced, because the ban is written out of band after the response that proved it. Gates on this tree: build 0 warnings 0 errors, unit 207/207, integration 219/219 in 20 s, smoke passed 48 failed 0, console 90 assertions 0 failed, compose 209 passed 0 failed, image 261 MB. OPEN-56 |
||
|
|
dbf3c725e6 |
an operator block can now be time-boxed, on the wire and on the page
The model always had it: BlockEntry.ExpiresAt, DecisionEngine asking IsLive before honouring a row, and the listing printing the column since OPEN-28. What did not exist was a way to set it — AddOperatorAsync wrote ExpiresAt = null for every operator block, and NewBlockRequest had no field for it. So "block this for the night" meant "block this, and remember to delete it in the morning", while the exemption form beside it already had a minutes box. POST /admin-api/blocks now takes expiresInMinutes with the same 1..5,256,000 bound and the same rule as the exemption's field: present sets the expiry, absent means the block stands until someone takes it off. Re-blocking an address that already carries an expiry moves it, because the second call means its own duration from now. 0 and 5,256,001 are a 400 naming the field rather than a permanent block bought by a zero in a box. The console gets the minutes input and refuses a zero before the round trip. Measured on this tree: build 0 warnings / 0 errors, unit 132/132, integration 185/185 in 19 s (4 new: the expiry lands and the listing says so; 0, -10 and 5,256,001 refused by name with nothing written and the address still itself; a block past its expiry stops being enforced while a second blocked address stays blocked and the dead row shows as expired rather than vanishing; a second POST moves the expiry), smoke 28/0, console 78 assertions 0 failed. The console gate run also printed the row it wrote: expiry cell "2026-10-04 15:05:37" against a permanent block's empty one. |
||
|
|
dcf8a733a9 |
A healed storage failure returned the edge to ready without waiting for traffic
OPEN-34, measured on the shipped image before this change. With writes to block_entries aborted, five refusals produced counted write failures and /readyz 503. The triggers were then REMOVED — write path healthy, zero triggers left — and no further request was sent from that source: t+30 s /readyz 503 /state: banWriteFailures 3, bansNotWritten 3 t+60 s /readyz 503 unchanged t+90 s /readyz 503 unchanged t+120 s /readyz 503 unchanged The ban pillar clears only on a successful ban write, and the only thing that produced one was the source crossing the threshold again. Readiness — the signal an orchestrator uses to keep an edge in rotation — was therefore coupled to attack traffic: the quieter the site, the longer a repaired edge sat out of service, enforcing everything except one ban nobody had written. The fix is on the write side, not on the gate. A ban the engine decided and could not write is kept as a PendingBan and re-attempted by a hosted loop on the same 15 s cadence the other writers use; the sentence still runs from the moment the ban was decided, so a retry that lands late cannot quietly lengthen it, and a pending ban whose sentence expired before it could be written is counted (bansNeverEnforced) and reported rather than rewritten as a fresh, longer ban. /state gained bansPendingRetry and bansNeverEnforced, because without the first a healed storage failure is indistinguishable from a quiet site. Teeth: PendingBanRetryTests (3) — the retry landing with no further request, the hosted loop doing it on its own (nobody calls it in that test), and an expired pending ban reported rather than written late. Compose gate gained a 5-assertion scene against the shipped image: the failed ban is queued, readiness returns after the repair with no traffic from that source, the ban reaches storage, the queue empties, and the source that was never banned during the break answers 403 afterwards. Gates at this commit — macOS host: unit 128/128, integration 141/141, smoke 28/0, compose 86/0, console 58/0, 0 containers left behind. Linux rehearsal, all three stages: PASS — source (128/128, 141/141, 28/0), compose 86/0 with enforcement lag 13 ms, console 58/0, 0 containers left behind. |
||
|
|
3f24c5d31c |
A ban that could not be written was logged as a concurrency race, and nothing was in force
Measured on the shipped image with writes to block_entries aborted by SQLite triggers while reads kept working: five refusals from one source at a threshold of 3 answered 404 five times, no ban reached storage or /state, /readyz answered 200, and the log said "BlockStore: concurrent ban on 203.0.113.12; keeping the winner" four times over an inner "SQLite Error 19: 'gate: ban write blocked'". Enforcement reads the snapshot and the snapshot is built from storage, so a ban that cannot be written is a ban that exists nowhere - and the only sentence the log offered said the opposite. BlockStore now asks storage which case it is: re-read the row. A live engine ban for that source means somebody won the unique-index race and nothing is wrong; no row, or a read that cannot run either, means the write never happened. The second case is counted (DurabilityHealth.Bans), logged with its real reason and its consequence, and gates /readyz - the enforcement path is the path that gates. That also moved the boundary drawn last cycle. Observations, alerts and retention are reporting pillars: counted, shown on /state and on the console, and no longer gating readiness. The measurement that forced it: with the gate in place, one lost alert left alertWriteFailures at 3 and /readyz at 503; the triggers were removed and the stand left idle for 120 s, and it answered 503 the whole time with the write path healthy. An alert pillar writes only when an alert happens to be raised, so "not yet proven healthy" had become "unready forever". ObservationWriter now retries every tracked source while it has an outstanding failure: the write-amplification bound protects against load, not against retries, and without this the lost rows waited for each source to be due again a full interval later. Teeth: BanWriteFailureTests (3) - 3 failed / 0 passed before the fix; two WriteFailureVisibilityTests assertions re-drawn for the new boundary. Gates: compose-smoke 63 -> 72 (the ban scene asserts 404x5, no row in storage, 503 naming bans, race lines 0/0 and the honest line present, then the ban landing on a later refusal), smoke.sh counters now include bans, console-check 57 -> 58. |
||
|
|
a77ab53ea8 |
A storage failure was reported to the operator as success, as their own bad request, and as ready
Measured on two shipped images of the same stand — openwaf:prefix built from
|
||
|
|
0161018d4d |
Say when the block listing is not the whole answer
GET /admin-api/blocks silently returned the newest 500 rows. The delete beside it is not capped, so an operator counting 500 rows on a page — or in the console — under-counts their own block list in one direction and over-trusts the clear button in the other. Found while measuring the snapshot refresh cost: 2 000 seeded blocks, 500 rows back, no word about it. The cap stays (a 2 000-row dump is not a page), but it now travels with the answer: X-Total-Count and X-Truncated headers, plus limit/offset (default 500, max 2000). The console renders the difference: showing the newest 500 of 2000, and clearing by provenance removes all of them, not just this page. Verified on the deployed image, not only in the fixture: with 600 blocks the default listing answers X-Total-Count: 600 / X-Truncated: true, and limit=1000 answers X-Truncated: false with all 600 rows. The first attempt at that check ran against a stale compose image — compose up without --build reuses it. The README and compose-smoke.sh both use --build; the check had to. Gates: 36 unit + 20 integration, 0 failed; smoke 19/19; compose-smoke 27/27; actionlint and shellcheck both 0. |
||
|
|
a3d0777492 |
openwaf: edge WAF with one decision point and a streak ban
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/. |