From 65cd3884f10ca5f2ac206b15dd42540b1d135733 Mon Sep 17 00:00:00 2001 From: Vistaar Juneja Date: Wed, 10 Jan 2024 11:48:31 +0100 Subject: [PATCH] add validations on response from /subscriptions API in ACR (#91) --- cmd/kaniko-acr/main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmd/kaniko-acr/main.go b/cmd/kaniko-acr/main.go index ff60c55..a9d45b6 100644 --- a/cmd/kaniko-acr/main.go +++ b/cmd/kaniko-acr/main.go @@ -432,6 +432,15 @@ func getPublicUrl(token, registryUrl, subscriptionId string) (string, error) { if err != nil { return "", errors.Wrap(err, "failed to send request for getting container registry setting") } + + if len(response.Value) == 0 { + return "", errors.New("did not receive any registry information from /subscriptions API") + } + + if response.Value[0].ID == "" { + return "", errors.New("received empty registry ID from /subscriptions API") + } + return finalUrl + encodeParam(response.Value[0].ID), nil }