From 99acf1fd18d4db63acd2e58dc2efcdb0e85b516f Mon Sep 17 00:00:00 2001 From: MassiveBox Date: Fri, 3 Nov 2023 22:53:54 +0100 Subject: [PATCH] Fix linter errors --- .golangci.yml | 1 - src/ecodash/config.go | 2 +- src/ecodash/http.go | 2 ++ src/main/main.go | 5 +++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 1bd5888..13ae91d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -234,7 +234,6 @@ linters: - wrapcheck - nonamedreturns - gomnd - - gosmopolitan - depguard enable-all: true diff --git a/src/ecodash/config.go b/src/ecodash/config.go index efa5841..c598902 100644 --- a/src/ecodash/config.go +++ b/src/ecodash/config.go @@ -38,11 +38,11 @@ type Administrator struct { PasswordHash string `json:"password_hash"` } type Dashboard struct { + MOTD *MessageCard `json:"motd"` Name string `json:"name"` Theme string `json:"theme"` FooterLinks []Link `json:"footer_links"` HeaderLinks []Link `json:"header_links"` - MOTD *MessageCard `json:"motd"` } type MessageCard struct { diff --git a/src/ecodash/http.go b/src/ecodash/http.go index 8cce565..46b9030 100644 --- a/src/ecodash/http.go +++ b/src/ecodash/http.go @@ -47,6 +47,7 @@ func (config *Config) AdminEndpoint(c *fiber.Ctx) error { if config.IsAuthorized(c) { // here the user is submitting the form to change configuration err := config.saveAdminForm(c) if err != nil { + // #nosec the input is admin-defined, and the admin is assumed to be trusted. return config.RenderAdminPanel(c, &MessageCard{ Title: "An error occurred!", Content: template.HTML(html.EscapeString(err.Error())), @@ -122,6 +123,7 @@ func (config *Config) saveAdminForm(c *fiber.Ctx) error { } if c.FormValue("motd_title") != "" || c.FormValue("motd_content") != "" { + // #nosec the input is admin-defined, and the admin is assumed to be trusted. form.Dashboard.MOTD = &MessageCard{ Title: c.FormValue("motd_title"), Content: template.HTML(c.FormValue("motd_content")), diff --git a/src/main/main.go b/src/main/main.go index 29ae004..52e0854 100644 --- a/src/main/main.go +++ b/src/main/main.go @@ -1,13 +1,14 @@ package main import ( + "log" + "os" + "git.massivebox.net/ecodash/ecodash/src/ecodash" "git.massivebox.net/ecodash/ecodash/src/tools" "github.com/gofiber/fiber/v2" "github.com/gofiber/template/html" "github.com/robfig/cron/v3" - "log" - "os" ) func main() {