From 96c0d1e6eb30f3ce1628d593bfb7b2253e60566e Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Tue, 21 Dec 2021 20:22:08 +0100 Subject: [PATCH] Alerting: fix gosec warning that is not valid (#43425) (#43442) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit ffc72aa25541a8f3a1930f59f7007a8e8301fd84) Co-authored-by: Jean-Philippe Quéméner --- pkg/services/ngalert/notifier/config.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/services/ngalert/notifier/config.go b/pkg/services/ngalert/notifier/config.go index 1f31910b55a..1879773bd38 100644 --- a/pkg/services/ngalert/notifier/config.go +++ b/pkg/services/ngalert/notifier/config.go @@ -34,7 +34,7 @@ func PersistTemplates(cfg *api.PostableUserConfig, path string) ([]string, bool, pathSet[file] = struct{}{} // Check if the template file already exists and if it has changed - // We can safeily ignore gosec here and we've previously checked the filename is clean + // We can safely ignore gosec here as we've previously checked the filename is clean // nolint:gosec if tmpl, err := ioutil.ReadFile(file); err == nil && string(tmpl) == content { // Templates file is the same we have, no-op and continue. @@ -43,10 +43,11 @@ func PersistTemplates(cfg *api.PostableUserConfig, path string) ([]string, bool, return nil, false, err } + // We can safely ignore gosec here as we've previously checked the filename is clean + // nolint:gosec if err := ioutil.WriteFile(file, []byte(content), 0644); err != nil { return nil, false, fmt.Errorf("unable to create Alertmanager template file %q: %s", file, err) } - // nolint:gosec templatesChanged = true }