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.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(processor:) ⇒ Component
constructor
A new instance of Component.
- #reconfigure(ruleset:, actions:) ⇒ Object
- #reconfigure_lock(&block) ⇒ Object
- #shutdown! ⇒ Object
Constructor Details
#initialize(processor:) ⇒ Component
Returns a new instance of Component.
61 62 63 64 |
# File 'lib/datadog/appsec/component.rb', line 61 def initialize(processor:) @processor = processor @mutex = Mutex.new end |
Instance Attribute Details
#processor ⇒ Object (readonly)
Returns the value of attribute processor.
59 60 61 |
# File 'lib/datadog/appsec/component.rb', line 59 def processor @processor end |
Class Method Details
.build_appsec_component(settings) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/datadog/appsec/component.rb', line 13 def build_appsec_component(settings) return unless settings.respond_to?(:appsec) && settings.appsec.enabled processor = create_processor(settings) # 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: processor) end |
Instance Method Details
#reconfigure(ruleset:, actions:) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/datadog/appsec/component.rb', line 66 def reconfigure(ruleset:, actions:) @mutex.synchronize do AppSec::Processor::Actions.merge(actions) new = Processor.new(ruleset: ruleset) if new && new.ready? old = @processor @processor = new old.finalize if old end end end |
#reconfigure_lock(&block) ⇒ Object
80 81 82 |
# File 'lib/datadog/appsec/component.rb', line 80 def reconfigure_lock(&block) @mutex.synchronize(&block) end |
#shutdown! ⇒ Object
84 85 86 87 88 89 90 91 |
# File 'lib/datadog/appsec/component.rb', line 84 def shutdown! @mutex.synchronize do if processor && processor.ready? processor.finalize @processor = nil end end end |