sqreen 1.23.2 → 1.24.0

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: 8e1881ab1def0e4a82ccfe791c150b0213517084619d71f5c942a0d14a0189e1
4
- data.tar.gz: beeef4f164a84efbc00824a5c63926da6a4e3fcc5952577442061e1c509e8fda
3
+ metadata.gz: b43caee6a7702bfde6a56f9a3d9ad735de10b5a214ce5d097c3c26c3527f5918
4
+ data.tar.gz: 803451b19b5277384c9e74b186e00e0a1d0d8a8a77cb5483cf486088a1705b0d
5
5
  SHA512:
6
- metadata.gz: b1d1ea43737baa0db830e556fc835f93104dc70465fc5695372c5a922e8108cb9e657e915cc7ffe06f655dc632b0d5e56daf659e0c6ef499b66484fcd6d33076
7
- data.tar.gz: 98b0e405e39de271a9d8988692ea037b5f462b2af9314d384b7ca7dfec9dce43229b1aa317fbb8fccde84f1cd743d90637dabde392a2c7bfe88d6a6353e25235
6
+ metadata.gz: 2d35106412544c74a99bcf5eb39b1bc33d95720efbce196e139c15f40c1259b1aaf4646cab127849b9235d3f1cf0ce421c01859eb1c4bc6076683d3f7beeef33
7
+ data.tar.gz: b0f5452dda0d2702397968e103313bf910bb996c09064354be78fcabb6492dbb15d898aa1caf5835307a5f21b878550fae59826fbc347382772cba1823cefea2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.24.0
2
+
3
+ * Add Sqreen event correlation with Datadog traces
4
+
1
5
  ## 1.23.2
2
6
 
3
7
  * Fix compatibility with NewRelic for attack events
@@ -63,6 +63,14 @@ module Sqreen
63
63
  payload['context']['backtrace']
64
64
  end
65
65
 
66
+ def datadog_trace_id
67
+ payload['context']['datadog_trace_id']
68
+ end
69
+
70
+ def datadog_span_id
71
+ payload['context']['datadog_span_id']
72
+ end
73
+
66
74
  def enqueue
67
75
  Sqreen.queue.push(self)
68
76
  end
@@ -173,7 +173,18 @@ module Sqreen
173
173
  :remote_port => req.env['REMOTE_PORT'],
174
174
  :remote_ip => remote_addr,
175
175
  :client_ip => client_ip,
176
- }
176
+ }.tap do |h|
177
+ h.merge!(
178
+ :datadog_trace_id => datadog_span.trace_id,
179
+ :datadog_span_id => datadog_span.span_id,
180
+ ) if datadog_span
181
+ end
182
+ end
183
+
184
+ def datadog_span
185
+ return unless defined?(Datadog) && (tracer = Datadog.tracer)
186
+
187
+ tracer.active_span
177
188
  end
178
189
 
179
190
  def response_infos
@@ -44,11 +44,17 @@ module Sqreen
44
44
  # XXX: not used because we don't use Sqreen::Attack
45
45
  def convert_attack(attack)
46
46
  # no need to set actor/context as we only include them in request records/traces
