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

Fixes #38076 - Sanitize content_view repository_ids param #11253

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/controllers/katello/api/v2/content_views_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,10 @@ def view_params
if (!@content_view || !@content_view.composite?)
attrs.push({:repository_ids => []}, :repository_ids)
end
params.require(:content_view).permit(*attrs).to_h
result = params.require(:content_view).permit(*attrs).to_h
# sanitize repository_ids to be a list of integers
result[:repository_ids] = result[:repository_ids].map(&:to_i) if result[:repository_ids].present?
result
end

def find_environment
Expand Down
4 changes: 2 additions & 2 deletions test/controllers/api/v2/content_views_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ def test_update_repositories_strings

params = { :repository_ids => [repository.id.to_s] }
assert_sync_task(::Actions::Katello::ContentView::Update) do |_content_view, content_view_params|
assert_equal content_view_params.key?(:repository_ids), true
assert_equal content_view_params[:repository_ids], params[:repository_ids]
assert content_view_params.key?(:repository_ids)
assert_equal [repository.id], content_view_params[:repository_ids]
end
put :update, params: { :id => @library_dev_staging_view.id, :content_view => params }

Expand Down
Loading