rails_surrogate_key_logging 1.4.0 → 1.5.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: 0c90ffc261a0cc4de8d88266fd00e0ce40c4c5a1802cf60b2fdaa72c6d345d61
4
- data.tar.gz: 13dfb52ddf21fd49d28930043a4c8a3160c466fb2a03dfc8e9e369ad9b0007ab
3
+ metadata.gz: b9ce65ad0880f73135e03ce8be79ba2c3dc31b042d7cac0bf4c34acf15dcf96b
4
+ data.tar.gz: da6cdd954ca7dfa890f862dac29789fd78413f8106c629267990577713c2105a
5
5
  SHA512:
6
- metadata.gz: cc2df820cec2c3c042552fd8e9e7f16c87b5c8592228a9f8c03e9c91e40417d5c0b7cf8cb2e15d729e56837e7ec6cccbb63a75e10c8cfd633ff55c6e029a7668
7
- data.tar.gz: 80ce2c893ef9394acec270591f2c63d4f5603d701fd12eb8562a9b23a9d07555f8af0481a0e1df92692900e080bf826025cd20f77295514e8ac5fe0186a659cd
6
+ metadata.gz: 5127d29dc7d316edbcb8d957ddb2440eaea33012d5bbf8f04f56b93f8b93e4d85bb9c601a25915f771ddf8faf060e1ca332d1ae17fc7a9b8067c38a9df005da1
7
+ data.tar.gz: 7254fc40a0900861e7b35d44e549484acf42a0f913abf4a7b585c2522b7d28f116c05e21f276fa7f7f4c3ed20b0e33ba5535dd0235f768fa83118afd19f053db
@@ -5,11 +5,11 @@ require 'active_support/concern'
5
5
  module SurrogateKeyLogging
6
6
  module ActionController
7
7
  module Params
8
- extend ActiveSupport::Concern
8
+ extend ::ActiveSupport::Concern
9
9
 
10
10
  class_methods do
11
11
  def surrogate_params(*params, action: '*')
12
- @surrogate_params ||= ActiveSupport::HashWithIndifferentAccess.new {|h,k| h[k] = [] }
12
+ @surrogate_params ||= ::ActiveSupport::HashWithIndifferentAccess.new {|h,k| h[k] = [] }
13
13
  params.each do |param|
14
14
  param = param.to_s
15
15
  @surrogate_params[action] << param
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SurrogateKeyLogging
4
4
  module ActionController
5
- extend ActiveSupport::Autoload
5
+ extend ::ActiveSupport::Autoload
6
6
 
7
7
  autoload :LogSubscriber
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SurrogateKeyLogging
4
4
  module ActionDispatch
5
- extend ActiveSupport::Autoload
5
+ extend ::ActiveSupport::Autoload
6
6
 
7
7
  autoload :ParamsFilter
8
8
  autoload :QueryStringFilter
@@ -5,7 +5,7 @@ require 'active_support/concern'
5
5
  module SurrogateKeyLogging
6
6
  module ActiveRecord
7
7
  module Attributes
8
- extend ActiveSupport::Concern
8
+ extend ::ActiveSupport::Concern
9
9
 
10
10
  class_methods do
11
11
  def surrogate_parent_names(*names)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SurrogateKeyLogging
4
4
  module ActiveRecord
5
- extend ActiveSupport::Autoload
5
+ extend ::ActiveSupport::Autoload
6
6
 
7
7
  autoload :Attributes
8
8
  autoload :LogSubscriber
@@ -1,36 +1,31 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/parameter_filter'
4
-
5
- # Add ability for @mask to be a class/instance/lambda/proc
6
- module ActiveSupport
7
- class ParameterFilter
8
- class CompiledFilter
9
-
10
- def value_for_key(key, value, parents = [], original_params = nil) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
11
- parents.push(key) if deep_regexps
12
- if regexps.any? { |r| r.match?(key.to_s) }
13
- value = @mask.respond_to?(:call) ? @mask.call(key, value, parents, original_params) : @mask
14
- elsif deep_regexps && (joined = parents.join('.')) && deep_regexps.any? { |r| r.match?(joined) } # rubocop:disable Lint/DuplicateBranch
15
- value = @mask.respond_to?(:call) ? @mask.call(key, value, parents, original_params) : @mask
16
- elsif value.is_a?(Hash)
17
- value = call(value, parents, original_params)
18
- elsif value.is_a?(Array)
19
- # If we don't pop the current parent it will be duplicated as we
20
- # process each array value.
21
- parents.pop if deep_regexps
22
- value = value.map { |v| value_for_key(key, v, parents, original_params) }
23
- # Restore the parent stack after processing the array.
24
- parents.push(key) if deep_regexps
25
- elsif blocks.any?
26
- key = key.dup if key.duplicable?
27
- value = value.dup if value.duplicable?
28
- blocks.each { |b| b.arity == 2 ? b.call(key, value) : b.call(key, value, original_params) }
29
- end
3
+ module SurrogateKeyLogging
4
+ module ActiveSupport
5
+ # Add ability for @mask to be a class/instance/lambda/proc
6
+ def value_for_key(key, value, parents = [], original_params = nil) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
7
+ parents.push(key) if deep_regexps
8
+ if regexps.any? { |r| r.match?(key.to_s) }
9
+ value = @mask.respond_to?(:call) ? @mask.call(key, value, parents, original_params) : @mask
10
+ elsif deep_regexps && (joined = parents.join('.')) && deep_regexps.any? { |r| r.match?(joined) } # rubocop:disable Lint/DuplicateBranch
11
+ value = @mask.respond_to?(:call) ? @mask.call(key, value, parents, original_params) : @mask
12
+ elsif value.is_a?(Hash)
13
+ value = call(value, parents, original_params)
14
+ elsif value.is_a?(Array)
15
+ # If we don't pop the current parent it will be duplicated as we
16
+ # process each array value.
30
17
  parents.pop if deep_regexps
