Commit f3de7855 authored by Giorgenes Gelatti's avatar Giorgenes Gelatti

Limit registry tag bulk delete to 15 items

parent 128a04ef
...@@ -5,6 +5,8 @@ module Projects ...@@ -5,6 +5,8 @@ module Projects
class TagsController < ::Projects::Registry::ApplicationController class TagsController < ::Projects::Registry::ApplicationController
before_action :authorize_destroy_container_image!, only: [:destroy] before_action :authorize_destroy_container_image!, only: [:destroy]
LIMIT = 15
def index def index
respond_to do |format| respond_to do |format|
format.json do format.json do
...@@ -34,7 +36,13 @@ module Projects ...@@ -34,7 +36,13 @@ module Projects
return return
end end
@tags = (params[:ids] || []).map { |tag_name| image.tag(tag_name) } tag_names = params[:ids] || []
if tag_names.size > LIMIT
head :bad_request
return
end
@tags = tag_names.map { |tag_name| image.tag(tag_name) }
unless @tags.all? { |tag| tag.valid_name? } unless @tags.all? { |tag| tag.valid_name? }
head :bad_request head :bad_request
return return
...@@ -55,7 +63,7 @@ module Projects ...@@ -55,7 +63,7 @@ module Projects
private private
def tags def tags
Kaminari::PaginatableArray.new(image.tags, limit: 15) Kaminari::PaginatableArray.new(image.tags, limit: LIMIT)
end end
def image def image
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment