Skip to content

feat(api): register portal-assistant:invoke and add chart roles validation test (#4683) - #4722

Open
kavix wants to merge 1 commit into
openchoreo:mainfrom
kavix:fix-authz-docs-action-lists-4683
Open

kavix wants to merge 1 commit into
openchoreo:mainfrom
kavix:fix-authz-docs-action-lists-4683

Conversation

@kavix

@kavix kavix commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Resolves #4683 (codebase portion).

During the authorization audit in #4683, portal-assistant:invoke was found to be granted to platform-engineer and developer roles in Helm chart values (install/helm/openchoreo-control-plane/values.yaml), and actively enforced by AuthRuntime in agents/portal-assistant/src/auth.py and agent_routes.py. However, it was missing from the registry in internal/authz/core/actions.go.

This PR formally registers ActionInvokePortalAssistant and introduces an automated drift-guard test to prevent future divergence between Helm bootstrap roles and the core action registry.

Approach

  1. Registered ActionInvokePortalAssistant = "portal-assistant:invoke" in internal/authz/core/actions.go with lowest scope ScopeCluster and IsInternal: false.
  2. Added internal/authz/core/chart_roles_test.go (TestBootstrapRoles_ActionValidity) which parses install/helm/openchoreo-control-plane/values.yaml and validates that every action granted across all bootstrap roles exists in core.ConcretePublicActions().

Related Issues

Checklist

  • Tests added or updated (unit, integration, etc.)
  • Samples updated (if applicable)
  • Added backport/<release-branch> label if this should be backported (e.g., backport/release-v1.0)
  • This PR includes AI-generated code or content

Remarks

Documentation updates bringing the 165 actions and 11 default roles up to date are submitted in companion PR: openchoreo/openchoreo.github.io#857

@coderabbitai

coderabbitai Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 6bfb7afd-2e7d-4e95-a50a-6a4ebc7e404e

📥 Commits

Reviewing files that changed from the base of the PR and between 98e6e07 and 2f2b51f.

📒 Files selected for processing (1)
  • internal/authz/core/actions_test.go

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Summary

Summary

  • Added portal-assistant:invoke to the public authorization registry.
  • Set its lowest scope to ScopeCluster.
  • Set IsInternal to false.
  • Added validation for Helm bootstrap role grants.

Changed files

Top-level folder Files
internal/ 2
api/, config/, pkg/, install/, docs/, openapi/, agents/, make/, cmd/, samples/ 0

API/CRD surface

  • No API or CRD changes.
  • Compatibility risk: Low.
  • The change adds one public authorization action and does not remove or alter existing actions.

Tests

  • Added TestActionInvokePortalAssistantRegistered.
    • Checks the action name.
    • Checks public registration.
    • Checks ScopeCluster.
    • Checks IsInternal: false.
  • Added TestBootstrapRoles_ActionValidity.
    • Loads install/helm/openchoreo-control-plane/values.yaml.
    • Checks that bootstrap roles exist and contain actions.
    • Rejects grants that are not in core.ConcretePublicActions().
    • Allows the * wildcard.
  • No test execution result was supplied.
  • No evidence was provided for end-to-end Portal Assistant authorization tests or Helm installation tests.

Risk hotspots

  • Authorization/RBAC: Medium. Bootstrap roles now receive validation against the registered public action set. An invalid grant can fail the test.
  • Portal Assistant authorization: Low to medium. The action is now registered with cluster scope and public visibility. Runtime endpoint enforcement is not covered by the supplied tests.
  • Secrets: No changes identified.
  • Reconciliation loops: No changes identified.
  • Install/upgrade paths: Low. The test reads the control-plane Helm values file, but no install or upgrade execution result was supplied.

Review finding severity counts: unavailable from the supplied evidence.

Walkthrough

The authorization registry adds portal-assistant:invoke as a public, cluster-scoped action. Tests verify its registration and validate bootstrap role actions against concrete public actions.

Changes

Portal assistant authorization

Layer / File(s) Summary
Register portal assistant action
internal/authz/core/actions.go, internal/authz/core/actions_test.go
Adds the portal-assistant:invoke constant and registers it as a public cluster-scoped system action. The registration test verifies its name, scope, and visibility.
Validate bootstrap role actions
internal/authz/core/actions_test.go, helm/.../values.yaml
Adds YAML-backed validation that bootstrap roles contain actions and reference concrete public actions, while allowing *.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 2f2b5

The portal assistant permission is registered as a public cluster-scoped action, and bootstrap-role configuration is checked against the action registry. No merge-blocking risk was identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description includes the required Purpose, Approach, Related Issues, Checklist, and Remarks sections. It clearly explains the action registration and drift-guard test. The checklist records the ad…
Title check ✅ Passed The title uses Conventional Commits format and clearly identifies the main changes: registering portal-assistant:invoke and adding chart role validation.
Linked Issues check ✅ Passed Issue #4683 requires resolving the unregistered portal-assistant:invoke grant. The PR defines ActionInvokePortalAssistant and registers it as a public action with ScopeCluster and `IsInternal: f…
Out of Scope Changes check ✅ Passed The changes add the required authorization registry entry and tests that protect the registry and Helm bootstrap-role alignment. The changes support the coding objectives in #4683. No unrelated change…
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kavix
kavix force-pushed the fix-authz-docs-action-lists-4683 branch from 5de73a3 to fa658c7 Compare September 11, 2026 22:39
@kavix kavix changed the title feat(authz): register portal-assistant:invoke and add chart roles validation test (#4683) feat(api): register portal-assistant:invoke and add chart roles validation test (#4683) Sep 11, 2026
@codecov

codecov Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

mevan-karu
mevan-karu previously approved these changes Sep 14, 2026
@mevan-karu

Copy link
Copy Markdown
Contributor

@kavix There are some conflicts. Can you resolve those and push again?

@kavix

kavix commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

@mevan-karu Done!

@kavix
kavix requested a review from mevan-karu September 17, 2026 12:39
Comment thread internal/authz/core/chart_roles_test.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Any reason for the file name? We have to have files for code and the test which follows name_test.go.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved into actions_test.go to match convention and removed chart_roles_test.go.

@kavix
kavix force-pushed the fix-authz-docs-action-lists-4683 branch from 98e6e07 to 2f2b51f Compare September 18, 2026 05:03
@savisaluwadana

Copy link
Copy Markdown

Hi @LakshanSS can you look into this thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Authorization docs action lists are out of date

5 participants