honeybadger 5.13.0 → 5.13.1
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 +9 -0
- data/lib/honeybadger/config.rb +0 -1
- data/lib/honeybadger/notification_subscriber.rb +10 -3
- data/lib/honeybadger/plugins/rails.rb +10 -8
- data/lib/honeybadger/util/sql.rb +16 -19
- data/lib/honeybadger/version.rb +1 -1
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 49f0e76e4da63a4398fcb71cc8fb153f5a854cd13a0d163924adc41473460401
         | 
| 4 | 
            +
              data.tar.gz: f8adacb9335c3d42f3fa2991eb05453551cb546b1d439e504fff32d5c41703b5
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 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 |  | 
    
        data/lib/honeybadger/config.rb
    CHANGED
    
    
| @@ -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]. | 
| 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 {  | 
| 74 | 
            +
                    requirement { defined?(::Rails.application) && ::Rails.application }
         | 
| 75 75 |  | 
| 76 76 | 
             
                    execution do
         | 
| 77 | 
            -
                       | 
| 78 | 
            -
             | 
| 79 | 
            -
             | 
| 80 | 
            -
             | 
| 81 | 
            -
             | 
| 82 | 
            -
             | 
| 83 | 
            -
             | 
| 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
         | 
    
        data/lib/honeybadger/util/sql.rb
    CHANGED
    
    | @@ -1,32 +1,29 @@ | |
| 1 1 | 
             
            module Honeybadger
         | 
| 2 2 | 
             
              module Util
         | 
| 3 3 | 
             
                class SQL
         | 
| 4 | 
            -
                   | 
| 5 | 
            -
                   | 
| 6 | 
            -
                   | 
| 7 | 
            -
                   | 
| 8 | 
            -
                   | 
| 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!( | 
| 16 | 
            -
                      s.gsub!( | 
| 17 | 
            -
                      s.gsub!( | 
| 18 | 
            -
                      s.gsub!( | 
| 19 | 
            -
                      s.gsub!( | 
| 20 | 
            -
                      s. | 
| 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( | 
| 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
         | 
    
        data/lib/honeybadger/version.rb
    CHANGED
    
    
    
        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. | 
| 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- | 
| 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:
         |