POST api/filter-check explains whether a name is blocked for a client, and one call adds a domain to the built-in custom allow or block list #107

Open
opened 2026-10-31 12:42:07 -04:00 by claude · 0 comments
Owner
  • Draft: PQ-9
  • Priority: high
  • Agent: coder
  • Depends on: #100
  • Decisions: Q-PQ-5

Why

An operator cannot ask why a name is blocked, or which lists contain it, without reading each list. Allow and block from the log need a list to write to; the owner chose two built-in custom lists.

What changes

  • IDnsFilterEngine and DnsFilterEngine: add ExplainDomainAsync(DnsName name, IPAddress client, string clientId, bool allLists, CancellationToken).
    • It returns every matching list (id, name, action, rule, whether an @@ exception cancelled it) and the final verdict after Precedence, from the same in-memory index the query path uses (DnsFilterEngine.cs:125-149).
    • allLists = true checks every enabled domain list, whatever the client. This covers "which list contains this domain" without a database scan.
  • Ninlil.Web/Controllers/FilterCheckController.cs (new): POST api/filter-check with body { domain, clientAddress?, clientId?, allLists? }.
    • The response is { verdict, filteringEnabled, matches[], scheduleBlock? }.
    • Requires filterlists:read, like FilterPatternPreviewController.
    • Validates the domain the same way that controller validates sample domains (:63-67).
  • Built-in custom lists. Technical call: each list has a fixed, well-known Guid constant (one for "Custom allow", one for "Custom block"), so no schema change is needed to find them, and a list the operator deleted is simply created again on next use.
    • POST api/filter-lists/custom-entries with body { domain, action: Allow|Block }, requiring filterlists:write.
    • On first use it creates the list: Source = Local, Kind domain, the matching Action, AppliesToAllClients = true (src/dotnet/src/Ninlil.Dns.Data.Abstractions/Entity/DnsFilterListEntity.cs:19-71).
    • It adds a Domain entry through the same validation as POST api/filter-lists/{listId}/entries (FilterListEntriesController.cs:137). An entry that already exists returns 200 with the existing entry; a new one returns 201.
    • A disabled custom list is left disabled, and the response says so, so the console can warn.
  • Models plus Swagger examples.

Acceptance

  • Test fails first in src/dotnet/tests/Ninlil.Dns.Server.Filtering.Tests. A name on block list A and allow list B with AllowWins explains as verdict Allowed, with two matches.
  • src/dotnet/tests/Ninlil.Web.Tests: POST api/filter-lists/custom-entries with Block creates the list on first call, returns 201, and a query for the domain is then blocked; a repeat returns 200 and adds no second entry.
  • src/dotnet/tests/Ninlil.Web.Tests: 400 for a blank or over-long domain; 403 without filterlists:read (check) or filterlists:write (custom entries).
  • API change (snapshot in #108).

Source

  • audit-feature-parity.md §2A #4.
  • Owner decision 2026-10-31 (Q-PQ-5): "built-in custom allow/block lists".
- **Draft:** PQ-9 - **Priority:** high - **Agent:** coder - **Depends on:** #100 - **Decisions:** Q-PQ-5 ### Why An operator cannot ask why a name is blocked, or which lists contain it, without reading each list. Allow and block from the log need a list to write to; the owner chose two built-in custom lists. ### What changes - `IDnsFilterEngine` and `DnsFilterEngine`: add `ExplainDomainAsync(DnsName name, IPAddress client, string clientId, bool allLists, CancellationToken)`. - It returns every matching list (id, name, action, rule, whether an `@@` exception cancelled it) and the final verdict after `Precedence`, from the same in-memory index the query path uses (`DnsFilterEngine.cs:125-149`). - `allLists = true` checks every enabled domain list, whatever the client. This covers "which list contains this domain" without a database scan. - `Ninlil.Web/Controllers/FilterCheckController.cs` (new): `POST api/filter-check` with body `{ domain, clientAddress?, clientId?, allLists? }`. - The response is `{ verdict, filteringEnabled, matches[], scheduleBlock? }`. - Requires `filterlists:read`, like `FilterPatternPreviewController`. - Validates the domain the same way that controller validates sample domains (`:63-67`). - Built-in custom lists. **Technical call:** each list has a fixed, well-known `Guid` constant (one for "Custom allow", one for "Custom block"), so no schema change is needed to find them, and a list the operator deleted is simply created again on next use. - `POST api/filter-lists/custom-entries` with body `{ domain, action: Allow|Block }`, requiring `filterlists:write`. - On first use it creates the list: `Source = Local`, `Kind` domain, the matching `Action`, `AppliesToAllClients = true` (`src/dotnet/src/Ninlil.Dns.Data.Abstractions/Entity/DnsFilterListEntity.cs:19-71`). - It adds a `Domain` entry through the same validation as `POST api/filter-lists/{listId}/entries` (`FilterListEntriesController.cs:137`). An entry that already exists returns 200 with the existing entry; a new one returns 201. - A disabled custom list is left disabled, and the response says so, so the console can warn. - Models plus Swagger examples. ### Acceptance - [ ] Test fails first in `src/dotnet/tests/Ninlil.Dns.Server.Filtering.Tests`. A name on block list A and allow list B with `AllowWins` explains as verdict Allowed, with two matches. - [ ] `src/dotnet/tests/Ninlil.Web.Tests`: `POST api/filter-lists/custom-entries` with `Block` creates the list on first call, returns 201, and a query for the domain is then blocked; a repeat returns 200 and adds no second entry. - [ ] `src/dotnet/tests/Ninlil.Web.Tests`: 400 for a blank or over-long domain; 403 without `filterlists:read` (check) or `filterlists:write` (custom entries). - [ ] API change (snapshot in #108). ### Source - `audit-feature-parity.md` §2A #4. - Owner decision 2026-10-31 (Q-PQ-5): "built-in custom allow/block lists".
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
lantea-one/ninlil#107
No description provided.