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

Abierto Apto para principiantes
#319 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
76/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
go
Área
cli

Línea de trabajo

Empieza en internal/output/writer.go: ensureCSV envuelve stdout en un csv.NewWriter, y writeCSVRows escribe cada fila sin hacer flush, así que el flush solo ocurre en Finish. Reproduce con -simulate -format csv ... | cat frente a -format jsonl. Se considera terminado cuando cada fila CSV en stdout se vacía al escribirse, y una prueba en el paquete output (usando -simulate o el servidor DNS de prueba local, no un dominio real) lee una fila de stdout antes de que termine la ejecución.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
Go
Estrellas
1
Forks
1
Merge medio
6 h 42 min
PR fusionados (30 d)
7

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de TMHSDigital/subenum

Todos los issues de TMHSDigital/subenum

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.