Skip to content

Commit 09b2c04

Browse files
TMHSDigitalclaude
andcommitted
Show the -no-abort guard warning as a warning (#308)
The engine already marks the reliability guard's warning under -no-abort as a non-fatal EventError. The CLI now writes it through a new output.ScanWarning ("Warning: ...", level warn in -log-format json) instead of ScanError, and does not keep it as the target's error, so a finished target's -stats entry no longer has an error next to "status": "ok". The TUI shows it with the warning marker and does not take it as the scan's error. The -no-abort -dL test now checks stderr and the per-target errors; a TUI test that hand-built a preflight error now sets Fatal and Failed as the engine does. Fixes #308 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 96a04d5 commit 09b2c04

7 files changed

Lines changed: 46 additions & 7 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6767
- Less memory on large wordlists and busy scans: `-sources`, `-ct`, `-axfr` and `-permute` check their names against the wordlist without building a set as large as it (about 200 MB per feature and target on a 5M-line list), a `-simulate-zone` lab scan no longer keeps a count per queried name (about 170 MB on a 1M-line list), and a `CNAME` lookup reads a UDP answer into a buffer sized for the 1232-byte EDNS payload it advertises instead of 64 KB. Results are unchanged (#321).
6868

6969
### Fixed
70+
- Under `-no-abort`, the reliability guard's warning is printed as `Warning: ...` (level `warn` with `-log-format json`) instead of `Error: warning: ...`, and a target that finished no longer carries it as its `error` in the `-stats` report next to `"status": "ok"`. The TUI shows it as a warning too (#308).
7071
- The resolver preflight and wildcard probes made before a target's first name no longer use up `-max-duration`. Under a low `-rate` they could take all of a short budget, so the run tested no names and each `-resume` probed again and made no progress. A budget that runs out before any name was tested now says so (#340).
7172
- Release archives and the container image carry the licence notices of the Go standard library and every module linked into the binary, in a `THIRD_PARTY_LICENSES` file generated at release time by `tools/licenses` from the module cache. The image also carries the project's `LICENSE`; both are in `/usr/share/doc/subenum/` (#326).
7273
- With `-format csv`, each row reaches stdout as its result is found, as with the other formats, instead of when 4 KB had built up or the run ended; a pipe sees live rows and a force quit loses none (#319).

‎internal/cli/cli.go‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,13 @@ func scanTarget(ctx context.Context, s *session, p scanPass, emit func(scan.Even
818818
case scan.EventNotice:
819819
out.ScanNotice(ev.Notice.String(), ev.Message)
820820
case scan.EventError:
821+
if !ev.Fatal {
822+
// The reliability guard's warning under -no-abort: the scan
823+
// goes on, so it is neither an error line nor the target's
824+
// error in the report (#308).
825+
out.ScanWarning(ev.Message)
826+
break
827+
}
821828
msg := out.ScanError(ev.Message)
822829
if res.err == "" {
823830
res.err = msg

‎internal/cli/session_test.go‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,9 @@ func TestE2EResolverAbortSkipsRemainingTargets(t *testing.T) {
104104

105105
// run scans the list against a resolver that answers for each apex and
106106
// fails every wordlist name. It returns the exit code, stderr, each
107-
// target's status and the number of queries the server saw per target.
108-
run := func(t *testing.T, extra ...string) (int, string, []string, map[string]int) {
107+
// target's status and error from the -stats report, and the number of
108+
// queries the server saw per target.
109+
run := func(t *testing.T, extra ...string) (int, string, []string, []string, map[string]int) {
109110
t.Helper()
110111
var mu sync.Mutex
111112
queries := map[string]int{}
@@ -138,18 +139,19 @@ func TestE2EResolverAbortSkipsRemainingTargets(t *testing.T) {
138139
if data, err := os.ReadFile(stats); err != nil || json.Unmarshal(data, &summary) != nil {
139140
t.Fatalf("reading -stats: %v\n%s", err, stderr)
140141
}
141-
var status []string
142+
var status, errs []string
142143
for _, tg := range summary.Targets {
143144
status = append(status, tg.Status)
145+
errs = append(errs, tg.Error)
144146
}
145147
mu.Lock()
146148
defer mu.Unlock()
147-
return code, stderr, status, queries
149+
return code, stderr, status, errs, queries
148150
}
149151

150152
t.Run("abort", func(t *testing.T) {
151153
t.Parallel()
152-
code, stderr, status, queries := run(t)
154+
code, stderr, status, _, queries := run(t)
153155
if code != exitFailure {
154156
t.Errorf("exit %d, want %d (every target failed or was skipped)\n%s", code, exitFailure, stderr)
155157
}
@@ -165,10 +167,18 @@ func TestE2EResolverAbortSkipsRemainingTargets(t *testing.T) {
165167
})
166168
t.Run("no-abort", func(t *testing.T) {
167169
t.Parallel()
168-
code, stderr, status, queries := run(t, "-no-abort")
170+
code, stderr, status, errs, queries := run(t, "-no-abort")
169171
if code != exitOK {
170172
t.Errorf("exit %d, want %d\n%s", code, exitOK, stderr)
171173
}
174+
// The guard's warning is a warning, not an error, and a target that
175+
// went on to finish does not report it as its error (#308).
176+
if !strings.Contains(stderr, "Warning: ") || strings.Contains(stderr, "Error: ") {
177+
t.Errorf("stderr shows the -no-abort warning as an error, or not at all:\n%s", stderr)
178+
}
179+
if got := strings.Join(errs, ""); got != "" {
180+
t.Errorf("target errors %q, want none", errs)
181+
}
172182
if strings.Contains(stderr, "remaining targets") {
173183
t.Errorf("targets were skipped under -no-abort:\n%s", stderr)
174184
}

‎internal/output/log.go‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,18 @@ func (w *Writer) ScanNotice(kind, msg string) {
189189
w.diagLocked(LevelWarn, kind, scan.Render(msg, scan.FlagName), scan.SettingsIn(msg))
190190
}
191191

192+
// ScanWarning writes a non-fatal engine error (the reliability guard's
193+
// warning under -no-abort) at warning level. The engine's message starts
194+
// with "warning: ", which becomes the "Warning: " marker (#308). Like
195+
// ScanError, and unlike ScanNotice, it is shown under SetQuiet: with over a fifth of
196+
// lookups failed, the results are incomplete.
197+
func (w *Writer) ScanWarning(msg string) {
198+
text := scan.Render(strings.TrimPrefix(msg, "warning: "), scan.FlagName)
199+
w.mu.Lock()
200+
defer w.mu.Unlock()
201+
w.diagLocked(LevelWarn, KindScan, "Warning: "+text, scan.SettingsIn(msg))
202+
}
203+
192204
// ScanError writes an engine error like Error, with its {setting} tokens
193205
// rendered as flag names and listed as codes in JSON output. It returns the
194206
// rendered message.

‎internal/tui/model_test.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,9 @@ func TestScanFailureStatusAndExitCode(t *testing.T) {
353353
if nv.failed() || exitCode(Model{scanView: nv}) != 0 {
354354
t.Error("-no-abort warning counted as a failure")
355355
}
356+
if v := nv.View(); !strings.Contains(v, "⚠ warning: 30% failed") || strings.Contains(v, "✗") || nv.errText != "" {
357+
t.Errorf("-no-abort warning shown as an error (errText %q):\n%s", nv.errText, v)
358+
}
356359

357360
// A user abort stays "Aborted" and exits 0.
358361
av := newScanViewModel(120, 40, false)

‎internal/tui/passes_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ func TestPermutationPassStates(t *testing.T) {
334334
m.out, m.outFile = output.NewFile(f.Writer, false, output.FormatJSON), f
335335
m.out.Emit(found("www.example.com", nil))
336336
m.scanView.perm = &permutationPass{seeds: 1, candidates: 90}
337-
m = update(m, eventMsg{scan.Event{Kind: scan.EventError, Message: "resolver failed preflight"}}, eventMsg{scan.Event{Kind: scan.EventDone, Stopped: true}})
337+
m = update(m, eventMsg{scan.Event{Kind: scan.EventError, Fatal: true, Message: "resolver failed preflight"}}, eventMsg{scan.Event{Kind: scan.EventDone, Stopped: true, Failed: true}})
338338
if !m.scanView.done || !m.scanView.failed() || exitCode(m) != 1 || !strings.Contains(m.scanView.View(), "processed 5/5") {
339339
t.Errorf("failed permutation pass: done %v, failed %v\n%s", m.scanView.done, m.scanView.failed(), m.scanView.View())
340340
}

‎internal/tui/scan_view.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,12 @@ func (m *scanViewModel) applyEvent(ev scan.Event) {
380380

381381
case scan.EventError:
382382
text := scan.Render(ev.Message, settingLabel)
383+
if !ev.Fatal {
384+
// The reliability warning under No Abort: the scan goes on, so
385+
// it is a warning, not the scan's error (#308).
386+
m.addMessage(wildcardStyle.Render("⚠ " + text))
387+
break
388+
}
383389
m.addMessage(errorStyle.Render("✗ " + text))
384390
if m.errText == "" {
385391
m.errText = text

0 commit comments

Comments
 (0)