diff --git a/report/json.go b/report/json.go index 424cb9c2..3a85312c 100644 --- a/report/json.go +++ b/report/json.go @@ -9,6 +9,8 @@ func writeJson(findings []Finding, w io.WriteCloser) error { if len(findings) == 0 { findings = []Finding{} } + defer w.Close() + encoder := json.NewEncoder(w) encoder.SetIndent("", " ") return encoder.Encode(findings) diff --git a/report/sarif.go b/report/sarif.go index 4cf345cd..09719e49 100644 --- a/report/sarif.go +++ b/report/sarif.go @@ -14,6 +14,7 @@ func writeSarif(cfg config.Config, findings []Finding, w io.WriteCloser) error { Version: "2.1.0", Runs: getRuns(cfg, findings), } + defer w.Close() encoder := json.NewEncoder(w) encoder.SetIndent("", " ")