ssllabs 1.11.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7dbe005740a0a4669fa93ba15df1cabf5d0709ce
4
+ data.tar.gz: 274947be2d1c3efebe383315b954e4cadc3f2253
5
+ SHA512:
6
+ metadata.gz: 5b1cb6eb7ba7bb1474c32ababce5564ec1ec7c65400a76d1acffecbad03f6b73d25fc31e383103ab970e44b70358bc0b6ecede451920945f408daa6fc4c7ec08
7
+ data.tar.gz: ecf13c211e3983107df9f785e8a9c7416fd51e134fb0e1029d66024cc1af1d4936c76a36ff93936a15bc806dba9dc9a5455a2087d31dce1085c5d456180c3a24
@@ -0,0 +1,20 @@
1
+ Copyright 2015 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,34 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Ssllabs'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+ Bundler::GemHelper.install_tasks
21
+
22
+ require 'rake/testtask'
23
+
24
+ Rake::TestTask.new(:test) do |t|
25
+ t.libs << 'lib'
26
+ t.libs << 'test'
27
+ t.pattern = 'test/**/*_test.rb'
28
+ t.verbose = false
29
+ end
30
+
31
+
32
+ task default: :test
33
+
34
+ import "./lib/tasks/ssllabs.rake"
@@ -0,0 +1,22 @@
1
+
2
+ module Ssllabs
3
+ API_LOCATION = 'https://api.ssllabs.com/api/v2/'
4
+ end
5
+
6
+ require 'ssllabs/api'
7
+ require 'ssllabs/api_object'
8
+ require 'ssllabs/info'
9
+ require 'ssllabs/key'
10
+ require 'ssllabs/cert'
11
+ require 'ssllabs/chain_cert'
12
+ require 'ssllabs/chain'
13
+ require 'ssllabs/protocol'
14
+ require 'ssllabs/suite'
15
+ require 'ssllabs/suites'
16
+ require 'ssllabs/sim_client'
17
+ require 'ssllabs/simulation'
18
+ require 'ssllabs/sim_details'
19
+ require 'ssllabs/endpoint_details'
20
+ require 'ssllabs/endpoint'
21
+ require 'ssllabs/host'
22
+ require 'ssllabs/status_codes'
@@ -0,0 +1,65 @@
1
+ require 'active_support/core_ext/hash'
2
+ require 'net/http'
3
+
4
+ module Ssllabs
5
+ class InvocationError < StandardError; end
6
+ class RequestRateTooHigh < StandardError; end
7
+ class InternalError < StandardError; end
8
+ class ServiceNotAvailable < StandardError; end
9
+ class ServiceOverloaded < StandardError; end
10
+
11
+ class Api
12
+ attr_reader :max_assessments, :current_assessments
13
+
14
+ def initialize
15
+ @max_assessments = 0
16
+ @current_assessments = 0
17
+ end
18
+
19
+ def request(name, params = {})
20
+ name = name.to_s.camelize(:lower)
21
+ uri = URI("#{API_LOCATION}#{name}?#{URI.encode_www_form(params)}")
22
+ r = Net::HTTP.get_response(uri)
23
+ if r.code.to_i == 200
24
+ @max_assessments = r['X-Max-Assessments']
25
+ @current_assessments = r['X-Current-Assessments']
26
+ r = JSON.load(r.body)
27
+ if r.key?('errors')
28
+ raise InvocationError, "API returned: #{r['errors']}"
29
+ end
30
+ return r
31
+ end
32
+
33
+ case r.code.to_i
34
+ when 400
35
+ raise InvocationError, "invalid parameters"
36
+ when 429
37
+ raise RequestRateTooHigh, "request rate is too high, please slow down"
38
+ when 500
39
+ raise InternalError, "service encountered an error, sleep 5 minutes"
40
+ when 503
41
+ raise ServiceNotAvailable, "service is not available, sleep 15 minutes"
42
+ when 529
43
+ raise ServiceOverloaded, "service is overloaded, sleep 30 minutes"
44
+ else
45
+ raise StandardError, "http error code #{r.code}"
46
+ end
47
+ end
48
+
49
+ def info
50
+ Info.load request(:info)
51
+ end
52
+
53
+ def analyse(params = {})
54
+ Host.load request(:analyze, params)
55
+ end
56
+
57
+ def get_endpoint_data(params = {})
58
+ Endpoint.load request(:get_endpoint_data, params)
59
+ end
60
+
61
+ def get_status_codes
62
+ StatusCodes.load request(:get_status_codes)
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,103 @@
1
+ require 'active_support/inflector'
2
+ require 'json'
3
+
4
+ module Ssllabs
5
+ class ApiObject
6
+
7
+ class << self;
8
+ attr_accessor :all_attributes
9
+ attr_accessor :fields
10
+ attr_accessor :lists
11
+ attr_accessor :refs
12
+ end
13
+
14
+ def self.inherited(base)
15
+ base.all_attributes = []
16
+ base.fields = []
17
+ base.lists = {}
18
+ base.refs = {}
19
+ end
20
+
21
+ def self.to_api_name(name)
22
+ name.to_s.gsub(/\?$/,'').camelize(:lower)
23
+ end
24
+
25
+ def self.to_attr_name(name)
26
+ name.to_s.gsub(/\?$/,'').gsub(/URI/,'Uri').underscore
27
+ end
28
+
29
+ def self.field_methods(name)
30
+ is_bool = name.to_s.end_with?('?')
31
+ attr_name = to_attr_name(name)
32
+ api_name = to_api_name(name)
33
+ class_eval <<-EOF, __FILE__, __LINE__
34
+ def #{attr_name}#{'?' if is_bool}
35
+ @#{api_name}
36
+ end
37
+ def #{attr_name}=(value)
38
+ @#{api_name} = value
39
+ end
40
+ EOF
41
+ end
42
+
43
+ def self.has_fields(*names)
44
+ names.each do |name|
45
+ @all_attributes << to_api_name(name)
46
+ @fields << to_api_name(name)
47
+ field_methods(name)
48
+ end
49
+ end
50
+
51
+ def self.has_objects_list(name, klass)
52
+ @all_attributes << to_api_name(name)
53
+ @lists[to_api_name(name)] = klass
54
+ field_methods(name)
55
+ end
56
+
57
+ def self.has_object_ref(name, klass)
58
+ @all_attributes << to_api_name(name)
59
+ @refs[to_api_name(name)] = klass
60
+ field_methods(name)
61
+ end
62
+
63
+ def self.load(attributes = {})
64
+ obj = self.new
65
+ attributes.each do |name,value|
66
+ if @fields.include?(name)
67
+ obj.instance_variable_set("@#{name}", value)
68
+ elsif @lists.key?(name)
69
+ obj.instance_variable_set("@#{name}", value.map { |v| @lists[name].load(v) }) unless value.nil?
70
+ elsif @refs.key?(name)
71
+ obj.instance_variable_set("@#{name}", @refs[name].load(value)) unless value.nil?
72
+ else
73
+ raise ArgumentError, "#{name} is not an attribute of object #{self.name}"
74
+ end
75
+ end
76
+ obj
77
+ end
78
+
79
+ def to_hash(with_api_names: false)
80
+ obj = {}
81
+ self.class.all_attributes.each do |api_name|
82
+ v = instance_variable_get("@#{api_name}")
83
+ key_name = with_api_names ? api_name : self.class.to_attr_name(api_name)
84
+ obj[key_name] = to_hash_value(v, with_api_names)
85
+ end
86
+ obj
87
+ end
88
+
89
+ def to_hash_value(entry, with_api_names)
90
+ if entry.respond_to?(:to_hash)
91
+ entry.to_hash(with_api_names: with_api_names)
92
+ elsif entry.is_a?(Array)
93
+ entry.map { |entry| to_hash_value(entry, with_api_names) }
94
+ else
95
+ entry
96
+ end
97
+ end
98
+
99
+ def to_json(opts={})
100
+ to_hash(with_api_names: true).to_json
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,33 @@
1
+ module Ssllabs
2
+ class Cert < ApiObject
3
+ has_fields :subject,
4
+ :commonNames,
5
+ :altNames,
6
+ :notBefore,
7
+ :notAfter,
8
+ :issuerSubject,
9
+ :sigAlg,
10
+ :issuerLabel,
11
+ :revocationInfo,
12
+ :crlURIs,
13
+ :ocspURIs,
14
+ :revocationStatus,
15
+ :crlRevocationStatus,
16
+ :ocspRevocationStatus,
17
+ :sha1Hash,
18
+ :pinSha256,
19
+ :sgc?,
20
+ :validationType,
21
+ :issues,
22
+ :sct?,
23
+ :mustStaple
24
+
25
+ def valid?
26
+ issues == 0
27
+ end
28
+
29
+ def invalid?
30
+ !valid?
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,14 @@
1
+ module Ssllabs
2
+ class Chain < ApiObject
3
+ has_objects_list :certs, ChainCert
4
+ has_fields :issues
5
+
6
+ def valid?
7
+ issues == 0
8
+ end
9
+
10
+ def invalid?
11
+ !valid?
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,29 @@
1
+ module Ssllabs
2
+ class ChainCert < ApiObject
3
+ has_fields :subject,
4
+ :label,
5
+ :notBefore,
6
+ :notAfter,
7
+ :issuerSubject,
8
+ :issuerLabel,
9
+ :sigAlg,
10
+ :issues,
11
+ :keyAlg,
12
+ :sha1Hash,
13
+ :pinSha256,
14
+ :keySize,
15
+ :keyStrength,
16
+ :revocationStatus,
17
+ :crlRevocationStatus,
18
+ :ocspRevocationStatus,
19
+ :raw
20
+
21
+ def valid?
22
+ issues == 0
23
+ end
24
+
25
+ def invalid?
26
+ !valid?
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,18 @@
1
+ module Ssllabs
2
+ class Endpoint < ApiObject
3
+ has_fields :ipAddress,
4
+ :serverName,
5
+ :statusMessage,
6
+ :statusDetails,
7
+ :statusDetailsMessage,
8
+ :grade,
9
+ :gradeTrustIgnored,
10
+ :hasWarnings?,
11
+ :isExceptional?,
12
+ :progress,
13
+ :duration,
14
+ :eta,
15
+ :delegation
16
+ has_object_ref :details, EndpointDetails
17
+ end
18
+ end
@@ -0,0 +1,60 @@
1
+ module Ssllabs
2
+ class EndpointDetails < ApiObject
3
+ has_fields :hostStartTime
4
+ has_object_ref :key, Key
5
+ has_object_ref :cert, Cert
6
+ has_object_ref :chain, Chain
7
+ has_objects_list :protocols, Protocol
8
+ has_object_ref :suites, Suites
9
+ has_fields :serverSignature,
10
+ :prefixDelegation?,
11
+ :nonPrefixDelegation?,
12
+ :vulnBeast?,
13
+ :renegSupport,
14
+ :stsResponseHeader,
15
+ :stsMaxAge,
16
+ :stsSubdomains?,
17
+ :pkpResponseHeader,
18
+ :sessionResumption,
19
+ :compressionMethods,
20
+ :supportsNpn?,
21
+ :npnProtocols,
22
+ :sessionTickets,
23
+ :ocspStapling?,
24
+ :staplingRevocationStatus,
25
+ :staplingRevocationErrorMessage,
26
+ :sniRequired?,
27
+ :httpStatusCode,
28
+ :httpForwarding,
29
+ :supportsRc4?,
30
+ :stsStatus,
31
+ :stsPreload,
32
+ :hstsPolicy,
33
+ :hstsPreloads,
34
+ :hpkpPolicy,
35
+ :hpkpRoPolicy,
36
+ :rc4Only,
37
+ :preloadChecks,
38
+ :forwardSecrecy,
39
+ :rc4WithModern?,
40
+ :drownHosts,
41
+ :drownErrors,
42
+ :drownVulnerable?,
43
+ :openSSLLuckyMinus20,
44
+ :chaCha20Preference,
45
+ :supportsAlpn
46
+ has_object_ref :sims, SimDetails
47
+ has_fields :heartbleed?,
48
+ :heartbeat?,
49
+ :openSslCcs,
50
+ :poodleTls,
51
+ :fallbackScsv?,
52
+ :poodle?,
53
+ :freak?,
54
+ :hasSct,
55
+ :dhPrimes,
56
+ :dhUsesKnownPrimes,
57
+ :dhYsReuse?,
58
+ :logjam?
59
+ end
60
+ end
@@ -0,0 +1,17 @@
1
+ module Ssllabs
2
+ class Host < ApiObject
3
+ has_fields :host,
4
+ :port,
5
+ :protocol,
6
+ :isPublic?,
7
+ :status,
8
+ :statusMessage,
9
+ :startTime,
10
+ :testTime,
11
+ :engineVersion,
12
+ :criteriaVersion,
13
+ :cacheExpiryTime
14
+ has_objects_list :endpoints, Endpoint
15
+ has_fields :certHostnames
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ module Ssllabs
2
+ class Info < ApiObject
3
+ has_fields :engineVersion,
4
+ :criteriaVersion,
5
+ :clientMaxAssessments,
6
+ :maxAssessments,
7
+ :currentAssessments,
8
+ :messages,
9
+ :newAssessmentCoolOff
10
+ end
11
+ end
@@ -0,0 +1,17 @@
1
+ module Ssllabs
2
+ class Key < ApiObject
3
+ has_fields :size,
4
+ :strength,
5
+ :alg,
6
+ :debianFlaw?,
7
+ :q
8
+
9
+ def insecure?
10
+ debian_flaw? || q == 0
11
+ end
12
+
13
+ def secure?
14
+ !insecure?
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module Ssllabs
2
+ class Protocol < ApiObject
3
+ has_fields :id,
4
+ :name,
5
+ :version,
6
+ :v2SuitesDisabled?,
7
+ :q
8
+
9
+ def insecure?
10
+ q == 0
11
+ end
12
+
13
+ def secure?
14
+ !insecure?
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ module Ssllabs
2
+ class SimClient < ApiObject
3
+ has_fields :id,
4
+ :name,
5
+ :platform,
6
+ :version,
7
+ :isReference?
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module Ssllabs
2
+ class SimDetails < ApiObject
3
+ has_objects_list :results, Simulation
4
+ end
5
+ end
@@ -0,0 +1,17 @@
1
+ module Ssllabs
2
+ class Simulation < ApiObject
3
+ has_object_ref :client, SimClient
4
+ has_fields :errorCode,
5
+ :attempts,
6
+ :protocolId,
7
+ :suiteId
8
+
9
+ def success?
10
+ error_code == 0
11
+ end
12
+
13
+ def error?
14
+ !success?
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ module Ssllabs
2
+ class StatusCodes < ApiObject
3
+ has_fields :statusDetails
4
+
5
+ def [](name)
6
+ status_details[name]
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,22 @@
1
+ module Ssllabs
2
+ class Suite < ApiObject
3
+ has_fields :id,
4
+ :name,
5
+ :cipherStrength,
6
+ :dhStrength,
7
+ :dhP,
8
+ :dhG,
9
+ :dhYs,
10
+ :ecdhBits,
11
+ :ecdhStrength,
12
+ :q
13
+
14
+ def insecure?
15
+ q == 0
16
+ end
17
+
18
+ def secure?
19
+ !insecure?
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,6 @@
1
+ module Ssllabs
2
+ class Suites < ApiObject
3
+ has_objects_list :list, Suite
4
+ has_fields :preference?
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module Ssllabs
2
+ VERSION = "1.11.6"
3
+ end
@@ -0,0 +1,43 @@
1
+ require 'ssllabs'
2
+
3
+ namespace :ssllabs do
4
+ desc "Retrieve API information"
5
+ task :info do
6
+ api = Ssllabs::Api.new
7
+ puts api.info.to_json
8
+ puts "Running assessments: #{api.current_assessments}/#{api.max_assessments}"
9
+ end
10
+
11
+ desc "Retrieve error messages"
12
+ task :status_codes do
13
+ api = Ssllabs::Api.new
14
+ puts api.get_status_codes.to_json
15
+ puts "Running assessments: #{api.current_assessments}/#{api.max_assessments}"
16
+ end
17
+
18
+ desc "Start analysis for a host"
19
+ task :analyze do
20
+ unless ENV['HOST']
21
+ puts "Specify HOST=... as environment variable"
22
+ next
23
+ end
24
+ api = Ssllabs::Api.new
25
+ r = api.analyse(host: ENV['HOST'],
26
+ publish: 'off', startNew: 'on', all: 'done')
27
+ puts JSON.generate(r)
28
+ puts "Running assessments: #{api.current_assessments}/#{api.max_assessments}"
29
+ end
30
+
31
+ desc "Retrieve endpoint data from cache"
32
+ task :endpoint_data do
33
+ unless ENV['HOST'] && ENV['IP']
34
+ puts "Specify HOST=... and IP=... as environment variable"
35
+ next
36
+ end
37
+ api = Ssllabs::Api.new
38
+ r = api.get_endpoint_data(host: ENV['HOST'],
39
+ s: ENV['IP'], fromCache: 'on')
40
+ puts JSON.generate(r)
41
+ puts "Running assessments: #{api.current_assessments}/#{api.max_assessments}"
42
+ end
43
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ssllabs
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.11.6
5
+ platform: ruby
6
+ authors:
7
+ - Francois Chagnon
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-31 00:00:00.000000000 Z
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: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: net
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: This is a ruby API to interact with Qualys SSL Labs API. API Documentation
56
+ is available at https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md
57
+ email:
58
+ - francois.chagnon@shopify.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - MIT-LICENSE
64
+ - Rakefile
65
+ - lib/ssllabs.rb
66
+ - lib/ssllabs/api.rb
67
+ - lib/ssllabs/api_object.rb
68
+ - lib/ssllabs/cert.rb
69
+ - lib/ssllabs/chain.rb
70
+ - lib/ssllabs/chain_cert.rb
71
+ - lib/ssllabs/endpoint.rb
72
+ - lib/ssllabs/endpoint_details.rb
73
+ - lib/ssllabs/host.rb
74
+ - lib/ssllabs/info.rb
75
+ - lib/ssllabs/key.rb
76
+ - lib/ssllabs/protocol.rb
77
+ - lib/ssllabs/sim_client.rb
78
+ - lib/ssllabs/sim_details.rb
79
+ - lib/ssllabs/simulation.rb
80
+ - lib/ssllabs/status_codes.rb
81
+ - lib/ssllabs/suite.rb
82
+ - lib/ssllabs/suites.rb
83
+ - lib/ssllabs/version.rb
84
+ - lib/tasks/ssllabs.rake
85
+ homepage: https://github.com/Shopify/ssllabs.rb/
86
+ licenses:
87
+ - MIT
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.5.1
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: Ruby API for Qualys SSL Labs scanner.
109
+ test_files: []