Welcome to mirror list, hosted at ThFree Co, Russian Federation.

importable_url_validator.rb « validators « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3ec1594e20217aacc01e31d3209478cc098f7ed5 (plain)
1
2
3
4
5
6
7
8
9
10
11
# 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, valid_ports: Project::VALID_IMPORT_PORTS)
      record.errors.add(attribute, "imports are not allowed from that URL")
    end
  end
end