Skip to content

internal/output: file lifecycle, SARIF and summary writers untested at package level #171

Closed

Description

@TMHSDigital

Summary

internal/output is 51% covered. The file lifecycle, SARIF and summary writers are reached only by main-package end-to-end tests, which flaked in this audit's run, so a writer regression has no fast isolated signal.

Where

  • internal/output/file.go:32, 59, 75 (CreateFile, Write, Close)
  • internal/output/sarif.go:86, 111 (WriteSARIF, fingerprints)
  • internal/output/summary.go:106, 127
  • internal/output/writer.go:125, 129, 131, 412 (SetDiff, diffPrefix, SetQuiet, Error)

Details

SARIF is consumed by GitHub code scanning (CI greps for dangling-cname, go.yml:131); a malformed document or unstable fingerprint passes until a downstream upload fails.

Suggested test cases

  • WriteSARIF with zero results: valid 2.1.0 document, empty results, rule still declared
  • Two takeovers on the same name with different kinds: distinct partialFingerprints; same input twice: byte-identical output
  • WriteSARIF to an unwritable path: error returned, no partial file
  • Summary/WriteSummaryFile: every verdict value renders; zero-processed scan; missing directory returns an error
  • CreateFile: new file created; symlink target written through; Close after a Write error leaves the original untouched; double Close is a no-op
  • SetDiff + Result: added/removed prefixes in text, JSONL and CSV; SetQuiet suppresses Info but not Error

Acceptance criteria

  • internal/output above 80% coverage in-package

Getting started

  • Relevant files: internal/output/*.go, internal/output/writer_test.go
  • How to run tests: go test -cover ./internal/output/
  • Related docs: README "Output formats", docs/pipelines.md

Filed by repo-audit/full-audit at 3139c44. Severity: medium. Effort: M. audit-key: testing|internal/output|file sarif summary writers

Activity

  1. added
    help wanted
    area: output
    testing
    severity: medium
    on Nov 9, 2026
  2. TMHSDigital commented on Nov 9, 2026

    @TMHSDigital
    OwnerAuthor

    Fixed in 77bc419: new internal/output/lifecycle_test.go covers the results-file lifecycle (commit, discard, double Close, missing dir, device target), WriteSARIF (empty run, rule dedupe and levels, distinct and stable fingerprints, byte-identical reruns, unwritable path), WriteSummaryFile for every verdict, the jsonl-only summary line, SetDiff in text, CSV and JSONL, and SetQuiet. Package coverage went from 61% to 94%. Verified on Windows (go test -race -shuffle=on) and on Linux via a cross-compiled test binary, plus golangci-lint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: outputhelp wantedseverity: mediumtesting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions