shikashi 0.1.1 → 0.1.2

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/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ 0.1.2 Fixed compatibility issues with ruby1.9
2
+
1
3
  0.1.1 Fixed issue 2: example2 failed when run under ruby1.9 (http://github.com/tario/shikashi/issues#issue/2)
2
4
 
3
5
  0.1.0 First functional release
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ require 'rake/gempackagetask'
6
6
 
7
7
  spec = Gem::Specification.new do |s|
8
8
  s.name = 'shikashi'
9
- s.version = '0.1.1'
9
+ s.version = '0.1.2'
10
10
  s.author = 'Dario Seminara'
11
11
  s.email = 'robertodarioseminara@gmail.com'
12
12
  s.platform = Gem::Platform::RUBY
@@ -1,5 +1,4 @@
1
1
  # call method defined in sandbox from outside
2
-
3
2
  require "rubygems"
4
3
  require "shikashi"
5
4
 
@@ -8,6 +7,8 @@ include Shikashi
8
7
  s = Sandbox.new
9
8
  priv = Privileges.new
10
9
 
10
+ priv.allow_method :singleton_method_added
11
+
11
12
  # allow execution of foo in this object
12
13
  priv.object(self).allow :foo
13
14
 
@@ -15,14 +16,19 @@ priv.object(self).allow :foo
15
16
  priv.object(self).allow :print
16
17
 
17
18
  #inside the sandbox, only can use method foo on main and method times on instances of Fixnum
18
- s.run(priv, "
19
- def inside_foo(a)
19
+ code = "
20
+ def self.inside_foo(a)
20
21
  print 'inside_foo'
21
22
  if (a)
22
23
  system('ls -l') # denied
23
24
  end
24
25
  end
25
- ")
26
+ "
26
27
 
28
+ s.run(priv, code)
29
+
30
+ s.run do
27
31
  inside_foo(false)
28
- inside_foo(true)
32
+ inside_foo(true) #SecurityError
33
+
34
+ end
@@ -11,11 +11,8 @@ priv = Privileges.new
11
11
  # allow execution of print
12
12
  priv.allow_method :print
13
13
 
14
- # allow execution of method_added
15
- priv.allow_method :method_added
16
-
17
- # allow execution of singleton_method_added
18
- priv.allow_method :singleton_method_added
14
+ # allow singleton methods
15
+ priv.allow_singleton_methods
19
16
 
20
17
  #inside the sandbox, only can use method foo on main and method times on instances of Fixnum
21
18
  s.run(priv, '
@@ -23,6 +23,7 @@ module Shikashi
23
23
  #Defines the permissions needed to declare classes within the sandbox
24
24
  def allow_class_definitions
25
25
  instances_of(Class).allow nil, :inherited, :method_added
26
+ allow_method "core#define_method".to_sym
26
27
  end
27
28
  end
28
29
  end
@@ -23,6 +23,7 @@ module Shikashi
23
23
  #Define the permissions needed to define singleton methods within the sandbox
24
24
  def allow_singleton_methods
25
25
  allow_method :singleton_method_added
26
+ allow_method "core#define_singleton_method".to_sym
26
27
  end
27
28
  end
28
29
  end
@@ -246,6 +246,8 @@ module Shikashi
246
246
  end
247
247
 
248
248
  if dest_source == ""
249
+ return nil if (method_name.to_s == "core#define_method")
250
+ return nil if (method_name.to_s == "core#define_singleton_method")
249
251
  return DummyWrapper.redirect_handler(klass,recv,method_name,method_id,sandbox)
250
252
  end
251
253
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shikashi
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dario Seminara
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-31 00:00:00 -03:00
18
+ date: 2010-08-07 00:00:00 -03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency