Class: Dependabot::Composer::ComposerErrorHandler
- Inherits:
-
Object
- Object
- Dependabot::Composer::ComposerErrorHandler
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/composer/update_checker/version_resolver.rb
Constant Summary collapse
- CURL_ERROR =
Private source errors
T.let(/curl error 52 while downloading (?<url>.*): Empty reply from server/, Regexp)
- PRIVATE_SOURCE_AUTH_FAIL =
T.let( [ /Could not authenticate against (?<url>.*)/, /The '(?<url>.*)' URL could not be accessed \(HTTP 403\)/, /The "(?<url>.*)" file could not be downloaded/ ].freeze, T::Array[Regexp] )
- REQUIREMENT_ERROR =
T.let(/^(?<req>.*) is invalid, it should not contain uppercase characters/, Regexp)
- NO_URL =
T.let("No URL specified", String)
Instance Method Summary collapse
Instance Method Details
#handle_composer_error(error) ⇒ Object
668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 |
# File 'lib/dependabot/composer/update_checker/version_resolver.rb', line 668 def handle_composer_error(error) # private source auth errors PRIVATE_SOURCE_AUTH_FAIL.each do |regex| next unless error..match?(regex) url = T.must(error..match(regex)).named_captures["url"] sanitized_url = sanitize_uri(T.must(url)) raise Dependabot::PrivateSourceAuthenticationFailure, sanitized_url.empty? ? NO_URL : sanitized_url end # invalid requirement mentioned in manifest file if error..match?(REQUIREMENT_ERROR) raise DependencyFileNotResolvable, "Invalid requirement: #{T.must(error.message.match(REQUIREMENT_ERROR)).named_captures['req']}" end return unless error..match?(CURL_ERROR) url = T.must(error..match(CURL_ERROR)).named_captures["url"] raise PrivateSourceBadResponse, T.must(url) end |
#sanitize_uri(url) ⇒ Object
659 660 661 662 663 664 |
# File 'lib/dependabot/composer/update_checker/version_resolver.rb', line 659 def sanitize_uri(url) url = "http://#{url}" unless url.start_with?("http") uri = URI.parse(url) host = T.must(uri.host).downcase host.start_with?("www.") ? T.must(host[4..-1]) : host end |