honeybadger 5.13.0 → 5.13.1

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: 02da7e28bdfb138d80a3e8e3e591d45383406fac1676ed04f0df139125e56247
4
- data.tar.gz: 2c08c2e0e4e42ea9b7532c09f28f8d1c60a4944dab1e0d1ebc277becb58f8947
3
+ metadata.gz: 49f0e76e4da63a4398fcb71cc8fb153f5a854cd13a0d163924adc41473460401
4
+ data.tar.gz: f8adacb9335c3d42f3fa2991eb05453551cb546b1d439e504fff32d5c41703b5
5
5
  SHA512:
6
- metadata.gz: cd07b8f3bfe423336690f00dc80addfb4fbda2db27bbcca0739204888b1565455ea09cbb6d5e643162f00c247ce09ff867e3eab0d71d7f59ca8d39bfc26164cd
7
- data.tar.gz: 93e0ad66065c9be2c216e69a0d631effe6ba795ff90f328bf05a24bd2d45b60369e1cf3df4b0fc15478c7a73ec497a8661265bdb3daf52b39668117a7b123c9b
6
+ metadata.gz: e5022f0122bb51b147f6014e25f204250906b33c4e0e25c9699302e8e8a1bc97bad41497546f93c2d8cb9442de53d207309003699dfc55ae6190e14c2b110cff
7
+ data.tar.gz: dc28062240092dd136fb22ccd54b45882e850a6982f13225924606ff4e7805451e12a9516a9deba75ee83c71d0f2fcae400c70df2be191d8d5b1b402c8a71365
data/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
1
  # Change Log
2
2
 
3
3
 
