Class: Datadog::AppSec::Component

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/appsec/component.rb

Overview

Core-pluggable component for AppSec

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(processor:) ⇒ Component

Returns a new instance of Component.



44
45
46
47
# File 'lib/datadog/appsec/component.rb', line 44

def initialize(processor:)
  @processor = processor
  @mutex = Mutex.new
end

Instance Attribute Details

#processorObject (readonly)

Returns the value of attribute processor.



42
43
44
# File 'lib/datadog/appsec/component.rb', line 42

def processor
  @processor
end

Class Method Details

.build_appsec_component(settings) ⇒ Object



12
13
14
15
16
17
# File 'lib/datadog/appsec/component.rb', line 12

def build_appsec_component(settings)
  return unless settings.respond_to?(:appsec) && settings.appsec.enabled

  processor = create_processor(settings)
  new(processor: processor)
end

Instance Method Details

#reconfigure(ruleset:) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/datadog/appsec/component.rb', line 49

def reconfigure(ruleset:)
  @mutex.synchronize do
    new = Processor.new(ruleset: ruleset)

    if new && new.ready?
      old = @processor
      @processor = new
      old.finalize
    end
  end
end

#reconfigure_lock(&block) ⇒ Object



61
62
63
# File 'lib/datadog/appsec/component.rb', line 61

def reconfigure_lock(&block)
  @mutex.synchronize(&block)
end

#shutdown!Object



65
66
67
68
69
70
71
72
# File 'lib/datadog/appsec/component.rb', line 65

def shutdown!
  @mutex.synchronize do
    if processor && processor.ready?
      processor.finalize
      @processor = nil
    end
  end
end