class Dependabot::GitMetadataFetcher
def uri_with_auth(uri)
def uri_with_auth(uri) uri = SharedHelpers.scp_to_standard(uri) uri = URI(uri) cred = credentials.select { |c| c["type"] == "git_source" } .find { |c| uri.host == c["host"] } uri.scheme = "https" if uri.scheme != "http" if !uri.password && cred&.fetch("username", nil) && cred.fetch("password", nil) # URI doesn't have authentication details, but we have credentials uri.user = URI.encode_www_form_component(cred["username"]) uri.password = URI.encode_www_form_component(cred["password"]) end uri.to_s end