Skip to content

Commit 95b1bac

Browse files
TMHSDigitalclaude
andcommitted
Map -tui -ct to Sources; explain the permutation verdict (#348)
subenum -tui -ct warned that the form has no field for -ct, although the Sources field takes ct. tuiOptions now adds ct to the Sources setting (next to any -sources, once) and no longer warns about -ct. Since #298 a target's verdict can come from its permutation pass, but explain_stats printed only the pass's candidates, seeds and found. It now gives the pass's names tested, queries and own verdict, and says when the pass set the target's verdict. Fixes #348 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent e09bab8 commit 95b1bac

7 files changed

Lines changed: 52 additions & 5 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+
- `subenum -tui -ct` puts `ct` in the form's Sources field instead of warning that the form has no field for `-ct`. `explain_stats` gives the permutation pass's own verdict, names tested and queries, and says when that pass set the target's verdict (#348).
7071
- The GitHub Action's job summary cuts its takeover and change lists to 50 entries in `jq` itself instead of piping into `head -50`, which under the step's `pipefail` could fail the step on a very long list after the scan had succeeded (#345).
7172
- The TUI's finished screen wraps its counters between counters to the terminal width and gives the extra lines to the layout, so with every counter set it still fits an 80×24 terminal instead of the terminal wrapping the line and pushing the screen one row down. ctrl+c during the permutation pass after a `-no-abort` reliability warning shows an abort, not a failure (#343).
7273
- A `-diff` baseline that is also an `-o` file is recognised however the two paths are spelled (`x` and `./x`, a relative and an absolute path, another case on Windows), so a stopped run leaves it unchanged for the resumed run, as it already did for identical spellings (#342).

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ No flags required. Fill in the form and press `ctrl+r` to start scanning. Last-u
607607

608608
<img src="docs/assets/tui-form.png" alt="subenum interactive TUI" width="640"/>
609609

610-
Flags and a domain given with `-tui` fill the form, so a prepared command line opens ready to run: `./subenum -tui example.com -w big.txt -r resolvers.txt`. The form takes one wordlist (the first `-w`), and `-tui` warns about any flag it has no field for. **Wordlist is optional:** leave the field empty to scan with the bundled top-5000 list, as a missing `-w` does on the command line. The **Resolver Pool** and **Rate/Resolver** fields are `-r` and `-rate-per-resolver`; the pool is not used with Simulate on. **Auto Rate**, **Max Duration** (blank for none, or a duration such as `20m`) and **Retry Inconclusive** are `-auto-rate`, `-max-duration` and `-retry-inconclusive`. **Sources** takes what `-sources` does (`ct`, `wayback` or both): the sources are asked while the wordlist loads, their names are scanned with the wordlist's, and a source that fails is a warning on the scan screen, not a failed scan; they are not asked with Simulate on. **Permute** is `-permute`: when the scan finishes, a second pass scans permutations of the names found, and its results are marked on the scan screen. With either field set, the results file says what proposed each name, as the CLI's does.
610+
Flags and a domain given with `-tui` fill the form, so a prepared command line opens ready to run: `./subenum -tui example.com -w big.txt -r resolvers.txt`. The form takes one wordlist (the first `-w`), and `-tui` warns about any flag it has no field for. **Wordlist is optional:** leave the field empty to scan with the bundled top-5000 list, as a missing `-w` does on the command line. The **Resolver Pool** and **Rate/Resolver** fields are `-r` and `-rate-per-resolver`; the pool is not used with Simulate on. **Auto Rate**, **Max Duration** (blank for none, or a duration such as `20m`) and **Retry Inconclusive** are `-auto-rate`, `-max-duration` and `-retry-inconclusive`. **Sources** takes what `-sources` does (`ct`, `wayback` or both; `-ct` fills in `ct`): the sources are asked while the wordlist loads, their names are scanned with the wordlist's, and a source that fails is a warning on the scan screen, not a failed scan; they are not asked with Simulate on. **Permute** is `-permute`: when the scan finishes, a second pass scans permutations of the names found, and its results are marked on the scan screen. With either field set, the results file says what proposed each name, as the CLI's does.
611611

612612
### Go library
613613

‎internal/cli/cli_test.go‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,24 @@ func TestTUIOptionsFromFlags(t *testing.T) {
394394
t.Errorf("two -o: Settings %v, stderr %q", opts.Settings, stderr.String())
395395
}
396396

397+
// -ct fills the Sources field, next to any -sources, without a warning
398+
// (#348).
399+
for _, tc := range []struct {
400+
args []string
401+
want string
402+
}{
403+
{[]string{"-tui", "-ct"}, "ct"},
404+
{[]string{"-tui", "-ct", "-sources", "wayback"}, "wayback,ct"},
405+
{[]string{"-tui", "-ct", "-sources", "ct,wayback"}, "ct,wayback"},
406+
} {
407+
f, pos, fs, _ = parseFlagsWith(tc.args, d.apply, nil)
408+
stderr.Reset()
409+
opts = tuiOptions(f, fs, pos, d, diag)
410+
if opts.Settings["sources"] != tc.want || stderr.Len() != 0 {
411+
t.Errorf("%v: Sources %q, stderr %q; want %q and no warning", tc.args, opts.Settings["sources"], stderr.String(), tc.want)
412+
}
413+
}
414+
397415
// A bare -tui warns about nothing.
398416
f, pos, fs, _ = parseFlagsWith([]string{"-tui"}, d.apply, nil)
399417
stderr.Reset()

‎internal/cli/config_test.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ func TestPrintConfigEffectiveAttempts(t *testing.T) {
308308
// tuiOmittedFlags are flags the TUI form deliberately has no field for: they
309309
// control CLI-only output, input sources, run state or modes the form does not
310310
// offer, so a command-line, SUBENUM_* or config file value for them never
311-
// seeds the form (-tui warns about one given on the command line).
311+
// seeds the form (-tui warns about one given on the command line). The one
312+
// exception is -ct, which tuiOptions turns into ct in the Sources field (#348).
312313
var tuiOmittedFlags = map[string]bool{
313314
"tui": true, "print-config": true, "dry-run": true, "version": true, "v": true, "progress": true, "silent": true,
314315
"simulate-zone": true, "retries": true, "show-records": true, "stats": true,

‎internal/cli/explain.go‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,16 @@ func explainTarget(p func(string, ...any), t output.TargetSummary) {
116116
p(" Passive source %s stopped at one of its limits: its %d names were scanned, but some hosts may be missing.", src.Name, src.Names)
117117
}
118118
}
119-
if t.Permutation != nil {
120-
p(" Permutation pass: %d candidates from %d seeds, %d found.", t.Permutation.Candidates, t.Permutation.Seeds, t.Permutation.Found)
119+
if pm := t.Permutation; pm != nil {
120+
if pm.Verdict == "" {
121+
p(" Permutation pass: %d candidates from %d seeds, %d found.", pm.Candidates, pm.Seeds, pm.Found)
122+
} else {
123+
p(" Permutation pass: %d candidates from %d seeds, %d tested with %d queries, %d found; its own verdict %s.",
124+
pm.Candidates, pm.Seeds, pm.Processed, pm.QueriesSent, pm.Found, pm.Verdict)
125+
}
126+
// Since #298 the pass's verdict becomes the target's when it is worse.
127+
if strings.HasPrefix(t.Reason, permutationReason) {
128+
p(" The permutation pass set this target's verdict: it went worse than the main pass, so its outcome is the one to act on.")
129+
}
121130
}
122131
}

‎internal/cli/mcp_test.go‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,11 @@ func TestMCPExplainStatsBranches(t *testing.T) {
470470
Sources: []output.SourceSummary{{Name: "wayback", Error: "503"}},
471471
Permutation: &output.PermutationSummary{Seeds: 4, Candidates: 40, Found: 1},
472472
Error: "resolver stopped answering",
473+
}, {
474+
// The permutation pass set this target's verdict (#298, #348).
475+
Domain: "two.example", Status: "ok", Verdict: "unreliable", Reason: "permutation pass: 30 of 60 lookups failed",
476+
Processed: 10, Total: 10, Outcomes: output.Outcomes{NXDomain: 10},
477+
Permutation: &output.PermutationSummary{Seeds: 2, Candidates: 60, Found: 0, Processed: 60, QueriesSent: 70, Verdict: "unreliable"},
473478
}},
474479
Diff: &output.DiffSummary{Previous: "prev.jsonl", Added: 1, Removed: 2, Unverified: 3},
475480
}
@@ -490,11 +495,16 @@ func TestMCPExplainStatsBranches(t *testing.T) {
490495
"Zone transfer (AXFR) was allowed by ns1.lab.example", "plain NSEC", "Passive source wayback failed (503)",
491496
"Permutation pass: 40 candidates from 4 seeds, 1 found", "Compared with prev.jsonl: 1 added, 2 removed",
492497
"3 earlier names could not be checked",
498+
"Permutation pass: 60 candidates from 2 seeds, 60 tested with 70 queries, 0 found; its own verdict unreliable",
499+
"The permutation pass set this target's verdict",
493500
} {
494501
if !strings.Contains(text, want) {
495502
t.Errorf("explanation lacks %q:\n%s", want, text)
496503
}
497504
}
505+
if n := strings.Count(text, "The permutation pass set"); n != 1 {
506+
t.Errorf("%d targets said the permutation pass set their verdict, want only two.example:\n%s", n, text)
507+
}
498508
}
499509

500510
// TestMCPVerdictMatchesReport is #263's drift guard: for the same finished

‎internal/cli/session.go‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,21 @@ func tuiOptions(f cliFlags, fs *flag.FlagSet, positionals []string, defaults *de
223223
var ignored []string
224224
fs.Visit(func(fl *flag.Flag) {
225225
switch {
226-
case fl.Name == "tui":
226+
case fl.Name == "tui", fl.Name == "ct": // -ct goes to Sources, below
227227
case wired[fl.Name]:
228228
settings[fl.Name] = fl.Value.String()
229229
default:
230230
ignored = append(ignored, "-"+fl.Name)
231231
}
232232
})
233+
if f.ct {
234+
// The form has no -ct field: -ct is the ct source of -sources, which
235+
// the Sources field takes (#348).
236+
sources := strings.Split(settings["sources"], ",")
237+
if !slices.Contains(sources, "ct") {
238+
settings["sources"] = strings.Trim(settings["sources"]+",ct", ",")
239+
}
240+
}
233241
if len(f.wordlists.paths) > 1 {
234242
settings["w"] = f.wordlists.paths[0]
235243
diag.Notice("Warning: the TUI takes one wordlist; using %s", f.wordlists.paths[0])

0 commit comments

Comments
 (0)