From 95a1829ee1996da8ca7b6cba45f4f56cb4094edf Mon Sep 17 00:00:00 2001 From: Hidde Beydals Date: Thu, 31 Mar 2022 13:28:40 +0200 Subject: [PATCH] sops/keyservice: handle nil key requests Signed-off-by: Hidde Beydals --- internal/sops/keyservice/server.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/sops/keyservice/server.go b/internal/sops/keyservice/server.go index 48699f437..4088705af 100644 --- a/internal/sops/keyservice/server.go +++ b/internal/sops/keyservice/server.go @@ -9,6 +9,8 @@ import ( "go.mozilla.org/sops/v3/keyservice" "golang.org/x/net/context" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" "github.com/fluxcd/kustomize-controller/internal/sops/age" "github.com/fluxcd/kustomize-controller/internal/sops/azkv" @@ -94,6 +96,8 @@ func (ks Server) Encrypt(ctx context.Context, req *keyservice.EncryptRequest) (* Ciphertext: ciphertext, }, nil } + case nil: + return nil, status.Errorf(codes.NotFound, "must provide a key") } // Fallback to default server for any other request. return ks.defaultServer.Encrypt(ctx, req) @@ -140,6 +144,8 @@ func (ks Server) Decrypt(ctx context.Context, req *keyservice.DecryptRequest) (* Plaintext: plaintext, }, nil } + case nil: + return nil, status.Errorf(codes.NotFound, "must provide a key") } // Fallback to default server for any other request. return ks.defaultServer.Decrypt(ctx, req)