cert_munger 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: 2f3d57b7cab1e4d9a8e8e12854e7df697a67d4aa
4
- data.tar.gz: 1b05487531aa24fe809d72b4042363702dc18a19
3
+ metadata.gz: cc7848d1decd68591525ba643fd8be3bb5979a86
4
+ data.tar.gz: b8a591e0183a08976a6ffde4f4875101ec60f3d7
5
5
  SHA512:
6
- metadata.gz: bfeab5bd41b934d4838c42c6ecd83b3917eb3cb312eee4f1b689c95ae86474e8e92b5da0be7ec576e842453dc52e357ccabcd3c0273c6a79368c903edeb7a516
7
- data.tar.gz: 8d2fa7bd0d5f54cab96cbae8d15bc546e23f09d4d573a7b750ddf2c35b58a69537ab2e3ad02bfe3e0dc52b3f11818c9daf5e2b8da3d404cfd3cef061d9e1aa70
6
+ metadata.gz: ba26f682f4dade354b79f8be9595e3564d981fcf7058e2eea70201f6947393f6dc221210784a72625cfc6ffee44d7a3104c3fdc4dece4ff4b1420f292f2083fd
7
+ data.tar.gz: 6766db9c810b9c6da996b4efb58a914f5ee20c123d91832fcafd5fdd77b266b8159d15b019f515d4c94583ee6657387daa00caae6a1c104b844214bc83f5a8f4
checksums.yaml.gz.sig CHANGED
Binary file
data/.travis.yml CHANGED
@@ -3,9 +3,8 @@ cache: bundler
3
3
 
4
4
  rvm:
5
5
  - ruby-head
6
- - jruby-head
7
- - 2.1.2
8
- - 2.1.1
6
+ - 2.2.3
7
+ - 2.1.6
9
8
  - 2.0.0
10
9
  - 1.9.3
11
10
 
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # CertMunger [![Gem Version](https://badge.fury.io/rb/cert_munger.png)](http://badge.fury.io/rb/cert_munger)
2
2
 
