ruby-sslyze 0.1.1 → 0.2.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
  SHA1:
3
- metadata.gz: bee86f9696ba9bc1f258a39a3674722c5da075e8
4
- data.tar.gz: 371902d6a7249430a2642d96d2924c11eb87edee
3
+ metadata.gz: 7170e79ae6e7d69becc03cea5c84b015253cce4d
4
+ data.tar.gz: 06f17142a24b912a7c26983b6dae5b1b8f4c4f86
5
5
  SHA512:
6
- metadata.gz: bf2dc962eec84bd8f420bbf10104da3947a7667b854e775ad81c07f3a0d714ed1e812cd02ff94e99586feadb974a2e31c3efd7069bf9a51dca461dd0cfc078e1
7
- data.tar.gz: 05bb76e5ea8445a67633c2b303f5505916e0ce2caf2ba51beb93848964f253d5d199b47cf57a42db15f11947f7f1d479197ea4926d6b7f8df8c1a5b4d130970d
6
+ metadata.gz: 6ec67afa81afa9ad7b3b1ffffc607c810a57b621a7a4f10444b554972d4b19822791b50ecf641cfbe66a963c836f791bd66913784da9426db327aa37720db80b
7
+ data.tar.gz: e9282b4878788e92a6c8e4643ff19d57745381701d29f43651e7f794a1cc789315b7e5b7fb4d2c869526a86eb6767a48fbd7bba2bbc622f3a7e51064a198b2c5
@@ -1,12 +1,11 @@
1
1
  language: ruby
2
2
  sudo: false
3
3
  rvm:
4
- - 1.9.3
5
4
  - 2.0
6
5
  - 2.1
6
+ - 2.2
7
7
  - ruby-head
8
- - jruby-19mode
9
- - jruby-head
8
+ - jruby
10
9
  - rbx-2
11
10
  matrix:
12
11
  allow_failures:
@@ -1,3 +1,19 @@
1
+ ### 0.2.0 / 2016-08-16
2
+
3
+ * Requires sslyze 0.12.x.
4
+ * Added {SSLyze::XML#each_invalid_target}.
5
+ * Added {SSLyze::XML#invalid_targets}.
6
+ * Added {SSLyze::InvalidTarget}.
7
+ * Added {SSLyze::Target#ssl_v2} alias.
8
+ * Added {SSLyze::Target#ssl_v3} alias.
9
+ * Added {SSLyze::Target#tls_v1} alias.
10
+ * Added {SSLyze::Target#tls_v1_1} alias.
11
+ * Added {SSLyze::Target#tls_v1_2} alias.
12
+ * Added {SSLyze::CertificateValidation#path?}.
13
+ * Added {SSLyze::CertificateValidation#results}.
14
+ * Fixed a bug in {SSLyze::CertInfo#validation} when the `certificateValidation`
15
+ node is omitted.
16
+
1
17
  ### 0.1.1 / 2015-12-08
2
18
 
3
19
  * `certificateValidation` may be omitted from `certinfo` if an OpenSSL
data/README.md CHANGED
@@ -17,7 +17,7 @@ A Ruby interface to [sslyze] python utility.
17
17
 
18
18
  * Provides a Ruby interface to `sslyze.py`.
19
19
  * Provides a Parser for consuming the sslyze XML output.
20
- * [sslyze] >= 0.12
20
+ * [sslyze] 0.12.x
21
21
 
22
22
  ## Examples
23
23
 
@@ -52,7 +52,7 @@ Parsing sslyze XML output:
52
52
 
53
53
  * [rprogram] ~> 0.3
54
54
  * [nokogiri] ~> 1.0
55
- * [sslyze] >= 0.12
55
+ * [sslyze] 0.12.x
56
56
 
57
57
  ## Install
58
58
 
@@ -27,6 +27,20 @@ module SSLyze
27
27
  Boolean[@node.at('hostnameValidation/@certificateMatchesServerHostname').value]
28
28
  end
29
29
 
30
+ #
31
+ # Retrieves the validation results for each trust store.
32
+ #
33
+ # @return [Hash{String => String}]
34
+ # The certificate store name and validation result.
35
+ #
36
+ # @since 0.2.0
37
+ #
38
+ def results
39
+ @path ||= Hash[@node.search('pathValidation').map { |path|
40
+ [path['usingTrustStore'], path['validationResult']]
41
+ }]
42
+ end
43
+
30
44
  #
31
45
  # Specifies whether the certificate path was validated against various
32
46
  # certificate stores.
@@ -35,10 +49,22 @@ module SSLyze
35
49
  # The certificate store name and validation result.
36
50
  #
37
51
  def path
38
- @path ||= Hash[@node.search('pathValidation').map { |path|
39
- [path['usingTrustStore'], path['validationResult'] == 'ok']
52
+ @path ||= Hash[results.map { |trust_store,result|
53
+ [trust_store, result == 'ok']
40
54
  }]
41
55
  end
42
56
 
57
+ #
58
+ # Determines whether the certificate was validated by all the certificate
59
+ # stores.
60
+ #
61
+ # @return [Boolean]
62
+ #
63
+ # @since 0.2.0
64
+ #
65
+ def path?
66
+ path.all? { |cert_store,trusted| trusted }
67
+ end
68
+
43
69
  end
44
70
  end
@@ -0,0 +1,35 @@
1
+ module SSLyze
2
+ #
3
+ # Represents the `<invalidTarget>` XML element.
4
+ #
5
+ class InvalidTarget
6
+
7
+ #
8
+ # Initializes the invalid target.
9
+ #
10
+ # @param [Nokogiri::XML::Node] node
11
+ # The `<invalid>` XML element.
12
+ #
13
+ def initialize(node)
14
+ @node = node
15
+ end
16
+
17
+ #
18
+ # The host name of the target.
19
+ #
20
+ # @return [String]
21
+ #
22
+ def host
23
+ @host ||= @node.text
24
+ end
25
+
26
+ #
27
+ # The error from the scan.
28
+ #
29
+ # @return [String]
30
+ #
31
+ def error
32
+ @ip ||= @node['error']
33
+ end
34
+ end
35
+ end
@@ -133,6 +133,8 @@ module SSLyze
133
133
  end
134
134
  end
135
135
 
136
+ alias ssl_v2 sslv2
137
+
136
138
  #
137
139
  # SSLv3 protocol information.
138
140
  #
@@ -144,6 +146,8 @@ module SSLyze
144
146
  end
145
147
  end
146
148
 
149
+ alias ssl_v3 sslv3
150
+
147
151
  #
148
152
  # TLSv1 protocol information.
149
153
  #
@@ -155,6 +159,8 @@ module SSLyze
155
159
  end
156
160
  end
157
161
 
162
+ alias tls_v1 tlsv1
163
+
158
164
  #
159
165
  # TLSv1.1 protocol information.
160
166
  #
@@ -166,6 +172,8 @@ module SSLyze
166
172
  end
167
173
  end
168
174
 
175
+ alias tls_v1_1 tlsv1_1
176
+
169
177
  #
170
178
  # TLSv1.2 protocol information.
171
179
  #
@@ -177,6 +185,8 @@ module SSLyze
177
185
  end
178
186
  end
179
187
 
188
+ alias tls_v1_2 tlsv1_2
189
+
180
190
  #
181
191
  # Iterates over every SSL protocol.
182
192
  #
@@ -1,4 +1,4 @@
1
1
  module SSLyze
2
2
  # ruby-sslyze version
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
@@ -1,4 +1,5 @@
1
1
  require 'sslyze/target'
2
+ require 'sslyze/invalid_target'
2
3
  require 'sslyze/types'
3
4
  require 'nokogiri'
4
5
 
@@ -90,12 +91,32 @@ module SSLyze
90
91
  end
91
92
 
92
93
  #
93
- # The invalid targets.
94
+ # @return [Array<InvalidTarget>]
94
95
  #
95
- # @raise [NotImplementedError]
96
+ # @see #each_invalid_target
97
+ #
98
+ # @since 0.2.0
96
99
  #
97
100
  def invalid_targets
98
- raise(NotImplementedError,"#{self.class}##{__method__} not implemented")
101
+ each_invalid_target.to_a
102
+ end
103
+
104
+ # Enumerates over each invalid target.
105
+ #
106
+ # @yield [invalidtarget]
107
+ #
108
+ # @yieldparam [InvalidTarget] invalid_target
109
+ #
110
+ # @return [Enumerator]
111
+ #
112
+ # @since 0.2.0
113
+ #
114
+ def each_invalid_target
115
+ return enum_for(__method__) unless block_given?
116
+
117
+ @doc.search('invalidTargets/invalidTarget').each do |inval|
118
+ yield InvalidTarget.new(inval)
119
+ end
99
120
  end
100
121
 
101
122
  #
@@ -17,6 +17,8 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ['lib']
19
19
 
20
+ gem.requirements << 'sslyze 0.12.x'
21
+
20
22
  gem.add_dependency 'rprogram', '~> 0.3'
21
23
  gem.add_dependency 'nokogiri', '~> 1.0'
22
24
 
@@ -13,8 +13,20 @@ describe SSLyze::CertificateValidation do
13
13
  end
14
14
  end
15
15
 
16
- describe "#path" do
16
+ describe "#results" do
17
17
  it "should parse the pathValidation elements into a Hash" do
18
+ expect(subject.results).to be == {
19
+ 'Mozilla NSS' => 'ok',
20
+ 'Microsoft' => 'ok',
21
+ 'Apple' => 'ok',
22
+ 'Java 6' => 'ok',
23
+ 'Google' => 'ok'
24
+ }
25
+ end
26
+ end
27
+
28
+ describe "#path" do
29
+ it "should check if each pathValidation/@validationResult is 'ok'" do
18
30
  expect(subject.path).to be == {
19
31
  'Mozilla NSS' => true,
20
32
  'Microsoft' => true,
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+ require 'xml_examples'
3
+ require 'sslyze/invalid_target'
4
+
5
+ describe SSLyze::InvalidTarget do
6
+ include_examples "XML specs"
7
+
8
+ subject { described_class.new(xml.at('/document/invalidTargets/invalidTarget')) }
9
+
10
+ describe "#host" do
11
+ it "must parse the host attribute" do
12
+ expect(subject.host).to be == '10.10.10.1:443'
13
+ end
14
+ end
15
+
16
+ describe "#error" do
17
+ it "must parse the ip attribute" do
18
+ expect(subject.error).to be == 'Could not connect (timeout)'
19
+ end
20
+ end
21
+ end
@@ -1,6 +1,9 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
2
  <document SSLyzeVersion="0.12.0" SSLyzeWeb="https://github.com/nabla-c0d3/sslyze" title="SSLyze Scan Results">
3
- <invalidTargets/>
3
+ <invalidTargets>
4
+ <invalidTarget error="Could not connect (timeout)">10.10.10.1:443</invalidTarget>
5
+ <invalidTarget error="Could not connect (timeout)">10.10.10.2:443</invalidTarget>
6
+ </invalidTargets>
4
7
  <results defaultTimeout="5" httpsTunnel="None" startTLS="None" totalScanTime="9.99340701103">
5
8
  <target host="github.com" ip="192.30.252.130" port="443">
6
9
  <certinfo argument="basic" title="Certificate Information">
@@ -103,6 +106,7 @@ XX4C2NesiZcLYbc2n7B9O+63M2k=
103
106
  <serialNumber>0C009310D206DBE337553580118DDC87</serialNumber>
104
107
  <subject>
105
108
  <serialNumber>5157550</serialNumber>
109
+ <organizationalUnitName>Information Security</organizationalUnitName>
106
110
  <organizationName>GitHub, Inc.</organizationName>
107
111
  <businessCategory>Private Organization</businessCategory>
108
112
  <jurisdictionCountryName>US</jurisdictionCountryName>
@@ -8,7 +8,9 @@ describe SSLyze::Certificate::Subject do
8
8
  subject { described_class.new(xml.at('/document/results/target/certinfo/certificateChain/certificate/subject')) }
9
9
 
10
10
  describe "#organizational_unit_name" do
11
- pending "need data"
11
+ it "should parse the organizationUnitName element" do
12
+ expect(subject.organizational_unit_name).to be == 'Information Security'
13
+ end
12
14
  end
13
15
 
14
16
  describe "#organization_name" do
@@ -47,14 +47,18 @@ describe SSLyze::XML do
47
47
  end
48
48
 
49
49
  describe "#invalid_targets" do
50
- pending "need data"
50
+ it "should return an Array of Strings" do
51
+ val = subject.invalid_targets
52
+ expect(val).to be_an(Array).and(all(be_a(InvalidTarget)))
53
+ expect(val.size).to be == 2
54
+ end
51
55
  end
52
56
 
53
- describe "#each_target" do
54
- it "should iterate over each target element under results" do
57
+ describe "#each_invalid_target" do
58
+ it "should iterate over each invalid target element under results" do
55
59
  expect { |b|
56
- subject.each_target(&b)
57
- }.to yield_successive_args(Target, Target, Target)
60
+ subject.each_invalid_target(&b)
61
+ }.to yield_successive_args(InvalidTarget, InvalidTarget)
58
62
  end
59
63
  end
60
64
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-sslyze
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hal Brodigan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-08 00:00:00.000000000 Z
11
+ date: 2016-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rprogram
@@ -89,6 +89,7 @@ files:
89
89
  - lib/sslyze/certificate_chain.rb
90
90
  - lib/sslyze/certificate_validation.rb
91
91
  - lib/sslyze/cipher_suite.rb
92
+ - lib/sslyze/invalid_target.rb
92
93
  - lib/sslyze/key_exchange.rb
93
94
  - lib/sslyze/ocsp_response.rb
94
95
  - lib/sslyze/program.rb
@@ -105,6 +106,7 @@ files:
105
106
  - spec/certificate_spec.rb
106
107
  - spec/certificate_validation_spec.rb
107
108
  - spec/cipher_suite_spec.rb
109
+ - spec/invalid_target_spec.rb
108
110
  - spec/issuer_spec.rb
109
111
  - spec/key_exchange_spec.rb
110
112
  - spec/ocsp_response_spec.rb
@@ -135,9 +137,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
137
  - - ">="
136
138
  - !ruby/object:Gem::Version
137
139
  version: '0'
138
- requirements: []
140
+ requirements:
141
+ - sslyze 0.12.x
139
142
  rubyforge_project:
140
- rubygems_version: 2.4.5
143
+ rubygems_version: 2.4.7
141
144
  signing_key:
142
145
  specification_version: 4
143
146
  summary: Ruby interface to sslyze
@@ -148,6 +151,7 @@ test_files:
148
151
  - spec/certificate_spec.rb
149
152
  - spec/certificate_validation_spec.rb
150
153
  - spec/cipher_suite_spec.rb
154
+ - spec/invalid_target_spec.rb
151
155
  - spec/issuer_spec.rb
152
156
  - spec/key_exchange_spec.rb
153
157
  - spec/ocsp_response_spec.rb