vault-tools 0.7.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +4 -3
- data/Gemfile +4 -3
- data/Gemfile.lock +65 -72
- data/README.md +0 -13
- data/lib/vault-tools.rb +15 -16
- data/lib/vault-tools/app.rb +3 -3
- data/lib/vault-tools/config.rb +6 -24
- data/lib/vault-tools/log.rb +4 -4
- data/lib/vault-tools/pipeline.rb +1 -1
- data/lib/vault-tools/s3.rb +9 -9
- data/lib/vault-tools/statement_store.rb +15 -9
- data/lib/vault-tools/time.rb +1 -1
- data/lib/vault-tools/user.rb +3 -3
- data/lib/vault-tools/version.rb +3 -1
- data/lib/vault-tools/web.rb +9 -1
- data/test/config_test.rb +7 -36
- data/test/defaults_test.rb +4 -4
- data/test/helper.rb +12 -46
- data/test/log_test.rb +5 -4
- data/test/s3_test.rb +16 -16
- data/test/statement_store_test.rb +9 -12
- data/test/web_test.rb +1 -0
- data/vault-tools.gemspec +10 -9
- metadata +17 -46
- data/lib/vault-tools/tracing.rb +0 -92
- data/lib/vault-tools/tracing/sidekiq_client.rb +0 -37
- data/lib/vault-tools/tracing/sidekiq_server.rb +0 -54
- data/test/tracing_test.rb +0 -86
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 94e958db62b7b6488e9e8369e0c2067cabd5a9ffdb6c2ebe91e774266dea2785
|
4
|
+
data.tar.gz: 75fbf49120000e5c48ff9b2ae1647aa88a63fc8e23fe64528c307653c310c5fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2cf15adf12bef707094105199bc93bbe11c54f8c6ca75b441d7860e3df0efab710c139a4425cb85b1e55ed3cdb3b41d96e4d2ef3188f162a000e5eec022c1cb
|
7
|
+
data.tar.gz: 1e0f0e3f31feaa53fdfb08c5788f91f13bd78d3142eacdc4a3b03d2ee9ad3a1aae68372d84c9a2983c7846e436f7c63b35456690648262a3e2ce0babcfc2a0fb
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -4,12 +4,13 @@ source 'https://rubygems.org'
|
|
4
4
|
gemspec
|
5
5
|
|
6
6
|
group :development do
|
7
|
-
gem 'rake'
|
8
|
-
gem 'shotgun'
|
7
|
+
gem 'rake', '~> 13.0'
|
8
|
+
gem 'shotgun', '~> 0.9.2'
|
9
9
|
gem 'yard-sinatra'
|
10
10
|
end
|
11
11
|
|
12
12
|
group :test do
|
13
|
-
gem 'vault-test-tools'
|
14
13
|
gem 'guard-minitest'
|
14
|
+
gem 'minitest-around'
|
15
|
+
gem 'vault-test-tools', '~> 1.0.0'
|
15
16
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,102 +1,94 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
vault-tools (0.
|
5
|
-
aws-sdk (~> 1.0)
|
4
|
+
vault-tools (2.0.2)
|
5
|
+
aws-sdk-s3 (~> 1.0)
|
6
6
|
coderay
|
7
7
|
excon
|
8
|
-
fernet (= 2.0
|
9
|
-
|
10
|
-
rack (~> 1.6.4)
|
8
|
+
fernet (= 2.0)
|
9
|
+
rack (~> 2.0)
|
11
10
|
rack-ssl-enforcer
|
12
|
-
rollbar (~> 2.
|
11
|
+
rollbar (~> 2.18.2)
|
13
12
|
scrolls (~> 0.9)
|
14
|
-
sinatra (~>
|
13
|
+
sinatra (~> 2.0.4)
|
15
14
|
uuidtools
|
16
|
-
zipkin-tracer (~> 0.27)
|
17
15
|
|
18
16
|
GEM
|
19
17
|
remote: https://rubygems.org/
|
20
18
|
specs:
|
21
|
-
|
22
|
-
aws-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
19
|
+
aws-eventstream (1.1.0)
|
20
|
+
aws-partitions (1.332.0)
|
21
|
+
aws-sdk-core (3.100.0)
|
22
|
+
aws-eventstream (~> 1, >= 1.0.2)
|
23
|
+
aws-partitions (~> 1, >= 1.239.0)
|
24
|
+
aws-sigv4 (~> 1.1)
|
25
|
+
jmespath (~> 1.0)
|
26
|
+
aws-sdk-kms (1.34.1)
|
27
|
+
aws-sdk-core (~> 3, >= 3.99.0)
|
28
|
+
aws-sigv4 (~> 1.1)
|
29
|
+
aws-sdk-s3 (1.69.1)
|
30
|
+
aws-sdk-core (~> 3, >= 3.99.0)
|
31
|
+
aws-sdk-kms (~> 1)
|
32
|
+
aws-sigv4 (~> 1.1)
|
33
|
+
aws-sigv4 (1.2.0)
|
34
|
+
aws-eventstream (~> 1, >= 1.0.2)
|
27
35
|
coderay (1.1.2)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
faraday (0.15.1)
|
32
|
-
multipart-post (>= 1.2, < 3)
|
33
|
-
fernet (2.0.rc2)
|
36
|
+
dotenv (2.5.0)
|
37
|
+
excon (0.75.0)
|
38
|
+
fernet (2.0)
|
34
39
|
valcro (= 0.1)
|
35
|
-
finagle-thrift (1.4.2)
|
36
|
-
thrift (~> 0.9.3)
|
37
40
|
guard-compat (1.2.1)
|
38
|
-
guard-minitest (2.4.
|
41
|
+
guard-minitest (2.4.6)
|
39
42
|
guard-compat (~> 1.2)
|
40
43
|
minitest (>= 3.0)
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
nokogiri (1.
|
52
|
-
mini_portile2 (~> 2.
|
53
|
-
pry (0.
|
44
|
+
jmespath (1.4.0)
|
45
|
+
logfmt (0.0.8)
|
46
|
+
method_source (0.9.2)
|
47
|
+
mini_portile2 (2.4.0)
|
48
|
+
minitest (5.11.3)
|
49
|
+
minitest-around (0.5.0)
|
50
|
+
minitest (~> 5.0)
|
51
|
+
multi_json (1.14.1)
|
52
|
+
mustermann (1.1.1)
|
53
|
+
ruby2_keywords (~> 0.0.1)
|
54
|
+
nokogiri (1.10.9)
|
55
|
+
mini_portile2 (~> 2.4.0)
|
56
|
+
pry (0.12.2)
|
54
57
|
coderay (~> 1.1.0)
|
55
58
|
method_source (~> 0.9.0)
|
56
|
-
rack (
|
57
|
-
rack-protection (
|
59
|
+
rack (2.0.6)
|
60
|
+
rack-protection (2.0.8.1)
|
58
61
|
rack
|
59
62
|
rack-ssl-enforcer (0.2.9)
|
60
|
-
rack-test (
|
61
|
-
rack (>= 1.0)
|
62
|
-
rake (
|
63
|
-
rdoc (6.
|
64
|
-
rollbar (2.
|
63
|
+
rack-test (1.1.0)
|
64
|
+
rack (>= 1.0, < 3)
|
65
|
+
rake (13.0.1)
|
66
|
+
rdoc (6.1.1)
|
67
|
+
rollbar (2.18.2)
|
65
68
|
multi_json
|
66
|
-
rr (1.1
|
69
|
+
rr (1.2.1)
|
70
|
+
ruby2_keywords (0.0.2)
|
67
71
|
scrolls (0.9.0)
|
68
|
-
shotgun (0.9.
|
72
|
+
shotgun (0.9.2)
|
69
73
|
rack (>= 1.0)
|
70
|
-
sinatra (
|
71
|
-
|
72
|
-
rack
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
thrift (0.9.3.0)
|
77
|
-
tilt (2.0.8)
|
78
|
-
turn (0.9.7)
|
79
|
-
ansi
|
80
|
-
minitest (~> 4)
|
74
|
+
sinatra (2.0.8.1)
|
75
|
+
mustermann (~> 1.0)
|
76
|
+
rack (~> 2.0)
|
77
|
+
rack-protection (= 2.0.8.1)
|
78
|
+
tilt (~> 2.0)
|
79
|
+
tilt (2.0.10)
|
81
80
|
uuidtools (2.1.5)
|
82
81
|
valcro (0.1)
|
83
|
-
vault-test-tools (0.
|
84
|
-
guard-minitest
|
82
|
+
vault-test-tools (1.0.0)
|
85
83
|
logfmt
|
86
|
-
minitest (~>
|
84
|
+
minitest (~> 5.11)
|
87
85
|
nokogiri
|
88
|
-
rack-test
|
86
|
+
rack-test (~> 1.1)
|
89
87
|
rr
|
90
|
-
scrolls
|
91
|
-
|
92
|
-
yard (0.9.12)
|
88
|
+
scrolls (= 0.9)
|
89
|
+
yard (0.9.25)
|
93
90
|
yard-sinatra (1.0.0)
|
94
91
|
yard (~> 0.7)
|
95
|
-
zipkin-tracer (0.27.2.1)
|
96
|
-
faraday (~> 0.8)
|
97
|
-
finagle-thrift (~> 1.4.2)
|
98
|
-
rack (>= 1.0)
|
99
|
-
sucker_punch (~> 2.0)
|
100
92
|
|
101
93
|
PLATFORMS
|
102
94
|
ruby
|
@@ -104,14 +96,15 @@ PLATFORMS
|
|
104
96
|
DEPENDENCIES
|
105
97
|
dotenv
|
106
98
|
guard-minitest
|
99
|
+
minitest-around
|
107
100
|
pry
|
108
|
-
rake
|
101
|
+
rake (~> 13.0)
|
109
102
|
rdoc
|
110
|
-
shotgun
|
111
|
-
vault-test-tools
|
103
|
+
shotgun (~> 0.9.2)
|
104
|
+
vault-test-tools (~> 1.0.0)
|
112
105
|
vault-tools!
|
113
106
|
yard
|
114
107
|
yard-sinatra
|
115
108
|
|
116
109
|
BUNDLED WITH
|
117
|
-
1.
|
110
|
+
1.17.3
|
data/README.md
CHANGED
@@ -26,9 +26,6 @@ calling `Vault.setup` will:
|
|
26
26
|
- if the `CONFIG_APP` environment variable is defined and this is
|
27
27
|
the production environment, it will attempt to use the Heroku API
|
28
28
|
to load the config vars from another app into `Vault::Config`
|
29
|
-
- enable distributed tracing via Zipkin, if the [required config
|
30
|
-
vars](#configs-for-tracing) are set
|
31
|
-
|
32
29
|
|
33
30
|
### `Vault::Config`
|
34
31
|
|
@@ -93,16 +90,6 @@ Generate the API documentation:
|
|
93
90
|
|
94
91
|
vendor/bin/d
|
95
92
|
|
96
|
-
## Configs for tracing
|
97
|
-
|
98
|
-
The following are config vars to be set in the consumer app for tracing with
|
99
|
-
Zipkin:
|
100
|
-
* `APP_NAME` (required) what the trace will show up as in the Zipkin interface.
|
101
|
-
* `ZIPKIN_ENABLED` (required) must be set to `true` to start tracing.
|
102
|
-
* `ZIPKIN_API_HOST` (required) where to post traces to. URL must contain the
|
103
|
-
basic auth creds from the Tools team.
|
104
|
-
* `ZIPKIN_SAMPLE_RATE` defaults to `0.1`.
|
105
|
-
|
106
93
|
## Releasing
|
107
94
|
|
108
95
|
> bundle exec rake release
|
data/lib/vault-tools.rb
CHANGED
@@ -3,19 +3,8 @@ require "vault-tools/version"
|
|
3
3
|
require 'sinatra/base'
|
4
4
|
require 'scrolls'
|
5
5
|
require 'rack/ssl-enforcer'
|
6
|
-
require 'heroku-api'
|
7
6
|
require 'rollbar'
|
8
|
-
|
9
|
-
Rollbar.configure do |config|
|
10
|
-
config.environment = ENV['RACK_ENV'] || ENV['RAILS_ENV'] || ENV['APP_ENV'] || ENV['ROLLBAR_ENV'] || 'unassigned'
|
11
|
-
config.access_token = ENV['ROLLBAR_ACCESS_TOKEN']
|
12
|
-
config.scrub_headers = (config.scrub_headers || []) | ["Authorization", "Cookie", "Set-Cookie", "X_CSRF_TOKEN", "X-CSRF-Token", "HTTP_X_CSRF_TOKEN"]
|
13
|
-
config.scrub_fields = (config.scrub_fields || []) | [:passwd, :password, :password_confirmation, :secret, :confirm_password,
|
14
|
-
:secret_token, :api_key, :access_token, :authenticity_token, :"bouncer.token", :"bouncer.refresh_token",
|
15
|
-
:heroku_oauth_token, :heroku_session_nonce, :heroku_users_session, :oauth_token, :postgres_session_nonce,
|
16
|
-
:"request.cookies.signup-sso-session", :sudo_oauth_token, :super_user_session_secret, :user_session_secret,
|
17
|
-
:"wwo-sso-session"]
|
18
|
-
end
|
7
|
+
require 'excon'
|
19
8
|
|
20
9
|
# Yes, there's a lot of stuff on STDERR. But its on
|
21
10
|
# stderr and not stdout so you can pipe to /dev/null if
|
@@ -83,7 +72,6 @@ module Vault
|
|
83
72
|
self.override_global_config
|
84
73
|
self.load_shared_config
|
85
74
|
self.init_scrolls
|
86
|
-
Tracing.configure
|
87
75
|
end
|
88
76
|
end
|
89
77
|
|
@@ -101,6 +89,17 @@ require 'vault-tools/time'
|
|
101
89
|
require 'vault-tools/s3'
|
102
90
|
require 'vault-tools/statement_store'
|
103
91
|
require 'vault-tools/rollbar_helper'
|
104
|
-
|
105
|
-
|
106
|
-
|
92
|
+
|
93
|
+
Rollbar.configure do |config|
|
94
|
+
config.environment = ENV['RACK_ENV'] || ENV['RAILS_ENV'] || ENV['APP_ENV'] || ENV['ROLLBAR_ENV'] || 'unassigned'
|
95
|
+
config.access_token = ENV['ROLLBAR_ACCESS_TOKEN']
|
96
|
+
config.scrub_headers = (config.scrub_headers || []) | ["Authorization", "Cookie", "Set-Cookie", "X_CSRF_TOKEN", "X-CSRF-Token", "HTTP_X_CSRF_TOKEN"]
|
97
|
+
config.scrub_fields = (config.scrub_fields || []) | [:passwd, :password, :password_confirmation, :secret, :confirm_password,
|
98
|
+
:secret_token, :api_key, :access_token, :authenticity_token, :"bouncer.token", :"bouncer.refresh_token",
|
99
|
+
:heroku_oauth_token, :heroku_session_nonce, :heroku_users_session, :oauth_token, :postgres_session_nonce,
|
100
|
+
:"request.cookies.signup-sso-session", :sudo_oauth_token, :super_user_session_secret, :user_session_secret,
|
101
|
+
:"wwo-sso-session"]
|
102
|
+
|
103
|
+
|
104
|
+
config.enabled = Vault::Config.production?
|
105
|
+
end
|
data/lib/vault-tools/app.rb
CHANGED
@@ -5,7 +5,7 @@ module Vault
|
|
5
5
|
ID_CAPTURE = /\Aapp(\d+)\@[\w\.]+com\z/
|
6
6
|
# Convert a core app ID into a Heroku app ID.
|
7
7
|
#
|
8
|
-
# @param app_id [
|
8
|
+
# @param app_id [Integer] A core app ID.
|
9
9
|
# @return [String] A Heroku ID that uniquely represents the app.
|
10
10
|
def self.id_to_hid(app_id)
|
11
11
|
"app#{app_id}@heroku.com"
|
@@ -13,7 +13,7 @@ module Vault
|
|
13
13
|
|
14
14
|
# Convert a core app ID into a v5 UUID.
|
15
15
|
#
|
16
|
-
# @param app_id [
|
16
|
+
# @param app_id [Integer] An app ID.
|
17
17
|
# @return [String] A v5 UUID that uniquely represents the app.
|
18
18
|
def self.id_to_uuid(app_id)
|
19
19
|
url = "https://vault.heroku.com/apps/#{app_id}"
|
@@ -24,7 +24,7 @@ module Vault
|
|
24
24
|
#
|
25
25
|
# @param heroku_id [String] A Heroku app ID, such as `app1234@heroku.com`.
|
26
26
|
# @raise [ArgumentError] Raised if a malformed Heroku ID is provided.
|
27
|
-
# @return [
|
27
|
+
# @return [Integer] The core app ID that uniquely represents the app.
|
28
28
|
def self.hid_to_id(heroku_id)
|
29
29
|
if app_id = heroku_id.slice(ID_CAPTURE, 1)
|
30
30
|
app_id.to_i
|
data/lib/vault-tools/config.rb
CHANGED
@@ -32,30 +32,12 @@ module Vault
|
|
32
32
|
ENV[var_name] || @@shared[var_name] || @@defaults[default_name]
|
33
33
|
end
|
34
34
|
|
35
|
-
# Loads config from another app.
|
36
|
-
def self.load_shared!(app = nil)
|
37
|
-
heroku = Heroku::API.new
|
38
|
-
@@shared = heroku.get_config_vars(app).body
|
39
|
-
end
|
40
|
-
|
41
35
|
# Reset defaults and shared values
|
42
36
|
def self.reset!
|
43
37
|
@@defaults = {}
|
44
38
|
@@shared = {}
|
45
39
|
end
|
46
40
|
|
47
|
-
# An environment variable from another app.
|
48
|
-
#
|
49
|
-
# @param app [String] The name of the app to get the value from.
|
50
|
-
# @param name [String] The name of the environment variable to fetch a
|
51
|
-
# value for.
|
52
|
-
# @return [String] The value of an environment variable from another
|
53
|
-
# Heroku app or nil if no match is available.
|
54
|
-
def self.remote_env(app, name)
|
55
|
-
heroku = Heroku::API.new
|
56
|
-
heroku.get_config_vars(app).body[name]
|
57
|
-
end
|
58
|
-
|
59
41
|
# An environment variable.
|
60
42
|
#
|
61
43
|
# @param name [String] The name of the environment variable to fetch a
|
@@ -126,7 +108,7 @@ module Vault
|
|
126
108
|
|
127
109
|
# The port to listen on for web requests.
|
128
110
|
#
|
129
|
-
# @return [
|
111
|
+
# @return [Integer] The port to listen on for web requests.
|
130
112
|
def self.port
|
131
113
|
env!("PORT").to_i
|
132
114
|
end
|
@@ -148,12 +130,12 @@ module Vault
|
|
148
130
|
!bool?('VAULT_TOOLS_DISABLE_SSL')
|
149
131
|
end
|
150
132
|
|
151
|
-
# An environment variable converted to a
|
133
|
+
# An environment variable converted to a Integer.
|
152
134
|
#
|
153
135
|
# @param name [String] The name of the environment variable to fetch a
|
154
|
-
#
|
155
|
-
# @return [
|
156
|
-
#
|
136
|
+
# Integer for.
|
137
|
+
# @return [Integer] The number or nil if the value couldn't be coerced to a
|
138
|
+
# Integer.
|
157
139
|
def self.int(name)
|
158
140
|
self[name] && self[name].to_i
|
159
141
|
end
|
@@ -194,7 +176,7 @@ module Vault
|
|
194
176
|
|
195
177
|
# The number of threads to use in Sidekiq workers.
|
196
178
|
#
|
197
|
-
# @return [
|
179
|
+
# @return [Integer] The number of threads from the `SIDEKIQ_CONCURRENCY`
|
198
180
|
# environment variable or 25 if no variable is defined.
|
199
181
|
def self.sidekiq_concurrency
|
200
182
|
int('SIDEKIQ_CONCURRENCY') || 25
|
data/lib/vault-tools/log.rb
CHANGED
@@ -19,9 +19,9 @@ module Vault
|
|
19
19
|
# This makes it possible to easily measure individual HTTP status codes as
|
20
20
|
# well as classes of HTTP status codes.
|
21
21
|
#
|
22
|
-
# @param status [
|
23
|
-
def self.count_status(status)
|
24
|
-
count("http.#{status}")
|
22
|
+
# @param status [Integer] The HTTP status code to record.
|
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
|
@@ -39,7 +39,7 @@ module Vault
|
|
39
39
|
# Log a timing metric.
|
40
40
|
#
|
41
41
|
# @param name [String] A Sinatra-formatted route URL.
|
42
|
-
# @param duration [
|
42
|
+
# @param duration [Integer] The duration to record, in milliseconds.
|
43
43
|
def self.time(name, duration)
|
44
44
|
if name
|
45
45
|
name.gsub(/\/:\w+/, ''). # Remove param names from path.
|
data/lib/vault-tools/pipeline.rb
CHANGED
data/lib/vault-tools/s3.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'aws-sdk'
|
1
|
+
require 'aws-sdk-s3'
|
2
2
|
|
3
3
|
module S3
|
4
4
|
extend self
|
@@ -10,7 +10,7 @@ module S3
|
|
10
10
|
# @param value [String]
|
11
11
|
def write(bucket, key, value)
|
12
12
|
Vault::Log.log(:fn => __method__, :key => key) do
|
13
|
-
s3.
|
13
|
+
s3.put_object({bucket: bucket, key: key, body: value})
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -20,17 +20,17 @@ module S3
|
|
20
20
|
# @param key [String]
|
21
21
|
def read(bucket, key)
|
22
22
|
Vault::Log.log(:fn => __method__, :key => key) do
|
23
|
-
s3.
|
23
|
+
s3.get_object({bucket: bucket, key: key}).body.read
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
# Get the underlying AWS::S3 instance, creating it using environment
|
28
|
-
# if necessary.
|
27
|
+
# Get the underlying AWS::S3::Client instance, creating it using environment
|
28
|
+
# vars if necessary.
|
29
29
|
def s3
|
30
|
-
@s3 ||=
|
31
|
-
:
|
32
|
-
|
33
|
-
:
|
30
|
+
@s3 ||= Aws::S3::Client.new(
|
31
|
+
credentials: Aws::Credentials.new(Config.env('AWS_ACCESS_KEY_ID'),
|
32
|
+
Config.env('AWS_SECRET_ACCESS_KEY')),
|
33
|
+
region: Config.env('AWS_REGION')
|
34
34
|
)
|
35
35
|
end
|
36
36
|
|