Skip to content

fix: add rbac error check to rest of cmx api calls#700

Merged
mikhailswift merged 2 commits intomainfrom
mikhail/add-missing-rbac-checks
Apr 23, 2026
Merged

fix: add rbac error check to rest of cmx api calls#700
mikhailswift merged 2 commits intomainfrom
mikhail/add-missing-rbac-checks

Conversation

@mikhailswift
Copy link
Copy Markdown
Member

No description provided.

Comment thread cli/cmd/cluster_ls.go
@mikhailswift mikhailswift force-pushed the mikhail/add-missing-rbac-checks branch from cb34d34 to 380a948 Compare April 23, 2026 18:49
Comment thread cli/cmd/vm_endpoints.go
@mikhailswift mikhailswift force-pushed the mikhail/add-missing-rbac-checks branch from 380a948 to aeb8d56 Compare April 23, 2026 18:57
Comment thread cli/cmd/vm_create.go Outdated
Comment thread cli/cmd/cluster_ls.go
@mikhailswift mikhailswift force-pushed the mikhail/add-missing-rbac-checks branch from f26a71f to 932fbb1 Compare April 23, 2026 20:34
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 932fbb1. Configure here.

Comment thread cli/cmd/errors.go
func isRBACDeniedError(err error) bool {
message := strings.TrimSpace(strings.ToLower(err.Error()))
return strings.Contains(message, "access to ") && strings.HasSuffix(message, " is denied")
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated RBAC error handling across 21 call sites

Medium Severity

The identical 3-line block — if isRBACDeniedError(err) { return …, errors.New(err.Error()) } followed by return …, ErrCompatibilityMatrixTermsNotAccepted — is copy-pasted across 21 call sites. A single helper (e.g. func forbiddenToError(err error) error) that encapsulates the RBAC-vs-terms check would eliminate the duplication. This matters because the network files (network_create.go, network_ls.go, network_rm.go, network_update.go, network_report.go) were already missed in this PR, demonstrating the maintenance risk of the repeated pattern.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 932fbb1. Configure here.

@mikhailswift mikhailswift merged commit aa8a205 into main Apr 23, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants