safemode 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of safemode might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a2ae334b96360e57f06053963af98bb3565e1d1
4
- data.tar.gz: 4ad12d5c492b17595d6dda6aa8caec4ca154f03f
3
+ metadata.gz: b4ce678e79def9e59fdb857730f9c35707658933
4
+ data.tar.gz: 4a9a39f6426692470932c93c28430d75feef9279
5
5
  SHA512:
6
- metadata.gz: '0942dbc88ee4246dc414c598555822b58b5ba18f6b7471edcb3e583ed1e42c442b3b0724a927d4150ea705b9eb95f7f33cd947074f83f2326dfecaabc65d880a'
7
- data.tar.gz: 9338694a4120ca2190e4dcf6151d2cf8822b155fc887396ae63e0671734075ba325cad4c5a38a44cc7b98540fa0b37ea28b611aed76be50e6d216c5a4a4f7cec
6
+ metadata.gz: '09455744a65edc92517cb77bc6b203011cddb2fb1f22bf6b504ab617634e681fe1df897474142871081ecf296e2c2d1289f0a535ed52fde8ff17498176b06ad3'
7
+ data.tar.gz: 0fdca751f3f5937314ca1903dbf53c8ef1c90644be8868e47a64a33b6e4473dc326a9480aa573196a8470f35b77ce5d5976fe1afa108eb42e1fc1863224326d7
@@ -0,0 +1,12 @@
1
+ ---
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1.10
7
+ - 2.2.6
8
+ - 2.3.3
9
+ - 2.4.0
10
+ - jruby-9
11
+ before_install: gem install bundler
12
+ sudo: false
data/Gemfile CHANGED
@@ -7,12 +7,11 @@ gem "ruby_parser", ">= 3.2.0"
7
7
  # Add dependencies to develop your gem here.
8
8
  # Include everything needed to run rake, tests, features, etc.
9
9
  group :development do
10
- gem "shoulda", ">= 0"
11
10
  gem "rdoc", "~> 3.12"
12
11
  gem "bundler", "~> 1.0"
13
- gem "jeweler", ">= 0"
12
+ gem "jeweler", RUBY_VERSION.start_with?("1.8") ? "~> 1.0" : ">= 0"
14
13
  gem "rcov", :platforms => :ruby_18
15
- gem "simplecov", :platforms => [:ruby_19, :ruby_20, :ruby_21, :ruby_22, :ruby_23, :ruby_24]
16
- gem "test-unit", :platforms => [:ruby_19, :ruby_20, :ruby_21, :ruby_22, :ruby_23, :ruby_24]
17
- gem "rake"
14
+ gem "simplecov", :platforms => [:ruby_19, :ruby_20, :ruby_21, :ruby_22, :ruby_23, :ruby_24, :jruby]
15
+ gem "test-unit", :platforms => [:ruby_19, :ruby_20, :ruby_21, :ruby_22, :ruby_23, :ruby_24, :jruby]
16
+ gem "rake", RUBY_VERSION.start_with?("1.8") ? "< 11" : ">= 0"
18
17
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.1
1
+ 1.3.2
@@ -1,7 +1,13 @@
1
1
  module Safemode
2
2
  class Blankslate
3
3
  @@allow_instance_methods = ['class', 'methods', 'respond_to?', 'respond_to_missing?', 'to_s', 'instance_variable_get']
4
- @@allow_class_methods = ['methods', 'new', 'name', '<', 'ancestors', '=='] # < needed in Rails Object#subclasses_of
4
+ @@allow_class_methods = ['methods', 'new', 'name', '<', 'ancestors', '=='] # < needed in Rails Object#subclasses_of
5
+ if defined?(JRUBY_VERSION)
6
+ # JRuby seems to silently fail to remove method_missing
7
+ # (also see https://github.com/jruby/jruby/blob/9.1.7.0/core/src/main/java/org/jruby/RubyModule.java#L1109)
8
+ @@allow_class_methods << 'method_missing'
9
+ (@@allow_class_methods << ['singleton_method_undefined', 'singleton_method_added']).flatten! # needed for JRuby support
10
+ end
5
11
 
