lib/saml_parser/fetch_xml.rb
def fetch_xml_page
    response = SsrfFilter.get(metadata_url,
      headers: DEFAULT_HEADERS,
      max_redirects: MAX_REDIRECTS,
      http_options: {
        open_timeout: 2,
        read_timeout: 5
      })

    if response.code.to_i != SUCCESS_RESPONSE
      handle_error(ErrorMessages::MESSAGE_MAPPINGS[:unsuccessful_response_code], response.message)
      return errors
    end

    response.body
  rescue Net::OpenTimeout, Net::ReadTimeout => e
    handle_error(ErrorMessages::MESSAGE_MAPPINGS[:http_timeout], error: e.message)
  rescue URI::InvalidURIError,
         SsrfFilter::InvalidUriScheme,
         SsrfFilter::PrivateIPAddress,
         SsrfFilter::Error,
         SsrfFilter::UnresolvedHostname,
         SsrfFilter::TooManyRedirects,
         SsrfFilter::CRLFInjection => e
    handle_error(ErrorMessages::MESSAGE_MAPPINGS[:http_error], error: e.message)
  end
# Handles the request. Using SsrfFilter to avoid Ssrf attacks
# @return [String] the resulting XML document body
Handles the request. Using SsrfFilter to avoid Ssrf attacks
Handles the request . Using SsrfFilter to avoid Ssrf attacks
def fetch_xml_page
    response = SsrfFilter.get(metadata_url,
      headers: DEFAULT_HEADERS,
      max_redirects: MAX_REDIRECTS,
      http_options: {
        open_timeout: 2,
        read_timeout: 5
      })
    if response.code.to_i != SUCCESS_RESPONSE
      handle_error(ErrorMessages::MESSAGE_MAPPINGS[:unsuccessful_response_code], response.message)
      return errors
    end
    response.body
  rescue Net::OpenTimeout, Net::ReadTimeout => e
    handle_error(ErrorMessages::MESSAGE_MAPPINGS[:http_timeout], error: e.message)
  rescue URI::InvalidURIError,
         SsrfFilter::InvalidUriScheme,
         SsrfFilter::PrivateIPAddress,
         SsrfFilter::Error,
         SsrfFilter::UnresolvedHostname,
         SsrfFilter::TooManyRedirects,
         SsrfFilter::CRLFInjection => e
    handle_error(ErrorMessages::MESSAGE_MAPPINGS[:http_error], error: e.message)
  end
def fetch_xml_page response = SsrfFilter . get ( metadata_url , headers : DEFAULT_HEADERS , max_redirects : MAX_REDIRECTS , http_options : { open_timeout : 2 , read_timeout : 5 } ) if response . code . to_i != SUCCESS_RESPONSE handle_error ( ErrorMessages :: MESSAGE_MAPPINGS [ :unsuccessful_response_code ] , response . message ) return errors end response . body rescue Net :: OpenTimeout , Net :: ReadTimeout => e handle_error ( ErrorMessages :: MESSAGE_MAPPINGS [ :http_timeout ] , error : e . message ) rescue URI :: InvalidURIError , SsrfFilter :: InvalidUriScheme , SsrfFilter :: PrivateIPAddress , SsrfFilter :: Error , SsrfFilter :: UnresolvedHostname , SsrfFilter :: TooManyRedirects , SsrfFilter :: CRLFInjection => e handle_error ( ErrorMessages :: MESSAGE_MAPPINGS [ :http_error ] , error : e . message ) end
Handles the request.
Handles the request .
the resulting XML document body
the resulting XML document body
String