-
Notifications
You must be signed in to change notification settings - Fork 50
Add Vulnerability and Advisor permissions for Insights apps #1135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Reviewer's GuideAdds four new Insights application permissions (Vulnerability and Advisor view/edit) to the Foreman RH Cloud plugin and includes them in the ForemanRhCloud role, setting the stage for finer-grained access control to Insights apps. Class diagram for ForemanRhCloud plugin permissions including new Insights app permissionsclassDiagram
class ForemanRhCloudPlugin {
+register()
}
class Permission {
+symbol
+resource_type
}
class Role {
+name
+permissions
}
class ForemanRhCloudPermissions {
+view_foreman_rh_cloud
+generate_foreman_rh_cloud
+view_insights_hits
+dispatch_cloud_requests
+control_organization_insights
}
class InsightsAppPermissions {
+view_vulnerability
+edit_vulnerability
+view_advisor
+edit_advisor
}
ForemanRhCloudPlugin "1" --> "*" Permission : defines
Role "1" --> "*" Permission : includes
ForemanRhCloudPermissions <|-- InsightsAppPermissions
Role --> ForemanRhCloudPermissions
Role --> InsightsAppPermissions
Flow diagram for adding new Vulnerability and Advisor permissions to ForemanRhCloud roleflowchart TD
A["ForemanRhCloudPlugin register"] --> B["Define existing core permissions
view_foreman_rh_cloud
generate_foreman_rh_cloud
view_insights_hits
dispatch_cloud_requests
control_organization_insights"]
B --> C["Define new Insights app permissions
view_vulnerability
edit_vulnerability
view_advisor
edit_advisor
resource_type = ForemanRhCloud"]
C --> D["Assemble plugin_permissions array
(core + new permissions)"]
D --> E["Create/extend ForemanRhCloud role
with plugin_permissions"]
E --> F["ForemanRhCloud role used by admin roles
ORG_ADMIN, MANAGER, SYSTEM_ADMIN"]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've found 1 issue, and left some high level feedback:
- The new insights permissions are all added under
ForemanRhCloudwithout reflecting the described grouping (e.g.,rh_cloud_permissionsvsinsights_permissions), which might be clearer and easier to maintain if expressed as separate arrays/constants composed intoplugin_permissions. - The
ForemanRhCloudrole description still only mentions inventory and report-related capabilities; consider updating the description to reflect the newly granted Vulnerability and Advisor permissions so the role’s behavior matches its documented intent.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new insights permissions are all added under `ForemanRhCloud` without reflecting the described grouping (e.g., `rh_cloud_permissions` vs `insights_permissions`), which might be clearer and easier to maintain if expressed as separate arrays/constants composed into `plugin_permissions`.
- The `ForemanRhCloud` role description still only mentions inventory and report-related capabilities; consider updating the description to reflect the newly granted Vulnerability and Advisor permissions so the role’s behavior matches its documented intent.
## Individual Comments
### Comment 1
<location> `lib/foreman_rh_cloud/plugin.rb:100-101` </location>
<code_context>
- plugin_permissions = [:view_foreman_rh_cloud, :generate_foreman_rh_cloud, :view_insights_hits, :dispatch_cloud_requests, :control_organization_insights]
+ plugin_permissions = [:view_foreman_rh_cloud, :generate_foreman_rh_cloud, :view_insights_hits, :dispatch_cloud_requests, :control_organization_insights, :view_vulnerability, :edit_vulnerability, :view_advisor, :edit_advisor]
role 'ForemanRhCloud', plugin_permissions, 'Role granting permissions to view the hosts inventory,
generate a report, upload it to the cloud and download it locally'
</code_context>
<issue_to_address>
**suggestion:** Update the role description to reflect the new Advisor and Vulnerability permissions.
Since this role now grants `view/edit_vulnerability` and `view/edit_advisor`, the description should also mention the Insights Vulnerability and Advisor access it provides so admins can understand its full scope.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| role 'ForemanRhCloud', plugin_permissions, 'Role granting permissions to view the hosts inventory, | ||
| generate a report, upload it to the cloud and download it locally' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Update the role description to reflect the new Advisor and Vulnerability permissions.
Since this role now grants view/edit_vulnerability and view/edit_advisor, the description should also mention the Insights Vulnerability and Advisor access it provides so admins can understand its full scope.
What are the changes introduced in this pull request?
Add Insights application permissions for Vulnerability and Advisor
Introduce new Foreman permissions to control access to Insights
applications (Vulnerability and Advisor). These permissions map to
Insights Chrome API permissions for frontend access control.
New permissions added:
Permissions are organized into two groups for clarity:
All permissions are included in the ForemanRhCloud role and added to
default admin roles (ORG_ADMIN, MANAGER, SYSTEM_ADMIN).
Considerations taken when implementing this change?
This is Part 1 of a 3-part PR series. The new permissions should be applied in
SCOPED_REQUESTSwithinapp/services/foreman_rh_cloud/insights_api_forwarder.rb.What are the testing steps for this pull request?
This PR should be tested in conjunction with the other related PRs. For now, ensure that:
Summary by Sourcery
Add new role-based permissions for controlling access to Insights Vulnerability and Advisor features and include them in the ForemanRhCloud role.
New Features:
Enhancements: