summaryrefslogtreecommitdiff
path: root/lib/container_registry
diff options
context:
space:
mode:
authorGiorgenes Gelatti <ggelatti@gitlab.com>2019-07-23 19:57:28 +1000
committerNathan Friend <nathan@gitlab.com>2019-07-30 13:49:48 -0300
commitc2d1fbe507cc1732927ca7c656078cf47754ceeb (patch)
tree5675a04d4ca55c51d71f6f9334fa9740e5d445ae /lib/container_registry
parent786133d31434d1dbb185b2c0ff5eee663f5841d5 (diff)
downloadgitlab-ce-c2d1fbe507cc1732927ca7c656078cf47754ceeb.tar.gz
Validates tag names and tags#bulk_destroy
Diffstat (limited to 'lib/container_registry')
-rw-r--r--lib/container_registry/tag.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/container_registry/tag.rb b/lib/container_registry/tag.rb
index ef41dc560c9..ebea84fa1ca 100644
--- a/lib/container_registry/tag.rb
+++ b/lib/container_registry/tag.rb
@@ -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