From 8adac556e5f326e7c47e74e213f16cd83a8859f0 Mon Sep 17 00:00:00 2001 From: davidrobert Date: Sun, 15 Dec 2024 11:34:51 +0200 Subject: [PATCH] Add type safety check --- src/shared/azureagent/customroles.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/shared/azureagent/customroles.go b/src/shared/azureagent/customroles.go index e4cf411e2..49676d20d 100644 --- a/src/shared/azureagent/customroles.go +++ b/src/shared/azureagent/customroles.go @@ -72,6 +72,10 @@ func (a *Agent) CreateCustomRole(ctx context.Context, scope string, uai armmsi.I } func (a *Agent) UpdateCustomRole(ctx context.Context, scope string, role *armauthorization.RoleDefinition, actions []v2alpha1.AzureAction, dataActions []v2alpha1.AzureDataAction) error { + if role == nil || role.Properties == nil || role.Properties.Permissions == nil || len(role.Properties.Permissions) == 0 { + return errors.Errorf("role definition is nil or does not have any permissions") + } + roleScope := a.getSubscriptionScope(scope) formattedActions := lo.Map(actions, func(action v2alpha1.AzureAction, _ int) *string {