A filter or schedule decision names the list, the matching rule and the check that blocked the query #100

Open
opened 2026-10-31 12:42:06 -04:00 by claude · 0 comments
Owner
  • Draft: PQ-2
  • Priority: high (prerequisite for #101, #107 and #112)
  • Agent: coder
  • Depends on: none
  • Decisions: none

Why

DnsFilterDecision has only IsDenied and a free-text Reason (src/dotnet/src/Ninlil.Dns.Server.Core/Filtering/DnsFilterDecision.cs:14-20). DnsFilterEngine.EvaluateDomainAsync loops over the lists but keeps only two booleans (src/dotnet/src/Ninlil.Dns.Server.Filtering/DnsFilterEngine.cs:133-149), so which list matched is lost. The same is true for CNAME targets (:336-360) and network lists (:564-580).

What changes

  • Ninlil.Dns.Server.Core/Filtering/DnsFilterDecision.cs: add Kind (a new DnsFilterMatchKindEnum: DomainList, CnameTarget, ResponseAddress, ClientSource), ListId (Guid?), ListName, MatchedRule (the entry value, or the CNAME target or address that matched). Keep Reason for logs. Add a Denied(kind, listId, listName, matchedRule, reason) factory. Keep Allowed as one shared instance, so an allowed query allocates nothing.
  • Ninlil.Dns.Server.Filtering/DnsFilterEngine.cs:
    • Record the first winning block list and its matching entry. DnsFilterListIndex must be able to return the entry it matched, not only a bool. Add a TryMatch… alongside ContainsDomain and MatchesAnyPattern.
    • The hot path stays allocation-free when nothing matches.
  • Ninlil.Dns.Server.Core/ClientSchedule/DnsClientScheduleDecision (used by DnsClientScheduleEngine.cs:70): add a kind (ClientPause, GroupPause, Schedule) and the client or group id.
  • Ninlil.Dns.Common/Enum/: the new enums, with EnumMember values like the existing enums.

Acceptance

  • Test fails first in src/dotnet/tests/Ninlil.Dns.Server.Filtering.Tests. A domain on block list "Ads" (entry ads.example) queried as x.ads.example returns Kind == DomainList, ListName == "Ads", MatchedRule == "ads.example". Further tests cover a wildcard entry, a CNAME target and a response address.
  • Allowed decisions still return the shared Allowed instance (a test asserts reference equality).
  • Pipeline benchmark (--filter '*PipelineLatency*' --engines Sqlite --scale Small): numbers before and after go in the PR description, with no regression on allowed queries.
  • dotnet test src/dotnet/tests/Ninlil.Dns.Server.Filtering.Tests, src/dotnet/tests/Ninlil.Dns.Server.ClientSchedule.Tests, and the whole solution, because Ninlil.Dns.Server.Core and Ninlil.Dns.Common are shared.
  • No schema, API or option change.

Source

audit-feature-parity.md §2A #2 and #4.

- **Draft:** PQ-2 - **Priority:** high (prerequisite for #101, #107 and #112) - **Agent:** coder - **Depends on:** none - **Decisions:** none ### Why `DnsFilterDecision` has only `IsDenied` and a free-text `Reason` (`src/dotnet/src/Ninlil.Dns.Server.Core/Filtering/DnsFilterDecision.cs:14-20`). `DnsFilterEngine.EvaluateDomainAsync` loops over the lists but keeps only two booleans (`src/dotnet/src/Ninlil.Dns.Server.Filtering/DnsFilterEngine.cs:133-149`), so which list matched is lost. The same is true for CNAME targets (`:336-360`) and network lists (`:564-580`). ### What changes - `Ninlil.Dns.Server.Core/Filtering/DnsFilterDecision.cs`: add `Kind` (a new `DnsFilterMatchKindEnum`: `DomainList`, `CnameTarget`, `ResponseAddress`, `ClientSource`), `ListId` (`Guid?`), `ListName`, `MatchedRule` (the entry value, or the CNAME target or address that matched). Keep `Reason` for logs. Add a `Denied(kind, listId, listName, matchedRule, reason)` factory. Keep `Allowed` as one shared instance, so an allowed query allocates nothing. - `Ninlil.Dns.Server.Filtering/DnsFilterEngine.cs`: - Record the first winning block list and its matching entry. `DnsFilterListIndex` must be able to return the entry it matched, not only a bool. Add a `TryMatch…` alongside `ContainsDomain` and `MatchesAnyPattern`. - The hot path stays allocation-free when nothing matches. - `Ninlil.Dns.Server.Core/ClientSchedule/DnsClientScheduleDecision` (used by `DnsClientScheduleEngine.cs:70`): add a kind (`ClientPause`, `GroupPause`, `Schedule`) and the client or group id. - `Ninlil.Dns.Common/Enum/`: the new enums, with `EnumMember` values like the existing enums. ### Acceptance - [ ] Test fails first in `src/dotnet/tests/Ninlil.Dns.Server.Filtering.Tests`. A domain on block list "Ads" (entry `ads.example`) queried as `x.ads.example` returns `Kind == DomainList`, `ListName == "Ads"`, `MatchedRule == "ads.example"`. Further tests cover a wildcard entry, a CNAME target and a response address. - [ ] Allowed decisions still return the shared `Allowed` instance (a test asserts reference equality). - [ ] Pipeline benchmark (`--filter '*PipelineLatency*' --engines Sqlite --scale Small`): numbers before and after go in the PR description, with no regression on allowed queries. - [ ] `dotnet test src/dotnet/tests/Ninlil.Dns.Server.Filtering.Tests`, `src/dotnet/tests/Ninlil.Dns.Server.ClientSchedule.Tests`, and the whole solution, because `Ninlil.Dns.Server.Core` and `Ninlil.Dns.Common` are shared. - [ ] No schema, API or option change. ### Source `audit-feature-parity.md` §2A #2 and #4.
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#100
No description provided.