From 35a86416aadac21de80303667940599d69562faf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 20 Nov 2024 09:46:40 +0100 Subject: [PATCH] always check for errors on type casting --- pkgs/sops-install-secrets/main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/sops-install-secrets/main.go b/pkgs/sops-install-secrets/main.go index 722b8ae..3914eae 100644 --- a/pkgs/sops-install-secrets/main.go +++ b/pkgs/sops-install-secrets/main.go @@ -322,7 +322,12 @@ func recurseSecretKey(keys map[string]interface{}, wantedKey string) (string, er currentData = make(map[string]interface{}) for key, value := range valWithWrongType { - currentData[key.(string)] = value + keyStr, ok := key.(string) + if !ok { + return "", fmt.Errorf("the key '%s' is not a string", key) + } + + currentData[keyStr] = value } }