Combined test/rbacrep by ksurabhi91 · Pull Request #21405 · stackrox/stackrox · GitHub
Skip to content

Combined test/rbacrep#21405

Draft
ksurabhi91 wants to merge 10 commits into
masterfrom
combined-test/rbacrep
Draft

Combined test/rbacrep#21405
ksurabhi91 wants to merge 10 commits into
masterfrom
combined-test/rbacrep

Conversation

@ksurabhi91

Copy link
Copy Markdown
Contributor

Description

change me!

User-facing documentation

Testing and quality

  • the change is production ready: the change is GA, or otherwise the functionality is gated by a feature flag
  • CI results are inspected

Automated testing

  • added unit tests
  • added e2e tests
  • added regression tests
  • added compatibility tests
  • modified existing tests

How I validated my change

change me!

@openshift-ci

openshift-ci Bot commented Jun 25, 2026

Copy link
Copy Markdown

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Reporting access is now governed by Image + Deployment permissions, enabling consistent enablement of view-based report features and downloads across vulnerability pages.
    • Report navigation/tabs now dynamically adapt to the permissions you have, including conditional configuration routing.
  • Bug Fixes

    • Corrected server-side authorization behavior for report history, cancellation, and download/config flows to align with the new permission model.
    • Fixed view-based snapshot persistence to reliably save snapshots under the appropriate access context.
  • Tests

    • Added coverage to validate authorization enforcement across multiple report RPC methods.

Walkthrough

Vulnerability report authorization and routing now use image-and-deployment access checks. Backend report routes and RPC methods were updated, the report page and tab layout use permission-gated routes, and workload pages changed their view-based report gating.

Changes

Vulnerability reports authorization and routing

Layer / File(s) Summary
Route keys and registrations
ui/apps/platform/src/routePaths.ts, ui/apps/platform/src/Containers/Vulnerabilities/VulnerablityReporting/VulnReportingPage.tsx
The vulnerabilities/reports route requirement changes to image plus deployment access, and VulnReportingPage rewrites the report route tree around configuration routes, view-based routes, and PageNotFound.
Tab layout filtering
ui/apps/platform/src/Containers/Vulnerabilities/VulnerablityReporting/VulnReports/VulnReportingLayout.tsx
VulnReportingLayout adds per-tab access requirements, filters tabs with usePermissions, and renders the active tab content directly from the filtered tab list.
View-based report gates
ui/apps/platform/src/Containers/Vulnerabilities/WorkloadCves/Overview/WorkloadCvesOverviewPage.tsx, ui/apps/platform/src/Containers/Vulnerabilities/WorkloadCves/Deployment/DeploymentPage.tsx, ui/apps/platform/src/Containers/Vulnerabilities/WorkloadCves/Image/ImagePage.tsx
DeploymentPage, ImagePage, and WorkloadCvesOverviewPage replace WorkflowAdministration-based view-based report gating with image-and-deployment read access, and WorkloadCvesOverviewPage removes the helper permission constant.
Report service authorization
central/main.go, central/reports/service/v2/service_impl.go, central/reports/service/v2/service_impl_test.go
The report download route and V2 report-service authorizer now require image and deployment permissions, PostViewBasedReport no longer performs the workflow write SAC check, and TestAuthzPermissions verifies the updated RPC permission sets.
Snapshot persistence context
central/reports/scheduler/v2/scheduler_impl.go
View-based vulnerability report snapshots are persisted with an elevated access context on the non-resubmission insert path.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is mostly the untouched template with "change me!" placeholders and no real implementation details. Replace the placeholders with a summary of the RBAC/reporting changes, documentation/testing status, and validation performed.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is vague and does not describe the actual RBAC/reporting changes in the PR. Use a concise title that names the main change, such as the reporting RBAC permission updates and test additions.
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch combined-test/rbacrep

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.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@central/reports/service/v2/service_impl.go`:
- Around line 67-70: RunReport and DeleteReport are too broadly authorized under
the View Image + View Deployment rule in the service authorizer. Update the
authorization mapping in ReportServiceImpl so both RPCs remain behind
WorkflowAdministration, and handle any user-owned delete allowance with a
method-level ownership check inside DeleteReport rather than weakening the
coarse RPC-level permissions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 027cdd7a-e090-4756-b800-a11d50d7a3f1

📥 Commits

Reviewing files that changed from the base of the PR and between b5a7f65 and c3af46b.

📒 Files selected for processing (10)
  • central/main.go
  • central/reports/service/v2/service_impl.go
  • central/reports/service/v2/service_impl_test.go
  • ui/apps/platform/src/Containers/MainPage/Body.tsx
  • ui/apps/platform/src/Containers/Vulnerabilities/VulnerablityReporting/VulnReportingPage.tsx
  • ui/apps/platform/src/Containers/Vulnerabilities/VulnerablityReporting/VulnReports/VulnReportingLayout.tsx
  • ui/apps/platform/src/Containers/Vulnerabilities/WorkloadCves/Deployment/DeploymentPage.tsx
  • ui/apps/platform/src/Containers/Vulnerabilities/WorkloadCves/Image/ImagePage.tsx
  • ui/apps/platform/src/Containers/Vulnerabilities/WorkloadCves/Overview/WorkloadCvesOverviewPage.tsx
  • ui/apps/platform/src/routePaths.ts

Comment on lines +67 to 70
// view permissions are enough if user is deleting a job created by the user
user.With(permissions.View(resources.Image), permissions.View(resources.Deployment)): {
apiV2.ReportService_RunReport_FullMethodName,
apiV2.ReportService_CancelReport_FullMethodName,
apiV2.ReportService_DeleteReport_FullMethodName,

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.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Keep collection report lifecycle methods behind WorkflowAdministration.

RunReport and DeleteReport are currently grouped under View Image + View Deployment, but the new auth tests expect both to reject viewImageDeployment without WorkflowAdministration. This also over-broadens collection report actions; if user-owned deletion should be allowed, add that as a method-level ownership check instead of lowering the coarse RPC authorizer.

Suggested authorization alignment
-		// view permissions are enough if user is deleting a job created by the user
-		user.With(permissions.View(resources.Image), permissions.View(resources.Deployment)): {
+		user.With(permissions.Modify(resources.WorkflowAdministration), permissions.View(resources.Image), permissions.View(resources.Deployment)): {
 			apiV2.ReportService_RunReport_FullMethodName,
 			apiV2.ReportService_DeleteReport_FullMethodName,
 		},
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// view permissions are enough if user is deleting a job created by the user
user.With(permissions.View(resources.Image), permissions.View(resources.Deployment)): {
apiV2.ReportService_RunReport_FullMethodName,
apiV2.ReportService_CancelReport_FullMethodName,
apiV2.ReportService_DeleteReport_FullMethodName,
// view permissions are enough if user is deleting a job created by the user
user.With(permissions.Modify(resources.WorkflowAdministration), permissions.View(resources.Image), permissions.View(resources.Deployment)): {
apiV2.ReportService_RunReport_FullMethodName,
apiV2.ReportService_DeleteReport_FullMethodName,
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@central/reports/service/v2/service_impl.go` around lines 67 - 70, RunReport
and DeleteReport are too broadly authorized under the View Image + View
Deployment rule in the service authorizer. Update the authorization mapping in
ReportServiceImpl so both RPCs remain behind WorkflowAdministration, and handle
any user-owned delete allowance with a method-level ownership check inside
DeleteReport rather than weakening the coarse RPC-level permissions.

