shikashi 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/Rakefile +1 -1
- data/examples/basic/example.rb +11 -5
- data/examples/basic/example4.rb +2 -5
- data/lib/shikashi/privileges/classes.rb +1 -0
- data/lib/shikashi/privileges/singleton_methods.rb +1 -0
- data/lib/shikashi/sandbox.rb +2 -0
- metadata +4 -4
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
data/examples/basic/example.rb
CHANGED
@@ -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
|
-
|
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
|
data/examples/basic/example4.rb
CHANGED
@@ -11,11 +11,8 @@ priv = Privileges.new
|
|
11
11
|
# allow execution of print
|
12
12
|
priv.allow_method :print
|
13
13
|
|
14
|
-
# allow
|
15
|
-
priv.
|
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, '
|
data/lib/shikashi/sandbox.rb
CHANGED
@@ -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:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.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
|
18
|
+
date: 2010-08-07 00:00:00 -03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|