47
+ location_h = {}
48
+ location_h.merge!(stack_trace: attack.backtrace) if attack.backtrace
49
+ location_h.merge!(datadog_trace_id: datadog_trace_id) if attack.datadog_trace_id
50
+ location_h.merge!(datadog_span_id: datadog_span_id) if attack.datadog_span_id
51
+ location = Kit::Signals::Location.new(location_h) unless location_h.empty?
52
+
47
53
  Kit::Signals::Specialized::Attack.new(
48
54
  signal_name: "sq.agent.attack.#{attack.attack_type}",
49
55
  source: "sqreen:rule:#{attack.rulespack_id}:#{attack.rule_name}",
50
56
  time: attack.time,
51
- location: Kit::Signals::Location.new(stack_trace: attack.backtrace),
57
+ location: location,
52
58
  payload: Kit::Signals::Specialized::Attack::Payload.new(
53
59
  test: attack.test?,
54
60
  block: attack.block?,
@@ -59,11 +65,17 @@ module Sqreen
59
65
 
60
66
  # see Sqreen::Rules::RuleCB.record_event
61
67
  def convert_unstructured_attack(payload)
68
+ location_h = {}
69
+ location_h.merge!(stack_trace: payload[:backtrace]) if payload[:backtrace]
70
+ location_h.merge!(datadog_trace_id: payload[:datadog_trace_id]) if payload[:datadog_span_id]
71
+ location_h.merge!(datadog_span_id: payload[:datadog_span_id]) if payload[:datadog_span_id]
72
+ location = Kit::Signals::Location.new(location_h) unless location_h.empty?
73
+
62
74
  Kit::Signals::Specialized::Attack.new(
63
75
  signal_name: "sq.agent.attack.#{payload[:attack_type]}",
64
76
  source: "sqreen:rule:#{payload[:rulespack_id]}:#{payload[:rule_name]}",
65
77
  time: payload[:time],
66
- location: (Kit::Signals::Location.new(stack_trace: payload[:backtrace]) if payload[:backtrace]),
78
+ location: location,
67
79
  payload: Kit::Signals::Specialized::Attack::Payload.new(
68
80
  test: payload[:test],
69
81
  block: payload[:block],
@@ -234,6 +246,9 @@ module Sqreen
234
246
  status: resp_payload[:status],
235
247
  content_length: resp_payload[:content_length],
236
248
  content_type: resp_payload[:content_type],
249
+ # datadog
250
+ datadog_trace_id: req_payload[:datadog_trace_id],
251
+ datadog_span_id: req_payload[:datadog_span_id],
237
252
  }
238
253
  )
239
254
  end
@@ -4,5 +4,5 @@
4
4
  # Please refer to our terms for more information: https://www.sqreen.com/terms.html
5
5
 
6
6
  module Sqreen
7
- VERSION = '1.23.2'.freeze
7
+ VERSION = '1.24.0'.freeze
8
8
  end
@@ -244,6 +244,10 @@ class Sqreen::Weave::Legacy::Instrumentation
244
244
 
245
245
  # shrinkwrap_timer = Sqreen::Graft::Timer.new('weave,shrinkwrap')
246
246
  # shrinkwrap_timer.start
247
+ if defined?(Datadog)
248
+ datadog_span = Datadog.tracer.active_root_span
249
+ Sqreen::Weave.logger.debug { "request datadog:true span_id:#{datadog_span.span_id} parent_id:#{datadog_span.parent_id} trace_id:#{datadog_span.trace_id}" }
250
+ end
247
251
 
248
252
  request_timer = Sqreen::Graft::Timer.new("request")
249
253
  request_timer.start
@@ -269,6 +273,7 @@ class Sqreen::Weave::Legacy::Instrumentation
269
273
  timed_level: timed_level,
270
274
  skipped_callbacks: [],
271
275
  # timed_shrinkwrap: shrinkwrap_timer,
276
+ datadog_span: datadog_span,
272
277
  }
273
278
 
274
279
  # shrinkwrap_timer.stop
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.23.2
4
+ version: 1.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sqreen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-29 00:00:00.000000000 Z
11
+ date: 2021-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqreen-backport
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.2.2
33
+ version: 0.2.3
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.2.2
40
+ version: 0.2.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: sq_mini_racer
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -47,7 +47,7 @@ dependencies:
47
47
  version: '0.2'
48
48
  - - "<"
49
49
  - !ruby/object:Gem::Version
50
- version: 0.4.a
50
+ version: 0.5.a
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
@@ -57,7 +57,7 @@ dependencies:
57
57
  version: '0.2'
58
58
  - - "<"
59
59
  - !ruby/object:Gem::Version
60
- version: 0.4.a
60
+ version: 0.5.a
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: libsqreen
63
63
  requirement: !ruby/object:Gem::Requirement