moderate_parameters 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +70 -0
- data/.rubocop.yml +4 -0
- data/Gemfile.lock +27 -22
- data/lib/generators/moderate_parameters/install_generator.rb +17 -0
- data/lib/generators/templates/moderate_parameters.rb +7 -0
- data/lib/moderate_parameters/breadcrumbs.rb +36 -0
- data/lib/moderate_parameters/logger.rb +2 -2
- data/lib/moderate_parameters/{moderate_parameters.rb → parameters.rb} +4 -4
- data/lib/moderate_parameters/version.rb +1 -1
- data/lib/moderate_parameters.rb +19 -3
- data/log/.gitkeep +0 -0
- data/moderate_parameters.gemspec +1 -0
- metadata +23 -4
- data/.travis.yml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 025154d5fcf0e85640487bb165610bc71b9c57337bdc38f6dfb6180e5446a66a
|
4
|
+
data.tar.gz: 4e6ddfbc51cd37e463e01fee38b4ab167c9c391aeb2d5e3674ef5624c5dac353
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9785b2538bfec4f143b9acfe1391f696e95e43bb4e837cc030a7669f1cf5c920157a0035aa8fa8ee7b9c3363712d8b71bac623b5f518fe529b8778e0c7246627
|
7
|
+
data.tar.gz: 53d7b1d10bff242410ca415b4f3e2c3aefa11eada31c7db50c1c4b3dd9dfa90e0a52ed1bccb88e52b20097bd330eacca811e10d4fe1d268345b8a69150506191
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# Ruby CircleCI 2.0 configuration file
|
2
|
+
#
|
3
|
+
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
|
4
|
+
#
|
5
|
+
version: 2
|
6
|
+
jobs:
|
7
|
+
build:
|
8
|
+
docker:
|
9
|
+
# specify the version you desire here
|
10
|
+
- image: circleci/ruby:2.6.1
|
11
|
+
environment:
|
12
|
+
BUNDLE_JOBS: 3
|
13
|
+
BUNDLE_RETRY: 3
|
14
|
+
BUNDLE_PATH: vendor/bundle
|
15
|
+
RAILS_ENV: test
|
16
|
+
|
17
|
+
# Specify service dependencies here if necessary
|
18
|
+
# CircleCI maintains a library of pre-built images
|
19
|
+
# documented at https://circleci.com/docs/2.0/circleci-images/
|
20
|
+
# - image: circleci/postgres:9.4
|
21
|
+
|
22
|
+
working_directory: ~/repo
|
23
|
+
|
24
|
+
steps:
|
25
|
+
- checkout
|
26
|
+
# Download and cache dependencies
|
27
|
+
- restore_cache:
|
28
|
+
keys:
|
29
|
+
- v1-dependencies-{{ checksum "Gemfile.lock" }}
|
30
|
+
# fallback to using the latest cache if no exact match is found
|
31
|
+
- v1-dependencies-
|
32
|
+
|
33
|
+
- run:
|
34
|
+
name: Configure Bundler
|
35
|
+
command: |
|
36
|
+
echo 'export BUNDLER_VERSION=$(cat Gemfile.lock | tail -1 | tr -d " ")' >> $BASH_ENV
|
37
|
+
source $BASH_ENV
|
38
|
+
gem install bundler
|
39
|
+
|
40
|
+
- run:
|
41
|
+
name: install dependencies
|
42
|
+
command: |
|
43
|
+
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
44
|
+
|
45
|
+
- save_cache:
|
46
|
+
paths:
|
47
|
+
- ./vendor/bundle
|
48
|
+
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
49
|
+
|
50
|
+
# run tests!
|
51
|
+
- run:
|
52
|
+
name: run tests
|
53
|
+
command: |
|
54
|
+
mkdir /tmp/test-results
|
55
|
+
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | \
|
56
|
+
circleci tests split --split-by=timings)"
|
57
|
+
|
58
|
+
bundle exec rspec \
|
59
|
+
--format progress \
|
60
|
+
--format RspecJunitFormatter \
|
61
|
+
--out /tmp/test-results/rspec.xml \
|
62
|
+
--format progress \
|
63
|
+
$TEST_FILES
|
64
|
+
|
65
|
+
# collect reports
|
66
|
+
- store_test_results:
|
67
|
+
path: /tmp/test-results
|
68
|
+
- store_artifacts:
|
69
|
+
path: /tmp/test-results
|
70
|
+
destination: test-results
|
data/.rubocop.yml
ADDED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
moderate_parameters (0.1.
|
4
|
+
moderate_parameters (0.1.1)
|
5
5
|
actionpack (>= 3.0, < 6.1)
|
6
6
|
activemodel (>= 3.0, < 6.1)
|
7
7
|
activesupport (>= 3.0, < 6.1)
|
@@ -10,32 +10,33 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
actionpack (
|
14
|
-
actionview (=
|
15
|
-
activesupport (=
|
13
|
+
actionpack (6.0.0)
|
14
|
+
actionview (= 6.0.0)
|
15
|
+
activesupport (= 6.0.0)
|
16
16
|
rack (~> 2.0)
|
17
17
|
rack-test (>= 0.6.3)
|
18
18
|
rails-dom-testing (~> 2.0)
|
19
|
-
rails-html-sanitizer (~> 1.0, >= 1.0
|
20
|
-
actionview (
|
21
|
-
activesupport (=
|
19
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
20
|
+
actionview (6.0.0)
|
21
|
+
activesupport (= 6.0.0)
|
22
22
|
builder (~> 3.1)
|
23
23
|
erubi (~> 1.4)
|
24
24
|
rails-dom-testing (~> 2.0)
|
25
|
-
rails-html-sanitizer (~> 1.
|
26
|
-
activemodel (
|
27
|
-
activesupport (=
|
28
|
-
activesupport (
|
25
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
26
|
+
activemodel (6.0.0)
|
27
|
+
activesupport (= 6.0.0)
|
28
|
+
activesupport (6.0.0)
|
29
29
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
30
30
|
i18n (>= 0.7, < 2)
|
31
31
|
minitest (~> 5.1)
|
32
32
|
tzinfo (~> 1.1)
|
33
|
+
zeitwerk (~> 2.1, >= 2.1.8)
|
33
34
|
builder (3.2.3)
|
34
35
|
coderay (1.1.2)
|
35
36
|
concurrent-ruby (1.1.5)
|
36
37
|
crass (1.0.4)
|
37
38
|
diff-lcs (1.3)
|
38
|
-
erubi (1.
|
39
|
+
erubi (1.9.0)
|
39
40
|
i18n (1.6.0)
|
40
41
|
concurrent-ruby (~> 1.0)
|
41
42
|
loofah (2.2.3)
|
@@ -43,7 +44,7 @@ GEM
|
|
43
44
|
nokogiri (>= 1.5.9)
|
44
45
|
method_source (0.9.2)
|
45
46
|
mini_portile2 (2.4.0)
|
46
|
-
minitest (5.
|
47
|
+
minitest (5.12.0)
|
47
48
|
nokogiri (1.10.4)
|
48
49
|
mini_portile2 (~> 2.4.0)
|
49
50
|
pry (0.12.2)
|
@@ -55,32 +56,35 @@ GEM
|
|
55
56
|
rails-dom-testing (2.0.3)
|
56
57
|
activesupport (>= 4.2.0)
|
57
58
|
nokogiri (>= 1.6)
|
58
|
-
rails-html-sanitizer (1.0
|
59
|
+
rails-html-sanitizer (1.2.0)
|
59
60
|
loofah (~> 2.2, >= 2.2.2)
|
60
|
-
railties (
|
61
|
-
actionpack (=
|
62
|
-
activesupport (=
|
61
|
+
railties (6.0.0)
|
62
|
+
actionpack (= 6.0.0)
|
63
|
+
activesupport (= 6.0.0)
|
63
64
|
method_source
|
64
65
|
rake (>= 0.8.7)
|
65
|
-
thor (>= 0.
|
66
|
+
thor (>= 0.20.3, < 2.0)
|
66
67
|
rake (10.5.0)
|
67
68
|
rspec (3.8.0)
|
68
69
|
rspec-core (~> 3.8.0)
|
69
70
|
rspec-expectations (~> 3.8.0)
|
70
71
|
rspec-mocks (~> 3.8.0)
|
71
|
-
rspec-core (3.8.
|
72
|
+
rspec-core (3.8.2)
|
72
73
|
rspec-support (~> 3.8.0)
|
73
|
-
rspec-expectations (3.8.
|
74
|
+
rspec-expectations (3.8.4)
|
74
75
|
diff-lcs (>= 1.2.0, < 2.0)
|
75
76
|
rspec-support (~> 3.8.0)
|
76
|
-
rspec-mocks (3.8.
|
77
|
+
rspec-mocks (3.8.1)
|
77
78
|
diff-lcs (>= 1.2.0, < 2.0)
|
78
79
|
rspec-support (~> 3.8.0)
|
79
|
-
rspec-support (3.8.
|
80
|
+
rspec-support (3.8.2)
|
81
|
+
rspec_junit_formatter (0.4.1)
|
82
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
80
83
|
thor (0.20.3)
|
81
84
|
thread_safe (0.3.6)
|
82
85
|
tzinfo (1.2.5)
|
83
86
|
thread_safe (~> 0.1)
|
87
|
+
zeitwerk (2.1.10)
|
84
88
|
|
85
89
|
PLATFORMS
|
86
90
|
ruby
|
@@ -91,6 +95,7 @@ DEPENDENCIES
|
|
91
95
|
pry (~> 0.12.2)
|
92
96
|
rake (~> 10.0)
|
93
97
|
rspec (~> 3.0)
|
98
|
+
rspec_junit_formatter (= 0.4.1)
|
94
99
|
|
95
100
|
BUNDLED WITH
|
96
101
|
2.0.1
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/generators/base'
|
4
|
+
|
5
|
+
module ModerateParameters
|
6
|
+
module Generators
|
7
|
+
class InstallGenerator < Rails::Generators::Base
|
8
|
+
source_root File.expand_path('../templates', __dir__)
|
9
|
+
|
10
|
+
desc 'Creates a ModerateParameters initializer.'
|
11
|
+
|
12
|
+
def copy_initializer
|
13
|
+
template 'moderate_parameters.rb', 'config/initializers/moderate_parameters.rb'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ModerateParameters
|
4
|
+
module Breadcrumbs
|
5
|
+
def [](key)
|
6
|
+
internal_param_logging(key, 'read', caller_locations) if ModerateParameters.breadcrumbs_enabled
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
def []=(key, value)
|
11
|
+
internal_param_logging(key, 'overwritten', caller_locations) if ModerateParameters.breadcrumbs_enabled
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def extract!(*keys)
|
16
|
+
internal_method_logging('extract!', keys, caller_locations) if ModerateParameters.breadcrumbs_enabled
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def internal_param_logging(key, action, stack_array)
|
23
|
+
ActiveSupport::Notifications.instrument('moderate_parameters') do |payload|
|
24
|
+
payload[:caller_locations] = stack_array
|
25
|
+
payload[:message] = "#{key} is being #{action} on: #{stack_array.join("\n")}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def internal_method_logging(method, keys, stack_array)
|
30
|
+
ActiveSupport::Notifications.instrument('moderate_parameters') do |payload|
|
31
|
+
payload[:caller_locations] = stack_array
|
32
|
+
payload[:message] = "#{method} is being called with #{keys} on: #{stack_array.join("\n")}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
$moderate_parameters_logger = Logger.new('log/moderate_parameters.log')
|
3
|
+
$moderate_parameters_logger = ActiveSupport::Logger.new('log/moderate_parameters.log')
|
4
4
|
|
5
|
-
ActiveSupport::Notifications.subscribe('moderate_parameters') do |
|
5
|
+
ActiveSupport::Notifications.subscribe('moderate_parameters') do |_, _, _, _, payload|
|
6
6
|
$moderate_parameters_logger.info "#{payload[:controller]}##{payload[:action]} #{payload[:message]}"
|
7
7
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
4
|
-
|
3
|
+
module ModerateParameters
|
4
|
+
module Parameters
|
5
5
|
def moderate(controller_name, action, *filters)
|
6
6
|
params = self.class.new
|
7
7
|
|
@@ -14,13 +14,13 @@ module ActionController
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
|
17
|
+
incoming_params_logging(params, controller_name, action)
|
18
18
|
permit!
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
22
22
|
|
23
|
-
def
|
23
|
+
def incoming_params_logging(params, controller_name, action)
|
24
24
|
unpermitted_keys(params).each do |k|
|
25
25
|
ActiveSupport::Notifications.instrument('moderate_parameters') do |payload|
|
26
26
|
payload[:controller] = controller_name
|
data/lib/moderate_parameters.rb
CHANGED
@@ -1,8 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require 'action_controller'
|
4
|
+
require 'active_support'
|
5
|
+
require 'moderate_parameters/version'
|
6
|
+
require 'moderate_parameters/logger'
|
7
|
+
require 'moderate_parameters/parameters'
|
8
|
+
require 'moderate_parameters/breadcrumbs'
|
6
9
|
|
7
10
|
module ModerateParameters
|
11
|
+
mattr_accessor :breadcrumbs_enabled
|
12
|
+
@@breadcrumbs_enabled = false
|
13
|
+
|
14
|
+
def self.configure
|
15
|
+
yield self
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
module ActionController
|
20
|
+
class Parameters
|
21
|
+
prepend ModerateParameters::Breadcrumbs
|
22
|
+
prepend ModerateParameters::Parameters
|
23
|
+
end
|
8
24
|
end
|
data/log/.gitkeep
ADDED
File without changes
|
data/moderate_parameters.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moderate_parameters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle Boe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -146,6 +146,20 @@ dependencies:
|
|
146
146
|
- - "~>"
|
147
147
|
- !ruby/object:Gem::Version
|
148
148
|
version: '3.0'
|
149
|
+
- !ruby/object:Gem::Dependency
|
150
|
+
name: rspec_junit_formatter
|
151
|
+
requirement: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - '='
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: 0.4.1
|
156
|
+
type: :development
|
157
|
+
prerelease: false
|
158
|
+
version_requirements: !ruby/object:Gem::Requirement
|
159
|
+
requirements:
|
160
|
+
- - '='
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: 0.4.1
|
149
163
|
description: A tool for migrating Rails applications from Protected Attributes to
|
150
164
|
Strong Parameters.
|
151
165
|
email:
|
@@ -156,9 +170,10 @@ executables:
|
|
156
170
|
extensions: []
|
157
171
|
extra_rdoc_files: []
|
158
172
|
files:
|
173
|
+
- ".circleci/config.yml"
|
159
174
|
- ".gitignore"
|
160
175
|
- ".rspec"
|
161
|
-
- ".
|
176
|
+
- ".rubocop.yml"
|
162
177
|
- CHANGELOG.md
|
163
178
|
- CODE_OF_CONDUCT.md
|
164
179
|
- Gemfile
|
@@ -168,10 +183,14 @@ files:
|
|
168
183
|
- Rakefile
|
169
184
|
- bin/console
|
170
185
|
- bin/setup
|
186
|
+
- lib/generators/moderate_parameters/install_generator.rb
|
187
|
+
- lib/generators/templates/moderate_parameters.rb
|
171
188
|
- lib/moderate_parameters.rb
|
189
|
+
- lib/moderate_parameters/breadcrumbs.rb
|
172
190
|
- lib/moderate_parameters/logger.rb
|
173
|
-
- lib/moderate_parameters/
|
191
|
+
- lib/moderate_parameters/parameters.rb
|
174
192
|
- lib/moderate_parameters/version.rb
|
193
|
+
- log/.gitkeep
|
175
194
|
- moderate_parameters.gemspec
|
176
195
|
homepage: https://github.com/hintmedia/moderate_parameters
|
177
196
|
licenses:
|