Alerting: fix gosec warning that is not valid (#43425) (#43442)

(cherry picked from commit ffc72aa255)

Co-authored-by: Jean-Philippe Quéméner <JohnnyQQQQ@users.noreply.github.com>
This commit is contained in:
Grot (@grafanabot)
2021-12-21 20:22:08 +01:00
committed by GitHub
co-authored by Jean-Philippe Quéméner
parent f74f806f09
commit 96c0d1e6eb
+3 -2
View File
@@ -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
}