Class: Datadog::AppSec::Processor
- Inherits:
-
Object
- Object
- Datadog::AppSec::Processor
- Defined in:
- lib/datadog/appsec/processor.rb,
lib/datadog/appsec/processor/actions.rb,
lib/datadog/appsec/processor/rule_loader.rb,
lib/datadog/appsec/processor/rule_merger.rb
Overview
Processor integrates libddwaf into datadog/appsec
Defined Under Namespace
Modules: Actions, RuleLoader, RuleMerger Classes: Context
Instance Attribute Summary collapse
-
#addresses ⇒ Object
readonly
Returns the value of attribute addresses.
-
#diagnostics ⇒ Object
readonly
Returns the value of attribute diagnostics.
Class Method Summary collapse
- .libddwaf_platform ⇒ Object
-
.libddwaf_provides_waf? ⇒ Boolean
check whether libddwaf is required and able to provide the needed feature.
- .libddwaf_spec ⇒ Object
-
.require_libddwaf ⇒ Object
libddwaf raises a LoadError on unsupported platforms; it may at some point succeed in being required yet not provide a specific needed feature.
- .ruby_platforms ⇒ Object
Instance Method Summary collapse
- #finalize ⇒ Object
-
#initialize(ruleset:) ⇒ Processor
constructor
A new instance of Processor.
- #ready? ⇒ Boolean
Constructor Details
#initialize(ruleset:) ⇒ Processor
Returns a new instance of Processor.
76 77 78 79 80 81 82 83 84 |
# File 'lib/datadog/appsec/processor.rb', line 76 def initialize(ruleset:) @diagnostics = nil @addresses = [] settings = Datadog.configuration.appsec unless load_libddwaf && create_waf_handle(settings, ruleset) Datadog.logger.warn { 'AppSec is disabled, see logged errors above' } end end |
Instance Attribute Details
#addresses ⇒ Object (readonly)
Returns the value of attribute addresses.
74 75 76 |
# File 'lib/datadog/appsec/processor.rb', line 74 def addresses @addresses end |
#diagnostics ⇒ Object (readonly)
Returns the value of attribute diagnostics.
74 75 76 |
# File 'lib/datadog/appsec/processor.rb', line 74 def diagnostics @diagnostics end |
Class Method Details
.libddwaf_platform ⇒ Object
161 162 163 |
# File 'lib/datadog/appsec/processor.rb', line 161 def libddwaf_platform libddwaf_spec ? libddwaf_spec.platform.to_s : 'unknown' end |
.libddwaf_provides_waf? ⇒ Boolean
check whether libddwaf is required and able to provide the needed feature
136 137 138 |
# File 'lib/datadog/appsec/processor.rb', line 136 def libddwaf_provides_waf? defined?(Datadog::AppSec::WAF) ? true : false end |
.libddwaf_spec ⇒ Object
157 158 159 |
# File 'lib/datadog/appsec/processor.rb', line 157 def libddwaf_spec Gem.loaded_specs['libddwaf'] end |
.require_libddwaf ⇒ Object
libddwaf raises a LoadError on unsupported platforms; it may at some point succeed in being required yet not provide a specific needed feature.
142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/datadog/appsec/processor.rb', line 142 def require_libddwaf Datadog.logger.debug { "libddwaf platform: #{libddwaf_platform}" } require 'libddwaf' true rescue LoadError => e Datadog.logger.error do 'libddwaf failed to load,' \ "installed platform: #{libddwaf_platform} ruby platforms: #{ruby_platforms} error: #{e.inspect}" end false end |
.ruby_platforms ⇒ Object
165 166 167 |
# File 'lib/datadog/appsec/processor.rb', line 165 def ruby_platforms Gem.platforms.map(&:to_s) end |
Instance Method Details
#finalize ⇒ Object
90 91 92 |
# File 'lib/datadog/appsec/processor.rb', line 90 def finalize @handle.finalize end |
#ready? ⇒ Boolean
86 87 88 |
# File 'lib/datadog/appsec/processor.rb', line 86 def ready? !@handle.nil? end |