From 2d181f9f70cea998e6ea2e21a829b1145bd91caf Mon Sep 17 00:00:00 2001 From: comp500 Date: Wed, 28 Aug 2024 19:10:45 +0100 Subject: [PATCH] Restrict rehash hashes to secure hashes --- cmd/rehash.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/rehash.go b/cmd/rehash.go index 4843496..3128ecf 100644 --- a/cmd/rehash.go +++ b/cmd/rehash.go @@ -6,6 +6,7 @@ import ( "github.com/packwiz/packwiz/core" "github.com/spf13/cobra" + "golang.org/x/exp/slices" ) // rehashCmd represents the rehash command @@ -36,6 +37,11 @@ var rehashCmd = &cobra.Command{ os.Exit(1) } + if !slices.Contains([]string{"sha1", "sha512", "sha256"}, args[0]) { + fmt.Printf("Hash format '%s' is not supported\n", args[0]) + os.Exit(1) + } + session, err := core.CreateDownloadSession(mods, []string{args[0]}) if err != nil { fmt.Printf("Error retrieving external files: %v\n", err)