Restrict rehash hashes to secure hashes

This commit is contained in:
comp500 2024-08-28 19:10:45 +01:00
parent 4779b0a218
commit 2d181f9f70

View File

@ -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)