Explorar o código

Fix closing file in writeJson and writeSarif (#1187)

Oleksandr Redko %!s(int64=3) %!d(string=hai) anos
pai
achega
190ac977be
Modificáronse 2 ficheiros con 3 adicións e 0 borrados
  1. 2 0
      report/json.go
  2. 1 0
      report/sarif.go

+ 2 - 0
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)

+ 1 - 0
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("", " ")