whiny-mass-assignment 0.1.5 → 0.1.6
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.
data/Manifest
CHANGED
@@ -7,6 +7,7 @@ Rakefile
|
|
7
7
|
lib/whiny-mass-assignment.rb
|
8
8
|
lib/whiny-mass-assignment/color_escapes.rb
|
9
9
|
lib/whiny-mass-assignment/configuration.rb
|
10
|
+
lib/whiny-mass-assignment/mass_assignment_security_overrides.rb
|
10
11
|
lib/whiny-mass-assignment/sanitizer.rb
|
11
12
|
lib/whiny_mass_assignment.rb
|
12
13
|
rails/init.rb
|
@@ -14,3 +15,4 @@ spec/config_spec.rb
|
|
14
15
|
spec/sanitizer_spec.rb
|
15
16
|
spec/spec_helper.rb
|
16
17
|
tasks/spec.rake
|
18
|
+
whiny-mass-assignment.gemspec
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new( 'whiny-mass-assignment', '0.1.
|
5
|
+
Echoe.new( 'whiny-mass-assignment', '0.1.6', ) do |p|
|
6
6
|
p.description = "Complain loudly when protected attributes are set through mass assignment."
|
7
7
|
p.url = "https://github.com/appsinyourpants/whiny-mass-assignment"
|
8
8
|
p.author = "Paul Alexander"
|
@@ -15,11 +15,20 @@ module WhinyMassAssignment
|
|
15
15
|
@mode = value
|
16
16
|
end
|
17
17
|
|
18
|
+
def whitelist
|
19
|
+
@whitelist ||= { :mode => :raise, :except => [] }
|
20
|
+
end
|
21
|
+
|
22
|
+
def whitelist=( options = {} )
|
23
|
+
options[:mode] ||= :raise
|
24
|
+
@whitelist = options
|
25
|
+
end
|
26
|
+
|
18
27
|
end
|
19
28
|
end
|
20
29
|
|
21
|
-
|
22
30
|
require 'whiny-mass-assignment/sanitizer'
|
31
|
+
require 'whiny-mass-assignment/mass_assignment_security_overrides'
|
23
32
|
if defined? Rails
|
24
33
|
require 'whiny-mass-assignment/configuration'
|
25
34
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'active_model/mass_assignment_security'
|
2
|
+
|
3
|
+
module ActiveModel
|
4
|
+
module MassAssignmentSecurity
|
5
|
+
|
6
|
+
|
7
|
+
def sanitize_for_mass_assignment_with_warning(attributes,&block)
|
8
|
+
debugger
|
9
|
+
sanitize_for_mass_assignment_without_warning(attributes,&block).tap{
|
10
|
+
return unless Config.whitelist[:mode] == :none
|
11
|
+
warn_when_mass_assignment_is_not_whitelist unless mass_assignment_authorizer === WhiteList
|
12
|
+
}
|
13
|
+
end
|
14
|
+
alias_method_chain :sanitize_for_mass_assignment, :warning
|
15
|
+
|
16
|
+
|
17
|
+
def warn_when_mass_assignment_is_not_whitelist
|
18
|
+
only = Config.whitelist[:only]
|
19
|
+
if only
|
20
|
+
return unless only.include?( self.class )
|
21
|
+
else
|
22
|
+
except = Config.whitelist[:except]
|
23
|
+
return if except && except.include?( self.class )
|
24
|
+
end
|
25
|
+
|
26
|
+
self.logger.debug WhinyMassAssignment::bc :yellow, "Mass assignment whitelisting has not been specified for #{ c [:bright, :red], self.class.name }" if self.logger
|
27
|
+
raise "Can't mass-assign protected attributes: #{attrs.join(', ')}" if Config.whitelist[:mode] == :raise
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{whiny-mass-assignment}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.6"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Paul Alexander"]
|
9
|
-
s.date = %q{2011-03-
|
9
|
+
s.date = %q{2011-03-18}
|
10
10
|
s.description = %q{Complain loudly when protected attributes are set through mass assignment.}
|
11
11
|
s.email = %q{paul@appsinyourpants.com}
|
12
|
-
s.extra_rdoc_files = ["LICENSE", "README.md", "lib/whiny-mass-assignment.rb", "lib/whiny-mass-assignment/color_escapes.rb", "lib/whiny-mass-assignment/configuration.rb", "lib/whiny-mass-assignment/sanitizer.rb", "lib/whiny_mass_assignment.rb", "tasks/spec.rake"]
|
13
|
-
s.files = ["Gemfile", "Gemfile.lock", "LICENSE", "Manifest", "README.md", "Rakefile", "lib/whiny-mass-assignment.rb", "lib/whiny-mass-assignment/color_escapes.rb", "lib/whiny-mass-assignment/configuration.rb", "lib/whiny-mass-assignment/sanitizer.rb", "lib/whiny_mass_assignment.rb", "rails/init.rb", "spec/config_spec.rb", "spec/sanitizer_spec.rb", "spec/spec_helper.rb", "tasks/spec.rake", "whiny-mass-assignment.gemspec"]
|
12
|
+
s.extra_rdoc_files = ["LICENSE", "README.md", "lib/whiny-mass-assignment.rb", "lib/whiny-mass-assignment/color_escapes.rb", "lib/whiny-mass-assignment/configuration.rb", "lib/whiny-mass-assignment/mass_assignment_security_overrides.rb", "lib/whiny-mass-assignment/sanitizer.rb", "lib/whiny_mass_assignment.rb", "tasks/spec.rake"]
|
13
|
+
s.files = ["Gemfile", "Gemfile.lock", "LICENSE", "Manifest", "README.md", "Rakefile", "lib/whiny-mass-assignment.rb", "lib/whiny-mass-assignment/color_escapes.rb", "lib/whiny-mass-assignment/configuration.rb", "lib/whiny-mass-assignment/mass_assignment_security_overrides.rb", "lib/whiny-mass-assignment/sanitizer.rb", "lib/whiny_mass_assignment.rb", "rails/init.rb", "spec/config_spec.rb", "spec/sanitizer_spec.rb", "spec/spec_helper.rb", "tasks/spec.rake", "whiny-mass-assignment.gemspec"]
|
14
14
|
s.homepage = %q{https://github.com/appsinyourpants/whiny-mass-assignment}
|
15
15
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Whiny-mass-assignment", "--main", "README.md"]
|
16
16
|
s.require_paths = ["lib"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whiny-mass-assignment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-03-
|
12
|
+
date: 2011-03-18 00:00:00.000000000 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
description: Complain loudly when protected attributes are set through mass assignment.
|
@@ -22,6 +22,7 @@ extra_rdoc_files:
|
|
22
22
|
- lib/whiny-mass-assignment.rb
|
23
23
|
- lib/whiny-mass-assignment/color_escapes.rb
|
24
24
|
- lib/whiny-mass-assignment/configuration.rb
|
25
|
+
- lib/whiny-mass-assignment/mass_assignment_security_overrides.rb
|
25
26
|
- lib/whiny-mass-assignment/sanitizer.rb
|
26
27
|
- lib/whiny_mass_assignment.rb
|
27
28
|
- tasks/spec.rake
|
@@ -35,6 +36,7 @@ files:
|
|
35
36
|
- lib/whiny-mass-assignment.rb
|
36
37
|
- lib/whiny-mass-assignment/color_escapes.rb
|
37
38
|
- lib/whiny-mass-assignment/configuration.rb
|
39
|
+
- lib/whiny-mass-assignment/mass_assignment_security_overrides.rb
|
38
40
|
- lib/whiny-mass-assignment/sanitizer.rb
|
39
41
|
- lib/whiny_mass_assignment.rb
|
40
42
|
- rails/init.rb
|