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 +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/sidekiq.rb +1 -1
- data/lib/surrogate_key_logging/version.rb +2 -2
- data/lib/surrogate_key_logging.rb +5 -3
- 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: b9ce65ad0880f73135e03ce8be79ba2c3dc31b042d7cac0bf4c34acf15dcf96b
|
4
|
+
data.tar.gz: da6cdd954ca7dfa890f862dac29789fd78413f8106c629267990577713c2105a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
@@ -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'
|
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
|
+
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-
|
11
|
+
date: 2023-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|