sqreen 1.11.1 → 1.11.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eee0cd857bae436a452af37bf21237fe240d24dd255f991586df7c925158ceb9
4
- data.tar.gz: 310700ff34c420244c49873f3b6ccd38b3c8141fbefba8ce2ba268876b2dc982
3
+ metadata.gz: 729e481e969ff8187a3927f867812792de037a77f107a84c11269876fd8be84e
4
+ data.tar.gz: 4d3cfc1c63134cfcd56d10c4086107df2e4ecf5e48b2c8cdd09797156d47e3fa
5
5
  SHA512:
6
- metadata.gz: 3e270c262f3583202ba31f4a58bbe06d292123903581a90b39bba351f434f81c4fd32c723e9abad6853cedb0d4a727409118828ddc037c92e9267a9a475a76d2
7
- data.tar.gz: 69a4b0158995ef8029d72c635e0cccd5781be910468ee77e65016a73038727066eb2c0a465cbb9c7869238bbc7cd5ebbaff1b94a107b15fe9e512e77684f8485
6
+ metadata.gz: 33f234007987eb877da95b7178259748302591799bacc9db8968529ee431079d6e13f2bb9557b1bca0ae2494315a67a3b0b3ae1d9da37458a4d9a23d55a534b2
7
+ data.tar.gz: 86b459747ae5d1eea783dbbbf64d354c7cb8a63ed48668232144f9e99a366e320fc501147f10a90c892936399f573af31413f04ebafc3c524075b1cac74aa0fc
@@ -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
@@ -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
- # A simple size limited queue.
6
- # When trying to enqueue more than the capacity
7
- # the older elements will get thrown
8
- class CappedQueue < Queue
9
- attr_reader :capacity
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
- def initialize(capacity)
12
- @capacity = capacity
13
- super()
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
- alias original_push push
37
+ alias original_push push
17
38
 
18
- def push(value)
19
- pop until size < @capacity
20
- original_push(value)
39
+ def push(value)
40
+ pop until size < @capacity
41
+ original_push(value)
42
+ end
21
43
  end
22
44
  end
23
45
  end
@@ -1,5 +1,5 @@
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
3
  module Sqreen
4
- VERSION = '1.11.1'.freeze
4
+ VERSION = '1.11.2'.freeze
5
5
  end
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.1
4
+ version: 1.11.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-03-20 00:00:00.000000000 Z
11
+ date: 2018-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: execjs
@@ -51,6 +51,7 @@ files:
51
51
  - lib/sqreen-alt.rb
52
52
  - lib/sqreen.rb
53
53
  - lib/sqreen/attack_detected.html
54
+ - lib/sqreen/backported_queue.rb
54
55
  - lib/sqreen/binding_accessor.rb
55
56
  - lib/sqreen/ca.crt
56
57
  - lib/sqreen/call_countable.rb