summaryrefslogtreecommitdiff
path: root/app/uploaders
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-02 18:02:43 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-02 18:02:43 +0000
commit04185eb6a5b28523c4b5b3a030f90d7ae20497de (patch)
treedaee46919114155d7dc9ca8f4f8c413677e2d2c9 /app/uploaders
parent691e57b53a551619cf55317124aa1c8ec9dd819a (diff)
downloadgitlab-ce-04185eb6a5b28523c4b5b3a030f90d7ae20497de.tar.gz
Add latest changes from gitlab-org/security/gitlab@12-7-stable-ee
Diffstat (limited to 'app/uploaders')
-rw-r--r--app/uploaders/file_uploader.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/app/uploaders/file_uploader.rb b/app/uploaders/file_uploader.rb
index b326b266017..12396a0e302 100644
--- a/app/uploaders/file_uploader.rb
+++ b/app/uploaders/file_uploader.rb
@@ -16,6 +16,9 @@ class FileUploader < GitlabUploader
MARKDOWN_PATTERN = %r{\!?\[.*?\]\(/uploads/(?<secret>[0-9a-f]{32})/(?<file>.*?)\)}.freeze
DYNAMIC_PATH_PATTERN = %r{.*(?<secret>\h{32})/(?<identifier>.*)}.freeze
+ VALID_SECRET_PATTERN = %r{\A\h{10,32}\z}.freeze
+
+ InvalidSecret = Class.new(StandardError)
after :remove, :prune_store_dir
@@ -153,6 +156,10 @@ class FileUploader < GitlabUploader
def secret
@secret ||= self.class.generate_secret
+
+ raise InvalidSecret unless @secret =~ VALID_SECRET_PATTERN
+
+ @secret
end
# return a new uploader with a file copy on another project