From 12a5a7a70d6e26eb373741850669b95fff51ebcb Mon Sep 17 00:00:00 2001 From: schakrad <58915923+schakrad@users.noreply.github.com> Date: Tue, 18 Jul 2023 13:07:44 -0700 Subject: [PATCH] fix(cli): argocd CLI RBAC validation doesn't work on actions (#13911) (#14578) * #11602 fix : Object options menu truncated when selected in ApplicationListView. Signed-off-by: schakradari * #11602 fix : Object options menu truncated when selected in ApplicationListView. Signed-off-by: schakradari * changes for argocd_rbac Signed-off-by: schakrad --------- Signed-off-by: schakradari Signed-off-by: schakrad Co-authored-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> --- cmd/argocd/commands/admin/settings_rbac.go | 4 ++++ cmd/argocd/commands/admin/settings_rbac_test.go | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/cmd/argocd/commands/admin/settings_rbac.go b/cmd/argocd/commands/admin/settings_rbac.go index 6164aa910a6e4..8d94feeaad466 100644 --- a/cmd/argocd/commands/admin/settings_rbac.go +++ b/cmd/argocd/commands/admin/settings_rbac.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "os" + "strings" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -373,6 +374,9 @@ func resolveRBACResourceName(name string) string { // isValidRBACAction checks whether a given action is a valid RBAC action func isValidRBACAction(action string) bool { + if strings.HasPrefix(action, rbacpolicy.ActionAction+"/") { + return true + } _, ok := validRBACActions[action] return ok } diff --git a/cmd/argocd/commands/admin/settings_rbac_test.go b/cmd/argocd/commands/admin/settings_rbac_test.go index e53a5ed6da1f9..a4b4b437e114c 100644 --- a/cmd/argocd/commands/admin/settings_rbac_test.go +++ b/cmd/argocd/commands/admin/settings_rbac_test.go @@ -27,6 +27,11 @@ func Test_isValidRBACAction(t *testing.T) { }) } +func Test_isValidRBACAction_ActionAction(t *testing.T) { + ok := isValidRBACAction("action/apps/Deployment/restart") + assert.True(t, ok) +} + func Test_isValidRBACResource(t *testing.T) { for k := range validRBACResources { t.Run(k, func(t *testing.T) {