Skip to content

Pre-scan candidate assembly is rebuilt separately by CLI, TUI, library, MCP and dry run #472

Backlog

Description

@TMHSDigital

Summary

"Ask the sources and the zone, gate on -exclude, add to a candidates.Set in a fixed order, take the lists, build permutations" is written five times: CLI, TUI, library, MCP and dry run. The copies have already drifted.

Where

  • CLI scanOneTarget: internal/cli/session.go:789-835 (sources, AXFR, NSEC, SRV, cands.Lists())
  • TUI loadWordlistCmd: internal/tui/model.go:233-247 (sources, AXFR, NSEC, msg.cands.Entries())
  • Library: pkg/subenum/subenum.go:538-546, pkg/subenum/sources.go:70
  • MCP scanTool: internal/cli/mcp_tools.go:316-321 (wraps the transfer as a fake source)
  • Dry run: internal/cli/dryrun.go:110-134 (recounts by hand)
  • The axfr Options/WalkOptions wiring and the "scanning X without a zone transfer or an NSEC walk" warning are built in four places: internal/cli/axfr.go:61-108, internal/tui/passes.go:117-156, pkg/subenum/zone.go:84-110, internal/cli/mcp_tools.go:349.

Details

Drift found:

  • The TUI takes cands.Entries(), the whole-wordlist copy that Smaller performance costs: cap walk, wordlist copies, serial AXFR, -dL, MCP queue #365 removed from the CLI and library.
  • The TUI's permutation pass drops capped (perms, tooLong, _ := candidates.Permutations(...), internal/tui/passes.go:98), so a TUI user is never told the pass stopped at MaxPermutations, which the CLI prints (internal/cli/permute.go:113).
  • The MCP transfer port default is a literal "53" (internal/cli/mcp_tools.go:346), while the library uses the test-settable zonePort.

Impact

Every new candidate source (-srv #419, -nsec-walk #437 and PTR #436 were the latest) has to be threaded through each front end with its own ordering, scope gate and message. An ordering mistake breaks resume, which indexes the joined list by position. Fixes land in one front end and not the others.

Suggested fix

Each step leaves the code working:

  1. Tests first: run one lab scenario (sources stubbed with an httptest server, plus AXFR and NSEC) through the CLI, the TUI's loadWordlistCmd and subenum.Run, and assert the same candidate order and per-source counts.
  2. Add Assemble(ctx, Plan) (Set, []Note) in internal/candidates (or a new internal/prescan). It owns the order, the scope gate and the info/warning lines.
  3. Move the zone wiring into one helper that builds Options, WalkOptions and the warning text. Switch the TUI, CLI, library and MCP to it, one commit each.
  4. Switch the TUI to Assemble and Lists(), and show the capped notice.
  5. Switch the CLI, keeping resume replay of held lines.
  6. Have dry run count from the same Plan.

Filed by repo-audit/full-audit at a45b999. Severity: medium. Effort: M. audit-key: tech-debt|internal/cli/session.go|candidate assembly

Activity

  1. added
    tech-debt
    severity: medium
    on Nov 29, 2026
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

    severity: mediumtech-debt

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions