vault-tools 2.0.0 → 2.1.1

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
  SHA256:
3
- metadata.gz: 9265591e92a631fd1b996644985ee742c622ac3259412dc5b7ca2e6ff3c7aebe
4
- data.tar.gz: b01e51fe465c1a001685bd909fcbfec83757005cad808b34918328af0fca4906
3
+ metadata.gz: 760a137b1c3e642183950c4e765d3ec9b60c327178b2faac45ff7048d94f9d82
4
+ data.tar.gz: 6743dd1b28722d7995215b8d9d6a9fc615572a97447fc64df5666d3f452bbe89
5
5
  SHA512:
6
- metadata.gz: 3910495873e72ce2299d303118e790fa42f22ec6acd0fe440d2d1ca595a394e50afc30e58751a352db9b5ed87f6448aa88db042ab8059bee6b9b58da53376df7
7
- data.tar.gz: 4dd78be8dec844bb89a2729309ffe80f8084736c9535e0d74ecf8a352cffde2fa9f548cc303443732aa0e750ae5c0074257adeae54e28f38c72548c804dab6d8
6
+ metadata.gz: f0b647bf7ab47175b9337434f2c9064f4ee89318f2df3aebb3e2354a47fde6edcab89a713a864e6b94d32651d755a267ea5ea502b197481d6ba8fb7f3b05183b
7
+ data.tar.gz: c2a4280ee1a422e1a80016afaa62b22ee3c7489bcc4a5b510b2aa485267bbf9564fb34aa1f6c9ce82593ceef698a11e44e5dc95a19221a1068f6306fd02033a7
@@ -0,0 +1,15 @@
1
+ version: 2.1
2
+
3
+ jobs:
4
+ build:
5
+ docker:
6
+ - image: circleci/ruby:2.7.1
7
+
8
+ steps:
9
+ - checkout
10
+ - run: export BUNDLE_GEMFILE=$PWD/Gemfile
11
+ - run: ruby --version
12
+ - run: gem update --system
13
+ - run: gem install bundler -v '< 2'
14
+ - run: bundle install --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}
15
+ - run: bundle exec rake
data/CODEOWNERS ADDED
@@ -0,0 +1,2 @@
1
+ # Comment line immediately above ownership line is reserved for related gus information. Please be careful while editing.
2
+ #ECCN:Open Source
data/Gemfile CHANGED
@@ -4,13 +4,12 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  group :development do
7
- gem 'rake', '~> 12.3'
7
+ gem 'rake', '~> 13.0'
8
8
  gem 'shotgun', '~> 0.9.2'
9
9
  gem 'yard-sinatra'
10
10
  end
11
11
 
12
12
  group :test do
13
- gem 'guard-minitest'
14
13
  gem 'minitest-around'
15
- gem 'vault-test-tools', '~> 1.0.0'
14
+ gem 'vault-test-tools', '~> 1.1.0'
16
15
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vault-tools (2.0.0)
4
+ vault-tools (2.1.1)
5
5
  aws-sdk-s3 (~> 1.0)
6
6
  coderay
7
7
  excon
@@ -16,74 +16,75 @@ PATH
16
16
  GEM
17
17
  remote: https://rubygems.org/
18
18
  specs:
19
- aws-eventstream (1.0.1)
20
- aws-partitions (1.127.0)
21
- aws-sdk-core (3.44.1)
22
- aws-eventstream (~> 1.0)
23
- aws-partitions (~> 1.0)
24
- aws-sigv4 (~> 1.0)
19
+ aws-eventstream (1.1.1)
20
+ aws-partitions (1.491.0)
21
+ aws-sdk-core (3.119.1)
22
+ aws-eventstream (~> 1, >= 1.0.2)
23
+ aws-partitions (~> 1, >= 1.239.0)
24
+ aws-sigv4 (~> 1.1)
25
25
  jmespath (~> 1.0)