31
- value
18
+ value = value.map { |v| value_for_key(key, v, parents, original_params) }
19
+ # Restore the parent stack after processing the array.
20
+ parents.push(key) if deep_regexps
21
+ elsif blocks.any?
22
+ key = key.dup if key.duplicable?
23
+ value = value.dup if value.duplicable?
24
+ blocks.each { |b| b.arity == 2 ? b.call(key, value) : b.call(key, value, original_params) }
32
25
  end
33
-
26
+ parents.pop if deep_regexps
27
+ value
34
28
  end
29
+
35
30
  end
36
31
  end
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SurrogateKeyLogging
4
- class Config < ActiveSupport::OrderedOptions
4
+ class Config < ::ActiveSupport::OrderedOptions
5
5
  end
6
6
 
7
7
  module Configuration
8
- extend ActiveSupport::Concern
8
+ extend ::ActiveSupport::Concern
9
9
 
10
10
  def surrogate_key_logging
11
11
  SurrogateKeyLogging.config
@@ -33,6 +33,7 @@ module SurrogateKeyLogging
33
33
 
34
34
  def call(_key, value, _parents = [], _original_params = nil)
35
35
  return "" if value.blank?
36
+ return value unless SurrogateKeyLogging.config.enabled
36
37
  surrogate = get(value)
37
38
  Rails.logger.tagged('SurrogateKeyLogging') { Rails.logger.info "Surrogate: `#{surrogate}`, value: `#{value}`" } if SurrogateKeyLogging.config.debug
38
39
  surrogate
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SurrogateKeyLogging
4
4
  module KeyStore
5
- extend ActiveSupport::Autoload
5
+ extend ::ActiveSupport::Autoload
6
6
 
7
7
  eager_autoload do
8
8
  autoload :Base
@@ -43,7 +43,7 @@ end
43
43
  module SurrogateKeyLogging
44
44
  class SidekiqMiddleware
45
45
 
46
- def call(env)
46
+ def call(*_)
47
47
  yield
48
48
  SurrogateKeyLogging.reset
49
49
  end
@@ -4,8 +4,8 @@ module SurrogateKeyLogging
4
4
 
5
5
  module Version
6
6
  MAJOR = 1
7
- MINOR = 4
8
- PATCH = 0
7
+ MINOR = 5
8
+ PATCH = 1
9
9
 
10
10
  end
11
11
 
@@ -4,7 +4,7 @@ require 'active_support'
4
4
 
5
5
  # Container Module
6
6
  module SurrogateKeyLogging
7
- extend ActiveSupport::Autoload
7
+ extend ::ActiveSupport::Autoload
8
8
 
9
9
  autoload :ActionController
10
10
  autoload :ActionDispatch
@@ -55,7 +55,7 @@ module SurrogateKeyLogging
55
55
  end
56
56
 
57
57
  def filter_for_attributes(attrs)
58
- config.enabled ? ::ActiveSupport::ParameterFilter.new(attrs, mask: key_manager) : attrs
58
+ ::ActiveSupport::ParameterFilter.new(config.enabled ? attrs : [], mask: key_manager)
59
59
  end
60
60
 
61
61
  def key_store
@@ -63,7 +63,7 @@ module SurrogateKeyLogging
63
63
  end
64
64
 
65
65
  def filter_parameters(params)
66
- config.enabled ? parameter_filter.filter(params) : params
66
+ parameter_filter.filter(params)
67
67
  end
68
68
 
69
69
  def surrogate_for(value)
@@ -84,6 +84,8 @@ module SurrogateKeyLogging
84
84
 
85
85
  end
86
86
 
87
+ require 'active_support/parameter_filter'
88
+ ::ActiveSupport::ParameterFilter::CompiledFilter.send(:prepend, ActiveSupport)
87
89
  KeyStore.eager_load!
88
90
  ::Rails::Application::Configuration.send(:include, Configuration)
89
91
  require 'surrogate_key_logging/engine'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_surrogate_key_logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Yelverton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-05 00:00:00.000000000 Z
11
+ date: 2023-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack