Skip to content
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

[WIP] Removing deleted Custom Buttons #370

Closed
wants to merge 1 commit into from

Conversation

romanblanco
Copy link
Member

@romanblanco romanblanco commented May 14, 2019

After ManageIQ/manageiq#18368 the purpose of set_data[:button_order]
has been changed, and an error is raised after going through an array,
where the button does not exist anymore

TODO:

before merging, this needs to

  • update two forms
    1. (Automation -> Automate -> Generic Object) -> Add a new Button
    2. (Automation -> Automate -> Customization -> Buttons) -> Add a new Button
  • add a hook to remove id from CustomButtonSet every time CustomButton is removed

cc/ @lpichler @himdel

@miq-bot miq-bot added the wip label May 14, 2019
@romanblanco romanblanco force-pushed the custom_button_set branch 2 times, most recently from 4ed36af to 9610d43 Compare May 14, 2019 12:54
next if cbs.set_data[:button_order].blank?
existing_buttons = CustomButton
.where(:id => cbs.set_data[:button_order])
.order("position(id::text in '#{cbs.set_data[:button_order].join(',')}')")
Copy link
Contributor

@himdel himdel May 21, 2019

Choose a reason for hiding this comment

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

Ugh, that looks like an SQL injection.
We can believe button_order only contains ints, but unless we check it, this is dangerous.

Why not sort it in ruby?

Copy link
Member Author

Choose a reason for hiding this comment

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

@lpichler as you've corrected me not to use Ruby sort, is there a good reason not to use the Ruby sort?

Copy link
Contributor

@lpichler lpichler Jun 7, 2019

Choose a reason for hiding this comment

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

I am not against ruby solution but I knew that we are using implementation in SQL

https://github.com/ManageIQ/manageiq/pull/18060/files#diff-72d768ae2e73b9e77080d4a7df59cf56R4

so you can copy with_array_order here or use ruby.

@@ -0,0 +1,21 @@
class UpdateCustomButtonSets < ActiveRecord::Migration[5.2]
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be [5.0] as manageiq doesn't support 5.2 yet.

We're going to move this repo back to 5.0 to avoid this until then.

Copy link
Member Author

Choose a reason for hiding this comment

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

@carbonin corrected. Thank you 👍

after manageiq/pull/18368 the purpose of `set_data[:button_order]`
has been changed, and an error is raised after going through an array,
where the button does not exist anymore
@miq-bot
Copy link
Member

miq-bot commented Jun 3, 2019

Checked commit romanblanco@f5a99d5 with ruby 2.3.3, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 6 offenses detected

db/migrate/20190509142148_update_custom_button_sets.rb

spec/migrations/20190509142148_update_custom_button_sets_spec.rb

@himdel
Copy link
Contributor

himdel commented Dec 3, 2019

It may be too late for a migration as this change has made it to hammer.

To fix https://bugzilla.redhat.com/show_bug.cgi?id=1770300, I think we'll need to change the validation to skip missing buttons instead of throwing.

So, I think we can close this one..

@h-kataria
Copy link
Contributor

@himdel ManageIQ/manageiq#19573 is merged, should we close this?

@himdel
Copy link
Contributor

himdel commented Dec 10, 2019

Indeed, there will be one more core PR to make sure service UI and the automate buttons tree is right too, but we can close this one.

@miq-bot close_issue

@miq-bot
Copy link
Member

miq-bot commented Dec 10, 2019

@himdel Only @romanblanco or a committer can close this pull request.

@romanblanco romanblanco deleted the custom_button_set branch December 16, 2019 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants