Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for rubies > 1.9.3 #12

Merged
merged 1 commit into from
Dec 17, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
source "http://rubygems.org"

gem 'sexp_processor', ">= 4.1.2"
gem 'ruby2ruby', ">= 2.0.1"
gem "ruby_parser", ">= 3.0.1"
gem 'sexp_processor', ">= 4.3.0"
gem 'ruby2ruby', ">= 2.0.6"
gem "ruby_parser", ">= 3.2.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the ruby2ruby/ruby_parser updates necessary? I guess otherwise you'd have to support both styles, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ruby_parser for sure, as the fix isn't backwards-compatible with older versions of ruby_parser. ruby2ruby depends on ruby_parser, so I'd rather update them both. Similar logic re: sexp_processor.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks.


# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
Expand All @@ -12,7 +12,7 @@ group :development do
gem "bundler", "~> 1.0"
gem "jeweler", "~> 1.8.3"
gem "rcov", :platforms => :ruby_18
gem "simplecov", :platforms => :ruby_19
gem "test-unit", :platforms => :ruby_19
gem "simplecov", :platforms => [:ruby_19, :ruby_20, :ruby_21]
gem "test-unit", :platforms => [:ruby_19, :ruby_20, :ruby_21]
gem "rake"
end
52 changes: 0 additions & 52 deletions Gemfile.lock

