Repository navigation
Closed
Labels
severity: mediumEdge-case bugs, degraded behavior, meaningful maintenance costtech-debtRefactoring and maintainability
Description
Summary
Results, stats and events exist in three vocabularies (scan, output, pkg/subenum) plus six TUI message types, connected by hand-written field-by-field translators with no completeness check. Small helpers are also duplicated across packages.
Where
internal/scan/runner.go:384-400(Event),:79-103(Stats),:356-366(NoticeKind),:149-166(snapshot)pkg/subenum/subenum.go:138-304(Record/Result/Stats/Kind/Notice/Event),:584-657(translate,stats)internal/output/writer.go:53-64(output.Result),:151-160(ResultandResultWithHintbesideEmit)internal/tui/scan_view.go:260-275,internal/tui/model.go:354-379(six message types)main.go:757-779(scan.Event->output.Result),main_resume.go:255-276(mergeStats),internal/report/report.go:80-92- Duplicated helpers:
internal/scan/runner.go:208vsinternal/dns/resolver.go:458(record key);internal/scan/scope.go:73-78vsinternal/scan/runner.go:270-273(parentOf);internal/validate/validate.go:37vsinternal/wordlist/reader.go:16(label regex)
Details
scan.Stats has 17 fields copied by hand into subenum.Stats, mergeStats, and the report. Takeover (#71), Permutation (#72) and Change (#84) each had to be added in three or four places. A dropped field is silent.
Why it hurts now
Any new per-result datum (TTL, answering resolver) requires editing scan.Event, output.Result, subenum.Result, translate, resultMsg, emitResult and the writers.
Suggested plan (each step leaves the tree green)
- Add reflection tests asserting
subenum.Statsandscan.Statsshare the same exported numeric field set and thatmergeStatsandtranslatecover every field (cheap drift guard, no behaviour change). - Define
scan.Result{Name, Records, Takeover}insidescan.Event; haveoutput.Resultembed it. - Collapse the TUI messages into one
eventMsg{scan.Event}and switch onKindinscanViewModel.Update. - Remove
Writer.Result/ResultWithHintin favour ofEmit(TUI is the onlyResultWithHintcaller,model.go:258). - Export
dns.RecordKey; useparentOfinisWildcardAnswer; share the label regex.
Tests to have first
pkg/subenum/subenum_test.go,internal/tui/scan_view_test.go,internal/output/writer_test.go
Acceptance criteria
- A test fails when a
Statsfield is added without updating the copies - One result struct flows from engine to writers
Getting started
- Relevant files: see "Where"
- How to run tests:
go test ./... - Related docs:
docs/library.md,docs/ARCHITECTURE.md
Filed by repo-audit/full-audit at 3139c44. Severity: medium. Effort: M. audit-key: tech-debt|pkg/subenum/subenum.go|translate
Metadata
Metadata
Assignees
Labels
severity: mediumEdge-case bugs, degraded behavior, meaningful maintenance costtech-debtRefactoring and maintainability
Activity
TMHSDigital commentedon Nov 10, 2026
Fixed in 2131669: one result struct now goes from the engine to the writers, and drift guards cover every
scan.Statscopy.scan.Result(subdomain, records, simulated, takeover) is carried asscan.Event.Resultand embedded inoutput.Result, which adds onlyChange,PreviousRecordsandPermutation. Because the embedded fields come first, JSON/JSONL/CSV/SARIF output does not change. A new test pins the JSON field order.eventMsg{scan.Event}, and the scan view switches onKind.Writer.ResultandWriter.ResultWithHintare removed; callers useEmit.dns.RecordKeyreplaces the duplicated key helper.scan.Statsfield is added without updatingpkg/subenum'sstats(),mergeStats, or the run-quality report. ThemergeStatsguard found a real drop: a resumed run lostExpired, so a resume that hit-max-durationreportedstopped_by: "queries".mergeStatsnow mergesExpired.The public
pkg/subenumAPI is unchanged.Deliberately not done:
isWildcardAnswerdoes not useparentOf.parentOfreturns""for a name with no dot, whileisWildcardAnswerkeeps the name itself in that case.Verified with
go build,go vet,go test -race -shuffle=on ./...andgolangci-lint run(0 issues).