sqreen 1.15.1 → 1.15.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/actions.rb +2 -0
- data/lib/sqreen/callbacks.rb +0 -34
- data/lib/sqreen/capped_queue.rb +5 -1
- data/lib/sqreen/event.rb +4 -0
- data/lib/sqreen/rule_callback.rb +34 -0
- data/lib/sqreen/session.rb +4 -0
- 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: bd9348f46f9d003e9a1302fdf2f138fe6f0db7e49e50a51d1482991ad68ee2a5
|
4
|
+
data.tar.gz: 2d49d42af3a45e9c1061d550c5b45c1652406f901f89c81525dca90c2f2c6584
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ccb75506d4344d4d2ec1d6c7f4e2c1957a762d7d60cee5e34bf2aec98abdf9d8c72158f4dd3e23fa0da8a054cbc694754d2a81d959facdbe9fd6911e36de1e2
|
7
|
+
data.tar.gz: 20933b21b52fa4f95de2964a3a15ab757f7dff8f4058b91a29547440f3446eae6510c40193ae4a44494c5494e60c9de1290d2c483033b687c79c5526dbff66ab
|
data/lib/sqreen/actions.rb
CHANGED
@@ -171,6 +171,7 @@ module Sqreen
|
|
171
171
|
def matching_actions(client_ip)
|
172
172
|
parsed_ip = IPAddr.new(client_ip)
|
173
173
|
trie = parsed_ip.family == Socket::AF_INET6 ? @trie_v6 : @trie_v4
|
174
|
+
return [] unless trie
|
174
175
|
found = trie.search_matching(parsed_ip.to_i, parsed_ip.family)
|
175
176
|
return [] unless found.size > 0
|
176
177
|
|
@@ -271,6 +272,7 @@ module Sqreen
|
|
271
272
|
|
272
273
|
class << self
|
273
274
|
def actions_matching(identity_params)
|
275
|
+
return [] unless @idx
|
274
276
|
key = stringify_keys(identity_params)
|
275
277
|
actions = @idx[key]
|
276
278
|
actions || []
|
data/lib/sqreen/callbacks.rb
CHANGED
@@ -127,23 +127,6 @@ module Sqreen
|
|
127
127
|
framework && !framework.whitelisted_match.nil?
|
128
128
|
end
|
129
129
|
|
130
|
-
# Record an attack event into Sqreen system
|
131
|
-
# @param infos [Hash] Additional information about request
|
132
|
-
def record_event(infos, at = Time.now.utc)
|
133
|
-
return unless framework
|
134
|
-
payload = {
|
135
|
-
:infos => infos,
|
136
|
-
:rulespack_id => rulespack_id,
|
137
|
-
:rule_name => rule_name,
|
138
|
-
:test => test,
|
139
|
-
:time => at,
|
140
|
-
}
|
141
|
-
if payload_tpl.include?('context')
|
142
|
-
payload[:backtrace] = Sqreen::Context.new.bt
|
143
|
-
end
|
144
|
-
framework.observe(:attacks, payload, payload_tpl)
|
145
|
-
end
|
146
|
-
|
147
130
|
# Record a metric observation
|
148
131
|
# @param category [String] Name of the metric observed
|
149
132
|
# @param key [String] aggregation key
|
@@ -153,22 +136,5 @@ module Sqreen
|
|
153
136
|
return unless framework
|
154
137
|
framework.observe(:observations, [category, key, observation, at], [], false)
|
155
138
|
end
|
156
|
-
|
157
|
-
# Record an exception that just occurred
|
158
|
-
# @param exception [Exception] Exception to send over
|
159
|
-
# @param infos [Hash] Additional contextual information
|
160
|
-
def record_exception(exception, infos = {}, at = Time.now.utc)
|
161
|
-
return unless framework
|
162
|
-
payload = {
|
163
|
-
:exception => exception,
|
164
|
-
:infos => infos,
|
165
|
-
:rulespack_id => rulespack_id,
|
166
|
-
:rule_name => rule_name,
|
167
|
-
:test => test,
|
168
|
-
:time => at,
|
169
|
-
:backtrace => exception.backtrace || Sqreen::Context.bt,
|
170
|
-
}
|
171
|
-
framework.observe(:sqreen_exceptions, payload)
|
172
|
-
end
|
173
139
|
end
|
174
140
|
end
|
data/lib/sqreen/capped_queue.rb
CHANGED
@@ -15,7 +15,11 @@ module Sqreen
|
|
15
15
|
alias original_push push
|
16
16
|
|
17
17
|
def push(value)
|
18
|
-
|
18
|
+
until size < @capacity
|
19
|
+
discarded = pop
|
20
|
+
Sqreen.log.debug { "Discarded from queue: #{discarded}" }
|
21
|
+
end
|
22
|
+
Sqreen.log.debug { "Pushed to the queue: #{value}" }
|
19
23
|
original_push(value)
|
20
24
|
end
|
21
25
|
end
|
data/lib/sqreen/event.rb
CHANGED
data/lib/sqreen/rule_callback.rb
CHANGED
@@ -51,6 +51,40 @@ module Sqreen
|
|
51
51
|
@rule[Attrs::PRIORITY] || super
|
52
52
|
end
|
53
53
|
|
54
|
+
# Record an attack event into Sqreen system
|
55
|
+
# @param infos [Hash] Additional information about request
|
56
|
+
def record_event(infos, at = Time.now.utc)
|
57
|
+
return unless framework
|
58
|
+
payload = {
|
59
|
+
:infos => infos,
|
60
|
+
:rulespack_id => rulespack_id,
|
61
|
+
:rule_name => rule_name,
|
62
|
+
:test => test,
|
63
|
+
:time => at,
|
64
|
+
}
|
65
|
+
if payload_tpl.include?('context')
|
66
|
+
payload[:backtrace] = Sqreen::Context.new.bt
|
67
|
+
end
|
68
|
+
framework.observe(:attacks, payload, payload_tpl)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Record an exception that just occurred
|
72
|
+
# @param exception [Exception] Exception to send over
|
73
|
+
# @param infos [Hash] Additional contextual information
|
74
|
+
def record_exception(exception, infos = {}, at = Time.now.utc)
|
75
|
+
return unless framework
|
76
|
+
payload = {
|
77
|
+
:exception => exception,
|
78
|
+
:infos => infos,
|
79
|
+
:rulespack_id => rulespack_id,
|
80
|
+
:rule_name => rule_name,
|
81
|
+
:test => test,
|
82
|
+
:time => at,
|
83
|
+
:backtrace => exception.backtrace || Sqreen::Context.bt,
|
84
|
+
}
|
85
|
+
framework.observe(:sqreen_exceptions, payload)
|
86
|
+
end
|
87
|
+
|
54
88
|
# Recommend taking an action (optionnally adding more data/context)
|
55
89
|
#
|
56
90
|
# This will format the requested action and optionnally
|
data/lib/sqreen/session.rb
CHANGED
@@ -292,6 +292,10 @@ module Sqreen
|
|
292
292
|
h[EVENT_TYPE_KEY] = event_kind(event)
|
293
293
|
h
|
294
294
|
end
|
295
|
+
Sqreen.log.debug do
|
296
|
+
tally = Hash[events.group_by(&:class).map{ |k,v| [k, v.count] }]
|
297
|
+
"Doing batch with the following tally of event types: #{tally}"
|
298
|
+
end
|
295
299
|
resilient_post(BATCH_KEY, BATCH_KEY => batch)
|
296
300
|
end
|
297
301
|
|
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.15.
|
4
|
+
version: 1.15.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-10-
|
11
|
+
date: 2018-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sq_mini_racer
|