Commit c2d1fbe5 authored by Giorgenes Gelatti's avatar Giorgenes Gelatti Committed by Nathan Friend

Validates tag names and tags#bulk_destroy

parent 786133d3
......@@ -29,7 +29,16 @@ module Projects
end
def bulk_destroy
unless params[:ids].present?
head :bad_request
return
end
@tags = (params[:ids] || []).map { |tag_name| image.tag(tag_name) }
unless @tags.all? { |tag| tag.valid_name? }
head :bad_request
return
end
success_count = 0
@tags.each do |tag|
......
......@@ -6,6 +6,9 @@ module ContainerRegistry
attr_reader :repository, :name
# https://github.com/docker/distribution/commit/3150937b9f2b1b5b096b2634d0e7c44d4a0f89fb
TAG_NAME_REGEX = /^[\w][\w.-]{0,127}$/.freeze
delegate :registry, :client, to: :repository
delegate :revision, :short_revision, to: :config_blob, allow_nil: true
......@@ -13,6 +16,10 @@ module ContainerRegistry
@repository, @name = repository, name
end
def valid_name?
!name.match(TAG_NAME_REGEX).nil?
end
def valid?
manifest.present?
end
......
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