2017-03-15 16:09:08 -04:00
|
|
|
# ImportableUrlValidator
|
|
|
|
#
|
|
|
|
# This validator blocks projects from using dangerous import_urls to help
|
|
|
|
# protect against Server-side Request Forgery (SSRF).
|
|
|
|
class ImportableUrlValidator < ActiveModel::EachValidator
|
|
|
|
def validate_each(record, attribute, value)
|
2018-03-13 18:38:25 -04:00
|
|
|
if Gitlab::UrlBlocker.blocked_url?(value, valid_ports: Project::VALID_IMPORT_PORTS)
|
2017-03-15 16:09:08 -04:00
|
|
|
record.errors.add(attribute, "imports are not allowed from that URL")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|