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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c18943a93c4707c1d5c8aa2b92925ac997fbd98fc08f9c4c58f9eb485c98f02
4
- data.tar.gz: e38d8c87ca688037a860a3b4af69d54f255f575d6cd3d5ca8b31e8bb0ff1639b
3
+ metadata.gz: 7a24358f9899f5d51901c6f1e26abb546cdbe21b04e961ce2a76d213cd1a9d23
4
+ data.tar.gz: 8ae4ce5d3b81edb69876408eb823b651841de5da64dfaf3a2288aa7eab42d503
5
5
  SHA512:
6
- metadata.gz: 1f9eead24427fed2fac91181599f75a87a5389b913b5a9a6042b4ebcfb27ffa7af213f76127182d7d05078bde22cbf3e431f414b86ca27ef8490175e761da60c
7
- data.tar.gz: f2a10234aea2f2402da52686c9500e2591d852d9757d267032fda58366650aead11b621eb4d0681819acfdfebd3c0d6010329e60758644dbada17f4106c6654b
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 >= Logger::ERROR && (e = detect_logged_exception(message))
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] = filter_pairs(cookie, cookie_obfuscator)
231
+ headers[COOKIE] = obfuscate_cookie(cookie, cookie_obfuscator)
232
232
  end
233
233
 
234
234
  headers.keys.each do |k|
@@ -1,3 +1,3 @@
1
1
  module LogjamAgent
2
- VERSION = "0.38.3"
2
+ VERSION = "0.38.5"
3
3
  end
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:]+$/
@@ -5,24 +5,23 @@ module LogjamAgent
5
5
  include Obfuscation
6
6
 
7
7
  test "obfuscates session cookie by default" do
8
- filter = LogjamAgent.cookie_obfuscator
9
- assert_equal "_session=[FILTERED]", filter_pairs("_session=data", filter)
10
- assert_equal "my_session=[FILTERED]", filter_pairs("my_session=mdata", filter)
11
- assert_equal "blabber=1; _session=[FILTERED]", filter_pairs("blabber=1; _session=data", filter)
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]", filter_pairs("_session=my_session; login=foo", filter)
18
- assert_equal "_session=[FILTERED]; my_login=[FILTERED]", filter_pairs("_session=my_session; my_login=foo", filter)
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]", filter_pairs("_session=my_session; login=foo", filter)
24
- assert_equal "_session=[FILTERED]; my_login=foo", filter_pairs("_session=my_session; my_login=foo", filter)
25
- assert_equal "my_session=[FILTERED]; my_login=foo", filter_pairs("my_session=my_session; my_login=foo", filter)
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.3
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-03-20 00:00:00.000000000 Z
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.3.26
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