Class: Datadog::AppSec::Component
- Inherits:
-
Object
- Object
- Datadog::AppSec::Component
- Defined in:
- lib/datadog/appsec/component.rb
Overview
Core-pluggable component for AppSec
Instance Attribute Summary collapse
-
#processor ⇒ Object
readonly
Returns the value of attribute processor.
-
#telemetry ⇒ Object
readonly
Returns the value of attribute telemetry.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(processor, telemetry) ⇒ Component
constructor
A new instance of Component.
- #reconfigure(ruleset:, telemetry:) ⇒ Object
- #reconfigure_lock(&block) ⇒ Object
- #shutdown! ⇒ Object
Constructor Details
#initialize(processor, telemetry) ⇒ Component
Returns a new instance of Component.
78 79 80 81 82 83 |
# File 'lib/datadog/appsec/component.rb', line 78 def initialize(processor, telemetry) @processor = processor @telemetry = telemetry @mutex = Mutex.new end |
Instance Attribute Details
#processor ⇒ Object (readonly)
Returns the value of attribute processor.
76 77 78 |
# File 'lib/datadog/appsec/component.rb', line 76 def processor @processor end |
#telemetry ⇒ Object (readonly)
Returns the value of attribute telemetry.
76 77 78 |
# File 'lib/datadog/appsec/component.rb', line 76 def telemetry @telemetry end |
Class Method Details
.build_appsec_component(settings, telemetry:) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/datadog/appsec/component.rb', line 13 def build_appsec_component(settings, telemetry:) return if !settings.respond_to?(:appsec) || !settings.appsec.enabled return if incompatible_ffi_version? processor = create_processor(settings, telemetry) # We want to always instrument user events when AppSec is enabled. # There could be cases in which users use the DD_APPSEC_ENABLED Env variable to # enable AppSec, in that case, Devise is already instrumented. # In the case that users do not use DD_APPSEC_ENABLED, we have to instrument it, # hence the lines above. devise_integration = Datadog::AppSec::Contrib::Devise::Integration.new settings.appsec.instrument(:devise) unless devise_integration.patcher.patched? new(processor, telemetry) end |
Instance Method Details
#reconfigure(ruleset:, telemetry:) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/datadog/appsec/component.rb', line 85 def reconfigure(ruleset:, telemetry:) @mutex.synchronize do new_processor = Processor.new(ruleset: ruleset, telemetry: telemetry) if new_processor && new_processor.ready? old_processor = @processor @telemetry = telemetry @processor = new_processor old_processor.finalize if old_processor end end end |
#reconfigure_lock(&block) ⇒ Object
100 101 102 |
# File 'lib/datadog/appsec/component.rb', line 100 def reconfigure_lock(&block) @mutex.synchronize(&block) end |
#shutdown! ⇒ Object
104 105 106 107 108 109 110 111 |
# File 'lib/datadog/appsec/component.rb', line 104 def shutdown! @mutex.synchronize do if processor && processor.ready? processor.finalize @processor = nil end end end |