-
Notifications
You must be signed in to change notification settings - Fork 356
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
Check selected Service Catalog Item for RBAC #779
Check selected Service Catalog Item for RBAC #779
Conversation
@sb[:cached_waypoint_ids] = MiqAeClass.waypoint_ids_for_state_machines | ||
checked[0] = params[:id] if checked.blank? && params[:id] | ||
@record = checked[0] ? find_by_id_filtered(ServiceTemplate, checked[0]) : ServiceTemplate.new | ||
@record = checked_id || ServiceTemplate.new |
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.
- @record = checked[0] ? find_by_id_filtered(ServiceTemplate, checked[0]) : ServiceTemplate.new
this was right
assert_privileges(params[:pressed]) if params[:pressed] | ||
checked = find_checked_items | ||
assert_privileges(params[:pressed]) if params[:pressed].present? | ||
checked_id = find_checked_id_items_with_rbac(ServiceTemplate).first || test_item_with_rbac(ServiceTemplate, params[:id]) |
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.
this check is not needed here.
2976866
to
a10efa1
Compare
@PanSpagetka thanks for the review 👍 @martinpovolny after my changes I've realised, this method was not problematic, but anyway, I think we could use the changes, after I took back what was wrong. I've introduced a method |
69a8ae0
to
d38bf8b
Compare
# Params: | ||
# klass - class of accessed object | ||
# id - accessed object id | ||
def find_by_id_filtered(klass, id, options = {}) |
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.
I'd like to change this methods name to find_item_with_rbac
:
-
to stop getting comments like
" ❗️ - Line 64, Col 37 - Rails/DynamicFindBy - Use find_by instead of dynamic find_by_id_filtered."
-
to have similar name as
find_checked_items_with_rbac
, that does the same, except for 2 or more items
any ideas before I do the change? @martinpovolny @PanSpagetka
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.
I aggree. It's good to rename the method so that Brakeman does not get confused.
d38bf8b
to
3701f4b
Compare
method: servicetemplate_edit reproduce: Services -> Catalogs -> Catalog Item -> Select Service Catalog Items -> (Edit Selected Item / Add a New Catalog Item / Add a New Catalog Bundle)
82a0212
to
3607a01
Compare
@romanblanco : please, fix the failing spec, otherwise looks good 👍 |
Also I have removed unnecessary parameter for 'assert_rbac'. It's not necessary to pass user in the argument when the method is always used used with current user
There is already a method that can be used for the same as the one I've introduced.
…h_rbac' - to stop getting comments like: " ❗️ - Line 64, Col 37 - Rails/DynamicFindBy - Use find_by instead of dynamic find_by_id_filtered." - to have similar name as 'find_checked_items_with_rbac' (that is still not expressive enough), that does the same, except for 2 or more items
Added again as it turns out the method is at least temporarily needed.
Renamed 'find_checked_items_with_rbac' to 'find_checked_ids_with_rbac' that should be more clear
Problem was that 'find' method raises ActiveRecord::RecordNotFound if id is not found, while 'find_by' returns nil. I'll leave the spec correction and 'find_by' replacing for a different PR
3607a01
to
5064aaf
Compare
@martinpovolny fixed. |
Please, unify the error messages for the 2 cases so that we do not leak any info to an unauthorized user. |
@martinpovolny updated |
c670110
to
6faf046
Compare
6faf046
to
59def9c
Compare
Checked commits romanblanco/manageiq-ui-classic@19d9369~...59def9c with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 app/controllers/application_controller.rb
app/controllers/catalog_controller.rb
app/controllers/host_controller.rb
app/controllers/report_controller/reports/editor.rb
app/controllers/vm_common.rb
|
…late_edit Check selected Service Catalog Item for RBAC (cherry picked from commit 37c1d94)
Fine backport details:
|
to go with #857 |
method: servicetemplate_edit
reproduce: Services -> Catalogs -> Catalog Item -> Select Service Catalog Items -> (Edit Selected Item / Add a New Catalog Item / Add a New Catalog Bundle)