6
12
  silently { undef_methods(*instance_methods.map(&:to_s) - @@allow_instance_methods) }
7
13
  class << self
@@ -85,7 +85,7 @@ module Safemode
85
85
  # :colon2 is used for module constants
86
86
  :colon2,
87
87
  # unnecessarily advanced?
88
- :argscat, :argspush, :splat, :block_pass,
88
+ :argscat, :argspush, :splat,
89
89
  :op_asgn1, :op_asgn2, :op_asgn_and, :op_asgn_or,
90
90
  # needed for haml
91
91
  :block ]
@@ -101,7 +101,11 @@ module Safemode
101
101
  :attrasgn, :cdecl, :cvasgn, :cvdecl, :cvar, :gvar, :gasgn,
102
102
  :xstr, :dxstr,
103
103
  # not sure how secure ruby regexp is, so leave it out for now
104
- :dregx, :dregx_once, :match2, :match3, :nth_ref, :back_ref ]
104
+ :dregx, :dregx_once, :match2, :match3, :nth_ref, :back_ref,
105
+ # block_pass represents &:method, which would bypass the whitelist e.g. by array.each(&:destroy)
106
+ # at this point we don't know the receiver so we rather disable it completely,
107
+ # use array.each { |item| item.destroy } instead
108
+ :block_pass ]
105
109
 
106
110
  # SexpProcessor bails when we overwrite these ... but they are listed as
107
111
  # "internal nodes that you can't get to" in sexp_processor.rb
@@ -2,22 +2,23 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: safemode 1.3.1 ruby lib
5
+ # stub: safemode 1.3.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "safemode".freeze
9
- s.version = "1.3.1"
9
+ s.version = "1.3.2"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Sven Fuchs".freeze, "Peter Cooper".freeze, "Matthias Viehweger".freeze, "Kingsley Hendrickse".freeze, "Ohad Levy".freeze, "Dmitri Dolguikh".freeze]
14
- s.date = "2017-02-13"
14
+ s.date = "2017-07-11"
15
15
  s.description = "A library for safe evaluation of Ruby code based on RubyParser and Ruby2Ruby. Provides Rails ActionView template handlers for ERB and Haml.".freeze
16
16
  s.email = "ohadlevy@gmail.com".freeze
17
17
  s.extra_rdoc_files = [
18
18
  "README.markdown"
19
19
  ]
20
20
  s.files = [
21
+ ".travis.yml",
21
22
  "Gemfile",
22
23
  "LICENCSE",
23
24
  "README.markdown",
@@ -48,7 +49,7 @@ Gem::Specification.new do |s|
48
49
  ]
49
50
  s.homepage = "http://github.com/svenfuchs/safemode".freeze
50
51
  s.licenses = ["MIT".freeze]
51
- s.rubygems_version = "2.6.10".freeze
52
+ s.rubygems_version = "2.6.8".freeze
52
53
  s.summary = "A library for safe evaluation of Ruby code based on ParseTree/RubyParser and Ruby2Ruby".freeze
53
54
 
54
55
  if s.respond_to? :specification_version then
@@ -58,7 +59,6 @@ Gem::Specification.new do |s|
58
59
  s.add_runtime_dependency(%q<sexp_processor>.freeze, [">= 4.3.0"])
59
60
  s.add_runtime_dependency(%q<ruby2ruby>.freeze, [">= 2.0.6"])
60
61
  s.add_runtime_dependency(%q<ruby_parser>.freeze, [">= 3.2.0"])
61
- s.add_development_dependency(%q<shoulda>.freeze, [">= 0"])
62
62
  s.add_development_dependency(%q<rdoc>.freeze, ["~> 3.12"])
63
63
  s.add_development_dependency(%q<bundler>.freeze, ["~> 1.0"])
64
64
  s.add_development_dependency(%q<jeweler>.freeze, [">= 0"])
