logjam_agent 0.38.3 → 0.38.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/logjam_agent/buffered_logger.rb +1 -1
- data/lib/logjam_agent/obfuscation.rb +4 -0
- data/lib/logjam_agent/rack/logger.rb +1 -1
- data/lib/logjam_agent/version.rb +1 -1
- data/lib/logjam_agent.rb +3 -0
- data/test/obfuscator_test.rb +9 -10
- 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: 7a24358f9899f5d51901c6f1e26abb546cdbe21b04e961ce2a76d213cd1a9d23
|
4
|
+
data.tar.gz: 8ae4ce5d3b81edb69876408eb823b651841de5da64dfaf3a2288aa7eab42d503
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d532f42b3b39e26448bab7c758076b003de095d2e42c4bf26c383b10936aa7c156b2fd0dd10049850eaeb5036abececfb50c0a6b1423747790f6a7943510394e
|
7
|
+
data.tar.gz: d0fb5cc2eef5c93477a6a41dda442186745a646f16653e21b949be49102d9d515e7216fe901bc268c0f0be8de56b68918a80fbcc9359daefa847e15e2aa63834
|
@@ -123,7 +123,7 @@ module LogjamAgent
|
|
123
123
|
message = LogjamAgent.json_encode_payload(message)
|
124
124
|
else
|
125
125
|
message = message.to_s
|
126
|
-
if request && severity >=
|
126
|
+
if request && severity >= LogjamAgent.exception_auto_detection_level && (e = detect_logged_exception(message))
|
127
127
|
request.add_exception(e)
|
128
128
|
end
|
129
129
|
end
|
@@ -16,6 +16,10 @@ module LogjamAgent
|
|
16
16
|
@cookie_obfuscator ||= ParameterFilter.new(obfuscated_cookies)
|
17
17
|
end
|
18
18
|
|
19
|
+
def obfuscate_cookie(cookie, filter = cookie_obfuscator)
|
20
|
+
filter_pairs(cookie, filter)
|
21
|
+
end
|
22
|
+
|
19
23
|
begin
|
20
24
|
# rails 6.1 and higher
|
21
25
|
require "active_support/parameter_filter"
|
@@ -228,7 +228,7 @@ module LogjamAgent
|
|
228
228
|
end
|
229
229
|
|
230
230
|
if (cookie = headers[COOKIE]) && obfuscated_cookies.present?
|
231
|
-
headers[COOKIE] =
|
231
|
+
headers[COOKIE] = obfuscate_cookie(cookie, cookie_obfuscator)
|
232
232
|
end
|
233
233
|
|
234
234
|
headers.keys.each do |k|
|
data/lib/logjam_agent/version.rb
CHANGED
data/lib/logjam_agent.rb
CHANGED
@@ -167,6 +167,9 @@ module LogjamAgent
|
|
167
167
|
true
|
168
168
|
end
|
169
169
|
|
170
|
+
mattr_accessor :exception_auto_detection_level
|
171
|
+
self.exception_auto_detection_level = Logger::ERROR
|
172
|
+
|
170
173
|
def self.auto_detect_exception(exception_class)
|
171
174
|
# ignore Exception classes created with Class.new (timeout.rb, my old friend)
|
172
175
|
if (class_name = exception_class.to_s) =~ /^[\w:]+$/
|
data/test/obfuscator_test.rb
CHANGED
@@ -5,24 +5,23 @@ module LogjamAgent
|
|
5
5
|
include Obfuscation
|
6
6
|
|
7
7
|
test "obfuscates session cookie by default" do
|
8
|
-
|
9
|
-
assert_equal "
|
10
|
-
assert_equal "
|
11
|
-
assert_equal "blabber=1; _session=[FILTERED]",
|
12
|
-
assert_equal "blabber=1; _session=[FILTERED]; blubber=2", filter_pairs("blabber=1; _session=data; blubber=2", filter)
|
8
|
+
assert_equal "_session=[FILTERED]", obfuscate_cookie("_session=data")
|
9
|
+
assert_equal "my_session=[FILTERED]", obfuscate_cookie("my_session=mdata")
|
10
|
+
assert_equal "blabber=1; _session=[FILTERED]", obfuscate_cookie("blabber=1; _session=data")
|
11
|
+
assert_equal "blabber=1; _session=[FILTERED]; blubber=2", obfuscate_cookie("blabber=1; _session=data; blubber=2")
|
13
12
|
end
|
14
13
|
|
15
14
|
test "obfuscates with complex regex" do
|
16
15
|
filter = ParameterFilter.new([/(login|_session)\z/])
|
17
|
-
assert_equal "_session=[FILTERED]; login=[FILTERED]",
|
18
|
-
assert_equal "_session=[FILTERED]; my_login=[FILTERED]",
|
16
|
+
assert_equal "_session=[FILTERED]; login=[FILTERED]", obfuscate_cookie("_session=my_session; login=foo", filter)
|
17
|
+
assert_equal "_session=[FILTERED]; my_login=[FILTERED]", obfuscate_cookie("_session=my_session; my_login=foo", filter)
|
19
18
|
end
|
20
19
|
|
21
20
|
test "obfuscates with exact matches" do
|
22
21
|
filter = ParameterFilter.new([/\A(login|.*_session)\z/])
|
23
|
-
assert_equal "_session=[FILTERED]; login=[FILTERED]",
|
24
|
-
assert_equal "_session=[FILTERED]; my_login=foo",
|
25
|
-
assert_equal "my_session=[FILTERED]; my_login=foo",
|
22
|
+
assert_equal "_session=[FILTERED]; login=[FILTERED]", obfuscate_cookie("_session=my_session; login=foo", filter)
|
23
|
+
assert_equal "_session=[FILTERED]; my_login=foo", obfuscate_cookie("_session=my_session; my_login=foo", filter)
|
24
|
+
assert_equal "my_session=[FILTERED]; my_login=foo", obfuscate_cookie("my_session=my_session; my_login=foo", filter)
|
26
25
|
end
|
27
26
|
end
|
28
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logjam_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.38.
|
4
|
+
version: 0.38.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Kaes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
128
|
- !ruby/object:Gem::Version
|
129
129
|
version: '0'
|
130
130
|
requirements: []
|
131
|
-
rubygems_version: 3.
|
131
|
+
rubygems_version: 3.4.10
|
132
132
|
signing_key:
|
133
133
|
specification_version: 4
|
134
134
|
summary: Logjam client library to be used with logjam
|