26
- aws-sdk-kms (1.13.0)
27
- aws-sdk-core (~> 3, >= 3.39.0)
28
- aws-sigv4 (~> 1.0)
29
- aws-sdk-s3 (1.30.0)
30
- aws-sdk-core (~> 3, >= 3.39.0)
26
+ aws-sdk-kms (1.46.0)
27
+ aws-sdk-core (~> 3, >= 3.119.0)
28
+ aws-sigv4 (~> 1.1)
29
+ aws-sdk-s3 (1.99.0)
30
+ aws-sdk-core (~> 3, >= 3.119.0)
31
31
  aws-sdk-kms (~> 1)
32
- aws-sigv4 (~> 1.0)
33
- aws-sigv4 (1.0.3)
34
- coderay (1.1.2)
35
- dotenv (2.5.0)
36
- excon (0.62.0)
32
+ aws-sigv4 (~> 1.1)
33
+ aws-sigv4 (1.2.4)
34
+ aws-eventstream (~> 1, >= 1.0.2)
35
+ coderay (1.1.3)
36
+ dotenv (2.7.6)
37
+ excon (0.85.0)
37
38
  fernet (2.0)
38
39
  valcro (= 0.1)
39
- guard-compat (1.2.1)
40
- guard-minitest (2.4.6)
41
- guard-compat (~> 1.2)
42
- minitest (>= 3.0)
43
40
  jmespath (1.4.0)
44
- logfmt (0.0.8)
45
- method_source (0.9.2)
46
- mini_portile2 (2.4.0)
47
- minitest (5.11.3)
41
+ logfmt (0.0.9)
42
+ method_source (1.0.0)
43
+ mini_portile2 (2.6.1)
44
+ minitest (5.14.4)
48
45
  minitest-around (0.5.0)
49
46
  minitest (~> 5.0)
50
- multi_json (1.13.1)
51
- mustermann (1.0.3)
52
- nokogiri (1.10.1)
53
- mini_portile2 (~> 2.4.0)
54
- pry (0.12.2)
55
- coderay (~> 1.1.0)
56
- method_source (~> 0.9.0)
57
- rack (2.0.6)
58
- rack-protection (2.0.5)
47
+ multi_json (1.15.0)
48
+ mustermann (1.1.1)
49
+ ruby2_keywords (~> 0.0.1)
50
+ nokogiri (1.12.3)
51
+ mini_portile2 (~> 2.6.1)
52
+ racc (~> 1.4)
53
+ pry (0.14.1)
54
+ coderay (~> 1.1)
55
+ method_source (~> 1.0)
56
+ racc (1.5.2)
57
+ rack (2.2.3)
58
+ rack-protection (2.0.8.1)
59
59
  rack
60
60
  rack-ssl-enforcer (0.2.9)
61
61
  rack-test (1.1.0)
62
62
  rack (>= 1.0, < 3)
63
- rake (12.3.2)
64
- rdoc (6.1.1)
63
+ rake (13.0.6)
64
+ rdoc (6.3.2)
65
65
  rollbar (2.18.2)
66
66
  multi_json
67
67
  rr (1.2.1)
68
- scrolls (0.9.0)
68
+ ruby2_keywords (0.0.5)
69
+ scrolls (0.9.1)
69
70
  shotgun (0.9.2)
70
71
  rack (>= 1.0)
71
- sinatra (2.0.5)
72
+ sinatra (2.0.8.1)
72
73
  mustermann (~> 1.0)
73
74
  rack (~> 2.0)
74
- rack-protection (= 2.0.5)
75
+ rack-protection (= 2.0.8.1)
75
76
  tilt (~> 2.0)
76
- tilt (2.0.9)
77
- uuidtools (2.1.5)
77
+ tilt (2.0.10)
78
+ uuidtools (2.2.0)
78
79
  valcro (0.1)
79
- vault-test-tools (1.0.0)
80
+ vault-test-tools (1.1.0)
80
81
  logfmt
81
82
  minitest (~> 5.11)
82
83
  nokogiri
83
84
  rack-test (~> 1.1)
84
- rr
85
- scrolls (= 0.9)
86
- yard (0.9.16)
85
+ rr (~> 1.2)
86
+ scrolls
87
+ yard (0.9.26)
87
88
  yard-sinatra (1.0.0)
88
89
  yard (~> 0.7)
89
90
 
@@ -92,16 +93,15 @@ PLATFORMS
92
93
 
