rails_surrogate_key_logging 1.4.0 → 1.5.0
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/lib/surrogate_key_logging/action_controller/params.rb +2 -2
- data/lib/surrogate_key_logging/action_controller.rb +1 -1
- data/lib/surrogate_key_logging/action_dispatch.rb +1 -1
- data/lib/surrogate_key_logging/active_record/attributes.rb +1 -1
- data/lib/surrogate_key_logging/active_record.rb +1 -1
- data/lib/surrogate_key_logging/active_support.rb +24 -29
- data/lib/surrogate_key_logging/configuration.rb +2 -2
- data/lib/surrogate_key_logging/key_manager.rb +1 -0
- data/lib/surrogate_key_logging/key_store.rb +1 -1
- data/lib/surrogate_key_logging/version.rb +1 -1
- data/lib/surrogate_key_logging.rb +5 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5d3a0747a79affaf71480538b5ca2567c962ddf03c6af176661ea082b7427e5
|
4
|
+
data.tar.gz: aec5af8fb44ca382501cef61b9d142328a8befa571df08821e4b9f5ef365490c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8ec40ce47168317e745ed14d707ca7c8a35ce7bd9eec78c7224baf4bcaa5f2a92b8eeade6024a745aa66d018ea11bbb65fb5989461923d635df60cf0eb0f060
|
7
|
+
data.tar.gz: b245a066710ba8440584f4fb51588bf0a968e969ef41eef0ae52e739bfdf266cc40d63770ccc4866917a806437b7d1ebb8eb5bcfdc48f914ee47df44ca60f26e
|
@@ -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
|
@@ -1,36 +1,31 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
# Add ability for @mask to be a class/instance/lambda/proc
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
@@ -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
|
-
|
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
|
-
|
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'
|