3
- [![Travis CI](https://travis-ci.org/stevenhaddox/cert_munger.svg?branch=master)](https://travis-ci.org/stevenhaddox/cert_munger) [![Dependency Status](https://gemnasium.com/stevenhaddox/cert_munger.png)](https://gemnasium.com/stevenhaddox/cert_munger) [![Coverage Status](https://coveralls.io/repos/stevenhaddox/cert_munger/badge.png)](https://coveralls.io/r/stevenhaddox/cert_munger) [![Code Climate](https://codeclimate.com/github/stevenhaddox/cert_munger/badges/gpa.svg)](https://codeclimate.com/github/stevenhaddox/cert_munger) [![Inline docs](http://inch-ci.org/github/stevenhaddox/cert_munger.svg?branch=master)](http://inch-ci.org/github/stevenhaddox/cert_munger)
3
+ [![Travis CI](https://travis-ci.org/stevenhaddox/cert_munger.svg?branch=master)](https://travis-ci.org/stevenhaddox/cert_munger) [![Dependency Status](https://gemnasium.com/stevenhaddox/cert_munger.png)](https://gemnasium.com/stevenhaddox/cert_munger) [![Test Coverage](https://codeclimate.com/github/stevenhaddox/cert_munger/badges/coverage.svg)](https://codeclimate.com/github/stevenhaddox/cert_munger/coverage) [![Code Climate](https://codeclimate.com/github/stevenhaddox/cert_munger/badges/gpa.svg)](https://codeclimate.com/github/stevenhaddox/cert_munger) [![Inline docs](http://inch-ci.org/github/stevenhaddox/cert_munger.svg?branch=master)](http://inch-ci.org/github/stevenhaddox/cert_munger)
4
4
 
5
5
  A gem that takes string input for X509 certificates and attempts to reformat
6
6
  them into a valid certificate. This gem extends the core String class to add
data/Rakefile CHANGED
@@ -1,10 +1,8 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rspec/core/rake_task'
3
3
  require 'rubocop/rake_task'
4
- require 'coveralls/rake/task'
5
- Coveralls::RakeTask.new
6
4
 
7
- task default: [:spec, :rubocop, 'coveralls:push']
5
+ task default: [:spec, :rubocop]
8
6
 
9
7
  desc 'Run specs'
10
8
  RSpec::Core::RakeTask.new(:spec)
data/cert_munger.gemspec CHANGED
@@ -23,13 +23,12 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_development_dependency 'awesome_print', '~> 1.2'
25
25
  spec.add_development_dependency 'bundler', '~> 1.6'
26
- spec.add_development_dependency 'coveralls', '~> 0.7'
26
+ spec.add_development_dependency 'codeclimate-test-reporter'
27
27
  spec.add_development_dependency 'rack', '~> 1.5'
28
28
  spec.add_development_dependency 'rack-test', '~> 0.6'
29
29
  spec.add_development_dependency 'rake', '~> 10.0'
30
30
  spec.add_development_dependency 'rubocop', '~> 0.27'
31
31
  spec.add_development_dependency 'rspec', '~> 3.1'
32
- spec.add_development_dependency 'simplecov', '~> 0.9'
33
32
  spec.add_development_dependency 'yard', '~> 0.8'
34
33
 
35
34
  spec.cert_chain = ['certs/stevenhaddox.pem']
@@ -63,12 +63,32 @@ module CertMunger
63
63
  # @param raw_cert [String] The string of text you wish to parse into a cert
64
64
  # @return [String] reformatted certificate body
65
65
  def one_line_contents(raw_cert)
66
- cert_contents = raw_cert.split('\n')
67
- cert_contents.pop
68
- cert_contents.shift
66
+ # Detect if we have newlines, if not, split on spaces
67
+ if raw_cert.include?('\n')
68
+ cert_contents = raw_cert.split('\n')
69
+ else
70
+ cert_contents = parse_space_delimited_cert(raw_cert)
71
+ end
72
+ cert_contents.pop # Remove -----BEGIN CERTIFICATE-----
73
+ cert_contents.shift # Remove -----END CERTIFICATE-----
74
+
69
75
  cert_contents.map! { |el| el.match('\W+[t|n|r](.*)')[1] }
70
76
  end
71
77
 
78
+ # Attempts to reformat one-line certificate bodies
79
+ #
80
+ # @param raw_cert [String] The string of text you wish to parse into a cert
81
+ # @return [Array] reformatted certificate content in Array format
82
+ def parse_space_delimited_cert(raw_cert)
83
+ cert_contents = raw_cert.split(' ')
84
+ # "-----BEGIN CERTIFICATE------" fix
85
+ cert_contents[0] += " #{cert_contents.delete_at(1)}"
86
+ # "-----END CERTIFICATE------" fix
87
+ cert_contents[-1] = "#{cert_contents[-2]} #{cert_contents.delete_at(-1)}"
88
+
89
+ cert_contents.map { |el| "\\t#{el}" } # Hack it to match expected syntax
90
+ end
91
+
72
92
  # Attempts to reformat multi-line certificate bodies
73
93
  #
74
94
  # @param raw_cert [String] The string of text you wish to parse into a cert
@@ -1,3 +1,3 @@
1
1
  module CertMunger
2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JSkqhJ4Bhff/Ol2RcDjEt4U6Hne6lRVB9qCAz0gE8MN4HagWOlS1U Nxd+cde+JIVBHuDz63gExGPCdLBRL/Mi3LORpZT41/ryw3JCqTir0dgPXsVTtJPr iMZ2EcsmShyBUKKj2AIok5gZzgM= -----END CERTIFICATE-----
@@ -15,6 +15,7 @@ describe CertMunger do
15
15
  let!(:certificate) { OpenSSL::X509::Certificate.new(raw_cert) }
16
16
  let!(:malformed_cert) { File.read("spec/certs/malformed.crt") }
17
17
  let!(:one_line_cert) { File.read("spec/certs/one_line.crt") }
18
+ let!(:one_line_spaces_cert) { File.read("spec/certs/one_line_spaces.crt") }
18
19
  let!(:passenger_nginx_cert) { File.read("spec/certs/passenger.crt") }
19
20
 
20
21
  #
@@ -36,6 +37,11 @@ describe CertMunger do
36
37
  new_cert = subject.to_cert(one_line_cert)
37
38
  expect(new_cert.to_s).to eq(certificate.to_s)
38
39
  end
40
+
41
+ it "should parse a certificate with all content in one line, space delimited" do
42
+ new_cert = subject.to_cert(one_line_spaces_cert)
43
+ expect(new_cert.to_s).to eq(certificate.to_s)
44
+ end
39
45
  end
40
46
 
41
47
  describe "#to_cert" do
data/spec/spec_helper.rb CHANGED
@@ -1,10 +1,5 @@
1
- require 'simplecov'
2
- require 'coveralls'
3
- SimpleCov.formatter = Coveralls::SimpleCov::Formatter
4
- SimpleCov.start do
5
- add_filter '/spec/'
6
- end
7
- # SimpleCov always comes before **anything** else
1
+ require "codeclimate-test-reporter"
2
+ CodeClimate::TestReporter.start
8
3
 
9
4
  require_relative '../lib/cert_munger'
10
5
  require 'awesome_print'
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cert_munger
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
  - Steven Haddox
@@ -30,7 +30,7 @@ cert_chain:
30
30
  42qdwEXvvkODZAD6KAIXPdmbMfBgPbcd+B/4eUA0PyKo+4dgL1NuqX4MPWToevIZ
31
31
  O8EKLF2X7NmC6FY1bOsSj/J8r1SOkx0rxgF+geRvY1P+hfNjDfxTsjU=
32
32
  -----END CERTIFICATE-----
33
- date: 2014-11-19 00:00:00.000000000 Z
33
+ date: 2015-10-07 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: logging
@@ -75,19 +75,19 @@ dependencies:
75
75
  - !ruby/object:Gem::Version
76
76
  version: '1.6'
77
77
  - !ruby/object:Gem::Dependency
78
- name: coveralls
78
+ name: codeclimate-test-reporter
79
79
  requirement: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - "~>"
81
+ - - ">="
82
82
  - !ruby/object:Gem::Version
83
- version: '0.7'
83
+ version: '0'
84
84
  type: :development
85
85
  prerelease: false
86
86
  version_requirements: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - "~>"
88
+ - - ">="
89
89
  - !ruby/object:Gem::Version
90
- version: '0.7'
90
+ version: '0'
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rack
93
93
  requirement: !ruby/object:Gem::Requirement
@@ -158,20 +158,6 @@ dependencies:
158
158
  - - "~>"
159
159
  - !ruby/object:Gem::Version
160
160
  version: '3.1'
161
- - !ruby/object:Gem::Dependency
162
- name: simplecov
163
- requirement: !ruby/object:Gem::Requirement
164
- requirements:
165
- - - "~>"
166
- - !ruby/object:Gem::Version
167
- version: '0.9'
168
- type: :development
169
- prerelease: false
170
- version_requirements: !ruby/object:Gem::Requirement
171
- requirements:
172
- - - "~>"
173
- - !ruby/object:Gem::Version
174
- version: '0.9'
175
161
  - !ruby/object:Gem::Dependency
176
162
  name: yard
177
163
  requirement: !ruby/object:Gem::Requirement
@@ -211,6 +197,7 @@ files:
211
197
  - spec/certs/create_spec_cert.rb
212
198
  - spec/certs/malformed.crt
213
199
  - spec/certs/one_line.crt
200
+ - spec/certs/one_line_spaces.crt
214
201
  - spec/certs/passenger.crt
215
202
  - spec/certs/ruby_user.crt
216
203
  - spec/certs/ruby_user.pub
@@ -237,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
237
224
  version: '0'
238
225
  requirements: []
239
226
  rubyforge_project:
240
- rubygems_version: 2.4.4
227
+ rubygems_version: 2.4.5.1
241
228
  signing_key:
242
229
  specification_version: 4
243
230
  summary: Reformat commonly malformatted X509 strings.
@@ -245,6 +232,7 @@ test_files:
245
232
  - spec/certs/create_spec_cert.rb
246
233
  - spec/certs/malformed.crt
247
234
  - spec/certs/one_line.crt
235
+ - spec/certs/one_line_spaces.crt
248
236
  - spec/certs/passenger.crt
249
237
  - spec/certs/ruby_user.crt
250
238
  - spec/certs/ruby_user.pub
metadata.gz.sig CHANGED
Binary file