From 5d8f3f765a53178aef51b39971986396d6c4354d Mon Sep 17 00:00:00 2001 From: Timo Reymann Date: Fri, 19 Apr 2024 13:46:36 +0200 Subject: [PATCH] fix(#9): Harden http image check --- pkg/assets/main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/assets/main.go b/pkg/assets/main.go index d4ced3c..fc2842e 100644 --- a/pkg/assets/main.go +++ b/pkg/assets/main.go @@ -6,6 +6,7 @@ import ( "io" "net/http" "os" + "strings" ) func loadFileOrUrl(path string) ([]byte, error) { @@ -17,7 +18,7 @@ func loadFileOrUrl(path string) ([]byte, error) { if err != nil { return nil, err } - } else { + } else if strings.HasPrefix(path, "http") { // File does not exist locally, download it from the internet resp, err := http.Get(path) if err != nil { @@ -29,6 +30,8 @@ func loadFileOrUrl(path string) ([]byte, error) { if err != nil { return nil, err } + } else { + return nil, fmt.Errorf(path + " could not be found and is no resolvable URL") } return data, nil }