gitlab-org--gitlab-foss/app/validators/importable_url_validator.rb
Douwe Maan 65aafb9917 Merge branch 'ssrf' into 'security'
Protect server against SSRF in project import URLs

See merge request !2068
2017-03-20 18:53:04 -07:00

11 lines
399 B
Ruby

# 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)
if Gitlab::UrlBlocker.blocked_url?(value)
record.errors.add(attribute, "imports are not allowed from that URL")
end
end
end