Skip to content

Capped recursive scan counts excluded children of late parents as skipped #393

Closed

Description

@TMHSDigital

Summary

A recursive scan that has already reached its -max-queries budget still counts every child of a newly found parent as skipped, including children -exclude rules out and, with multi-label entries, children already reached from another parent. The report then shows too many skipped names and too few excluded ones.

Where

  • internal/scan/dispatcher.go:467 (expand, the case d.capped: branch: d.skipped += d.n)

Details

#361 made stopAdmitting count the untested remainder exactly: excluded names go to excluded, and names reachable twice are counted once. A parent that resolves after the cap goes through expand instead, which adds all d.n children to skipped without checking -exclude or the visited set. The two paths therefore disagree on the same kind of name.

Impact

-stats and the run-quality report misstate skipped and excluded for a capped recursive scan whose parents keep resolving after the cap. Totals still add up, but the split between skipped and excluded is wrong. A resumed run inherits the wrong split.

Steps to reproduce

  1. Run a -recursive scan with -max-queries low enough to cap during the first level, an -exclude pattern that matches some children (for example -exclude 'dev.*'), and a wordlist containing dev.
  2. Let a first-level name resolve after the cap.
  3. Compare skipped and excluded in -stats with the number of children the exclusion matches: excluded children are counted as skipped.

Suggested fix

In the d.capped branch, count the parent's children the way stopAdmitting counts its remainder: reuse its walk (or countUnbuilt when every entry is a single label and there is no -exclude), so excluded children go to excluded and visited ones are not counted twice.

Acceptance criteria

  • A capped recursive scan whose parent resolves after the cap reports excluded children as excluded, not skipped
  • Tested plus skipped plus excluded still equals every candidate
  • A test in internal/scan/dispatcher_test.go covers it

Getting started


Filed by repo-audit/fix-issues at 3cc069c. Severity: low. Effort: S. audit-key: bug|internal/scan/dispatcher.go|expand-capped

Activity

  1. TMHSDigital commented on Nov 17, 2026

    @TMHSDigital
    OwnerAuthor

    Fixed by #394 (bdaf171): a parent found after the cap now has its children counted through stopAdmitting, so -exclude'd children land in excluded and recursive repeats are counted once.

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: scanScan engine / dispatcherbugSomething isn't workinggood first issueGood for newcomersseverity: lowMinor polish and nice-to-haves

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions