scopes_extractor 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2720124a1d479958f99a1e40d303f5a8fa1fb45727b7c575197561522245cd3f
4
- data.tar.gz: bc579dc76168344ac983876d54db4b55977099e6488fbe26a0971bf85488af35
3
+ metadata.gz: 9213285da286cb2ad488374dc8e5971d34bb06987b710c2bbd4dcac12f3d1384
4
+ data.tar.gz: af84cd2c4e8e8a43ccb40f126bc1996e812bf66b828e2a3b4aea6bd5dcba9531
5
5
  SHA512:
6
- metadata.gz: 9b5387a228e502be7cd36c5ea4e67151ece0a046406931619c159c17d4345069b0885b5de27683a63190b5ac0a108023dc7524e406e836179eb12cf820c6be41
7
- data.tar.gz: 784560b6ed8def4699d7c3e03a34ee02ef5db707183acc7d702e3c058cf0bb0df0c38ceca648609f24cb79941d10dd78bc1f64b8dd4583098bef70dcb19c6f78
6
+ metadata.gz: 20bbb233618c27774be21ab80ac56e8e9ac2b6e749922bdb1768c634b30f7b7b04f23e622f0a958ddc257e6ed5ef1239fb94aec973eafbfe0c20c3300c831d60
7
+ data.tar.gz: 5612a5f74b44fd9904e0f7b3ba22218104ee68e36ca27b15dbcaf8f437e22e74f680f997a832d64ddf0580f4f0d8421baac3532aee8537a8c587f48c45bf7369
@@ -2,10 +2,12 @@
2
2
 
3
3
  # HttpClient Class
4
4
  class HttpClient
5
- @request_options = {
6
- ssl_verifypeer: false,
7
- ssl_verifyhost: 0
8
- }
5
+ def self.request_options
6
+ {
7
+ ssl_verifypeer: false,
8
+ ssl_verifyhost: 0
9
+ }
10
+ end
9
11
 
10
12
  def self.headers(url, authentication)
11
13
  if url.include?('yeswehack')
@@ -15,23 +17,25 @@ class HttpClient
15
17
  elsif url.include?('bugcrowd')
16
18
  { 'Cookie' => authentication }
17
19
  elsif url.include?('hackerone')
18
- @request_options[:userpwd] = "#{ENV.fetch('H1_USERNAME', nil)}:#{ENV.fetch('H1_API_KEY', nil)}"
19
- { 'Accept' => 'application/json' }
20
+ h1_credz = Base64.urlsafe_encode64("#{ENV.fetch('H1_USERNAME', nil)}:#{ENV.fetch('H1_API_KEY', nil)}")
21
+ { 'Accept' => 'application/json', 'Authorization' => "Basic #{h1_credz}" }
20
22
  else
21
23
  { 'Content-Type' => 'application/json' }
22
24
  end
23
25
  end
24
26
 
25
27
  def self.get(url, authentication = nil)
26
- @request_options[:headers] = headers(url, authentication)
28
+ options = request_options
29
+ options[:headers] = headers(url, authentication)
27
30
 
28
- Typhoeus.get(url, @request_options)
31
+ Typhoeus.get(url, options)
29
32
  end
30
33
 
31
34
  def self.post(url, data)
32
- @request_options[:headers] = { 'Content-Type' => 'application/json' }
33
- @request_options[:body] = data
35
+ options = request_options
36
+ options[:headers] = { 'Content-Type' => 'application/json' }
37
+ options[:body] = data
34
38
 
35
- Typhoeus.post(url, @request_options)
39
+ Typhoeus.post(url, options)
36
40
  end
37
41
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'base64'
3
4
  require 'dotenv'
4
5
  require 'json'
5
6
  require 'rotp'
@@ -56,6 +57,8 @@ class ScopesExtractor
56
57
  Hackerone::Programs.sync(results['Hackerone'], options)
57
58
  end
58
59
 
60
+ File.open('extract.json', 'w') { |f| f.write(JSON.pretty_generate(results)) } if options[:save]
61
+
59
62
  results
60
63
  end
61
64
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scopes_extractor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua MARTINELLE
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-16 00:00:00.000000000 Z
11
+ date: 2023-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize