From 405760d68047eb32676bebee6a28f9c7a186c8f6 Mon Sep 17 00:00:00 2001 From: nova-loop Date: Thu, 3 Dec 2026 09:53:59 +0800 Subject: [PATCH] Count the -ptr pass's tested names in the -diff removed-name budget (#495) --- CHANGELOG.md | 1 + docs/output.md | 2 +- docs/schemas/stats.v1.json | 1 + internal/cli/diff.go | 1 + internal/cli/ptr_test.go | 17 +++++++++++++++++ internal/output/summary.go | 4 +++- internal/report/ptr.go | 1 + 7 files changed, 25 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1848d5d..66651d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - TUI: a **Follow Records** toggle, `-follow-records`; `-tui -follow-records` now fills it in instead of warning that the flag is ignored (#476). ### Changed +- `-diff`'s removed-name check subtracts the names the `-ptr` pass tested from the `-max-queries` budget; the report's new `ptr_processed` gives that count (#495). - `-max-queries` is one budget per target on the command line and in the TUI (**Max Names**), as it already was in the library and the MCP server: the `-permute` pass and the names the `-ptr` pass tests get what the passes before them left, where each pass used to get the full number. A pass with nothing left reports its candidates as skipped by the cap, so the target is `degraded`. `-ptr` still looks up at most `-max-queries` addresses, and `-nsec-walk` still sends at most that many queries, on their own. Raise `-max-queries` if you relied on the per-pass meaning (#478). - CI: the weekly Vulncheck workflow has a **Pin freshness** job that lists, as warnings and in its summary, the SHA-pinned actions, digest-pinned images, GoReleaser and golangci-lint versions that a newer release has passed. It reports and never fails on a stale pin (#485). - The `-permute` and `-ptr` passes (and the TUI's permutation pass) reuse the main pass's wildcard check of the same target instead of sending the wildcard probes again, so each extra pass sends only its apex lookup before it starts; wildcard filtering is unchanged (#464). diff --git a/docs/output.md b/docs/output.md index ba464e2..f0cb240 100644 --- a/docs/output.md +++ b/docs/output.md @@ -108,7 +108,7 @@ Text output is one name per line. `-show-records` appends the records as ` TYPE= | `nsec_names`, `nsec_found`, `nsec_stop` | integer, integer, string | when set | `-nsec-walk`: names the walk listed, results it proposed, and why it stopped before the end of the chain or did not run. | | `parent_checks`, `parent_queries` | integer, integer | when set | `-type NS`: names that failed with SERVFAIL whose delegation was asked of the zone's own name servers, and the queries that took (the name server lookups included; `queries_sent` counts them too). A subzone whose every name server is gone is found this way and flagged `dangling-ns`. | | `records_found` | integer | when set | `-follow-records`: results that a found name's `CNAME`, `MX`, `NS` or `HTTPS` record pointed at. | -| `ptr_addresses`, `ptr_queries`, `ptr_names`, `ptr_found` | integer | when set | `-ptr`: public addresses looked up, PTR queries sent (`queries_sent` includes them and the lookups of the names), names under the target the answers gave that were tested, and results they proposed. | +| `ptr_addresses`, `ptr_queries`, `ptr_names`, `ptr_processed`, `ptr_found` | integer | when set | `-ptr`: public addresses looked up, PTR queries sent (`queries_sent` includes them and the lookups of the names), names under the target the answers gave that were tested, the lookups the scan of those names did (`-diff` spends the `-max-queries` budget less these), and results they proposed. | | `zone_denial` | string | when set | The DNSSEC probe of `-axfr` or `-nsec-walk`: `nsec` (anyone can list the zone), `nsec3` or `none`. | | `pool_hits`, `confirmed`, `unconfirmed` | integer | when set | `-r`: pool hits, and how many the trusted resolver confirmed or denied. | | `wildcard` | boolean | always | `true` when the target answers names that do not exist. | diff --git a/docs/schemas/stats.v1.json b/docs/schemas/stats.v1.json index 6a10b42..9f023d1 100644 --- a/docs/schemas/stats.v1.json +++ b/docs/schemas/stats.v1.json @@ -76,6 +76,7 @@ "ptr_addresses": { "type": "integer", "minimum": 0, "description": "-ptr: public addresses whose PTR records were looked up. Absent when 0." }, "ptr_queries": { "type": "integer", "minimum": 0, "description": "-ptr: PTR queries sent; queries_sent includes them. Absent when 0." }, "ptr_names": { "type": "integer", "minimum": 0, "description": "-ptr: names under the target the PTR answers gave that were tested. Absent when 0." }, + "ptr_processed": { "type": "integer", "minimum": 0, "description": "-ptr: lookups the scan of the PTR names did; -diff subtracts them from the -max-queries budget. Absent when 0." }, "ptr_found": { "type": "integer", "minimum": 0, "description": "-ptr: results the PTR answers proposed, each confirmed by a forward lookup. Absent when 0." }, "zone_denial": { "type": "string", "enum": ["nsec", "nsec3", "none"], "description": "How the zone proves a name does not exist, from the DNSSEC probe of -axfr or -nsec-walk: nsec means anyone can list it by walking it. Absent when not probed or no server answered." }, "pool_hits": { "type": "integer", "minimum": 0, "description": "-r: names a pool resolver said exist. Absent when 0." }, diff --git a/internal/cli/diff.go b/internal/cli/diff.go index 596d18c..3b8bc99 100644 --- a/internal/cli/diff.go +++ b/internal/cli/diff.go @@ -294,6 +294,7 @@ func emitRemoved(ctx context.Context, s *session, summary *output.Summary) int64 if t.Permutation != nil { left -= t.Permutation.Processed } + left -= t.PTRProcessed } if left < 1 { out.Info("Note: -diff is not checking removed names because the -max-queries budget is spent") diff --git a/internal/cli/ptr_test.go b/internal/cli/ptr_test.go index cf741e2..f739e73 100644 --- a/internal/cli/ptr_test.go +++ b/internal/cli/ptr_test.go @@ -407,3 +407,20 @@ func TestE2EPTRSharesMaxQueries(t *testing.T) { t.Errorf("-max-queries 1: verdict %q (%s), want degraded", ts.Verdict, ts.Reason) } } + +// TestE2EDiffBudgetCountsPTRNames: the -diff removed-name check spends what +// the scan and the -ptr pass left of -max-queries. The scan tests 1 name and +// the PTR pass 3, so under -max-queries 5 one of the two missing names can be +// checked and the other is unverified. +func TestE2EDiffBudgetCountsPTRNames(t *testing.T) { + t.Parallel() + z := &ptrTrioZone{} + prev := writeFile(t, "prev.txt", "trio.example.com\ngone-1.example.com\ngone-2.example.com\n") + _, out, ts := runPTRTrio(t, dnstest.Start(t, z.answer), "-max-queries", "5", "-diff", prev) + if ts.PTRProcessed != 3 { + t.Errorf("ptr_processed %d, want 3\n%s", ts.PTRProcessed, out) + } + if !strings.Contains(out, "the remaining -max-queries budget covers 1 of them") { + t.Errorf("want the removed-name check limited to 1 of 2 names:\n%s", out) + } +} diff --git a/internal/output/summary.go b/internal/output/summary.go index 593132c..9c7b109 100644 --- a/internal/output/summary.go +++ b/internal/output/summary.go @@ -120,10 +120,12 @@ type TargetSummary struct { // PTRAddresses counts the public addresses -ptr looked up, PTRQueries // the PTR queries that took (queries_sent includes them and the scan of // the names), PTRNames the names under the target the answers gave that - // were tested, and PTRFound the ones that resolved (#436). + // were tested, PTRProcessed the lookups the scan of them did, and PTRFound + // the ones that resolved (#436). PTRAddresses int `json:"ptr_addresses,omitempty"` PTRQueries int64 `json:"ptr_queries,omitempty"` PTRNames int `json:"ptr_names,omitempty"` + PTRProcessed int64 `json:"ptr_processed,omitempty"` PTRFound int `json:"ptr_found,omitempty"` // ZoneDenial is how the zone proves a name does not exist, from the // DNSSEC probe of -axfr or -nsec-walk: "nsec" (walkable: every name can be listed), "nsec3" or diff --git a/internal/report/ptr.go b/internal/report/ptr.go index 682bb73..237c9f2 100644 --- a/internal/report/ptr.go +++ b/internal/report/ptr.go @@ -37,6 +37,7 @@ func PTR(t *output.TargetSummary, p PTRPass, interrupted bool, name func(scan.Se case p.Final != nil: final := p.Final t.QueriesSent += final.Stats.QueriesSent + t.PTRProcessed = final.Processed // Its results count toward the target's takeover and internal // totals like the main pass's (#458). t.Takeover += final.Stats.Takeover