sqreen 1.11.1-java → 1.11.2-java
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.
- checksums.yaml +4 -4
- data/lib/sqreen/backported_queue.rb +110 -0
- data/lib/sqreen/capped_queue.rb +34 -12
- data/lib/sqreen/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4dfdb8465c560693a881e41c966844e86a9ac3749411bc07c4393a06fd6f843
|
4
|
+
data.tar.gz: c9121844fddfb01f5da67954c6e21d6bc1a5f3ef90fbba1681b8f8849374976e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c352c227db08adc5be3d298106e6b7c3b78c583626c07a2317296489ebd1173c03801b6f7fb5a78b238fe0c5afa4f69f5cba40fb64f3d4e0fe658489b1f820a8
|
7
|
+
data.tar.gz: 2bb3acb9a2db28c897f6cc8b1335bca65ee73fe5f066da2a2a5c9821ad1548c33b785ae9214e48e6e6872d06208f4c527374bfff456daef7eb704659f49c6f8b
|
@@ -0,0 +1,110 @@
|
|
1
|
+
## Backported PureRuby queue from Ruby 2.0.0
|
2
|
+
# Necessary while ruby 2.5.0 native queue are segfaulting
|
3
|
+
module Sqreen
|
4
|
+
class BackportedQueue
|
5
|
+
#
|
6
|
+
# Creates a new queue.
|
7
|
+
#
|
8
|
+
def initialize
|
9
|
+
@que = []
|
10
|
+
@que.taint # enable tainted communication
|
11
|
+
@num_waiting = 0
|
12
|
+
self.taint
|
13
|
+
@mutex = Mutex.new
|
14
|
+
@cond = ConditionVariable.new
|
15
|
+
end
|
16
|
+
|
17
|
+
#
|
18
|
+
# Pushes +obj+ to the queue.
|
19
|
+
#
|
20
|
+
def push(obj)
|
21
|
+
Thread.handle_interrupt(StandardError => :on_blocking) do
|
22
|
+
@mutex.synchronize do
|
23
|
+
@que.push obj
|
24
|
+
@cond.signal
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# Alias of push
|
31
|
+
#
|
32
|
+
alias << push
|
33
|
+
|
34
|
+
#
|
35
|
+
# Alias of push
|
36
|
+
#
|
37
|
+
alias enq push
|
38
|
+
|
39
|
+
#
|
40
|
+
# Retrieves data from the queue. If the queue is empty, the calling thread is
|
41
|
+
# suspended until data is pushed onto the queue. If +non_block+ is true, the
|
42
|
+
# thread isn't suspended, and an exception is raised.
|
43
|
+
#
|
44
|
+
def pop(non_block=false)
|
45
|
+
Thread.handle_interrupt(StandardError => :on_blocking) do
|
46
|
+
@mutex.synchronize do
|
47
|
+
while true
|
48
|
+
if @que.empty?
|
49
|
+
if non_block
|
50
|
+
raise ThreadError, "queue empty"
|
51
|
+
else
|
52
|
+
begin
|
53
|
+
@num_waiting += 1
|
54
|
+
@cond.wait @mutex
|
55
|
+
ensure
|
56
|
+
@num_waiting -= 1
|
57
|
+
end
|
58
|
+
end
|
59
|
+
else
|
60
|
+
return @que.shift
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
#
|
68
|
+
# Alias of pop
|
69
|
+
#
|
70
|
+
alias shift pop
|
71
|
+
|
72
|
+
#
|
73
|
+
# Alias of pop
|
74
|
+
#
|
75
|
+
alias deq pop
|
76
|
+
|
77
|
+
#
|
78
|
+
# Returns +true+ if the queue is empty.
|
79
|
+
#
|
80
|
+
def empty?
|
81
|
+
@que.empty?
|
82
|
+
end
|
83
|
+
|
84
|
+
#
|
85
|
+
# Removes all objects from the queue.
|
86
|
+
#
|
87
|
+
def clear
|
88
|
+
@que.clear
|
89
|
+
end
|
90
|
+
|
91
|
+
#
|
92
|
+
# Returns the length of the queue.
|
93
|
+
#
|
94
|
+
def length
|
95
|
+
@que.length
|
96
|
+
end
|
97
|
+
|
98
|
+
#
|
99
|
+
# Alias of length.
|
100
|
+
#
|
101
|
+
alias size length
|
102
|
+
|
103
|
+
#
|
104
|
+
# Returns the number of threads waiting on the queue.
|
105
|
+
#
|
106
|
+
def num_waiting
|
107
|
+
@num_waiting
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
data/lib/sqreen/capped_queue.rb
CHANGED
@@ -1,23 +1,45 @@
|
|
1
1
|
# Copyright (c) 2015 Sqreen. All Rights Reserved.
|
2
2
|
# Please refer to our terms for more information: https://www.sqreen.io/terms.html
|
3
|
+
require "sqreen/backported_queue" if RUBY_VERSION >= "2.5.0"
|
3
4
|
|
4
5
|
module Sqreen
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
if RUBY_VERSION >= "2.5.0"
|
7
|
+
# A simple size limited queue.
|
8
|
+
# When trying to enqueue more than the capacity
|
9
|
+
# the older elements will get thrown
|
10
|
+
class CappedQueue < BackportedQueue
|
11
|
+
attr_reader :capacity
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
13
|
+
def initialize(capacity)
|
14
|
+
@capacity = capacity
|
15
|
+
super()
|
16
|
+
end
|
17
|
+
|
18
|
+
alias original_push push
|
19
|
+
|
20
|
+
def push(value)
|
21
|
+
pop until size < @capacity
|
22
|
+
original_push(value)
|
23
|
+
end
|
14
24
|
end
|
25
|
+
else
|
26
|
+
# A simple size limited queue.
|
27
|
+
# When trying to enqueue more than the capacity
|
28
|
+
# the older elements will get thrown
|
29
|
+
class CappedQueue < Queue
|
30
|
+
attr_reader :capacity
|
31
|
+
|
32
|
+
def initialize(capacity)
|
33
|
+
@capacity = capacity
|
34
|
+
super()
|
35
|
+
end
|
15
36
|
|
16
|
-
|
37
|
+
alias original_push push
|
17
38
|
|
18
|
-
|
19
|
-
|
20
|
-
|
39
|
+
def push(value)
|
40
|
+
pop until size < @capacity
|
41
|
+
original_push(value)
|
42
|
+
end
|
21
43
|
end
|
22
44
|
end
|
23
45
|
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.11.
|
4
|
+
version: 1.11.2
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Sqreen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: execjs
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- lib/sqreen-alt.rb
|
51
51
|
- lib/sqreen.rb
|
52
52
|
- lib/sqreen/attack_detected.html
|
53
|
+
- lib/sqreen/backported_queue.rb
|
53
54
|
- lib/sqreen/binding_accessor.rb
|
54
55
|
- lib/sqreen/ca.crt
|
55
56
|
- lib/sqreen/call_countable.rb
|