gruf 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/lib/gruf/instrumentation/request_logging/hook.rb +44 -3
- data/lib/gruf/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c3c699dd26122a8e6fb4d74ea2c86b3c4d52900
|
4
|
+
data.tar.gz: 41f9f4833353086c36421a155dd66076416d9e00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce500f6213a21560ff8a7dc0b2e8f8e5b64d0f93ebf29b5474c9ad1ba557994504d6fc67100eef18f1feac0a4aa422e7a7ba795bf25d49f88be05af175bbc019
|
7
|
+
data.tar.gz: 548b0fff743db41630cc4aae899a1886a5be5a591bac0f8a4170a35205cead1db0ff9daef2c2c944b907a4c535071b5a4c9f08ff49cf43080bdc72fd8411dd19
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@ Changelog for the gruf gem. This includes internal history before the gem was ma
|
|
2
2
|
|
3
3
|
### Pending release
|
4
4
|
|
5
|
+
### 1.2.3
|
6
|
+
|
7
|
+
- Support nested blacklist parameters in path.to.key format
|
8
|
+
|
5
9
|
### 1.2.2
|
6
10
|
|
7
11
|
- Pin Google Protobuf to 3.3.x due to failures in protobuf in Ruby at 3.4.x
|
data/README.md
CHANGED
@@ -320,7 +320,7 @@ It comes with a few more options as well:
|
|
320
320
|
| ------ | ----------- | ------- |
|
321
321
|
| formatter | The formatter to use. By default `:plain` and `:logstash` are supported. | `:plain` |
|
322
322
|
| log_parameters | If set to true, will log parameters in the response | `false` |
|
323
|
-
| blacklist | An array of parameter key names to redact from logging | `[]` |
|
323
|
+
| blacklist | An array of parameter key names to redact from logging, in path.to.key format | `[]` |
|
324
324
|
| redacted_string | The string to use for redacted parameters. | `REDACTED` |
|
325
325
|
|
326
326
|
It's important to maintain a safe blacklist should you decide to log parameters; gruf does no
|
@@ -124,11 +124,13 @@ module Gruf
|
|
124
124
|
# @return [Hash] The sanitized params in hash form
|
125
125
|
#
|
126
126
|
def sanitize(params = {})
|
127
|
-
|
127
|
+
blacklists = options.fetch(:blacklist, []).map(&:to_s)
|
128
128
|
redacted_string = options.fetch(:redacted_string, 'REDACTED')
|
129
|
-
|
130
|
-
|
129
|
+
blacklists.each do |blacklist|
|
130
|
+
parts = blacklist.split('.').map(&:to_sym)
|
131
|
+
redact!(parts, 0, params, redacted_string)
|
131
132
|
end
|
133
|
+
params
|
132
134
|
end
|
133
135
|
|
134
136
|
##
|
@@ -139,6 +141,45 @@ module Gruf
|
|
139
141
|
def options
|
140
142
|
super().fetch(:request_logging, {})
|
141
143
|
end
|
144
|
+
|
145
|
+
##
|
146
|
+
# Helper method to recursively redact based on the black list
|
147
|
+
#
|
148
|
+
# @param [Array] The blacklist. ex. 'data.schema' -> [:data, :schema]
|
149
|
+
# @param [Integer] The current index of the blacklist
|
150
|
+
# @param [Hash] The hash of parameters to sanitize
|
151
|
+
# @param [String] The custom redact string
|
152
|
+
# @return [Nil]
|
153
|
+
#
|
154
|
+
def redact!(parts, i, params, redacted_string)
|
155
|
+
return if i >= parts.size || !params.key?(parts[i])
|
156
|
+
if i == parts.size - 1
|
157
|
+
if params[parts[i]].is_a? Hash
|
158
|
+
hash_deep_redact!(params[parts[i]], redacted_string)
|
159
|
+
else
|
160
|
+
params[parts[i]] = redacted_string
|
161
|
+
end
|
162
|
+
return
|
163
|
+
end
|
164
|
+
redact!(parts, i + 1, params[parts[i]], redacted_string)
|
165
|
+
end
|
166
|
+
|
167
|
+
##
|
168
|
+
# Helper method to recursively redact the value of all hash keys
|
169
|
+
#
|
170
|
+
# @param [Hash] Part of the hash of parameters to sanitize
|
171
|
+
# @param [String] The custom redact string
|
172
|
+
# @return [Nil]
|
173
|
+
#
|
174
|
+
def hash_deep_redact!(hash, redacted_string)
|
175
|
+
hash.keys.each do |key|
|
176
|
+
if hash[key].is_a? Hash
|
177
|
+
hash_deep_redact!(hash[key], redacted_string)
|
178
|
+
else
|
179
|
+
hash[key] = redacted_string
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
142
183
|
end
|
143
184
|
end
|
144
185
|
end
|
data/lib/gruf/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gruf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shaun McCormick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|