Repository navigation
Description
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, thecase 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
- Run a
-recursivescan with-max-querieslow enough to cap during the first level, an-excludepattern that matches some children (for example-exclude 'dev.*'), and a wordlist containingdev. - Let a first-level name resolve after the cap.
- Compare
skippedandexcludedin-statswith 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, notskipped - Tested plus skipped plus excluded still equals every candidate
- A test in
internal/scan/dispatcher_test.gocovers it
Getting started
- Relevant files:
internal/scan/dispatcher.go,internal/scan/dispatcher_test.go - How to run tests:
go test ./internal/scan/ - Related: Regression: a budget stop miscounts excluded and duplicate candidates as skipped #361
Filed by repo-audit/fix-issues at 3cc069c. Severity: low. Effort: S. audit-key: bug|internal/scan/dispatcher.go|expand-capped
Activity
Count a capped expand's children as stopAdmitting counts its remainder (
TMHSDigital commentedon Nov 17, 2026
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.