@@ -70,7 +70,6 @@ Gem::Specification.new do |s|
70
70
  s.add_dependency(%q<sexp_processor>.freeze, [">= 4.3.0"])
71
71
  s.add_dependency(%q<ruby2ruby>.freeze, [">= 2.0.6"])
72
72
  s.add_dependency(%q<ruby_parser>.freeze, [">= 3.2.0"])
73
- s.add_dependency(%q<shoulda>.freeze, [">= 0"])
74
73
  s.add_dependency(%q<rdoc>.freeze, ["~> 3.12"])
75
74
  s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
76
75
  s.add_dependency(%q<jeweler>.freeze, [">= 0"])
@@ -83,7 +82,6 @@ Gem::Specification.new do |s|
83
82
  s.add_dependency(%q<sexp_processor>.freeze, [">= 4.3.0"])
84
83
  s.add_dependency(%q<ruby2ruby>.freeze, [">= 2.0.6"])
85
84
  s.add_dependency(%q<ruby_parser>.freeze, [">= 3.2.0"])
86
- s.add_dependency(%q<shoulda>.freeze, [">= 0"])
87
85
  s.add_dependency(%q<rdoc>.freeze, ["~> 3.12"])
88
86
  s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
89
87
  s.add_dependency(%q<jeweler>.freeze, [">= 0"])
@@ -37,8 +37,12 @@ class TestJail < Test::Unit::TestCase
37
37
  "allow_instance_method", "allow_class_method", "allowed_instance_method?",
38
38
  "allowed_class_method?", "allowed_instance_methods", "allowed_class_methods",
39
39
  "<", # < needed in Rails Object#subclasses_of
40
- "ancestors", "==" # ancestors and == needed in Rails::Generator::Spec#lookup_class
41
- ]
40
+ "ancestors", "=="] # ancestors and == needed in Rails::Generator::Spec#lookup_class
41
+
42
+ if defined?(JRUBY_VERSION)
43
+ (expected << ['method_missing', 'singleton_method_undefined', 'singleton_method_added']).flatten! # needed for running under jruby
44
+ end
45
+
42
46
  objects.each do |object|
43
47
  assert_equal expected.sort, reject_pretty_methods(object.to_jail.class.methods.map(&:to_s).sort)
44
48
  end
@@ -31,6 +31,12 @@ class TestSafemodeParser < Test::Unit::TestCase
31
31
  end
32
32
  end
33
33
 
34
+ def test_block_pass_is_disabled
35
+ assert_raise Safemode::SecurityError do
36
+ jail('[].each(&:delete)')
37
+ end
38
+ end
39
+
34
40
  private
35
41
 
36
42
  def assert_jailed(expected, code)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safemode
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Fuchs
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2017-02-13 00:00:00.000000000 Z
16
+ date: 2017-07-11 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: sexp_processor
@@ -57,20 +57,6 @@ dependencies:
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
59
  version: 3.2.0
60
- - !ruby/object:Gem::Dependency
61
- name: shoulda
62
- requirement: !ruby/object:Gem::Requirement
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: '0'
67
- type: :development
68
- prerelease: false
69
- version_requirements: !ruby/object:Gem::Requirement
70
- requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- version: '0'
74
60
  - !ruby/object:Gem::Dependency
75
61
  name: rdoc
76
62
  requirement: !ruby/object:Gem::Requirement
@@ -177,6 +163,7 @@ extensions: []
177
163
  extra_rdoc_files:
178
164
  - README.markdown
179
165
  files:
166
+ - ".travis.yml"
180
167
  - Gemfile
181
168
  - LICENCSE
182
169
  - README.markdown
@@ -224,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
224
211
  version: '0'
225
212
  requirements: []
226
213
  rubyforge_project:
227
- rubygems_version: 2.6.10
214
+ rubygems_version: 2.6.8
228
215
  signing_key:
229
216
  specification_version: 4
230
217
  summary: A library for safe evaluation of Ruby code based on ParseTree/RubyParser