From 87e7c90f1ec59131d99bbff59e5a7b5fe200c4f0 Mon Sep 17 00:00:00 2001 From: Dan Anglin Date: Tue, 15 Oct 2024 17:20:23 +0100 Subject: [PATCH] use filepath.Clean to fix gosec G304 --- internal/config/config.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/config/config.go b/internal/config/config.go index 27f83e4..8684b00 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "os" + "path/filepath" ) type Config struct { @@ -13,6 +14,8 @@ type Config struct { } func NewConfig(path string) (Config, error) { + path = filepath.Clean(path) + data, err := os.ReadFile(path) if err != nil { return Config{}, fmt.Errorf(