-
Notifications
You must be signed in to change notification settings - Fork 394
Description
Background: we enable tracing
dynamically per host, so it's disabled by default and later enabled at runtime by looking at some AWS tags.
We are trying ASM, so we just pasted the recommended config:
c.appsec.enabled = true
c.appsec.instrument :rails
However, it seems that ASM has a strong dependency over tracing, and one can't be enabled without enabling the other.
Current behaviour
We get an undefined method 'set_tag' for nil:NilClass
exception on lib/datadog/appsec/contrib/devise/tracking.rb:34
when logging in.
undefined method `set_tag' for nil:NilClass
ddtrace (1.21.1) lib/datadog/appsec/contrib/devise/tracking.rb:34:in `track'
ddtrace (1.21.1) lib/datadog/appsec/contrib/devise/tracking.rb:16:in `track_login_success'
ddtrace (1.21.1) lib/datadog/appsec/contrib/devise/patcher/authenticatable_patch.rb:40:in `validate'
devise (4.8.1) lib/devise/strategies/database_authenticatable.rb:13:in `authenticate!'
warden (1.2.9) lib/warden/strategies/base.rb:55:in `_run!'
warden (1.2.9) lib/warden/proxy.rb:372:in `block in _run_strategies_for'
warden (1.2.9) lib/warden/proxy.rb:365:in `each'
warden (1.2.9) lib/warden/proxy.rb:365:in `_run_strategies_for'
warden (1.2.9) lib/warden/proxy.rb:335:in `_perform_authentication'
warden (1.2.9) lib/warden/proxy.rb:133:in `authenticate!'
devise (4.8.1) app/controllers/devise/sessions_controller.rb:19:in `create'
actionpack (6.0.5.1) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (6.0.5.1) lib/abstract_controller/base.rb:195:in `process_action'
ddtrace (1.21.1) lib/datadog/appsec/contrib/rails/patcher.rb:83:in `block in process_action'
ddtrace (1.21.1) lib/datadog/appsec/instrumentation/gateway.rb:37:in `block in push'
ddtrace (1.21.1) lib/datadog/appsec/contrib/rails/gateway/watcher.rb:53:in `block in watch_request_action'
ddtrace (1.21.1) lib/datadog/appsec/instrumentation/gateway.rb:19:in `call'
ddtrace (1.21.1) lib/datadog/appsec/instrumentation/gateway.rb:43:in `block (2 levels) in push'
ddtrace (1.21.1) lib/datadog/appsec/instrumentation/gateway.rb:47:in `push'
ddtrace (1.21.1) lib/datadog/appsec/contrib/rails/patcher.rb:82:in `process_action'
ddtrace (1.21.1) lib/datadog/tracing/contrib/action_pack/action_controller/instrumentation.rb:105:in `process_action'
actionpack (6.0.5.1) lib/action_controller/metal/rendering.rb:30:in `process_action'
...
actionpack (6.0.5.1) lib/action_dispatch/middleware/host_authorization.rb:103:in `call'
ddtrace (1.21.1) lib/datadog/appsec/contrib/rack/request_middleware.rb:61:in `block (2 levels) in call'
ddtrace (1.21.1) lib/datadog/appsec/instrumentation/gateway.rb:37:in `block in push'
ddtrace (1.21.1) lib/datadog/appsec/contrib/rack/gateway/watcher.rb:56:in `block in watch_request'
ddtrace (1.21.1) lib/datadog/appsec/instrumentation/gateway.rb:19:in `call'
ddtrace (1.21.1) lib/datadog/appsec/instrumentation/gateway.rb:43:in `block (2 levels) in push'
ddtrace (1.21.1) lib/datadog/appsec/instrumentation/gateway.rb:47:in `push'
ddtrace (1.21.1) lib/datadog/appsec/contrib/rack/request_middleware.rb:60:in `block in call'
ddtrace (1.21.1) lib/datadog/appsec/contrib/rack/request_middleware.rb:59:in `catch'
ddtrace (1.21.1) lib/datadog/appsec/contrib/rack/request_middleware.rb:59:in `call'
ddtrace (1.21.1) lib/datadog/tracing/contrib/rack/middlewares.rb:109:in `call'
webpacker (5.4.3) lib/webpacker/dev_server_proxy.rb:25:in `perform_request'
Expected behaviour
No errors, to disable ASM if tracing is disabled, or some exception at configuration time. Not sure what should be the behaviour.
To bypass the error, we just disabled appsec
on static config and enabled it dynamically along with tracing
.
Steps to reproduce
- Disable tracing and enable ASM
Datadog.configure do |c|
c.tracing.enabled = false
c.tracing.instrument :rails
c.appsec.enabled = true
c.appsec.instrument :rails
end
- Login using devise on a rails application.
How does ddtrace
help you?
Environment
- ddtrace version: 1.21.1
- Configuration block (
Datadog.configure ...
): - Ruby version: 3.0.6
- Operating system: Ubuntu 23.10
- Relevant library versions: