Skip to content

Commit

Permalink
fix(#9): Harden http image check
Browse files Browse the repository at this point in the history
  • Loading branch information
timo-reymann committed Apr 19, 2024
1 parent 797908d commit 5d8f3f7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/assets/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"net/http"
"os"
"strings"
)

func loadFileOrUrl(path string) ([]byte, error) {
Expand All @@ -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 {
Expand All @@ -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")

Check warning on line 34 in pkg/assets/main.go

View check run for this annotation

Codecov / codecov/patch

pkg/assets/main.go#L33-L34

Added lines #L33 - L34 were not covered by tests
}
return data, nil
}
Expand Down

0 comments on commit 5d8f3f7

Please sign in to comment.