Skip to content

Query/time budgets count excluded candidates as skipped and degrade the verdict #238

Closed

Description

@TMHSDigital

Summary

When -max-queries or -max-duration stops admission, every remaining candidate is counted as skipped, including candidates -exclude would never have queried. The scan then reports a degraded verdict even though every in-scope name was tested.

Where

  • internal/scan/dispatcher.go:123-131 (next): the deadline and MaxQueries checks run before the exclude and visited filtering
  • internal/scan/dispatcher.go:91-96 (stopAdmitting): d.skipped += d.remaining
  • internal/scan/verdict.go:44-47: any skipped count gives degraded

Details

if d.cfg.MaxQueries > 0 && d.admitted >= d.cfg.MaxQueries {
    d.stopAdmitting()   // all remaining candidates -> skipped
    return job{}, false
}
entry := d.cfg.Entries[e.next] // exclude/visited filtering happens after this

Impact

  • A false degraded verdict.
  • Wrong Skipped and Excluded counts in -stats, JSONL, SARIF and MCP reports.
  • -diff does not report removals because the verdict is not complete (main_diff.go:195).

Steps to reproduce

With 100 entries where the last 10 match -exclude, and MaxQueries: 90, the result is admitted=90 skipped=10 excluded=0 verdict=degraded. Expected: complete, with excluded=10.

Suggested fix

When a budget stops admission, keep walking the remaining candidates. Count excluded ones as excluded and drop duplicates. Only candidates that would actually be queried should count as skipped. Do this cheaply: a single pass without admitting anything.

Acceptance criteria

  • The case above reports complete with excluded=10.
  • A mix of excluded and in-scope candidates past the cap counts only the in-scope ones as skipped.

Getting started

  • Relevant files: internal/scan/dispatcher.go
  • How to run tests: go test ./internal/scan/
  • Related docs: docs/ARCHITECTURE.md

Filed by repo-audit/full-audit at 3f671b2. Severity: low. Effort: S. audit-key: bug|internal/scan/dispatcher.go|stopAdmitting

Activity

  1. added
    bug
    good first issue
    severity: low
    on Nov 14, 2026
  2. TMHSDigital commented on Nov 14, 2026

    @TMHSDigital
    OwnerAuthor

    Fixed in 65e5f8a: stopAdmitting counts the unadmitted candidates that -exclude (or the recursive visited set) would have kept out as excluded/ignored instead of skipped; with no exclusions it keeps the O(1) path. Verified with TestCapLeavesExcludedOutOfSkipped (100 entries, last 10 excluded, cap 90 -> skipped 0 excluded 10; cap 80 -> 10 and 10), go test ./... and golangci-lint.

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

    buggood first issueseverity: low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions