secure 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@ module Secure
3
3
  def initialize(opts, read_file, write_file)
4
4
  read_file.close
5
5
  @pipe = write_file
6
- @timeout = opts[:timeout] || 1
6
+ @timeout = opts[:timeout]
7
7
  end
8
8
 
9
9
  def guard_threads
@@ -15,14 +15,16 @@ module Secure
15
15
  $SAFE=3
16
16
  yield
17
17
  end
18
-
19
- guard_threads << GuardThread.kill_thread_on_timeout(@timeout, thread)
20
-
18
+ decorate_with_guard_threads(thread)
21
19
  Response.success(thread.value)
22
20
  rescue Exception => e
23
21
  Response.error(e)
24
22
  end
25
23
 
24
+ def decorate_with_guard_threads(thread)
25
+ GuardThread.kill_thread_on_timeout(@timeout, thread) if @timeout
26
+ end
27
+
26
28
  def execute
27
29
  ret = safely_run_block { yield }
28
30
  @pipe.write(Marshal.dump(ret))
data/lib/secure/runner.rb CHANGED
@@ -11,7 +11,7 @@ module Secure
11
11
  begin
12
12
  ChildProcess.new(@opts, read_file, write_file).execute { yield }
13
13
  ensure
14
- exit!
14
+ exit
15
15
  end
16
16
  end
17
17
 
@@ -1,3 +1,3 @@
1
1
  module Secure
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/spec/secure_spec.rb CHANGED
@@ -91,4 +91,15 @@ describe Secure do
91
91
  response.should be_success
92
92
  end
93
93
  end
94
+
95
+ context "error information" do
96
+ it "should know where the syntax is invalid" do
97
+ string = "while true; end; end"
98
+ response = Secure.ly({}, string) do |string|
99
+ eval(string)
100
+ end
101
+ response.should_not be_success
102
+ response.error.should be_a(SyntaxError)
103
+ end
104
+ end
94
105
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: secure
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tejas Dinkar