apullo 0.1.1 → 0.1.2

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: b744411a938bb7f98a04598b275b8b5fe589ea80eb6a7c17a3b73f55fcdf587c
4
- data.tar.gz: 5287747186cca299dd42f43b600cd94934602f25c42ce340c6f6fd4d3428fd49
3
+ metadata.gz: 2f1f9e5d90ef5abdc9a8caf4084a6afa69d36938aefe6ea5b22d97df003dee16
4
+ data.tar.gz: 5b25da846587a8a2a96b649a7cb2cd2fec853070a09a13ac57e7e176f20f8199
5
5
  SHA512:
6
- metadata.gz: f354bee48a12084cdb1d85c71d256ebe6a7f1dacfbcf99b93f2f0d114ccfffdb39aecc201fa1d09f47db0bbdf484cf6e3020d4b9b662a36324b82d00513dd5c4
7
- data.tar.gz: a15315ca8452f8b8eb1501f980baabc85594e7202bb3777e54f585432d3d7ee7406318d3b85bd28135efce59ea4c400b8c0cd9a3118c59279d1da54d7b0e0309
6
+ metadata.gz: afe5791fb852dbf7b162dea37380a057f1491f4878a59186831610e0e9221c7c17c4766e9b169c0e0be68b10f0440482afd355b2b468e127d17f9b1d3a6cfc05
7
+ data.tar.gz: aa23fc08523091e1f9444fe3261131cda5dd65f8655af513be3c2f7cfd34ebcbbf36aae3aa6724122afb2fdbaad1997caf888e5436479848f17e1c30a514363b
data/apullo.gemspec CHANGED
@@ -36,6 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.add_dependency "mem", "~> 0.1"
37
37
  spec.add_dependency "murmurhash3", "~> 0.1"
38
38
  spec.add_dependency "oga", "~> 2.15"
39
+ spec.add_dependency "parallel", "~> 1.18"
39
40
  spec.add_dependency "public_suffix", "~> 4.0"
40
41
  spec.add_dependency "ssh_scan", "~> 0.0"
41
42
  spec.add_dependency "thor", "~> 0.20"
data/lib/apullo/cli.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "thor"
4
3
  require "json"
4
+ require "parallel"
5
+ require "thor"
5
6
 
6
7
  module Apullo
7
8
  class CLI < Thor
@@ -24,7 +25,7 @@ module Apullo
24
25
  }
25
26
  end
26
27
 
27
- Apullo.fingerprints.map do |klass|
28
+ Parallel.map(Apullo.fingerprints) do |klass|
28
29
  fingerprint = klass.new(target)
29
30
  [fingerprint.name, fingerprint.results]
30
31
  end.to_h
@@ -52,8 +52,12 @@ module Apullo
52
52
  values.reject(&:empty?).empty? ? [] : values
53
53
  end
54
54
 
55
+ def whois_client
56
+ @whois_client ||= Whois::Client.new(timeout: 3)
57
+ end
58
+
55
59
  def whois
56
- @whois ||= Whois.whois(target.host)
60
+ @whois ||= whois_client.lookup(target.host)
57
61
  rescue Timeout::Error, Whois::Error
58
62
  nil
59
63
  end
@@ -34,7 +34,7 @@ module Apullo
34
34
  def b64_favicon_data
35
35
  @b64_favicon_data ||= [].tap do |out|
36
36
  data = get(uri.path)
37
- break unless data
37
+ next unless data
38
38
 
39
39
  b64 = Base64.strict_encode64(data)
40
40
  out << b64.chars.each_slice(76).map(&:join).join("\n") + "\n"
@@ -46,7 +46,8 @@ module Apullo
46
46
  path = path.empty? ? "/" : path
47
47
  request = Net::HTTP::Get.new(path)
48
48
  response = http.request(request)
49
- response.body
49
+
50
+ response.code.to_i == 200 ? response.body : nil
50
51
  rescue Errno::ECONNREFUSED, Net::HTTPError, OpenSSL::OpenSSLError => _e
51
52
  nil
52
53
  end
@@ -53,15 +53,19 @@ module Apullo
53
53
 
54
54
  private
55
55
 
56
+ def default_favicon_url
57
+ "#{target.uri.scheme}://#{target.uri.host}:#{target.uri.port}/favicon.ico"
58
+ end
59
+
56
60
  def favicon_url
57
61
  return nil unless @body
58
62
 
59
63
  doc = Oga.parse_html(@body)
60
64
  icon = doc.at_css("link[rel='shortcut icon']") || doc.at_css("link[rel='icon']")
61
- return nil unless icon
65
+ return default_favicon_url unless icon
62
66
 
63
67
  href = icon.get("href")
64
- return nil unless href
68
+ return default_favicon_url unless href
65
69
 
66
70
  href.start_with?("http://", "https://") ? href : target.url + href
67
71
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Apullo
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apullo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manabu Niseki
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: '2.15'
167
+ - !ruby/object:Gem::Dependency
168
+ name: parallel
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '1.18'
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '1.18'
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: public_suffix
169
183
  requirement: !ruby/object:Gem::Requirement