datadog 2.12.2 → 2.13.0
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/CHANGELOG.md +36 -1
- data/ext/datadog_profiling_native_extension/collectors_thread_context.c +14 -13
- data/lib/datadog/appsec/actions_handler/serializable_backtrace.rb +89 -0
- data/lib/datadog/appsec/actions_handler.rb +22 -1
- data/lib/datadog/appsec/anonymizer.rb +16 -0
- data/lib/datadog/appsec/configuration/settings.rb +62 -10
- data/lib/datadog/appsec/contrib/auto_instrument.rb +1 -1
- data/lib/datadog/appsec/contrib/devise/configuration.rb +7 -31
- data/lib/datadog/appsec/contrib/devise/data_extractor.rb +79 -0
- data/lib/datadog/appsec/contrib/devise/ext.rb +21 -0
- data/lib/datadog/appsec/contrib/devise/integration.rb +0 -1
- data/lib/datadog/appsec/contrib/devise/patcher.rb +36 -23
- data/lib/datadog/appsec/contrib/devise/patches/signin_tracking_patch.rb +102 -0
- data/lib/datadog/appsec/contrib/devise/patches/signup_tracking_patch.rb +69 -0
- data/lib/datadog/appsec/contrib/devise/{patcher/rememberable_patch.rb → patches/skip_signin_tracking_patch.rb} +2 -2
- data/lib/datadog/appsec/contrib/devise/tracking_middleware.rb +93 -0
- data/lib/datadog/appsec/contrib/rack/ext.rb +14 -0
- data/lib/datadog/appsec/contrib/rack/gateway/watcher.rb +10 -3
- data/lib/datadog/appsec/contrib/rack/request_middleware.rb +0 -2
- data/lib/datadog/appsec/event.rb +1 -1
- data/lib/datadog/appsec/ext.rb +4 -2
- data/lib/datadog/appsec/instrumentation/gateway/argument.rb +4 -2
- data/lib/datadog/appsec/monitor/gateway/watcher.rb +8 -3
- data/lib/datadog/appsec/security_engine/runner.rb +2 -2
- data/lib/datadog/appsec/utils.rb +0 -2
- data/lib/datadog/core/configuration/components.rb +2 -1
- data/lib/datadog/core/configuration/ext.rb +4 -0
- data/lib/datadog/core/configuration/options.rb +2 -2
- data/lib/datadog/core/configuration/settings.rb +53 -30
- data/lib/datadog/core/environment/agent_info.rb +4 -3
- data/lib/datadog/core/remote/component.rb +3 -6
- data/lib/datadog/core/remote/configuration/repository.rb +2 -1
- data/lib/datadog/core/remote/negotiation.rb +9 -9
- data/lib/datadog/core/remote/transport/config.rb +4 -3
- data/lib/datadog/core/remote/transport/http/client.rb +4 -3
- data/lib/datadog/core/remote/transport/http/config.rb +6 -32
- data/lib/datadog/core/remote/transport/http/negotiation.rb +6 -32
- data/lib/datadog/core/remote/transport/http.rb +22 -57
- data/lib/datadog/core/remote/transport/negotiation.rb +4 -3
- data/lib/datadog/core/runtime/metrics.rb +8 -1
- data/lib/datadog/core/telemetry/http/adapters/net.rb +1 -1
- data/lib/datadog/core/transport/http/api/instance.rb +17 -0
- data/lib/datadog/core/transport/http/api/spec.rb +17 -0
- data/lib/datadog/core/transport/http/builder.rb +5 -3
- data/lib/datadog/core/transport/http.rb +39 -2
- data/lib/datadog/di/component.rb +0 -2
- data/lib/datadog/di/probe_notifier_worker.rb +16 -16
- data/lib/datadog/di/transport/diagnostics.rb +4 -3
- data/lib/datadog/di/transport/http/api.rb +2 -12
- data/lib/datadog/di/transport/http/client.rb +4 -3
- data/lib/datadog/di/transport/http/diagnostics.rb +7 -33
- data/lib/datadog/di/transport/http/input.rb +7 -33
- data/lib/datadog/di/transport/http.rb +14 -56
- data/lib/datadog/di/transport/input.rb +4 -3
- data/lib/datadog/di/utils.rb +5 -0
- data/lib/datadog/kit/appsec/events.rb +9 -0
- data/lib/datadog/kit/identity.rb +5 -1
- data/lib/datadog/opentelemetry/api/baggage.rb +90 -0
- data/lib/datadog/opentelemetry/api/baggage.rbs +26 -0
- data/lib/datadog/opentelemetry/api/context.rb +16 -2
- data/lib/datadog/opentelemetry/sdk/trace/span.rb +1 -1
- data/lib/datadog/opentelemetry.rb +2 -1
- data/lib/datadog/profiling/collectors/thread_context.rb +1 -1
- data/lib/datadog/profiling.rb +5 -2
- data/lib/datadog/tracing/component.rb +15 -12
- data/lib/datadog/tracing/configuration/ext.rb +7 -1
- data/lib/datadog/tracing/configuration/settings.rb +18 -2
- data/lib/datadog/tracing/context_provider.rb +1 -1
- data/lib/datadog/tracing/contrib/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/ethon/easy_patch.rb +4 -5
- data/lib/datadog/tracing/contrib/excon/middleware.rb +5 -3
- data/lib/datadog/tracing/contrib/faraday/middleware.rb +5 -3
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +7 -1
- data/lib/datadog/tracing/contrib/grpc/distributed/propagation.rb +3 -0
- data/lib/datadog/tracing/contrib/http/circuit_breaker.rb +0 -15
- data/lib/datadog/tracing/contrib/http/distributed/propagation.rb +4 -1
- data/lib/datadog/tracing/contrib/http/instrumentation.rb +5 -5
- data/lib/datadog/tracing/contrib/httpclient/instrumentation.rb +5 -11
- data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +6 -10
- data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +5 -3
- data/lib/datadog/tracing/contrib/sidekiq/client_tracer.rb +6 -1
- data/lib/datadog/tracing/contrib/sidekiq/distributed/propagation.rb +3 -0
- data/lib/datadog/tracing/correlation.rb +9 -2
- data/lib/datadog/tracing/distributed/baggage.rb +131 -0
- data/lib/datadog/tracing/distributed/datadog.rb +2 -0
- data/lib/datadog/tracing/distributed/propagation.rb +25 -4
- data/lib/datadog/tracing/distributed/propagation_policy.rb +42 -0
- data/lib/datadog/tracing/metadata/ext.rb +5 -0
- data/lib/datadog/tracing/sampling/span/rule.rb +0 -1
- data/lib/datadog/tracing/span_operation.rb +2 -1
- data/lib/datadog/tracing/sync_writer.rb +1 -2
- data/lib/datadog/tracing/trace_digest.rb +9 -2
- data/lib/datadog/tracing/trace_operation.rb +29 -17
- data/lib/datadog/tracing/trace_segment.rb +6 -4
- data/lib/datadog/tracing/tracer.rb +38 -2
- data/lib/datadog/tracing/transport/http/api.rb +2 -10
- data/lib/datadog/tracing/transport/http/client.rb +5 -4
- data/lib/datadog/tracing/transport/http/traces.rb +13 -41
- data/lib/datadog/tracing/transport/http.rb +11 -44
- data/lib/datadog/tracing/transport/trace_formatter.rb +7 -0
- data/lib/datadog/tracing/transport/traces.rb +21 -9
- data/lib/datadog/tracing/workers/trace_writer.rb +2 -6
- data/lib/datadog/tracing/writer.rb +2 -6
- data/lib/datadog/tracing.rb +16 -3
- data/lib/datadog/version.rb +2 -2
- metadata +17 -13
- data/lib/datadog/appsec/contrib/devise/event.rb +0 -54
- data/lib/datadog/appsec/contrib/devise/patcher/authenticatable_patch.rb +0 -72
- data/lib/datadog/appsec/contrib/devise/patcher/registration_controller_patch.rb +0 -47
- data/lib/datadog/appsec/contrib/devise/resource.rb +0 -35
- data/lib/datadog/appsec/contrib/devise/tracking.rb +0 -57
- data/lib/datadog/appsec/utils/trace_operation.rb +0 -15
data/lib/datadog/tracing.rb
CHANGED
@@ -26,7 +26,6 @@ module Datadog
|
|
26
26
|
id: nil,
|
27
27
|
&block
|
28
28
|
)
|
29
|
-
|
30
29
|
tracer.trace(
|
31
30
|
name,
|
32
31
|
continue_from: continue_from,
|
@@ -82,7 +81,7 @@ module Datadog
|
|
82
81
|
# @public_api
|
83
82
|
def keep!
|
84
83
|
trace = active_trace
|
85
|
-
|
84
|
+
trace.keep! if trace
|
86
85
|
end
|
87
86
|
|
88
87
|
# (see Datadog::Tracing::TraceSegment#reject!)
|
@@ -90,7 +89,7 @@ module Datadog
|
|
90
89
|
# @public_api
|
91
90
|
def reject!
|
92
91
|
trace = active_trace
|
93
|
-
|
92
|
+
trace.reject! if trace
|
94
93
|
end
|
95
94
|
|
96
95
|
# (see Datadog::Tracing::Tracer#active_correlation)
|
@@ -127,6 +126,20 @@ module Datadog
|
|
127
126
|
correlation.to_log_format
|
128
127
|
end
|
129
128
|
|
129
|
+
# Returns the baggage for the current trace.
|
130
|
+
#
|
131
|
+
# If there is no active trace, a new one is created.
|
132
|
+
#
|
133
|
+
# @return [Datadog::Tracing::Distributed::Baggage] The baggage for the current trace.
|
134
|
+
# @public_api
|
135
|
+
def baggage
|
136
|
+
# Baggage should not be dependent on there being an active trace.
|
137
|
+
# So we create a new TraceOperation if there isn't one.
|
138
|
+
active_trace = self.active_trace || tracer.continue_trace!(nil)
|
139
|
+
active_trace.baggage ||= {}
|
140
|
+
active_trace.baggage
|
141
|
+
end
|
142
|
+
|
130
143
|
# Gracefully shuts down the tracer.
|
131
144
|
#
|
132
145
|
# The public tracing API will still respond to method calls as usual
|
data/lib/datadog/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datadog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Datadog, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
47
|
+
version: 1.21.0.0.1
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
54
|
+
version: 1.21.0.0.1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: libdatadog
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -152,6 +152,8 @@ files:
|
|
152
152
|
- lib/datadog.rb
|
153
153
|
- lib/datadog/appsec.rb
|
154
154
|
- lib/datadog/appsec/actions_handler.rb
|
155
|
+
- lib/datadog/appsec/actions_handler/serializable_backtrace.rb
|
156
|
+
- lib/datadog/appsec/anonymizer.rb
|
155
157
|
- lib/datadog/appsec/assets.rb
|
156
158
|
- lib/datadog/appsec/assets/blocked.html
|
157
159
|
- lib/datadog/appsec/assets/blocked.json
|
@@ -171,15 +173,14 @@ files:
|
|
171
173
|
- lib/datadog/appsec/contrib/active_record/patcher.rb
|
172
174
|
- lib/datadog/appsec/contrib/auto_instrument.rb
|
173
175
|
- lib/datadog/appsec/contrib/devise/configuration.rb
|
174
|
-
- lib/datadog/appsec/contrib/devise/
|
176
|
+
- lib/datadog/appsec/contrib/devise/data_extractor.rb
|
175
177
|
- lib/datadog/appsec/contrib/devise/ext.rb
|
176
178
|
- lib/datadog/appsec/contrib/devise/integration.rb
|
177
179
|
- lib/datadog/appsec/contrib/devise/patcher.rb
|
178
|
-
- lib/datadog/appsec/contrib/devise/
|
179
|
-
- lib/datadog/appsec/contrib/devise/
|
180
|
-
- lib/datadog/appsec/contrib/devise/
|
181
|
-
- lib/datadog/appsec/contrib/devise/
|
182
|
-
- lib/datadog/appsec/contrib/devise/tracking.rb
|
180
|
+
- lib/datadog/appsec/contrib/devise/patches/signin_tracking_patch.rb
|
181
|
+
- lib/datadog/appsec/contrib/devise/patches/signup_tracking_patch.rb
|
182
|
+
- lib/datadog/appsec/contrib/devise/patches/skip_signin_tracking_patch.rb
|
183
|
+
- lib/datadog/appsec/contrib/devise/tracking_middleware.rb
|
183
184
|
- lib/datadog/appsec/contrib/excon/integration.rb
|
184
185
|
- lib/datadog/appsec/contrib/excon/patcher.rb
|
185
186
|
- lib/datadog/appsec/contrib/excon/ssrf_detection_middleware.rb
|
@@ -247,7 +248,6 @@ files:
|
|
247
248
|
- lib/datadog/appsec/utils/http.rb
|
248
249
|
- lib/datadog/appsec/utils/http/media_range.rb
|
249
250
|
- lib/datadog/appsec/utils/http/media_type.rb
|
250
|
-
- lib/datadog/appsec/utils/trace_operation.rb
|
251
251
|
- lib/datadog/auto_instrument.rb
|
252
252
|
- lib/datadog/auto_instrument_base.rb
|
253
253
|
- lib/datadog/core.rb
|
@@ -421,6 +421,8 @@ files:
|
|
421
421
|
- lib/datadog/kit/enable_core_dumps.rb
|
422
422
|
- lib/datadog/kit/identity.rb
|
423
423
|
- lib/datadog/opentelemetry.rb
|
424
|
+
- lib/datadog/opentelemetry/api/baggage.rb
|
425
|
+
- lib/datadog/opentelemetry/api/baggage.rbs
|
424
426
|
- lib/datadog/opentelemetry/api/context.rb
|
425
427
|
- lib/datadog/opentelemetry/api/trace/span.rb
|
426
428
|
- lib/datadog/opentelemetry/sdk/configurator.rb
|
@@ -864,12 +866,14 @@ files:
|
|
864
866
|
- lib/datadog/tracing/diagnostics/health.rb
|
865
867
|
- lib/datadog/tracing/distributed/b3_multi.rb
|
866
868
|
- lib/datadog/tracing/distributed/b3_single.rb
|
869
|
+
- lib/datadog/tracing/distributed/baggage.rb
|
867
870
|
- lib/datadog/tracing/distributed/datadog.rb
|
868
871
|
- lib/datadog/tracing/distributed/datadog_tags_codec.rb
|
869
872
|
- lib/datadog/tracing/distributed/fetcher.rb
|
870
873
|
- lib/datadog/tracing/distributed/helpers.rb
|
871
874
|
- lib/datadog/tracing/distributed/none.rb
|
872
875
|
- lib/datadog/tracing/distributed/propagation.rb
|
876
|
+
- lib/datadog/tracing/distributed/propagation_policy.rb
|
873
877
|
- lib/datadog/tracing/distributed/trace_context.rb
|
874
878
|
- lib/datadog/tracing/event.rb
|
875
879
|
- lib/datadog/tracing/flush.rb
|
@@ -933,8 +937,8 @@ licenses:
|
|
933
937
|
- Apache-2.0
|
934
938
|
metadata:
|
935
939
|
allowed_push_host: https://rubygems.org
|
936
|
-
changelog_uri: https://github.com/DataDog/dd-trace-rb/blob/v2.
|
937
|
-
source_code_uri: https://github.com/DataDog/dd-trace-rb/tree/v2.
|
940
|
+
changelog_uri: https://github.com/DataDog/dd-trace-rb/blob/v2.13.0/CHANGELOG.md
|
941
|
+
source_code_uri: https://github.com/DataDog/dd-trace-rb/tree/v2.13.0
|
938
942
|
post_install_message:
|
939
943
|
rdoc_options: []
|
940
944
|
require_paths:
|
@@ -1,54 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Datadog
|
4
|
-
module AppSec
|
5
|
-
module Contrib
|
6
|
-
module Devise
|
7
|
-
# Class to extract event information from the resource
|
8
|
-
class Event
|
9
|
-
UUID_REGEX = /^\h{8}-\h{4}-\h{4}-\h{4}-\h{12}$/.freeze
|
10
|
-
|
11
|
-
attr_reader :user_id
|
12
|
-
|
13
|
-
def initialize(resource, mode)
|
14
|
-
@resource = resource
|
15
|
-
@mode = mode
|
16
|
-
@user_id = nil
|
17
|
-
@email = nil
|
18
|
-
@username = nil
|
19
|
-
|
20
|
-
extract if @resource
|
21
|
-
end
|
22
|
-
|
23
|
-
def to_h
|
24
|
-
return @event if defined?(@event)
|
25
|
-
|
26
|
-
@event = {}
|
27
|
-
@event[:email] = @email if @email
|
28
|
-
@event[:username] = @username if @username
|
29
|
-
@event
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def extract
|
35
|
-
@user_id = @resource.id
|
36
|
-
|
37
|
-
case @mode
|
38
|
-
when AppSec::Configuration::Settings::IDENTIFICATION_AUTO_USER_INSTRUMENTATION_MODE
|
39
|
-
@email = @resource.email
|
40
|
-
@username = @resource.username
|
41
|
-
when AppSec::Configuration::Settings::ANONYMIZATION_AUTO_USER_INSTRUMENTATION_MODE
|
42
|
-
@user_id = nil unless @user_id && @user_id.to_s =~ UUID_REGEX
|
43
|
-
else
|
44
|
-
Datadog.logger.warn(
|
45
|
-
"Invalid auto_user_instrumentation.mode: `#{@mode}`. " \
|
46
|
-
"Supported modes are: #{AppSec::Configuration::Settings::AUTO_USER_INSTRUMENTATION_MODES.join(' | ')}."
|
47
|
-
)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../configuration'
|
4
|
-
require_relative '../tracking'
|
5
|
-
require_relative '../resource'
|
6
|
-
require_relative '../event'
|
7
|
-
|
8
|
-
module Datadog
|
9
|
-
module AppSec
|
10
|
-
module Contrib
|
11
|
-
module Devise
|
12
|
-
module Patcher
|
13
|
-
# Hook in devise validate method
|
14
|
-
module AuthenticatablePatch
|
15
|
-
# rubocop:disable Metrics/MethodLength
|
16
|
-
def validate(resource, &block)
|
17
|
-
result = super
|
18
|
-
|
19
|
-
return result unless AppSec.enabled?
|
20
|
-
return result if @_datadog_appsec_skip_track_login_event
|
21
|
-
return result unless Configuration.auto_user_instrumentation_enabled?
|
22
|
-
return result unless AppSec.active_context
|
23
|
-
|
24
|
-
devise_resource = resource ? Resource.new(resource) : nil
|
25
|
-
event_information = Event.new(devise_resource, Configuration.auto_user_instrumentation_mode)
|
26
|
-
|
27
|
-
if result
|
28
|
-
if event_information.user_id
|
29
|
-
Datadog.logger.debug { 'AppSec: User successful login event' }
|
30
|
-
else
|
31
|
-
Datadog.logger.debug do
|
32
|
-
"AppSec: User successful login event, but can't extract user ID. Tracking empty event"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
Tracking.track_login_success(
|
37
|
-
AppSec.active_context.trace,
|
38
|
-
AppSec.active_context.span,
|
39
|
-
user_id: event_information.user_id,
|
40
|
-
**event_information.to_h
|
41
|
-
)
|
42
|
-
|
43
|
-
return result
|
44
|
-
end
|
45
|
-
|
46
|
-
user_exists = nil
|
47
|
-
|
48
|
-
if resource
|
49
|
-
user_exists = true
|
50
|
-
Datadog.logger.debug { 'AppSec: User failed login event, but user exists' }
|
51
|
-
else
|
52
|
-
user_exists = false
|
53
|
-
Datadog.logger.debug { 'AppSec: User failed login event and user does not exist' }
|
54
|
-
end
|
55
|
-
|
56
|
-
Tracking.track_login_failure(
|
57
|
-
AppSec.active_context.trace,
|
58
|
-
AppSec.active_context.span,
|
59
|
-
user_id: event_information.user_id,
|
60
|
-
user_exists: user_exists,
|
61
|
-
**event_information.to_h
|
62
|
-
)
|
63
|
-
|
64
|
-
result
|
65
|
-
end
|
66
|
-
# rubocop:enable Metrics/MethodLength
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../configuration'
|
4
|
-
require_relative '../tracking'
|
5
|
-
require_relative '../resource'
|
6
|
-
require_relative '../event'
|
7
|
-
|
8
|
-
module Datadog
|
9
|
-
module AppSec
|
10
|
-
module Contrib
|
11
|
-
module Devise
|
12
|
-
module Patcher
|
13
|
-
# Hook in devise registration controller
|
14
|
-
module RegistrationControllerPatch
|
15
|
-
def create
|
16
|
-
return super unless AppSec.enabled?
|
17
|
-
return super unless Configuration.auto_user_instrumentation_enabled?
|
18
|
-
return super unless AppSec.active_context
|
19
|
-
|
20
|
-
super do |resource|
|
21
|
-
if resource.persisted?
|
22
|
-
devise_resource = Resource.new(resource)
|
23
|
-
event_information = Event.new(devise_resource, Configuration.auto_user_instrumentation_mode)
|
24
|
-
|
25
|
-
if event_information.user_id
|
26
|
-
Datadog.logger.debug { 'AppSec: User signup event' }
|
27
|
-
else
|
28
|
-
Datadog.logger.warn { "AppSec: User signup event, but can't extract user ID. Tracking empty event" }
|
29
|
-
end
|
30
|
-
|
31
|
-
Tracking.track_signup(
|
32
|
-
AppSec.active_context.trace,
|
33
|
-
AppSec.active_context.span,
|
34
|
-
user_id: event_information.user_id,
|
35
|
-
**event_information.to_h
|
36
|
-
)
|
37
|
-
end
|
38
|
-
|
39
|
-
yield resource if block_given?
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Datadog
|
4
|
-
module AppSec
|
5
|
-
module Contrib
|
6
|
-
module Devise
|
7
|
-
# Class to encpasulate extracting information from a Devise resource
|
8
|
-
# Normally a devise resource would be an Active::Record instance
|
9
|
-
class Resource
|
10
|
-
def initialize(resource)
|
11
|
-
@resource = resource
|
12
|
-
end
|
13
|
-
|
14
|
-
def id
|
15
|
-
extract(:id) || extract(:uuid)
|
16
|
-
end
|
17
|
-
|
18
|
-
def email
|
19
|
-
extract(:email)
|
20
|
-
end
|
21
|
-
|
22
|
-
def username
|
23
|
-
extract(:username)
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def extract(method)
|
29
|
-
@resource.send(method) if @resource.respond_to?(method)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../../../kit/identity'
|
4
|
-
|
5
|
-
module Datadog
|
6
|
-
module AppSec
|
7
|
-
module Contrib
|
8
|
-
module Devise
|
9
|
-
# Internal module to track user events
|
10
|
-
module Tracking
|
11
|
-
LOGIN_SUCCESS_EVENT = 'users.login.success'
|
12
|
-
LOGIN_FAILURE_EVENT = 'users.login.failure'
|
13
|
-
SIGNUP_EVENT = 'users.signup'
|
14
|
-
|
15
|
-
def self.track_login_success(trace, span, user_id:, **others)
|
16
|
-
return if trace.nil? || span.nil?
|
17
|
-
|
18
|
-
track(LOGIN_SUCCESS_EVENT, trace, span, **others)
|
19
|
-
|
20
|
-
Kit::Identity.set_user(trace, span, id: user_id.to_s, **others) if user_id
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.track_login_failure(trace, span, user_id:, user_exists:, **others)
|
24
|
-
return if trace.nil? || span.nil?
|
25
|
-
|
26
|
-
track(LOGIN_FAILURE_EVENT, trace, span, **others)
|
27
|
-
|
28
|
-
span.set_tag('appsec.events.users.login.failure.usr.id', user_id) if user_id
|
29
|
-
span.set_tag('appsec.events.users.login.failure.usr.exists', user_exists)
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.track_signup(trace, span, user_id:, **others)
|
33
|
-
return if trace.nil? || span.nil?
|
34
|
-
|
35
|
-
track(SIGNUP_EVENT, trace, span, **others)
|
36
|
-
Kit::Identity.set_user(trace, id: user_id.to_s, **others) if user_id
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.track(event, trace, span, **others)
|
40
|
-
return if trace.nil? || span.nil?
|
41
|
-
|
42
|
-
span.set_tag("appsec.events.#{event}.track", 'true')
|
43
|
-
span.set_tag("_dd.appsec.events.#{event}.auto.mode", Configuration.track_user_events_mode)
|
44
|
-
|
45
|
-
others.each do |k, v|
|
46
|
-
raise ArgumentError, 'key cannot be :track' if k.to_sym == :track
|
47
|
-
|
48
|
-
span.set_tag("appsec.events.#{event}.#{k}", v) unless v.nil?
|
49
|
-
end
|
50
|
-
|
51
|
-
trace.keep!
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Datadog
|
4
|
-
module AppSec
|
5
|
-
module Utils
|
6
|
-
# Utility class to to AppSec-specific trace operations
|
7
|
-
class TraceOperation
|
8
|
-
def self.appsec_standalone_reject?(trace)
|
9
|
-
Datadog.configuration.appsec.standalone.enabled &&
|
10
|
-
(trace.nil? || trace.get_tag(Datadog::AppSec::Ext::TAG_DISTRIBUTED_APPSEC_EVENT) != '1')
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|