Write log export CSV rows with safecsv WriteRow

Document that Write and WriteRow sanitize fields; export
streaming uses WriteRow at call sites instead of Write([]string).

Signed-off-by: Cursor Agent <cursoragent@cursor.com>

Co-authored-by: Bryan FRIMIN <bryan@frimin.fr>
This commit is contained in:
Cursor Agent
2026-07-30 09:57:27 +00:00
parent 5ea732a97f
commit 010fdcd51e
2 changed files with 19 additions and 15 deletions

View File

@@ -41,12 +41,16 @@ func NewWriter(w io.Writer) *Writer {
return &Writer{inner: csv.NewWriter(w)}
}
// Write encodes a CSV record after sanitizing every field. Prefer WriteRow for
// literal column values at call sites.
func (w *Writer) Write(record []string) error {
return w.inner.Write(SanitizeRecord(record))
}
// WriteRow encodes one CSV record from fields, sanitizing each value before
// encoding (spreadsheet formula injection mitigation).
func (w *Writer) WriteRow(fields ...string) error {
return w.Write(fields)
return w.inner.Write(SanitizeRecord(fields))
}
func (w *Writer) Flush() {