appsignal 3.4.5 → 3.4.6
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/appsignal/utils/hash_sanitizer.rb +21 -9
- data/lib/appsignal/version.rb +1 -1
- data/spec/lib/appsignal/utils/hash_sanitizer_spec.rb +42 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2ca2df33b93d5de3deda35c427430f86c701e811c1e00a340d8a02e956fbb77
|
4
|
+
data.tar.gz: 69d319fa4870d64c3e54bb78f12c643934bb0a17c20145dcc373b52defcea554
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5791a6df017a1c54ce7631bbe61042150d500028dee4eda3f85d94c339c5c0728d103ece2586ed0cff2c45d8983de3e7ee1512a0b9221bd75db76e042a851f05
|
7
|
+
data.tar.gz: e23e971908c575908983bd7f16ed6321f559799af5e6442766208532a117722dc51d245b11d723a08a22e348b18cbec6f2911f52abe598df87be24cc2aea1743
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# AppSignal for Ruby gem Changelog
|
2
2
|
|
3
|
+
## 3.4.6
|
4
|
+
|
5
|
+
### Changed
|
6
|
+
|
7
|
+
- [85c155a0](https://github.com/appsignal/appsignal-ruby/commit/85c155a0a4b2b618c04db52c34ee7f0adba8f3c5) patch - When sanitizing an array or hash, replace recursively nested values with a placeholder string. This fixes a SystemStackError issue when sanitising arrays and hashes.
|
8
|
+
|
3
9
|
## 3.4.5
|
4
10
|
|
5
11
|
### Added
|
@@ -5,20 +5,21 @@ module Appsignal
|
|
5
5
|
# @api private
|
6
6
|
class HashSanitizer
|
7
7
|
FILTERED = "[FILTERED]"
|
8
|
+
RECURSIVE = "[RECURSIVE VALUE]"
|
8
9
|
|
9
10
|
class << self
|
10
11
|
def sanitize(value, filter_keys = [])
|
11
|
-
sanitize_value(value, filter_keys)
|
12
|
+
sanitize_value(value, filter_keys, [])
|
12
13
|
end
|
13
14
|
|
14
15
|
private
|
15
16
|
|
16
|
-
def sanitize_value(value, filter_keys)
|
17
|
+
def sanitize_value(value, filter_keys, seen)
|
17
18
|
case value
|
18
19
|
when Hash
|
19
|
-
sanitize_hash(value, filter_keys)
|
20
|
+
sanitize_hash(value, filter_keys, seen)
|
20
21
|
when Array
|
21
|
-
sanitize_array(value, filter_keys)
|
22
|
+
sanitize_array(value, filter_keys, seen)
|
22
23
|
when TrueClass, FalseClass, NilClass, Integer, String, Symbol, Float
|
23
24
|
unmodified(value)
|
24
25
|
else
|
@@ -26,23 +27,34 @@ module Appsignal
|
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
29
|
-
def sanitize_hash(source, filter_keys)
|
30
|
+
def sanitize_hash(source, filter_keys, seen)
|
31
|
+
seen = seen.clone << source.object_id
|
32
|
+
|
30
33
|
{}.tap do |hash|
|
31
34
|
source.each_pair do |key, value|
|
32
35
|
hash[key] =
|
33
|
-
if
|
36
|
+
if seen.include?(value.object_id)
|
37
|
+
RECURSIVE
|
38
|
+
elsif filter_keys.include?(key.to_s)
|
34
39
|
FILTERED
|
35
40
|
else
|
36
|
-
sanitize_value(value, filter_keys)
|
41
|
+
sanitize_value(value, filter_keys, seen)
|
37
42
|
end
|
38
43
|
end
|
39
44
|
end
|
40
45
|
end
|
41
46
|
|
42
|
-
def sanitize_array(source, filter_keys)
|
47
|
+
def sanitize_array(source, filter_keys, seen)
|
48
|
+
seen = seen.clone << source.object_id
|
49
|
+
|
43
50
|
[].tap do |array|
|
44
51
|
source.each_with_index do |item, index|
|
45
|
-
array[index] =
|
52
|
+
array[index] =
|
53
|
+
if seen.include?(item.object_id)
|
54
|
+
RECURSIVE
|
55
|
+
else
|
56
|
+
sanitize_value(item, filter_keys, seen)
|
57
|
+
end
|
46
58
|
end
|
47
59
|
end
|
48
60
|
end
|
data/lib/appsignal/version.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
describe Appsignal::Utils::HashSanitizer do
|
2
2
|
let(:file) { uploaded_file }
|
3
|
+
let(:some_array) { [1, 2, 3] }
|
4
|
+
let(:some_hash) { { :a => 1, :b => 2 } }
|
3
5
|
let(:params) do
|
4
6
|
{
|
5
7
|
:text => "string",
|
@@ -8,6 +10,10 @@ describe Appsignal::Utils::HashSanitizer do
|
|
8
10
|
:float => 0.0,
|
9
11
|
:bool_true => true,
|
10
12
|
:bool_false => false,
|
13
|
+
# Non-recursive appearances of the same array instance
|
14
|
+
:some_arrays => [some_array, some_array],
|
15
|
+
# Non-recursive appearances of the same hash instance
|
16
|
+
:some_hashes => { :a => some_hash, :b => some_hash },
|
11
17
|
:nil => nil,
|
12
18
|
:int => 1, # Fixnum
|
13
19
|
:int64 => 1 << 64, # Bignum
|
@@ -20,9 +26,20 @@ describe Appsignal::Utils::HashSanitizer do
|
|
20
26
|
{
|
21
27
|
:key => "value",
|
22
28
|
:file => file
|
23
|
-
}
|
24
|
-
|
25
|
-
|
29
|
+
}.tap do |hsh|
|
30
|
+
# Recursive hash-in-hash (should be [:nested_array][3][:recursive_hash])
|
31
|
+
hsh[:recursive_hash] = hsh
|
32
|
+
end
|
33
|
+
].tap do |ary|
|
34
|
+
# Recursive array-in-array (should be [:nested_array][4])
|
35
|
+
ary << ary
|
36
|
+
# Recursive array-in-hash (should be [:nested_array][3][:recursive_array])
|
37
|
+
ary[3][:recursive_array] = ary
|
38
|
+
end
|
39
|
+
}.tap do |hsh|
|
40
|
+
# Recursive hash-in-array (should be [:nested_array][5])
|
41
|
+
hsh[:nested_array] << hsh
|
42
|
+
end
|
26
43
|
}
|
27
44
|
end
|
28
45
|
|
@@ -43,6 +60,9 @@ describe Appsignal::Utils::HashSanitizer do
|
|
43
60
|
expect(subject[:nil]).to be_nil
|
44
61
|
expect(subject[:int]).to eq(1)
|
45
62
|
expect(subject[:int64]).to eq(1 << 64)
|
63
|
+
expect(subject[:some_arrays]).to eq([[1, 2, 3], [1, 2, 3]])
|
64
|
+
expect(subject[:some_hashes]).to eq({ :a => { :a => 1, :b => 2 },
|
65
|
+
:b => { :a => 1, :b => 2 } })
|
46
66
|
end
|
47
67
|
|
48
68
|
it "does not change the original params" do
|
@@ -72,7 +92,7 @@ describe Appsignal::Utils::HashSanitizer do
|
|
72
92
|
expect(subject[2]).to include "::UploadedFile"
|
73
93
|
end
|
74
94
|
|
75
|
-
describe "
|
95
|
+
describe "nested hash" do
|
76
96
|
subject { sanitized_params[:hash][:nested_array][3] }
|
77
97
|
|
78
98
|
it "returns a sanitized Hash" do
|
@@ -82,6 +102,24 @@ describe Appsignal::Utils::HashSanitizer do
|
|
82
102
|
expect(subject[:file]).to be_instance_of String
|
83
103
|
expect(subject[:file]).to include "::UploadedFile"
|
84
104
|
end
|
105
|
+
|
106
|
+
it "replaces a recursive array" do
|
107
|
+
expect(subject[:recursive_array]).to eq("[RECURSIVE VALUE]")
|
108
|
+
end
|
109
|
+
|
110
|
+
it "replaces a recursive hash" do
|
111
|
+
expect(subject[:recursive_hash]).to eq("[RECURSIVE VALUE]")
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "nested array" do
|
116
|
+
it "replaces a recursive array" do
|
117
|
+
expect(sanitized_params[:hash][:nested_array][4]).to eq("[RECURSIVE VALUE]")
|
118
|
+
end
|
119
|
+
|
120
|
+
it "replaces a recursive hash" do
|
121
|
+
expect(sanitized_params[:hash][:nested_array][5]).to eq("[RECURSIVE VALUE]")
|
122
|
+
end
|
85
123
|
end
|
86
124
|
end
|
87
125
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appsignal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.4.
|
4
|
+
version: 3.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Beekman
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-
|
13
|
+
date: 2023-07-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rack
|
@@ -439,7 +439,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
439
439
|
- !ruby/object:Gem::Version
|
440
440
|
version: '0'
|
441
441
|
requirements: []
|
442
|
-
rubygems_version: 3.
|
442
|
+
rubygems_version: 3.3.7
|
443
443
|
signing_key:
|
444
444
|
specification_version: 4
|
445
445
|
summary: Logs performance and exception data from your app to appsignal.com
|