Sha256: 05e8188da286bfd5e8520cb6a9c0ea2c8a413cfc0fe2886585f1d2361e5466b1

Contents?: true

Size: 929 Bytes

Versions: 6

Compression:

Stored size: 929 Bytes

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

module NewRelic
  module Agent
    module Database
      module ObfuscationHelpers
        NUMERICS = /\b\d+\b/
        SINGLE_QUOTES = /'(?:[^']|'')*'/
        DOUBLE_QUOTES = /"(?:[^"]|"")*"/

        def remove_escaped_quotes(sql)
          sql.gsub(/\\"/, '').gsub(/\\'/, '')
        end

        def obfuscate_single_quote_literals(sql)
          sql.gsub(SINGLE_QUOTES, '?')
        end

        def obfuscate_double_quote_literals(sql)
          sql.gsub(DOUBLE_QUOTES, '?')
        end

        def obfuscate_numeric_literals(sql)
          sql.gsub(NUMERICS, "?")
        end

        def find_literals(sql)
          literals = sql.scan(NUMERICS)
          literals << sql.scan(SINGLE_QUOTES)
          literals.flatten
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
newrelic_rpm-3.9.1.236 lib/new_relic/agent/database/obfuscation_helpers.rb
newrelic_rpm-3.9.0.229 lib/new_relic/agent/database/obfuscation_helpers.rb
newrelic_rpm-3.8.1.221 lib/new_relic/agent/database/obfuscation_helpers.rb
newrelic_rpm-3.8.0.218 lib/new_relic/agent/database/obfuscation_helpers.rb
newrelic_rpm-3.7.3.204 lib/new_relic/agent/database/obfuscation_helpers.rb
newrelic_rpm-3.7.3.199 lib/new_relic/agent/database/obfuscation_helpers.rb