Class: HttpClient
- Inherits:
-
Object
- Object
- HttpClient
- Defined in:
- lib/scopes_extractor/http_client.rb
Overview
HttpClient Class
Class Method Summary collapse
- .get(url, authentication = nil) ⇒ Object
- .headers(url, authentication) ⇒ Object
- .post(url, data) ⇒ Object
- .request_options ⇒ Object
Class Method Details
.get(url, authentication = nil) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/scopes_extractor/http_client.rb', line 27 def self.get(url, authentication = nil) = [:headers] = headers(url, authentication) Typhoeus.get(url, ) end |
.headers(url, authentication) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/scopes_extractor/http_client.rb', line 12 def self.headers(url, authentication) if url.include?('yeswehack') { 'Content-Type' => 'application/json', Authorization: "Bearer #{authentication}" } elsif url.include?('intigriti') { Authorization: "Bearer #{authentication}" } elsif url.include?('bugcrowd') { 'Cookie' => authentication } elsif url.include?('hackerone') h1_credz = Base64.urlsafe_encode64("#{ENV.fetch('H1_USERNAME', nil)}:#{ENV.fetch('H1_API_KEY', nil)}") { 'Accept' => 'application/json', 'Authorization' => "Basic #{h1_credz}" } else { 'Content-Type' => 'application/json' } end end |
.post(url, data) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/scopes_extractor/http_client.rb', line 34 def self.post(url, data) = [:headers] = { 'Content-Type' => 'application/json' } [:body] = data Typhoeus.post(url, ) end |
.request_options ⇒ Object
5 6 7 8 9 10 |
# File 'lib/scopes_extractor/http_client.rb', line 5 def self. { ssl_verifypeer: false, ssl_verifyhost: 0 } end |