fingerprinter 0.1.3 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fingerprinter.rb +19 -3
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b224d61b1b79fce378d1b8ad8ac84ac4f1de81cd37195281aee7e0051c684d6
4
- data.tar.gz: df4ba4f706f8a5de13b778f050ee1568a5f9bdbf6cabaa7732ec5fcb745b0f39
3
+ metadata.gz: 8f6821303bf8854c4b159cc1038bfb08af71d170b07a24e19376f49f88bba6ee
4
+ data.tar.gz: edd7faad955013acf5c94e897e4994e340baafc493c3f2c1bfccdb2bf7558f7c
5
5
  SHA512:
6
- metadata.gz: cc74aa0e8bf750f3a9d8a727a958e23d3a285491c0501763238cd5493e865bebe9590c42090b7bbf1f1cdea2ba9ac56824784eb3079b7fafeb9923deed1eae07
7
- data.tar.gz: 7e70c7c5e3fabafd2c73dd53a1a41b1a05769044978005f0a521646b30a78ba5bc1b3a701ccd9d0b05a2cd5d6266fa35bf5075bf7f908f6babe0ff2ada89541f
6
+ metadata.gz: 711d27cdd3329f07e6e24daa9400e36a8e8f62c6467870c0dc0309ed75bd1aa9713aaede490b9c882e91e1e69d8b9ccb0c20077f6e42a00353b03db685483078
7
+ data.tar.gz: 49b065930036587200a211e12337e67bd6a61643e0101c9e2ddb860bc5454542ce74fb33557a4ac830dfa27159410ea2317eee8f751ed49848265a8bc4834bb0
data/lib/fingerprinter.rb CHANGED
@@ -44,7 +44,7 @@ module Fingerprinter
44
44
  doc = Utilities::Parser.doc(response.body)
45
45
 
46
46
  results[url] = Concurrent::Array.new
47
- data = { response: response, doc: doc, url: url }
47
+ data = { response:, doc:, url: }
48
48
  Technologies.subclasses.each { |technology| results[url] << technology.run(data) }
49
49
  end
50
50
  end
@@ -59,11 +59,19 @@ module Fingerprinter
59
59
  response = nil
60
60
  3.times do
61
61
  response = Fingerprinter.http_client.get(url, { follow_location: true })[url]
62
- break if response&.code != 0 && !response.return_message.include?('Stream error')
62
+ break if response&.code != 0 || timeout_without_scheme?(url, response)
63
63
 
64
64
  sleep(1)
65
65
  end
66
- return response if response&.code&.zero? || same_scope?(url, response)
66
+
67
+ if stream_error?(response)
68
+ return
69
+ elsif timeout_without_scheme?(url, response)
70
+ url = "https://#{url}"
71
+ return get_response(url)
72
+ end
73
+ return if response&.code == 0
74
+ return response if same_scope?(url, response)
67
75
 
68
76
  response.redirections.first
69
77
  end
@@ -73,5 +81,13 @@ module Fingerprinter
73
81
 
74
82
  Utilities::Urls.uri_parse(url)&.host == Utilities::Urls.uri_parse(response&.effective_url)&.host
75
83
  end
84
+
85
+ def stream_error?(response)
86
+ response&.code&.zero? && response.return_message.include?('Stream error')
87
+ end
88
+
89
+ def timeout_without_scheme?(url, response)
90
+ response&.code == 0 && !url.start_with?('http') && response.return_message.include?('Timeout was reached')
91
+ end
76
92
  end
77
93
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fingerprinter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua MARTINELLE
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-10 00:00:00.000000000 Z
11
+ date: 2024-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby