ssl_labs 0.0.1 → 0.0.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
  SHA1:
3
- metadata.gz: 757eafa88db5476feb6a61d68a5cf7fe7ca31433
4
- data.tar.gz: 367750793ad3ed2d792145c511b536a81144388c
3
+ metadata.gz: cf7eb84ab8a2af805d670dc1dabc82ffd511c889
4
+ data.tar.gz: 25699a813d19b158d8438e0ce635e42818ad7c52
5
5
  SHA512:
6
- metadata.gz: da209d49df109bbf639114dbaaa396eb2ad51d538655b77119c7e3361281924d90e807c06679d91b388803a1aeae8b373ce8330b63937bd6aa791a9b127ca0eb
7
- data.tar.gz: 1cc4c8e4429aff72b64e1c65276e370db2db5026cbf33cbe671e869e046de81c2ee1d092cfb80f137a700d81aeed9da162830d04eafb085ef28ea3ab5d64b769
6
+ metadata.gz: 8691a86faa72742401114c35e0ab27fe1e18fc807a9cfbfab1e6404155bd908466cb9011029b7935168ca53e840e620b04c2681b571bfb9023ed04d86b5aad76
7
+ data.tar.gz: a8498e9f3b63e761a9c674e9a1b67941b82a1b6a09951839c5ae72a356ec0acbc395c4bfc5d05cb603ac7d5cf444b2e2e3614b7df39cddba08ffb4cf902c95ae
data/README.md CHANGED
@@ -11,3 +11,18 @@ The reference client is at https://github.com/ssllabs/ssllabs-scan
11
11
 
12
12
  * Tests
13
13
 
14
+ * Weirdness: #analyze and #analyze! return different things
15
+
16
+ * Helper #methods? for boolean attributes
17
+
18
+ * SslLabs constructor must take a URI string _with a scheme_
19
+
20
+ * Gem version is hardcoded twice
21
+
22
+ * `endpoint_data.details.foo` is annoying; remove `details`
23
+
24
+ * Configurable poll delay
25
+
26
+ * Cert and ChainCert are melded
27
+
28
+ * Suites.preference is MIA
@@ -28,12 +28,11 @@ class SslLabs
28
28
  endpoint = self.new
29
29
  hash.each do |k, v|
30
30
  sym = Util.underscore(k).to_sym
31
- if ATTRS.include?(sym)
32
- if sym == :ip_address
33
- endpoint.ip_address = IPAddr.new(v)
34
- else
35
- endpoint.send("#{sym}=", v)
36
- end
31
+ case sym
32
+ when :ip_address
33
+ endpoint.ip_address = IPAddr.new(v)
34
+ when *ATTRS
35
+ endpoint.send("#{sym}=", v)
37
36
  else
38
37
  raise ArgumentError, "Unknown key #{k.inspect} (#{sym})"
39
38
  end
@@ -22,7 +22,7 @@ class SslLabs
22
22
  :raw,
23
23
  :revocation_info,
24
24
  :revocation_status,
25
- :sgc,
25
+ :scg,
26
26
  :sig_alg,
27
27
  :subject,
28
28
  :validation_type
@@ -33,8 +33,7 @@ class SslLabs
33
33
  def self.from_hash(hash)
34
34
  cert = self.new
35
35
  hash.each do |k, v|
36
- sym = Util.underscore(k).to_sym
37
- case sym
36
+ case sym = Util.underscore(k).to_sym
38
37
  when :crl_ur_is
39
38
  cert.crl_uris = v
40
39
  when :not_after
@@ -43,8 +42,6 @@ class SslLabs
43
42
  cert.not_before = Time.at(v / 1000.0)
44
43
  when :ocsp_ur_is
45
44
  cert.ocsp_uris = v
46
- when :scg
47
- cert.sgc = v
48
45
  when *ATTRS
49
46
  cert.send("#{sym}=", v)
50
47
  else
@@ -18,8 +18,7 @@ class SslLabs
18
18
  def self.from_hash(hash)
19
19
  chain = self.new
20
20
  hash.each do |k, v|
21
- sym = Util.underscore(k).to_sym
22
- case sym
21
+ case sym = Util.underscore(k).to_sym
23
22
  when :certs
24
23
  chain.certs = v.map { |cert| Cert.from_hash(cert) }
25
24
  when *ATTRS
@@ -21,8 +21,8 @@ class SslLabs
21
21
  def self.from_hash(hash)
22
22
  key = self.new
23
23
  hash.each do |k, v|
24
- sym = Util.underscore(k).to_sym
25
- if ATTRS.include?(sym)
24
+ case sym = Util.underscore(k).to_sym
25
+ when *ATTRS
26
26
  key.send("#{sym}=", v)
27
27
  else
28
28
  raise ArgumentError, "Unknown key #{k.inspect} (#{sym.inspect})"
