From 64563989b5d464cfa8f439ca7453f2b265f68b85 Mon Sep 17 00:00:00 2001 From: eikendev Date: Sat, 11 Feb 2023 23:58:47 +0100 Subject: [PATCH] Address CWE-703 in hibp.go --- internal/authentication/credentials/hibp.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/authentication/credentials/hibp.go b/internal/authentication/credentials/hibp.go index 99d7f76..a14dd7a 100644 --- a/internal/authentication/credentials/hibp.go +++ b/internal/authentication/credentials/hibp.go @@ -39,12 +39,16 @@ func IsPasswordPwned(password string) (bool, error) { log.L.Fatalf("Request failed with HTTP %s.", resp.Status) } - defer resp.Body.Close() bodyText, err := io.ReadAll(resp.Body) if err != nil { log.L.Fatal(err) } + err = resp.Body.Close() + if err != nil { + log.L.Warnf("Failed to close file: %s.", err) + } + bodyStr := string(bodyText) lines := strings.Split(bodyStr, "\n")