pact_broker 2.14.0 → 2.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1bff63de2839f330d5263f10405807c379b9bf19
4
- data.tar.gz: dca5739d3c0ac1ff475d562cbef60aa1f7f4dca5
3
+ metadata.gz: 404111dc7e6ebc927394295e7d75df78fdd1a1e3
4
+ data.tar.gz: 52f7cbf51020f206ae07a5a876c4d04d4adecec8
5
5
  SHA512:
6
- metadata.gz: 670ad21e3643323cd4aab278693fe568462121f7df52f98244fc3575c0a23d8b09368091b528cb52757d6304fe0485645630a76ecde396df887703acb9282da4
7
- data.tar.gz: 05e0e8605022baba6a5b6b09be2812e1c628fde7d0b287e72796a63b6c7f07c3620e18fb93acfe5ab979db14b85333088a1dba15eef390008ab6aaef08852ece
6
+ metadata.gz: b0e7b2db30b4e2f4045cfb391c23b88df8384676d314e867bdc7ef72597eadce0f0abf6c13bd6186269bb01573e71b912cfa34a307ddef2cf8076a2977d72020
7
+ data.tar.gz: afd391d5952f47ac4278c676e2846521b94b6d58fdc7c6658697dfbbcb0d8f9b2e4e77b160c605a6abf8353854bdfc4fa958669ba72ef4d75bf48c1835bdcd9d
data/.gitignore CHANGED
@@ -13,6 +13,7 @@ test/tmp
13
13
  test/version_tmp
14
14
  tmp
15
15
  reports
16
+ dev
16
17
 
17
18
  # YARD artifacts
18
19
  .yardoc
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.3.4
1
+ 2.4.0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ <a name="v2.15.0"></a>
2
+ ### v2.15.0 (2018-02-26)
3
+
4
+
5
+ #### Features
6
+
7
+ * upgrade to latest versions of padrino-core and sinatra to fix CVE-2018-7212 ([08ba1cb](/../../commit/08ba1cb))
8
+
9
+ * **http**
10
+ * set http options globally ([cdf36ba](/../../commit/cdf36ba))
11
+
12
+ * **ssl**
13
+ * allow single certificates to be uploaded ([9417f10](/../../commit/9417f10))
14
+
15
+
1
16
  <a name="v2.14.0"></a>
2
17
  ### v2.14.0 (2018-02-15)
3
18
 
data/CONTRIBUTING.md CHANGED
@@ -7,15 +7,23 @@ Please provide the following information with your issue to enable us to respond
7
7
 
8
8
  * The relevant versions of the gems or packages you are using.
9
9
  * The steps to recreate your issue.
10
- * An executable code example where possible. You can use the [pact-ruby-e2e-example] codebase to quickly recreate your issue.
11
- * Where you are using a pact broker deployed on third party infrastructure, please include the relevant details.
10
+ * An executable code example where possible.
11
+ * Details of the environment the Pact Broker is deployed in (eg. docker, AWS, local machine)
12
12
 
13
13
  # Pull requests
14
+
14
15
  * Write tests for any changes
15
16
  * Follow existing code style and conventions
16
17
  * Separate unrelated changes into multiple pull requests
18
+ * [Squash your commits](squash) into one commit before submitting your PR.
19
+ * Use [semantic commit messages](semantic-commit-messages) so that your changes will show up correctly in the generated change log.
20
+
17
21
  * For bigger changes, make sure you start a discussion first by creating an issue and explaining the intended change
18
22
 
23
+ See [DEVELOPER_SETUP.md](./DEVELOPER_SETUP.md) and [DEVELOPER_DOCUMENTATION.md](./DEVELOPER_DOCUMENTATION.md) for more information.
24
+
19
25
  [wiki]: https://github.com/pact-foundation/pact_broker/wiki
20
26
  [stackoverflow]: https://stackoverflow.com/questions/tagged/pact-broker
21
27
  [pact-ruby-e2e-example]: https://github.com/pact-foundation/pact-ruby-e2e-example
