Skip to content

Near-miss wildcard revalidation loop is never executed by a test #169

Closed

Description

@TMHSDigital

Summary

The near-miss wildcard revalidation loop added for #48 is never executed by any test. isWildcardAnswer is 25% covered and the probe loop shows zero hits.

Where

  • internal/scan/runner.go:265-282 (isWildcardAnswer; loop at 270-281 unreached)
  • internal/scan/runner_test.go:637-689 (TestRunRotatingPoolWildcardFiltered, the only test on this path)

Details

In the existing test all 8 rotating IPs are already in the fingerprint after preflight probing, so every answer is covered and the loop at line 274 never runs. The loop is also short-circuited whenever cfg.resolveHook != nil || cfg.Simulate (line 267), so none of the hook-based tests can reach it.

Impact

A rotating-pool wildcard with more IPs than preflight caught (the real #48 scenario) could pass unfiltered, and the fingerprint-growth logic can break silently.

Suggested test cases

  • Rotating wildcard with 64 IPs returning 2 records per answer: at least 95% of wildcard names filtered AND done.Fingerprint grew beyond the preflight size
  • A real name sharing one record with the fingerprint (CNAME to the wildcard target plus its own A): reported, not filtered, with exactly nearMissProbes extra queries charged (check Stats.Queries)
  • Near-miss probe with the context cancelled mid-probe: returns false (keeps the result) and the scan still ends with one EventDone
  • Let the hook path exercise the loop (hook answers random-label probes) or add a table test calling isWildcardAnswer directly with a stub resolver

Acceptance criteria

  • isWildcardAnswer fully covered
  • Tests run against the in-repo dnsserver, no live DNS

Getting started

  • Relevant files: internal/scan/runner.go, internal/scan/runner_test.go, internal/dnsserver
  • How to run tests: go test -cover ./internal/scan/
  • Related docs: README "Wildcard handling"

Related: #48


Filed by repo-audit/full-audit at 3139c44. Severity: medium. Effort: M. audit-key: testing|internal/scan/runner.go|wildcard near-miss

Activity

  1. added
    testing
    area: scan
    severity: medium
    on Nov 9, 2026
  2. TMHSDigital commented on Nov 9, 2026

    @TMHSDigital
    OwnerAuthor

    Fixed in e5e38c3.

    internal/scan/nearmiss_test.go calls isWildcardAnswer directly against the in-repo DNS server (no live DNS), with every name answering like a rotating pool that preflight only partly saw. Cases: covered answer (no probes); real name sharing nothing (no probes); near miss the pool explains (1 probe, fingerprint grows, filtered); real name sharing one record (exactly nearMissProbes probes, kept); cancelled context (kept); simulated run (never probes). Probe counts come from the server's query counter.

    go tool cover shows isWildcardAnswer at 100%. Passes under -race; full suite and lint pass. The engine-level 64-address rotation scenario from the suggestions was not added; the table test covers the same logic deterministically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: scanseverity: mediumtesting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions