sqreen 1.10.1 → 1.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sqreen/rules_callbacks/execjs.rb +26 -10
- data/lib/sqreen/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3129e4afc077e7ca7afbe1704c49e3584fc8677de552575307f28d1a11e2a71e
|
4
|
+
data.tar.gz: 6a84e5d01b162c304195e50e13b32d301d9faa5190fcfe7d2ebc657e66f7ed25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5b855e58472a20f7f190b37e6c7dce6dd36ca3117dd80b9ff8b406fb5c24c7e99713ad11d14833f0887c2af8497971ca0d0a5c3d93069987175f95b414a2956
|
7
|
+
data.tar.gz: 305d5048bbbe5df8d6c9b21c26fae636a6aa6738a77adf8dcc87ff08575b893e7dacb546d4d695ca36b838e9b69cfa0a54410e4ae90ddc5daa0e3da515726e43
|
@@ -3,14 +3,15 @@
|
|
3
3
|
|
4
4
|
if defined?(::JRUBY_VERSION)
|
5
5
|
require 'rhino'
|
6
|
-
|
6
|
+
SQREEN_MINI_RACER = false
|
7
7
|
else
|
8
8
|
begin
|
9
9
|
require 'mini_racer'
|
10
|
-
|
10
|
+
SQREEN_MINI_RACER = true
|
11
|
+
GC_MINI_RACER = 10000
|
11
12
|
rescue LoadError
|
12
13
|
require 'therubyracer'
|
13
|
-
|
14
|
+
SQREEN_MINI_RACER = false
|
14
15
|
end
|
15
16
|
end
|
16
17
|
|
@@ -40,9 +41,10 @@ module Sqreen
|
|
40
41
|
end
|
41
42
|
|
42
43
|
build_runnable(callbacks)
|
43
|
-
if !
|
44
|
+
if !SQREEN_MINI_RACER
|
44
45
|
@compiled = ExecJS.compile(@source)
|
45
46
|
else
|
47
|
+
@snapshot = MiniRacer::Snapshot.new(@source)
|
46
48
|
@runtimes = []
|
47
49
|
end
|
48
50
|
@restrict_max_depth = 20
|
@@ -146,11 +148,23 @@ module Sqreen
|
|
146
148
|
end
|
147
149
|
|
148
150
|
def call_callback(name, inst, args, rv = nil)
|
149
|
-
if
|
150
|
-
|
151
|
-
|
151
|
+
if SQREEN_MINI_RACER
|
152
|
+
mini_racer_context = Thread.current["SQREEN_MINI_RACER_CONTEXT_#{self.object_id}"]
|
153
|
+
if mini_racer_context.nil? || mini_racer_context[:r].nil? || !mini_racer_context[:r].weakref_alive?
|
154
|
+
runtime = MiniRacer::Context.new(snapshot: @snapshot)
|
152
155
|
@runtimes.push runtime
|
153
|
-
Thread.current["
|
156
|
+
Thread.current["SQREEN_MINI_RACER_CONTEXT_#{self.object_id}"] = {:c => 0, :r => WeakRef.new(runtime)}
|
157
|
+
elsif mini_racer_context[:c] >= GC_MINI_RACER
|
158
|
+
@runtimes.delete(mini_racer_context[:r])
|
159
|
+
mini_racer_context[:r].dispose
|
160
|
+
|
161
|
+
new_runtime = MiniRacer::Context.new(snapshot: @snapshot)
|
162
|
+
@runtimes.push new_runtime
|
163
|
+
|
164
|
+
Thread.current["SQREEN_MINI_RACER_CONTEXT_#{self.object_id}"] = {
|
165
|
+
:c => 0,
|
166
|
+
:r => WeakRef.new(new_runtime)
|
167
|
+
}
|
154
168
|
end
|
155
169
|
end
|
156
170
|
ret = nil
|
@@ -162,8 +176,10 @@ module Sqreen
|
|
162
176
|
end
|
163
177
|
arguments = restrict(name, arguments) if @conditions.key?(name)
|
164
178
|
Sqreen.log.debug { [name, arguments].inspect }
|
165
|
-
if
|
166
|
-
|
179
|
+
if SQREEN_MINI_RACER
|
180
|
+
mini_racer_context = Thread.current["SQREEN_MINI_RACER_CONTEXT_#{self.object_id}"]
|
181
|
+
mini_racer_context[:c] += 1
|
182
|
+
ret = mini_racer_context[:r].eval("#{name}.apply(this, #{::JSON.generate(arguments)})")
|
167
183
|
else
|
168
184
|
ret = @compiled.call(name, *arguments)
|
169
185
|
end
|
data/lib/sqreen/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sqreen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.10.
|
4
|
+
version: 1.10.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sqreen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: execjs
|