sqreen-alt 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: a04af20485331ca42056930bb78f81c6f11f0e4b4385f73b81f71f6e6af413e3
4
- data.tar.gz: 0cbe16e0bdbc373ec5f948dfebbcb39e7379a57efea2bd2b93a1dceff9c389b2
3
+ metadata.gz: ed1bf3668ee726d4f9414ea85a805775d3a75a160b507ea96d53da5d3e87cd62
4
+ data.tar.gz: 615bd9a36ce087cd039ebd5dc1729e119fe9b36e73ef209702d5654ec63e0f5b
5
5
  SHA512:
6
- metadata.gz: 7b1eda52335145dbf4bf4dbc279c36ab63f4f10b6e673d96f8da395d6e6a369febf869fc42ff43b3a7a27233a6ce287305045bccea1657524398f39b2f987db9
7
- data.tar.gz: 840409d8a53ff8d1d3e362f6f3721d26051ee1ce7cae2677aaa5044ab9815e454361277896a3ae29665a6a92d24e2c002d985ab734f99930cbda419c6ff36abc
6
+ metadata.gz: f45492974f68638ad57611baf6f9c7373e251d87ac5434fa512935a1406f5e5e0f0ba1d1a6cb3fb9bc9f993864ef2a697fecce262ca250dc53e6caa63267bc64
7
+ data.tar.gz: 5e82c549535af6ac729b49b926779857d39436d112ce2bb8743a90a03f787a226958dce279645c1514f2fe8590dc1444affc33837bd0b680dcf2a0624900664a
@@ -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-alt
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