From ffc72aa25541a8f3a1930f59f7007a8e8301fd84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Qu=C3=A9m=C3=A9ner?= Date: Tue, 21 Dec 2021 19:47:47 +0100 Subject: [PATCH] Alerting: fix gosec warning that is not valid (#43425) --- 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 }