4
+ ## [5.13.1](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.13.0...v5.13.1) (2024-07-01)
5
+
6
+
7
+ ### Bug Fixes
8
+
9
+ * do not check for rails console ([#574](https://github.com/honeybadger-io/honeybadger-ruby/issues/574)) ([ba74af8](https://github.com/honeybadger-io/honeybadger-ruby/commit/ba74af8b55393ea0a96962085ea48c4376380be3))
10
+ * ignore content-less SQL statements ([#572](https://github.com/honeybadger-io/honeybadger-ruby/issues/572)) ([e7ecd36](https://github.com/honeybadger-io/honeybadger-ruby/commit/e7ecd36969922496e276a246406fe7d792de00e3))
11
+ * sanitize SQL when reporting SQL queries ([#571](https://github.com/honeybadger-io/honeybadger-ruby/issues/571)) ([40d4a79](https://github.com/honeybadger-io/honeybadger-ruby/commit/40d4a79a5c1f758fe49779e63697d56599537235))
12
+
4
13
  ## [5.13.0](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.12.0...v5.13.0) (2024-06-18)
5
14
 
6
15
 
@@ -277,7 +277,6 @@ module Honeybadger
277
277
  end
278
278
 
279
279
  def insights_enabled?
280
- return false if defined?(::Rails.application) && ::Rails.const_defined?("Console")
281
280
  !!self[:'insights.enabled']
282
281
  end
283
282
 
@@ -1,4 +1,5 @@
1
1
  require 'honeybadger/instrumentation_helper'
2
+ require 'honeybadger/util/sql'
2
3
 
3
4
  module Honeybadger
4
5
  class NotificationSubscriber
@@ -9,7 +10,7 @@ module Honeybadger
9
10
  def finish(name, id, payload)
10
11
  @finish_time = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
11
12
 
12
- return unless process?(name)
13
+ return unless process?(name, payload)
13
14
 
14
15
  payload = {
15
16
  instrumenter_id: id,
@@ -23,7 +24,7 @@ module Honeybadger
23
24
  Honeybadger.event(name, payload)
24
25
  end
25
26
 
26
- def process?(event)
27
+ def process?(event, payload)
27
28
  true
28
29
  end
29
30
 
@@ -58,10 +59,16 @@ module Honeybadger
58
59
  class ActiveRecordSubscriber < NotificationSubscriber
59
60
  def format_payload(payload)
60
61
  {
61
- query: payload[:sql].to_s.gsub(/\s+/, ' ').strip,
62
+ query: Util::SQL.obfuscate(payload[:sql], payload[:connection].adapter_name),
62
63
  async: payload[:async]
63
64
  }
64
65
  end
66
+
67
+ def process?(event, payload)
68
+ return false if payload[:name] == "SCHEMA"
69
+ return false if payload[:sql]&.match?(/^(begin|commit)( transaction)?$/i)
70
+ true
71
+ end
65
72
  end
66
73
 
67
74
  class ActiveJobSubscriber < NotificationSubscriber
@@ -71,16 +71,18 @@ module Honeybadger
71
71
  end
72
72
 
73
73
  Plugin.register :rails do
74
- requirement { config.load_plugin_insights?(:rails_metrics) && defined?(::Rails.application) && ::Rails.application }
74
+ requirement { defined?(::Rails.application) && ::Rails.application }
75
75
 
76
76
  execution do
77
- ::ActiveSupport::Notifications.subscribe(/(process_action|send_file|redirect_to|halted_callback|unpermitted_parameters)\.action_controller/, Honeybadger::ActionControllerSubscriber.new)
78
- ::ActiveSupport::Notifications.subscribe(/(write_fragment|read_fragment|expire_fragment|exist_fragment\?)\.action_controller/, Honeybadger::ActionControllerCacheSubscriber.new)
79
- ::ActiveSupport::Notifications.subscribe(/cache_(read|read_multi|generate|fetch_hit|write|write_multi|increment|decrement|delete|delete_multi|cleanup|prune|exist\?)\.active_support/, Honeybadger::ActiveSupportCacheSubscriber.new)
80
- ::ActiveSupport::Notifications.subscribe(/^render_(template|partial|collection)\.action_view/, Honeybadger::ActionViewSubscriber.new)
81
- ::ActiveSupport::Notifications.subscribe("sql.active_record", Honeybadger::ActiveRecordSubscriber.new)
82
- ::ActiveSupport::Notifications.subscribe("process.action_mailer", Honeybadger::ActionMailerSubscriber.new)
83
- ::ActiveSupport::Notifications.subscribe(/(service_upload|service_download)\.active_storage/, Honeybadger::ActiveStorageSubscriber.new)
77
+ if config.load_plugin_insights?(:rails)
78
+ ::ActiveSupport::Notifications.subscribe(/(process_action|send_file|redirect_to|halted_callback|unpermitted_parameters)\.action_controller/, Honeybadger::ActionControllerSubscriber.new)
79
+ ::ActiveSupport::Notifications.subscribe(/(write_fragment|read_fragment|expire_fragment|exist_fragment\?)\.action_controller/, Honeybadger::ActionControllerCacheSubscriber.new)
80
+ ::ActiveSupport::Notifications.subscribe(/cache_(read|read_multi|generate|fetch_hit|write|write_multi|increment|decrement|delete|delete_multi|cleanup|prune|exist\?)\.active_support/, Honeybadger::ActiveSupportCacheSubscriber.new)
81
+ ::ActiveSupport::Notifications.subscribe(/^render_(template|partial|collection)\.action_view/, Honeybadger::ActionViewSubscriber.new)
82
+ ::ActiveSupport::Notifications.subscribe("sql.active_record", Honeybadger::ActiveRecordSubscriber.new)
83
+ ::ActiveSupport::Notifications.subscribe("process.action_mailer", Honeybadger::ActionMailerSubscriber.new)
84
+ ::ActiveSupport::Notifications.subscribe(/(service_upload|service_download)\.active_storage/, Honeybadger::ActiveStorageSubscriber.new)
85
+ end
84
86
  end
85
87
  end
86
88
  end
@@ -1,32 +1,29 @@
1
1
  module Honeybadger
2
2
  module Util
3
3
  class SQL
4
- EscapedQuotes = /(\\"|\\')/.freeze
5
- SQuotedData = /'(?:[^']|'')*'/.freeze
6
- DQuotedData = /"(?:[^"]|"")*"/.freeze
7
- NumericData = /\b\d+\b/.freeze
8
- Newline = /\n/.freeze
9
- Replacement = "?".freeze
10
- EmptyReplacement = "".freeze
11
- DoubleQuoters = /(postgres|sqlite|postgis)/.freeze
4
+ ESCAPE_QUOTES = /(\\"|\\')/
5
+ SQUOTE_DATA = /'(?:[^']|'')*'/
6
+ DQUOTE_DATA = /"(?:[^"]|"")*"/
7
+ NUMBER_DATA = /\b\d+\b/
8
+ DOUBLE_QUOTERS = /(postgres|sqlite|postgis)/i
12
9
 
13
10
  def self.obfuscate(sql, adapter)
14
- force_utf_8(sql.dup).tap do |s|
15
- s.gsub!(EscapedQuotes, EmptyReplacement)
16
- s.gsub!(SQuotedData, Replacement)
17
- s.gsub!(DQuotedData, Replacement) if adapter =~ DoubleQuoters
18
- s.gsub!(NumericData, Replacement)
19
- s.gsub!(Newline, EmptyReplacement)
20
- s.squeeze!(' ')
11
+ force_utf_8(sql.to_s.dup).tap do |s|
12
+ s.gsub!(/\s+/, " ")
13
+ s.gsub!(ESCAPE_QUOTES, "".freeze)
14
+ s.gsub!(SQUOTE_DATA, "'?'".freeze)
15
+ s.gsub!(DQUOTE_DATA, '"?"'.freeze) unless adapter.to_s.match?(DOUBLE_QUOTERS)
16
+ s.gsub!(NUMBER_DATA, "?".freeze)
17
+ s.strip!
21
18
  end
22
19
  end
23
20
 
24
21
  def self.force_utf_8(string)
25
22
  string.encode(
26
- Encoding.find('UTF-8'),
27
- invalid: :replace,
28
- undef: :replace,
29
- replace: ''
23
+ Encoding.find("UTF-8"),
24
+ invalid: :replace,
25
+ undef: :replace,
26
+ replace: ""
30
27
  )
31
28
  end
32
29
  end
@@ -1,4 +1,4 @@
1
1
  module Honeybadger
2
2
  # The current String Honeybadger version.
3
- VERSION = '5.13.0'.freeze
3
+ VERSION = '5.13.1'.freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: honeybadger
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.13.0
4
+ version: 5.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Honeybadger Industries LLC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-18 00:00:00.000000000 Z
11
+ date: 2024-07-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Make managing application errors a more pleasant experience.
14
14
  email: