From 4e0a67890a0952391760490bfec7c98aa5fda7c5 Mon Sep 17 00:00:00 2001 From: "gcp-cherry-pick-bot[bot]" <98988430+gcp-cherry-pick-bot[bot]@users.noreply.github.com> Date: Tue, 18 Jul 2023 16:22:16 -0400 Subject: [PATCH] fix(cli): argocd CLI RBAC validation doesn't work on actions (#13911) (#14578) (#14582) * #11602 fix : Object options menu truncated when selected in ApplicationListView. * #11602 fix : Object options menu truncated when selected in ApplicationListView. * changes for argocd_rbac --------- Signed-off-by: schakradari Signed-off-by: schakrad Co-authored-by: schakrad <58915923+schakrad@users.noreply.github.com> Co-authored-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> Signed-off-by: schakrad <58915923+schakrad@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 e52887fe33071..ae7377f126cf1 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" "github.com/ghodss/yaml" log "github.com/sirupsen/logrus" @@ -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 93601eed1d303..49cd6b73ffb50 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) {