CSV rows for stdout sit in a 4 KB buffer until the run ends

未關閉 適合新手
#319 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
76/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
go
領域
cli

研究方向

從 internal/output/writer.go 開始:ensureCSV 將 stdout 包裝在 csv.NewWriter 中,而 writeCSVRows 在寫入每一列時不做刷新,因此刷新只發生在 Finish 中。使用 -simulate -format csv ... | cat 與 -format jsonl 進行對照重現。完成標準是:stdout 上的每一筆 CSV 列在寫入時即被刷新;並且 output 套件中的一個測試(使用 -simulate 或本地 DNS 測試伺服器,而非真實網域)能在執行結束前從 stdout 讀到一列。

由索引模型根據 Issue 內容生成。

描述

area: output bug good first issue severity: low

Summary

With -format csv, results reach stdout only when 4 KB has accumulated or the run finishes, unlike text, JSON and JSONL, which are written as each result is found; a force quit loses the buffered rows.

Where

  • internal/output/writer.go:328
  • internal/output/writer.go:354
  • internal/output/writer.go:390
  • internal/output/writer.go:30

Details

ensureCSV wraps stdout in csv.NewWriter(w.stdOut()) (line 328) and writeCSVRows only calls w.csvStdout.Write(row) (line 355). encoding/csv.Writer buffers through a bufio.Writer and is flushed in exactly one place, Finish (lines 390-392; git grep "Flush()" confirms). Text, JSONL and even the JSON array (w.stdOut().Write(data), line 279) are written to stdout as each result is found. The FormatCSV doc comment says it "streams" rows (line 30).

Impact

With -format csv, nothing reaches stdout until 4 KB of rows have accumulated or the run finishes: a consumer on a pipe sees no live results, on a terminal the rows appear after the "Scan complete" breakdown instead of as they are found, and a force quit (the second Ctrl+C, which main_session.go:519-521 deliberately restores) loses every buffered row. The other three formats do not behave this way.

Steps to reproduce

subenum -simulate -hit-rate 100 -rate 2 -format csv -w examples/sample_wordlist.txt example.com | cat prints nothing until the scan ends; the same command with -format jsonl prints a line per hit.

Suggested fix

Call w.csvStdout.Flush() at the end of writeCSVRows when w.csvStdout != nil (stdout only; the file writer already sits on the -o bufio.Writer and can stay buffered).

Acceptance criteria

  • Each CSV row written to stdout is flushed when it is written
  • A test reads a row from stdout before the run finishes

Getting started

  • Relevant files: internal/output/writer.go
  • How to run tests: make test (or go test ./...). Tests must stay hermetic: use -simulate, -simulate-zone or the local DNS test server, never a live domain.
  • Related docs: docs/DEVELOPER_GUIDE.md, docs/ARCHITECTURE.md

Filed by repo-audit/full-audit at d0c56f0. Severity: low. Effort: S. audit-key: bug|internal/output/writer.go|writeCSVRows

主要語言
Go
星號
1
分支
1
平均合併
6 小時 42 分鐘
30 天內合併 PR
7

環境準備

在 Codespaces 中開啟

在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

TMHSDigital/subenum 的其他 Issue

查看 TMHSDigital/subenum 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。