@@ -11,6 +11,8 @@ class SslLabs
11
11
  ATTRS = [
12
12
  :id,
13
13
  :name,
14
+ :q,
15
+ :v2_suites_disabled,
14
16
  :version
15
17
  ]
16
18
 
@@ -19,8 +21,8 @@ class SslLabs
19
21
  def self.from_hash(hash)
20
22
  protocol = self.new
21
23
  hash.each do |k, v|
22
- sym = Util.underscore(k).to_sym
23
- if ATTRS.include?(sym)
24
+ case sym = Util.underscore(k).to_sym
25
+ when *ATTRS
24
26
  protocol.send("#{sym}=", v)
25
27
  else
26
28
  raise ArgumentError, "Unknown key #{k.inspect} (#{sym.inspect})"
@@ -22,8 +22,8 @@ class SslLabs
22
22
  def self.from_hash(hash)
23
23
  client = self.new
24
24
  hash.each do |k, v|
25
- sym = Util.underscore(k).to_sym
26
- if ATTRS.include?(sym)
25
+ case sym = Util.underscore(k).to_sym
26
+ when *ATTRS
27
27
  client.send("#{sym}=", v)
28
28
  else
29
29
  raise ArgumentError, "Unknown key #{k.inspect} (#{sym.inspect})"
@@ -22,10 +22,10 @@ class SslLabs
22
22
  def self.from_hash(hash)
23
23
  sim = self.new
24
24
  hash.each do |k, v|
25
- sym = Util.underscore(k).to_sym
26
- if sym == :client
25
+ case sym = Util.underscore(k).to_sym
26
+ when :client
27
27
  sim.client = Sim::Client.from_hash(v)
28
- elsif ATTRS.include?(sym)
28
+ when *ATTRS
29
29
  sim.send("#{sym}=", v)
30
30
  else
31
31
  raise ArgumentError, "Unknown key #{k.inspect} (#{sym.inspect})"
@@ -24,8 +24,8 @@ class SslLabs
24
24
  def self.from_hash(hash)
25
25
  suite = self.new
26
26
  hash.each do |k, v|
27
- sym = Util.underscore(k).to_sym
28
- if ATTRS.include?(sym)
27
+ case sym = Util.underscore(k).to_sym
28
+ when *ATTRS
29
29
  suite.send("#{sym}=", v)
30
30
  else
31
31
  raise ArgumentError, "Unknown key #{k.inspect} (#{sym.inspect})"
@@ -16,28 +16,34 @@ class SslLabs
16
16
  :cert,
17
17
  :chain,
18
18
  :compression_methods,
19
+ :forward_secrecy,
20
+ :heartbeat,
21
+ :heartbleed,
19
22
  :host_start_time,
23
+ :http_forwarding,
24
+ :http_status_code,
20
25
  :key,
21
26
  :non_prefix_delegation,
27
+ :npn_protocols,
28
+ :ocsp_stapling,
29
+ :open_ssl_ccs,
30
+ :pkp_response_header,
22
31
  :prefix_delegation,
23
32
  :protocols,
33
+ :rc4_with_modern,
24
34
  :reneg_support,
25
35
  :server_signature,
26
36
  :session_resumption,
27
- :suites,
28
- :vuln_beast,
29
- :heartbleed,
30
- :heartbeat,
31
- :open_ssl_ccs,
32
37
  :session_tickets,
38
+ :sims,
33
39
  :sni_required,
34
- :ocsp_stapling,
40
+ :sts_response_header,
41
+ :sts_max_age,
42
+ :sts_sub_domains,
43
+ :suites,
35
44
  :supports_npn,
36
45
  :supports_rc4,
37
- :forward_secrecy,
38
- :rc4_with_modern,
39
- :http_status_code,
40
- :sims
46
+ :vuln_beast,
41
47
  ]
42
48
 
43
49
  attr_accessor(*ATTRS)
@@ -45,8 +51,7 @@ class SslLabs
45
51
  def self.from_hash(hash)
46
52
  details = self.new
47
53
  hash.each do |k, v|
48
- sym = Util.underscore(k).to_sym
49
- case sym
54
+ case sym = Util.underscore(k).to_sym
50
55
  when :cert
51
56
  details.cert = Cert.from_hash(v)
52
57
  when :chain
@@ -24,19 +24,17 @@ class SslLabs
24
24
 
25
25
  attr_accessor(*ATTRS)
26
26
 
27
- def self.from_hash(hash)
27
+ def self.from_json(str)
28
+ json = JSON.parse(str)
28
29
  endpoint = self.new
29
- hash.each do |k, v|
30
- sym = Util.underscore(k).to_sym
31
- if ATTRS.include?(sym)
32
- case sym
33
- when :ip_address
34
- endpoint.ip_address = IPAddr.new(v)
35
- when :details
36
- endpoint.details = EndpointData::Details.from_hash(v)
37
- else
38
- endpoint.send("#{sym}=", v)
39
- end
30
+ json.each do |k, v|
31
+ case sym = Util.underscore(k).to_sym
32
+ when :ip_address
33
+ endpoint.ip_address = IPAddr.new(v)
34
+ when :details
35
+ endpoint.details = EndpointData::Details.from_hash(v)
36
+ when *ATTRS
37
+ endpoint.send("#{sym}=", v)
40
38
  else
