Class: Datadog::AppSec::WAF::Handle
- Inherits:
-
Object
- Object
- Datadog::AppSec::WAF::Handle
- Defined in:
- lib/datadog/appsec/waf/handle.rb
Overview
Ruby representation of the ddwaf_handle in libddwaf See github.com/DataDog/libddwaf/blob/10e3a1dfc7bc9bb8ab11a09a9f8b6b339eaf3271/BINDING_IMPL_NOTES.md?plain=1#L4-L19
Instance Method Summary collapse
-
#build_context ⇒ Handle
Builds a WAF context.
-
#finalize! ⇒ Object
Destroys the WAF handle and sets the pointer to nil.
-
#initialize(handle_ptr) ⇒ Handle
constructor
A new instance of Handle.
-
#known_addresses ⇒ Array<String>
Returns the list of known addresses in the WAF handle.
Constructor Details
#initialize(handle_ptr) ⇒ Handle
Returns a new instance of Handle.
9 10 11 |
# File 'lib/datadog/appsec/waf/handle.rb', line 9 def initialize(handle_ptr) @handle_ptr = handle_ptr end |
Instance Method Details
#build_context ⇒ Handle
Builds a WAF context.
27 28 29 30 31 32 33 34 |
# File 'lib/datadog/appsec/waf/handle.rb', line 27 def build_context ensure_pointer_presence! context_obj = LibDDWAF.ddwaf_context_init(@handle_ptr) raise LibDDWAFError, "Could not create context" if context_obj.null? Context.new(context_obj) end |
#finalize! ⇒ Object
Destroys the WAF handle and sets the pointer to nil.
The instance becomes unusable after this method is called.
16 17 18 19 20 21 |
# File 'lib/datadog/appsec/waf/handle.rb', line 16 def finalize! handle_ptr_to_destroy = @handle_ptr @handle_ptr = nil LibDDWAF.ddwaf_destroy(handle_ptr_to_destroy) end |
#known_addresses ⇒ Array<String>
Returns the list of known addresses in the WAF handle.
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/datadog/appsec/waf/handle.rb', line 39 def known_addresses return @known_addresses if defined?(@known_addresses) ensure_pointer_presence! count = LibDDWAF::UInt32Ptr.new list = LibDDWAF.ddwaf_known_addresses(@handle_ptr, count) return [] if count == 0 # list is null @known_addresses = list.get_array_of_string(0, count[:value]).compact end |