28
+ [semantic-commit-messages]: http://karma-runner.github.io/2.0/dev/git-commit-msg.html
29
+ [squash]: https://github.com/todotxt/todo.txt-android/wiki/Squash-All-Commits-Related-to-a-Single-Issue-into-a-Single-Commit
@@ -0,0 +1,15 @@
1
+ # Developer setup
2
+
3
+ * You will need to install Ruby 2.4, and preferably a ruby version manager. I recommend using [chruby](chruby) and [ruby-install](ruby-install).
4
+ * Install bundler (the Ruby gem dependency manager) `gem install bundler`
5
+ * Check out the pact_broker repository.
6
+ * Run `bundle exec pact_broker:dev:setup`. This will create an example application that you can run locally, that uses the local source code.
7
+ * To run the example:
8
+
9
+ cd dev
10
+ bundle exec rackup
11
+
12
+ * The application will be available on `http://localhost:9292`
13
+
14
+ [chruby]: https://github.com/postmodern/chruby
15
+ [ruby-install]: https://github.com/postmodern/ruby-install
data/README.md CHANGED
@@ -59,6 +59,8 @@ The following funcationality is in beta release. Your feedback would be apprecia
59
59
  1. The Consumer CI determines if the pact has been verified by running `pact-broker can-i-deploy --pacticipant CONSUMER_NAME --version CONSUMER_VERSION ...` (see documentation [here](https://github.com/pact-foundation/pact_broker-client#can-i-deploy))
60
60
  1. If the pact has been verified, the deployment can proceed.
61
61
 
62
+ Read more about how to use the Pact Broker in the [overview][overview] on the wiki page.
63
+
62
64
  ## Documentation
63
65
 
64
66
  See the [wiki][wiki] for documentation on the Pact Broker.
@@ -163,3 +165,4 @@ Please read the [UPGRADING.md](UPGRADING.md) documentation before upgrading your
163
165
  [pact-docs]: http://docs.pact.io
164
166
  [cli]: https://github.com/pact-foundation/pact-ruby-standalone/releases
165
167
  [travisyml]: https://github.com/pact-foundation/pact_broker/blob/master/.travis.yml
168
+ [overview]: https://github.com/pact-foundation/pact_broker/wiki/Overview
@@ -3,6 +3,7 @@ require 'uri'
3
3
  require 'pact_broker/project_root'
4
4
  require 'pact_broker/logging'
5
5
  require 'pact_broker/configuration'
6
+ require 'pact_broker/build_http_options'
6
7
 
7
8
  module PactBroker
8
9
  module Badges
@@ -102,12 +103,10 @@ module PactBroker
102
103
  def do_request(uri)
103
104
  with_cache uri do
104
105
  request = Net::HTTP::Get.new(uri)
105
- Net::HTTP.start(uri.hostname, uri.port,
106
- use_ssl: uri.scheme == 'https',
107
- read_timeout: 3,
108
- open_timeout: 1,
109
- ssl_timeout: 1,
110
- continue_timeout: 1) do |http|
106
+ options = {read_timeout: 3, open_timeout: 1, ssl_timeout: 1, continue_timeout: 1}
107
+ options.merge! PactBroker::BuildHttpOptions.call(uri)
108
+
109
+ Net::HTTP.start(uri.hostname, uri.port, :ENV, options) do |http|
111
110
  http.request request
112
111
  end
113
112
  end
@@ -0,0 +1,32 @@
1
+ require 'pact_broker/services'
2
+
3
+ module PactBroker
4
+ class BuildHttpOptions
5
+ extend PactBroker::Services
6
+
7
+ def self.call uri
8
+ uri = URI(uri)
9
+ options = {}
10
+
11
+ if uri.scheme == 'https'
12
+ options[:use_ssl] = true
13
+ options[:cert_store] = cert_store
14
+ if disable_ssl_verification?
15
+ options[:verify_mode] = OpenSSL::SSL::VERIFY_NONE
16
+ else
17
+ options[:verify_mode] = OpenSSL::SSL::VERIFY_PEER
18
+ end
19
+ end
20
+ options
21
+ end
22
+
23
+ def self.disable_ssl_verification?
24
+ PactBroker.configuration.disable_ssl_verification
25
+ end
26
+
27
+ def self.cert_store
28
+ certificate_service.cert_store
29
+ end
30
+ end
31
+ end
32
+
@@ -25,7 +25,7 @@ module PactBroker
25
25
 
26
26
  def find_all_certificates
27
27
  Certificate.collect do | certificate |
28
- cert_arr = certificate.content.split(/(-----END [^\-]+-----)/).each_slice(2).map(&:join)
28
+ cert_arr = certificate.content.split(/(-----END [^\-]+-----)/).each_slice(2).map(&:join).map(&:strip).select{|s| !s.empty?}
29
29
  cert_arr.collect do |c|
30
30
  begin
31
31
  OpenSSL::X509::Certificate.new(c)
@@ -18,7 +18,8 @@ module PactBroker
18
18
  :shields_io_base_url,
19
19
  :check_for_potential_duplicate_pacticipant_names,
20
20
  :webhook_retry_schedule,
21
- :semver_formats
21
+ :semver_formats,
22
+ :disable_ssl_verification
22
23
  ]
23
24
 
24
25
  attr_accessor :log_dir, :database_connection, :auto_migrate_db, :use_hal_browser, :html_pact_renderer
@@ -28,6 +29,7 @@ module PactBroker
28
29
  attr_accessor :semver_formats
29
30
  attr_accessor :enable_public_badge_access, :shields_io_base_url
30
31
  attr_accessor :webhook_retry_schedule
32
+ attr_accessor :disable_ssl_verification
31
33
  attr_writer :logger
32
34
 
33
35
  def initialize
@@ -60,6 +62,7 @@ module PactBroker
60
62
  config.semver_formats = ["%M.%m.%p%s%d", "%M.%m", "%M"]
61
63
  config.webhook_retry_schedule = [10, 60, 120, 300, 600, 1200] #10 sec, 1 min, 2 min, 5 min, 10 min, 20 min => 38 minutes
62
64
  config.check_for_potential_duplicate_pacticipant_names = true
65
+ config.disable_ssl_verification = false
63
66
  config
64
67
  end
65
68
 
@@ -1,3 +1,4 @@
1
+ require 'pact_broker/build_http_options'
1
2
  require 'pact_broker/domain/webhook_request_header'
2
3
  require 'pact_broker/domain/webhook_execution_result'
3
4
  require 'pact_broker/logging'
@@ -5,7 +6,7 @@ require 'pact_broker/messages'
5
6
  require 'net/http'
6
7
  require 'pact_broker/webhooks/redact_logs'
7
8
  require 'pact_broker/api/pact_broker_urls'
8
- require 'pact_broker/services'
9
+ require 'pact_broker/build_http_options'
9
10
 
10
11
  module PactBroker
11
12
 
@@ -24,7 +25,6 @@ module PactBroker
24
25
 
25
26
  include PactBroker::Logging
26
27
  include PactBroker::Messages
27
- include PactBroker::Services
28
28
 
29
29
  attr_accessor :method, :url, :headers, :body, :username, :password, :uuid
30
30
 
@@ -104,13 +104,8 @@ module PactBroker
104
104
 
105
105
  def do_request uri, req
106
106
  logger.info "Making webhook #{uuid} request #{to_s}"
107
- options = {}
108
- if uri.scheme == 'https'
109
- options[:use_ssl] = true
110
- options[:verify_mode] = OpenSSL::SSL::VERIFY_PEER
111
- options[:cert_store] = cert_store
112
- end
113
- Net::HTTP.start(uri.hostname, uri.port, options) do |http|
107
+ options = PactBroker::BuildHttpOptions.call(uri)
108
+ Net::HTTP.start(uri.hostname, uri.port, :ENV, options) do |http|
114
109
  http.request req
115
110
  end
116
111
  end
@@ -174,10 +169,6 @@ module PactBroker
174
169
  escaped_pact_url = CGI::escape(pact_url)
175
170
  url.gsub('${pactbroker.pactUrl}', escaped_pact_url)
176
171
  end
177
-
178
- def cert_store
179
- certificate_service.cert_store
180
- end
181
172
  end
182
173
  end
183
174
  end
@@ -1,3 +1,3 @@
1
1
  module PactBroker
2
- VERSION = '2.14.0'
2
+ VERSION = '2.15.0'
3
3
  end
data/pact_broker.gemspec CHANGED
@@ -32,7 +32,8 @@ Gem::Specification.new do |gem|
32
32
  gem.add_runtime_dependency 'rack', '~>2.0'
33
33
  gem.add_runtime_dependency 'redcarpet', '>=3.3.2', '~>3.3'
34
34
  gem.add_runtime_dependency 'pact-support'
35
- gem.add_runtime_dependency 'padrino-core', '~>0.14.1'
35
+ gem.add_runtime_dependency 'padrino-core', '>= 0.14.3', '~> 0.14'
36
+ gem.add_runtime_dependency 'sinatra', '>= 2.0.1'
36
37
  gem.add_runtime_dependency 'haml', '~>4.0'
37
38
  gem.add_runtime_dependency 'sucker_punch', '~>2.0'
38
39
  gem.add_runtime_dependency 'rack-protection', '~>2.0'
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+ require 'pact_broker/build_http_options'
3
+
4
+ module PactBroker
5
+ describe BuildHttpOptions do
6
+
7
+ subject { PactBroker::BuildHttpOptions.call(url) }
8
+
9
+ context "default http options" do
10
+ before do
11
+ PactBroker.configuration.disable_ssl_verification = false
12
+ end
13
+
14
+ describe "when given an insecure URL" do
15
+ let(:url) { 'http://example.org/insecure' }
16
+
17
+ it "should provide an empty configuration object" do
18
+ expect(subject).to eq({})
19
+ end
20
+
21
+ end
22
+
23
+ describe "when given a secure URL" do
24
+ let(:url) { 'https://example.org/secure' }
25
+
26
+ it "should validate the full certificate chain" do
27
+ expect(subject).to include({:use_ssl => true, :verify_mode => 1})
28
+ end
29
+
30
+ end
31
+ end
32
+
33
+ context "disable_ssl_verification is set to true" do
34
+ before do
35
+ PactBroker.configuration.disable_ssl_verification = true
36
+ end
37
+
38
+ let(:url) { 'https://example.org/secure' }
39
+
40
+ describe "when given a secure URL" do
41
+ it "should not validate certificates" do
42
+ expect(subject).to include({:use_ssl => true, :verify_mode => 0})
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -36,12 +36,21 @@ module PactBroker
36
36
 
37
37
  subject { Service.find_all_certificates }
38
38
 
39
- context "with a valid certificate file" do
39
+ context "with a valid certificate chain" do
40
40
  it "returns all the X509 Certificate objects" do
41
41
  expect(subject.size).to eq 2
42
42
  end
43
43
  end
44
44
 
45
+ context "with a valid CA file" do
46
+ let(:certificate_content) { File.read('spec/fixtures/certificates/cacert.pem') }
47
+
48
+ it "returns all the X509 Certificate objects" do
49
+ expect(PactBroker.logger).to_not receive(:error).with(/Error.*1234/)
50
+ expect(subject.size).to eq 1
51
+ end
52
+ end
53
+
45
54
  context "with an invalid certificate file" do
46
55
  let(:certificate_content) { File.read('spec/fixtures/certificate-invalid.pem') }
47
56
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact_broker
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.14.0
4
+ version: 2.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bethany Skurrie
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-02-15 00:00:00.000000000 Z
13
+ date: 2018-02-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
@@ -182,16 +182,36 @@ dependencies:
182
182
  name: padrino-core
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: 0.14.3
185
188
  - - "~>"
186
189
  - !ruby/object:Gem::Version
187
- version: 0.14.1
190
+ version: '0.14'
188
191
  type: :runtime
189
192
  prerelease: false
190
193
  version_requirements: !ruby/object:Gem::Requirement
191
194
  requirements:
195
+ - - ">="
196
+ - !ruby/object:Gem::Version
197
+ version: 0.14.3
192
198
  - - "~>"
193
199
  - !ruby/object:Gem::Version
194
- version: 0.14.1
200
+ version: '0.14'
201
+ - !ruby/object:Gem::Dependency
202
+ name: sinatra
203
+ requirement: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - ">="
206
+ - !ruby/object:Gem::Version
207
+ version: 2.0.1
208
+ type: :runtime
209
+ prerelease: false
210
+ version_requirements: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - ">="
213
+ - !ruby/object:Gem::Version
214
+ version: 2.0.1
195
215
  - !ruby/object:Gem::Dependency
196
216
  name: haml
197
217
  requirement: !ruby/object:Gem::Requirement
@@ -494,6 +514,7 @@ files:
494
514
  - CHANGELOG.md
495
515
  - CONTRIBUTING.md
496
516
  - DEVELOPER_DOCUMENTATION.md
517
+ - DEVELOPER_SETUP.md
497
518
  - Gemfile
498
519
  - LICENSE.txt
499
520
  - README.md
@@ -694,6 +715,7 @@ files:
694
715
  - lib/pact_broker/api/resources/webhooks.rb
695
716
  - lib/pact_broker/app.rb
696
717
  - lib/pact_broker/badges/service.rb
718
+ - lib/pact_broker/build_http_options.rb
697
719
  - lib/pact_broker/certificates/certificate.rb
698
720
  - lib/pact_broker/certificates/service.rb
699
721
  - lib/pact_broker/config/load.rb
@@ -985,6 +1007,7 @@ files:
985
1007
  - spec/lib/pact_broker/api/resources/webhooks_spec.rb
986
1008
  - spec/lib/pact_broker/app_spec.rb
987
1009
  - spec/lib/pact_broker/badges/service_spec.rb
1010
+ - spec/lib/pact_broker/build_http_options_spec.rb
988
1011
  - spec/lib/pact_broker/certificates/service_spec.rb
989
1012
  - spec/lib/pact_broker/config/load_spec.rb
990
1013
  - spec/lib/pact_broker/config/save_and_load_spec.rb
@@ -1248,6 +1271,7 @@ test_files:
1248
1271
  - spec/lib/pact_broker/api/resources/webhooks_spec.rb
1249
1272
  - spec/lib/pact_broker/app_spec.rb
1250
1273
  - spec/lib/pact_broker/badges/service_spec.rb
1274
+ - spec/lib/pact_broker/build_http_options_spec.rb
1251
1275
  - spec/lib/pact_broker/certificates/service_spec.rb
1252
1276
  - spec/lib/pact_broker/config/load_spec.rb
1253
1277
  - spec/lib/pact_broker/config/save_and_load_spec.rb