summaryrefslogtreecommitdiff
path: root/app/validators
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2018-03-28 19:27:16 +0200
committerDouwe Maan <douwe@selenight.nl>2018-04-02 17:20:01 +0200
commit2e3bc6a9415688d769134ee669fd457d63f497f8 (patch)
tree2f92ef930bbf16b90e01920cc22d78003e39f7cf /app/validators
parent6b5ec93ad9e3a55ae0cba4fb677c2a6cff04cd70 (diff)
downloadgitlab-ce-2e3bc6a9415688d769134ee669fd457d63f497f8.tar.gz
Raise more descriptive errors when URLs are blocked
Diffstat (limited to 'app/validators')
-rw-r--r--app/validators/importable_url_validator.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/app/validators/importable_url_validator.rb b/app/validators/importable_url_validator.rb
index 3ec1594e202..cafb43e69a2 100644
--- a/app/validators/importable_url_validator.rb
+++ b/app/validators/importable_url_validator.rb
@@ -4,8 +4,10 @@
# protect against Server-side Request Forgery (SSRF).
class ImportableUrlValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
- if Gitlab::UrlBlocker.blocked_url?(value, valid_ports: Project::VALID_IMPORT_PORTS)
- record.errors.add(attribute, "imports are not allowed from that URL")
+ begin
+ Gitlab::UrlBlocker.validate!(value, valid_ports: Project::VALID_IMPORT_PORTS)
+ rescue Gitlab::UrlBlocker::BlockedUrlError => e
+ record.errors.add(attribute, "is blocked: #{e.message}")
end
end
end