@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

🚀 Build Images Ready

Images are ready for commit 1734777. To use with deploy scripts:

export MAIN_IMAGE_TAG=4.12.x-316-g1734777b9c

@ksurabhi91 ksurabhi91 force-pushed the combined-test/rbacrep branch from 8aedf7f to 1734777 Compare June 26, 2026 04:42

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@central/reports/scheduler/v2/scheduler_impl.go`:
- Around line 563-570: The context elevation added for view-based report
persistence is only applied in the insert path, while the resubmission path
still uses the original ctx when calling UpdateReportSnapshot. Update the
reSubmission branch in scheduler_impl.go to use the same conditional
sac.WithAllAccess(ctx) logic based on snapshot.GetViewBasedVulnReportFilters(),
so both AddReportSnapshot and UpdateReportSnapshot run with the privileged
context for view-based reports.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: bd08e4d6-296b-48c5-bc7c-f224bc8cb335

📥 Commits

Reviewing files that changed from the base of the PR and between 8aedf7f and 1734777.

📒 Files selected for processing (2)
  • central/reports/scheduler/v2/scheduler_impl.go
  • ui/apps/platform/src/routePaths.ts
💤 Files with no reviewable changes (1)
  • ui/apps/platform/src/routePaths.ts

Comment on lines +563 to +570

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.

🎯 Functional Correctness | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify whether view-based report snapshots can reach validateAndPersistSnapshot with reSubmission=true.
# Expectation: no call path combines ViewBasedVulnReportFilters with reSubmission=true under a user ctx
# lacking WorkflowAdministration write, or the update branch should also use the privileged persist context.

rg -n -C4 '\bvalidateAndPersistSnapshot\s*\(' central/reports central/main.go
rg -n -C6 'reSubmission|resubmission|ViewBasedVulnReportFilters|VIEW_BASED|PostViewBasedReport' central/reports central/main.go

Repository: stackrox/stackrox

Length of output: 43484


Ensure context elevation applies to the resubmission (update) path.

The fix correctly elevates context for the initial insert of view-based reports, but the reSubmission=true branch at line 572 still calls UpdateReportSnapshot(ctx, snapshot) using the non-elevated user context. Since UpdateReportSnapshot enforces the same WorkflowAdministration write gate as AddReportSnapshot, any future scenario where a view-based report is resubmitted will fail at the datastore layer.

Apply the same conditional context elevation logic to the resubmission block:

	} else {
-		snapshot.ReportId, err = s.reportSnapshotStore.UpdateReportSnapshot(ctx, snapshot)
+		persistCtx := ctx
+		if snapshot.GetViewBasedVulnReportFilters() != nil {
+			persistCtx = sac.WithAllAccess(ctx)
+		}
+		snapshot.ReportId, err = s.reportSnapshotStore.UpdateReportSnapshot(persistCtx, snapshot)
	}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@central/reports/scheduler/v2/scheduler_impl.go` around lines 563 - 570, The
context elevation added for view-based report persistence is only applied in the
insert path, while the resubmission path still uses the original ctx when
calling UpdateReportSnapshot. Update the reSubmission branch in
scheduler_impl.go to use the same conditional sac.WithAllAccess(ctx) logic based
on snapshot.GetViewBasedVulnReportFilters(), so both AddReportSnapshot and
UpdateReportSnapshot run with the privileged context for view-based reports.

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.

1 participant