shikashi 0.5.0 → 0.5.1
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/AUTHORS +1 -0
- data/README +10 -0
- data/Rakefile +4 -13
- data/lib/shikashi/sandbox.rb +23 -2
- metadata +44 -72
data/AUTHORS
CHANGED
data/README
CHANGED
@@ -24,6 +24,16 @@ OR
|
|
24
24
|
|
25
25
|
sudo gem install shikashi-X.X.X.gem.
|
26
26
|
|
27
|
+
=== Troubleshooting
|
28
|
+
|
29
|
+
ERROR: While executing gem ... (Gem::DependencyError)
|
30
|
+
Unable to resolve dependencies: ruby2ruby requires sexp_processor (~> 3.0); ruby_parser requires sexp_processor (~> 3.0)
|
31
|
+
|
32
|
+
The version of ruby2ruby and ruby_parser required depends on sexp_processor 3.X but for some reason this version of the gem
|
33
|
+
is not automatically installed by gem, you can workaround this issue by installing it before using:
|
34
|
+
|
35
|
+
gem install sexp_processor --version '~> 3.2'
|
36
|
+
|
27
37
|
== Documentation
|
28
38
|
|
29
39
|
Full API documentation can be found on:
|
data/Rakefile
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rake'
|
3
|
+
require 'rdoc/task'
|
4
|
+
require 'rubygems/package_task'
|
3
5
|
require 'rake/testtask'
|
4
|
-
require 'rake/rdoctask'
|
5
|
-
require 'rake/gempackagetask'
|
6
6
|
|
7
7
|
spec = Gem::Specification.new do |s|
|
8
8
|
s.name = 'shikashi'
|
9
|
-
s.version = '0.5.
|
9
|
+
s.version = '0.5.1'
|
10
10
|
s.author = 'Dario Seminara'
|
11
11
|
s.email = 'robertodarioseminara@gmail.com'
|
12
12
|
s.platform = Gem::Platform::RUBY
|
@@ -21,15 +21,6 @@ spec = Gem::Specification.new do |s|
|
|
21
21
|
[ 'LICENSE', 'AUTHORS', 'CHANGELOG', 'README', 'Rakefile', 'TODO' ]
|
22
22
|
end
|
23
23
|
|
24
|
-
desc 'Run tests'
|
25
|
-
task :default => [ :test ]
|
26
|
-
|
27
|
-
Rake::TestTask.new('test') do |t|
|
28
|
-
t.libs << 'test'
|
29
|
-
t.pattern = '{test}/**/test_*.rb'
|
30
|
-
t.verbose = true
|
31
|
-
end
|
32
|
-
|
33
24
|
desc 'Generate RDoc'
|
34
25
|
Rake::RDocTask.new :rdoc do |rd|
|
35
26
|
rd.rdoc_dir = 'doc'
|
@@ -38,7 +29,7 @@ Rake::RDocTask.new :rdoc do |rd|
|
|
38
29
|
end
|
39
30
|
|
40
31
|
desc 'Build Gem'
|
41
|
-
|
32
|
+
Gem::PackageTask.new spec do |pkg|
|
42
33
|
pkg.need_tar = true
|
43
34
|
end
|
44
35
|
|
data/lib/shikashi/sandbox.rb
CHANGED
@@ -281,7 +281,8 @@ module Shikashi
|
|
281
281
|
# :base_namespace Alternate module to contain all classes and constants defined by the unprivileged code
|
282
282
|
# if not specified, by default, the base_namespace is created with the sandbox itself
|
283
283
|
# :no_base_namespace Specify to do not use a base_namespace (default false, not recommended to change)
|
284
|
-
#
|
284
|
+
# :encoding Specify the encoding of source (example: "utf-8"), the encoding also can be
|
285
|
+
# specified on header like a ruby normal source file
|
285
286
|
#
|
286
287
|
#The arguments can be passed in any order and using hash notation or not, examples:
|
287
288
|
#
|
@@ -343,6 +344,8 @@ module Shikashi
|
|
343
344
|
# :base_namespace Alternate module to contain all classes and constants defined by the unprivileged code
|
344
345
|
# if not specified, by default, the base_namespace is created with the sandbox itself
|
345
346
|
# :no_base_namespace Specify to do not use a base_namespace (default false, not recommended to change)
|
347
|
+
# :encoding Specify the encoding of source (example: "utf-8"), the encoding also can be
|
348
|
+
# specified on header like a ruby normal source file
|
346
349
|
#
|
347
350
|
# NOTE: arguments are the same as for Sandbox#run method, except for timeout and binding which can be
|
348
351
|
# used when calling Shikashi::Sandbox::Packet#run
|
@@ -367,6 +370,7 @@ module Shikashi
|
|
367
370
|
base_namespace = args.pick(:base_namespace) do nil end
|
368
371
|
no_base_namespace = args.pick(:no_base_namespace) do @no_base_namespace end
|
369
372
|
privileges_ = args.pick(Privileges,:privileges) do Privileges.new end
|
373
|
+
encoding = get_source_encoding(code) || args.pick(:encoding) do nil end
|
370
374
|
|
371
375
|
hook_handler = nil
|
372
376
|
|
@@ -392,6 +396,10 @@ module Shikashi
|
|
392
396
|
end
|
393
397
|
end
|
394
398
|
|
399
|
+
if encoding
|
400
|
+
code = "# encoding: #{encoding}\n" + code
|
401
|
+
end
|
402
|
+
|
395
403
|
evalhook_packet = @hook_handler.packet(code)
|
396
404
|
Shikashi::Sandbox::Packet.new(evalhook_packet, privileges_, source)
|
397
405
|
end
|
@@ -438,6 +446,7 @@ private
|
|
438
446
|
source = args.pick(:source) do generate_id end
|
439
447
|
base_namespace = args.pick(:base_namespace) do nil end
|
440
448
|
no_base_namespace = args.pick(:no_base_namespace) do @no_base_namespace end
|
449
|
+
encoding = get_source_encoding(code) || args.pick(:encoding) do nil end
|
441
450
|
|
442
451
|
hook_handler = nil
|
443
452
|
|
@@ -461,6 +470,10 @@ private
|
|
461
470
|
end
|
462
471
|
end
|
463
472
|
|
473
|
+
if encoding
|
474
|
+
# preend encoding
|
475
|
+
code = "# encoding: #{encoding}\n" + code
|
476
|
+
end
|
464
477
|
hook_handler.evalhook(code, binding_, source)
|
465
478
|
end
|
466
479
|
rescue ::Timeout::Error
|
@@ -471,7 +484,15 @@ private
|
|
471
484
|
|
472
485
|
end
|
473
486
|
|
474
|
-
|
487
|
+
def get_source_encoding(code)
|
488
|
+
first_line = code.to_s.lines.first.to_s
|
489
|
+
m = first_line.match(/encoding:(.*)$/)
|
490
|
+
if m
|
491
|
+
m[1]
|
492
|
+
else
|
493
|
+
nil
|
494
|
+
end
|
495
|
+
end
|
475
496
|
end
|
476
497
|
|
477
498
|
Shikashi.global_binding = binding()
|
metadata
CHANGED
@@ -1,82 +1,63 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: shikashi
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 5
|
9
|
-
- 0
|
10
|
-
version: 0.5.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.1
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Dario Seminara
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-06-17 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: evalhook
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &82511730 !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 11
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
- 5
|
33
|
-
- 0
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
34
21
|
version: 0.5.0
|
35
22
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: getsource
|
39
23
|
prerelease: false
|
40
|
-
|
24
|
+
version_requirements: *82511730
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: getsource
|
27
|
+
requirement: &82511270 !ruby/object:Gem::Requirement
|
41
28
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
hash: 27
|
46
|
-
segments:
|
47
|
-
- 0
|
48
|
-
- 1
|
49
|
-
- 0
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
50
32
|
version: 0.1.0
|
51
33
|
type: :runtime
|
52
|
-
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *82511270
|
53
36
|
description:
|
54
37
|
email: robertodarioseminara@gmail.com
|
55
38
|
executables: []
|
56
|
-
|
57
39
|
extensions: []
|
58
|
-
|
59
|
-
extra_rdoc_files:
|
40
|
+
extra_rdoc_files:
|
60
41
|
- README
|
61
|
-
files:
|
62
|
-
- examples/
|
63
|
-
- examples/benchmark/bm2.rb
|
64
|
-
- examples/basic/example1.rb
|
42
|
+
files:
|
43
|
+
- examples/basic/example2.rb
|
65
44
|
- examples/basic/example3.rb
|
66
45
|
- examples/basic/example5.rb
|
67
|
-
- examples/basic/example4.rb
|
68
46
|
- examples/basic/example8.rb
|
47
|
+
- examples/basic/example4.rb
|
48
|
+
- examples/basic/example1.rb
|
69
49
|
- examples/basic/example6.rb
|
70
50
|
- examples/basic/example.rb
|
71
51
|
- examples/basic/example7.rb
|
72
|
-
- examples/
|
52
|
+
- examples/benchmark/bm2.rb
|
53
|
+
- examples/benchmark/bm1.rb
|
73
54
|
- examples/timeout/example1.rb
|
74
55
|
- lib/shikashi.rb
|
75
56
|
- lib/shikashi/pick_argument.rb
|
76
57
|
- lib/shikashi/sandbox.rb
|
77
|
-
- lib/shikashi/privileges/exceptions.rb
|
78
58
|
- lib/shikashi/privileges/singleton_methods.rb
|
79
59
|
- lib/shikashi/privileges/classes.rb
|
60
|
+
- lib/shikashi/privileges/exceptions.rb
|
80
61
|
- lib/shikashi/privileges.rb
|
81
62
|
- LICENSE
|
82
63
|
- AUTHORS
|
@@ -84,39 +65,30 @@ files:
|
|
84
65
|
- README
|
85
66
|
- Rakefile
|
86
67
|
- TODO
|
87
|
-
has_rdoc: true
|
88
68
|
homepage: http://github.com/tario/shikashi
|
89
69
|
licenses: []
|
90
|
-
|
91
70
|
post_install_message:
|
92
71
|
rdoc_options: []
|
93
|
-
|
94
|
-
require_paths:
|
72
|
+
require_paths:
|
95
73
|
- lib
|
96
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
75
|
none: false
|
98
|
-
requirements:
|
99
|
-
- -
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
|
102
|
-
|
103
|
-
- 0
|
104
|
-
version: "0"
|
105
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
81
|
none: false
|
107
|
-
requirements:
|
108
|
-
- -
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
|
111
|
-
segments:
|
112
|
-
- 0
|
113
|
-
version: "0"
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
114
86
|
requirements: []
|
115
|
-
|
116
87
|
rubyforge_project:
|
117
|
-
rubygems_version: 1.
|
88
|
+
rubygems_version: 1.8.10
|
118
89
|
signing_key:
|
119
90
|
specification_version: 3
|
120
|
-
summary: shikashi is a ruby sandbox that permits the execution of "unprivileged" scripts
|
91
|
+
summary: shikashi is a ruby sandbox that permits the execution of "unprivileged" scripts
|
92
|
+
by defining the permitted methods and constants the scripts can invoke with a white
|
93
|
+
list logic
|
121
94
|
test_files: []
|
122
|
-
|