Skip to content

Commit a776076

Browse files
TMHSDigitalclaude
andcommitted
fix(cli): ignore -ct in simulation mode (#150)
-simulate promises that nothing leaves the machine, but -ct still made an HTTPS request to crt.sh with the target name. Skip CT seeding under -simulate with a note, as -r already does, and add an end-to-end test that a local CT server is never contacted. Fixes #150 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LpkeXSPwrzd7ZCuX3no7gD
1 parent 037fc69 commit a776076

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

‎main.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,12 @@ func run() (code int) {
644644
out.Info("╚════════════════════════════════════════════════════════════════════╝")
645645
out.Info("Simulation seed: %d (pass -seed %d to reproduce these results)", f.seed, f.seed)
646646
out.Info("")
647+
if f.ct {
648+
// -ct is an HTTPS request to crt.sh: it would send the target
649+
// off the machine despite the banner above (#150).
650+
out.Info("Note: -ct is ignored in simulation mode, which sends nothing off the machine")
651+
f.ct = false
652+
}
647653
}
648654

649655
pool, poolCode := loadPool(f, out)

‎main_ct_test.go‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,28 @@ func TestE2ECertificateTransparency(t *testing.T) {
6767
}
6868
}
6969

70+
// TestE2ESimulateSkipsCT covers #150: simulation mode sends nothing off the
71+
// machine, so -ct is ignored with a note instead of querying crt.sh.
72+
func TestE2ESimulateSkipsCT(t *testing.T) {
73+
hit := false
74+
ct := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
75+
hit = true
76+
_, _ = w.Write([]byte(`[]`))
77+
}))
78+
defer ct.Close()
79+
ctBaseURL = ct.URL + "/"
80+
t.Cleanup(func() { ctBaseURL = "" })
81+
82+
wl := writeFile(t, "wl.txt", "www\nmail\n")
83+
code, out := runCLIMerged(t, "-ct", "-simulate", "-seed", "1", "-progress=false", "-w", wl, "example.com")
84+
if code != 0 || !strings.Contains(out, "-ct is ignored in simulation mode") {
85+
t.Errorf("exit %d, want 0 and a note that -ct is ignored\n%s", code, out)
86+
}
87+
if hit {
88+
t.Error("-simulate -ct contacted the CT server")
89+
}
90+
}
91+
7092
// TestE2ELabRefusesCT: -ct reaches crt.sh, so lab mode refuses it.
7193
func TestE2ELabRefusesCT(t *testing.T) {
7294
zone := filepath.Join("examples", "labs", "lab1-first-scan.zone")

0 commit comments

Comments
 (0)