93
94
  DEPENDENCIES
94
95
  dotenv
95
- guard-minitest
96
96
  minitest-around
97
97
  pry
98
- rake (~> 12.3)
98
+ rake (~> 13.0)
99
99
  rdoc
100
100
  shotgun (~> 0.9.2)
101
- vault-test-tools (~> 1.0.0)
101
+ vault-test-tools (~> 1.1.0)
102
102
  vault-tools!
103
103
  yard
104
104
  yard-sinatra
105
105
 
106
106
  BUNDLED WITH
107
- 1.17.1
107
+ 2.2.26
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  Tools is the English word for ツール. Tooling for the Heroku Vault
4
4
  team to enable faster bootstrapping for Ruby projects.
5
5
 
6
- [![Build Status](https://travis-ci.org/heroku/vault-tools.png?branch=master)](https://travis-ci.org/heroku/vault-tools)
6
+ [![CircleCI](https://circleci.com/gh/heroku/vault-tools/tree/master.svg?style=shield&circle-token=39ec638ab252a4440ca919f9b09dc258b4459c58)](_https://circleci.com/gh/heroku/vault-tools/tree/master_)
7
7
 
8
8
  ## Installation
9
9
 
@@ -93,3 +93,10 @@ Generate the API documentation:
93
93
  ## Releasing
94
94
 
95
95
  > bundle exec rake release
96
+
97
+ ## Release Notes
98
+ Version 2.1.1 (2022-01-06):
99
+ - Added tooling to support metadata tags on request status metrics.
100
+ - Reverted change to minimum supported ruby version.
101
+ Version 2.1.0 (2021-08-26):
102
+ guard-minitest was removed due to it causing problems with the ruby version upgrade. Was not actively used anymore. Hasn't been updated in a long time.
@@ -20,8 +20,8 @@ module Vault
20
20
  # well as classes of HTTP status codes.
21
21
  #
22
22
  # @param status [Integer] The HTTP status code to record.
23
- def self.count_status(status)
24
- count("http.#{status}")
23
+ def self.count_status(status, data)
24
+ count("http.#{status}", 1, data)
25
25
  if status_prefix = status.to_s.match(/\d/)[0]
26
26
  count("http.#{status_prefix}xx")
27
27
  end
@@ -16,7 +16,7 @@ module Vault
16
16
  class Pipeline
17
17
  def self.use(*args)
18
18
  @filters ||= []
19
- @filters.push *args
19
+ @filters.push(*args)
20
20
  end
21
21
 
22
22
  def self.filters
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Vault
4
4
  module Tools
5
- VERSION = '2.0.0'
5
+ VERSION = '2.1.1'
6
6
  end
7
7
  end
@@ -53,7 +53,7 @@ module Vault
53
53
  # protect! is used
54
54
  %w{get put post delete head options path link unlink}.each do |meth|
55
55
  define_method "#{meth}_unprotected".to_sym do |path, opts = {}, &block|
56
- pattern = compile!(meth.upcase, path, block, opts).first
56
+ pattern = compile!(meth.upcase, path, block, **opts).first
57
57
  set :unprotected_paths, settings.unprotected_paths + [pattern]
58
58
  if meth.downcase == 'get'
59
59
  conditions = @conditions.dup
@@ -100,12 +100,20 @@ module Vault
100
100
  # Start timing the request.
101
101
  before do
102
102
  @start_request = Time.now
103
+ # if client sends content_type: application/json which no longer works
104
+ # https://github.com/puma/puma/compare/4.3.1...4.3.5#commitcomment-39478516
105
+ #
106
+ # fixing this here so that we do not break all client users at once
107
+ if request.env["CONTENT_TYPE"].nil? && request.env["HTTP_CONTENT_TYPE"]
108
+ request.env["CONTENT_TYPE"] = request.env["HTTP_CONTENT_TYPE"]
109
+ end
103
110
  end
104
111
 
105
112
  # Log details about the request including how long it took.
106
113
  after do
107
114
  @action ||= 'unknown'
108
- Log.count_status(response.status)
115
+ @metadata ||= {}
116
+ Log.count_status(response.status, @metadata.merge(request_path: request.path_info))
109
117
  Log.time("http.#{@action}", (Time.now - @start_request) * 1000)
110
118
  end
111
119
 
data/test/log_test.rb CHANGED
@@ -31,10 +31,11 @@ class LogTest < Vault::TestCase
31
31
 
32
32
  # Vault::Log.count_status emits metrics to measure HTTP responses.
33
33
  def test_count_status
34
- Vault::Log.count_status(201)
35
- assert_equal '1', logged_data['count#test-app.http.201']
36
- assert_equal '1', logged_data['count#test-app.http.2xx']
37
- assert_equal 'test-deploy', logged_data['source']
34
+ Vault::Log.count_status(201, request_path: '/some/request/path')
35
+ assert_equal 1, logdata['count#test-app.http.201']
36
+ assert_equal 1, logdata['count#test-app.http.2xx']
37
+ assert_equal '/some/request/path', logdata['request_path']
38
+ assert_equal 'test-deploy', logdata['source']
38
39
  end
39
40
 
40
41
  def test_measure
@@ -115,6 +116,6 @@ class LogTest < Vault::TestCase
115
116
  assert_equal 'true', logged_data['A']
116
117
  assert_equal 'true', logged_data['B']
117
118
  assert_equal 'test-deploy', logged_data['source']
118
- assert_match /\d/, logged_data['elapsed']
119
+ assert_match(/\d/, logged_data['elapsed'])
119
120
  end
120
121
  end
data/test/web_test.rb CHANGED
@@ -155,6 +155,7 @@ class WebTest < Vault::TestCase
155
155
  head '/'
156
156
  assert_equal '1', logged_data['count#test-app.http.200']
157
157
  assert_equal '1', logged_data['count#test-app.http.2xx']
158
+ assert_equal '/', logged_data['request_path']
158
159
  assert_equal(200, last_response.status)
159
160
  end
160
161
 
@@ -246,6 +247,18 @@ class WebTest < Vault::TestCase
246
247
  assert_equal request_id, last_response.headers['Request-ID']
247
248
  end
248
249
 
250
+ def test_that_metadata_gets_logged
251
+ mock(Vault::Log).count_status(200, {
252
+ 'user' => 'amanda',
253
+ 'some_flag' => 'true',
254
+ request_path: '/logging-test'
255
+ })
256
+ app.get '/logging-test' do
257
+ @metadata = {'user' => 'amanda', 'some_flag' => 'true'}
258
+ end
259
+ get '/logging-test'
260
+ end
261
+
249
262
  def test_that_excon_proxies_request_id
250
263
  request_id = 'JKJK-123'
251
264
  Excon.stub(
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vault-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Continanza
8
8
  - Jamu Kakar
9
9
  - Kenny Parnell
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-01-14 00:00:00.000000000 Z
13
+ date: 2022-01-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: scrolls
@@ -220,9 +220,10 @@ executables: []
220
220
  extensions: []
221
221
  extra_rdoc_files: []
222
222
  files:
223
+ - ".circleci/config.yml"
223
224
  - ".gitignore"
224
- - ".travis.yml"
225
225
  - ".yardopts"
226
+ - CODEOWNERS
226
227
  - Gemfile
227
228
  - Gemfile.lock
228
229
  - Guardfile
@@ -270,7 +271,7 @@ files:
270
271
  homepage: ''
271
272
  licenses: []
272
273
  metadata: {}
273
- post_install_message:
274
+ post_install_message:
274
275
  rdoc_options: []
275
276
  require_paths:
276
277
  - lib
@@ -285,9 +286,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
285
286
  - !ruby/object:Gem::Version
286
287
  version: '0'
287
288
  requirements: []
288
- rubyforge_project:
289
- rubygems_version: 2.7.6
290
- signing_key:
289
+ rubygems_version: 3.1.2
290
+ signing_key:
291
291
  specification_version: 4
292
292
  summary: Test classes, base web classes, and helpers - oh my!
293
293
  test_files: []
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
- rvm:
4
- - 2.6.0
5
- - 2.5.3
6
- before_install:
7
- - gem install bundler -v '< 2'