41
39
  raise ArgumentError, "Unknown key #{k.inspect} (#{sym})"
42
40
  end
data/lib/ssl_labs/host.rb CHANGED
@@ -6,6 +6,7 @@ class SslLabs
6
6
  class Host
7
7
 
8
8
  ATTRS = [
9
+ :cache_expiry_time,
9
10
  :criteria_version,
10
11
  :delegation,
11
12
  :duration,
@@ -36,16 +37,17 @@ class SslLabs
36
37
  json = JSON.parse(str)
37
38
  host = self.new
38
39
  json.each do |k, v|
39
- sym = Util.underscore(k).to_sym
40
- if ATTRS.include?(sym)
41
- case sym
42
- when :start_time
43
- host.start_time = Time.at(v / 1000.0)
44
- when :endpoints
45
- host.endpoints += v.map { |ep| Endpoint.from_hash(ep) }
46
- else
47
- host.send("#{sym}=", v)
48
- end
40
+ case sym = Util.underscore(k).to_sym
41
+ when :cache_expiry_time
42
+ host.cache_expiry_time = Time.at(v / 1000.0)
43
+ when :start_time
44
+ host.start_time = Time.at(v / 1000.0)
45
+ when :test_time
46
+ host.test_time = Time.at(v / 1000.0)
47
+ when :endpoints
48
+ host.endpoints = v.map { |ep| Endpoint.from_hash(ep) }
49
+ when *ATTRS
50
+ host.send("#{sym}=", v)
49
51
  else
50
52
  raise ArgumentError, "Unknown JSON key #{k.inspect} (#{sym.inspect})"
51
53
  end
data/lib/ssl_labs/info.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'json'
2
2
 
3
+ require 'ssl_labs/util'
4
+
3
5
  class SslLabs
4
6
 
5
7
  class Info
@@ -7,7 +9,8 @@ class SslLabs
7
9
  ATTRS = [
8
10
  :engine_version,
9
11
  :criteria_version,
10
- :client_max_assessments
12
+ :client_max_assessments,
13
+ :notice
11
14
  ]
12
15
 
13
16
  attr_accessor(*ATTRS)
@@ -17,13 +20,11 @@ class SslLabs
17
20
  json = JSON.parse(str)
18
21
  info = self.new
19
22
  json.each do |k, v|
20
- case k
21
- when 'engineVersion'
22
- info.engine_version = v
23
- when 'criteriaVersion'
24
- info.criteria_version = v
25
- when 'clientMaxAssessments'
23
+ case sym = Util.underscore(k).to_sym
24
+ when :client_max_assessments
26
25
  info.client_max_assessments = v.to_i
26
+ when *ATTRS
27
+ info.send("#{sym}=", v)
27
28
  else
28
29
  raise ArgumentError, "Unknown key #{k.inspect}"
29
30
  end
data/lib/ssl_labs.rb CHANGED
@@ -9,7 +9,7 @@ require 'ssl_labs/info'
9
9
  class SslLabs
10
10
 
11
11
  # Gem version.
12
- VERSION = '0.0.1'
12
+ VERSION = '0.0.2'
13
13
 
14
14
  # User agent for client.
15
15
  USER_AGENT = "ssl_labs.rb #{VERSION}"
@@ -33,14 +33,15 @@ class SslLabs
33
33
  opts_a = opts.flat_map do |k, v|
34
34
  case k
35
35
  when :publish, :clear_cache, :from_cache
36
- [k, v ? 'on' : 'off']
36
+ [k, v ? :on : :off]
37
37
  when :all
38
- if v == true
39
- [k, 'on']
40
- elsif v == :done
38
+ case v
39
+ when true
40
+ [k, :on]
41
+ when :done
41
42
  [k, v]
42
43
  else
43
- raise ArgumentError, "Invalid value for option #{k.inspect}"
44
+ raise ArgumentError, "Invalid value #{v.inspect} for option #{k.inspect}"
44
45
  end
45
46
  else
46
47
  raise ArgumentError, "Invalid option #{k.inspect}"
@@ -67,7 +68,7 @@ class SslLabs
67
68
  body = invoke(:get_endpoint_data,
68
69
  :host => uri.host,
69
70
  :s => ep.ip_address,
70
- :from_cache => from_cache ? 'on' : 'off')
71
+ :from_cache => from_cache ? :on : :off)
71
72
  EndpointData.from_json(body)
72
73
  end
73
74
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ssl_labs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Carpenter
@@ -10,6 +10,20 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2014-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 4.0.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 4.0.1
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: mechanize
15
29
  requirement: !ruby/object:Gem::Requirement