This file was deleted.

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.1
1.2.2
10 changes: 6 additions & 4 deletions lib/safemode/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ def process_iasgn(exp)
:self,
# :args is now used for block parameters
:args,
# :colon2 is used for module constants
:colon2,
# unnecessarily advanced?
:argscat, :argspush, :splat, :block_pass,
:op_asgn1, :op_asgn2, :op_asgn_and, :op_asgn_or,
Expand All @@ -91,7 +93,7 @@ def process_iasgn(exp)
disallowed = [ # :self, # self doesn't seem to be needed for vcalls?
# see below for :const handling
:defn, :defs, :alias, :valias, :undef, :class, :attrset,
:module, :sclass, :colon2, :colon3,
:module, :sclass, :colon3,
:fbody, :scope, :block_arg, :postexe,
:redo, :retry, :begin, :rescue, :resbody, :ensure,
:defined, :super, :zsuper, :return,
Expand All @@ -113,10 +115,10 @@ def process_iasgn(exp)
end

# handling of Encoding constants in ruby 1.9.
# Note: ruby_parser evaluates __ENCODING__ to :const Encoding::UTF_8
# Note: ruby_parser evaluates __ENCODING__ to s(:colon2, s(:const, :Encoding), :UTF_8)
def process_const(arg)
raise_security_error("constant", super(arg)) unless (RUBY_VERSION >= "1.9" and arg.sexp_type.class == Encoding)
"Encoding::#{super(arg).gsub('-', '_')}"
raise_security_error("constant", super(arg)) unless (RUBY_VERSION >= "1.9" and arg.sexp_type == :Encoding)
"#{super(arg).gsub('-', '_')}"
end

def raise_security_error(type, info)
Expand Down
31 changes: 15 additions & 16 deletions safemode.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
# stub: safemode 1.2.2 ruby lib

Gem::Specification.new do |s|
s.name = "safemode"
s.version = "1.2.1"
s.version = "1.2.2"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib"]
s.authors = ["Sven Fuchs", "Peter Cooper", "Matthias Viehweger", "Kingsley Hendrickse", "Ohad Levy", "Dmitri Dolguikh"]
s.date = "2013-02-11"
s.date = "2014-11-27"
s.description = "A library for safe evaluation of Ruby code based on RubyParser and Ruby2Ruby. Provides Rails ActionView template handlers for ERB and Haml."
s.email = "ohadlevy@gmail.com"
s.extra_rdoc_files = [
"README.markdown"
]
s.files = [
"Gemfile",
"Gemfile.lock",
"LICENCSE",
"README.markdown",
"Rakefile",
Expand All @@ -39,7 +40,6 @@ Gem::Specification.new do |s|
"lib/safemode/parser.rb",
"lib/safemode/scope.rb",
"safemode.gemspec",
"test/test_all.rb",
"test/test_erb_eval.rb",
"test/test_helper.rb",
"test/test_jail.rb",
Expand All @@ -48,17 +48,16 @@ Gem::Specification.new do |s|
]
s.homepage = "http://github.com/svenfuchs/safemode"
s.licenses = ["MIT"]
s.require_paths = ["lib"]
s.rubygems_version = "1.8.24"
s.rubygems_version = "2.2.2"
s.summary = "A library for safe evaluation of Ruby code based on ParseTree/RubyParser and Ruby2Ruby"

if s.respond_to? :specification_version then
s.specification_version = 3
s.specification_version = 4

if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<sexp_processor>, [">= 4.1.2"])
s.add_runtime_dependency(%q<ruby2ruby>, [">= 2.0.1"])
s.add_runtime_dependency(%q<ruby_parser>, [">= 3.0.1"])
s.add_runtime_dependency(%q<sexp_processor>, [">= 4.3.0"])
s.add_runtime_dependency(%q<ruby2ruby>, [">= 2.0.6"])
s.add_runtime_dependency(%q<ruby_parser>, [">= 3.2.0"])
s.add_development_dependency(%q<shoulda>, [">= 0"])
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
Expand All @@ -68,9 +67,9 @@ Gem::Specification.new do |s|
s.add_development_dependency(%q<test-unit>, [">= 0"])
s.add_development_dependency(%q<rake>, [">= 0"])
else
s.add_dependency(%q<sexp_processor>, [">= 4.1.2"])
s.add_dependency(%q<ruby2ruby>, [">= 2.0.1"])
s.add_dependency(%q<ruby_parser>, [">= 3.0.1"])
s.add_dependency(%q<sexp_processor>, [">= 4.3.0"])
s.add_dependency(%q<ruby2ruby>, [">= 2.0.6"])
s.add_dependency(%q<ruby_parser>, [">= 3.2.0"])
s.add_dependency(%q<shoulda>, [">= 0"])
s.add_dependency(%q<rdoc>, ["~> 3.12"])
s.add_dependency(%q<bundler>, ["~> 1.0"])
Expand All @@ -81,9 +80,9 @@ Gem::Specification.new do |s|
s.add_dependency(%q<rake>, [">= 0"])
end
else
s.add_dependency(%q<sexp_processor>, [">= 4.1.2"])
s.add_dependency(%q<ruby2ruby>, [">= 2.0.1"])
s.add_dependency(%q<ruby_parser>, [">= 3.0.1"])
s.add_dependency(%q<sexp_processor>, [">= 4.3.0"])
s.add_dependency(%q<ruby2ruby>, [">= 2.0.6"])
s.add_dependency(%q<ruby_parser>, [">= 3.2.0"])
s.add_dependency(%q<shoulda>, [">= 0"])
s.add_dependency(%q<rdoc>, ["~> 3.12"])
s.add_dependency(%q<bundler>, ["~> 1.0"])
Expand Down
14 changes: 0 additions & 14 deletions test/test_all.rb

This file was deleted.

1 change: 1 addition & 0 deletions test/test_jail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def test_sending_to_jail_to_an_object_should_return_a_jail

def test_jail_instances_should_have_limited_methods
expected = ["class", "inspect", "method_missing", "methods", "respond_to?", "respond_to_missing?", "to_jail", "to_s", "instance_variable_get"]
expected.delete('respond_to_missing?') if RUBY_VERSION > '1.9.3' # respond_to_missing? is private in rubies above 1.9.3
objects.each do |object|
assert_equal expected.sort, reject_pretty_methods(object.to_jail.methods.map(&:to_s).sort)
end
Expand Down