libddwaf 1.10.0.0.0-x86_64-linux → 1.11.0.0.0-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d56706dbb5d0523cece21cbf535919cfdd84b5853519fa5510932666f670f94
4
- data.tar.gz: 4f496a70dcddbc9be0dbbc2b63c946c5d791411f720f7365d69fb7666b4336b9
3
+ metadata.gz: bc6b34328b53329c7cbdff6986bb71d8ce6169a020b3468079ad23f1c6cffa50
4
+ data.tar.gz: cdaf779c80feb701be702b7943af1cb437ad362582b7d79ce61fba07fa6b96d6
5
5
  SHA512:
6
- metadata.gz: 65ba5e74b5c1d30cebf23b4a4c73f9b7ee60a0f9987242c38381656e9007db031767d19e2f46c4c2669c88bce85308b81789951b0788161b166ffc2425027bd0
7
- data.tar.gz: 11136155d2460c0a29b9a92d6e0114c763aa40d06eb718e61c0b325fe54ce2a90a7f9877c19d0063cdd18c9a33738ad3fc31c0e3a4c17fb1ef1554e1b573e50f
6
+ metadata.gz: 7d5179a6def6bb42ea379461c6274ae529a043b31b70ed76b4b9c20c26936f7db25a94d46aa072a16c6432d8af9c16f120a89993d42cc8a9b7a34139a9fa1d53
7
+ data.tar.gz: dcc4a1f9f2d593f6f2663b18b92c6ea7777883112dc3a2eed6c5dc01921c972252889b806a4899a8463b6da28612b573de39f418d207a75a14dd2dcbbcea7152
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ # 2023-08-29 v.1.11.0.0.0
2
+
3
+ - Update to libddwaf 1.11.0
4
+ - Rename Handle#ruleset_info to Handle#diagnostics. (Breaking change)
5
+ The schema of the new diagnostics variable can be [here](https://github.com/DataDog/libddwaf/blob/master/schema/diagnostics.json)
6
+
7
+
8
+ # 2023-08-28 v.1.10.0.0.0
9
+
10
+ - Update to libddwaf 1.10.0
11
+
1
12
  # 2023-06-13 v.1.9.0.0.1
2
13
 
3
14
  - Handle invalid encoding
@@ -2,7 +2,7 @@ module Datadog
2
2
  module AppSec
3
3
  module WAF
4
4
  module VERSION
5
- BASE_STRING = '1.10.0'
5
+ BASE_STRING = '1.11.0'
6
6
  STRING = "#{BASE_STRING}.0.0"
7
7
  MINIMUM_RUBY_VERSION = '2.1'
8
8
  end
@@ -8,10 +8,10 @@ module Datadog
8
8
  module WAF
9
9
  module LibDDWAF
10
10
  class Error < StandardError
11
- attr_reader :ruleset_info
11
+ attr_reader :diagnostics
12
12
 
13
- def initialize(msg, ruleset_info: nil)
14
- @ruleset_info = ruleset_info
13
+ def initialize(msg, diagnostics: nil)
14
+ @diagnostics = diagnostics
15
15
  end
16
16
  end
17
17
 
@@ -216,20 +216,8 @@ module Datadog
216
216
 
217
217
  typedef Config.by_ref, :ddwaf_config
218
218
 
219
- class RuleSetInfo < ::FFI::Struct
220
- layout :loaded, :uint16,
221
- :failed, :uint16,
222
- :errors, Object,
223
- :version, :string
224
- end
225
-
226
- typedef RuleSetInfo.by_ref, :ddwaf_ruleset_info
227
- RuleSetInfoNone = Datadog::AppSec::WAF::LibDDWAF::RuleSetInfo.new(::FFI::Pointer::NULL)
228
-
229
- attach_function :ddwaf_ruleset_info_free, [:ddwaf_ruleset_info], :void
230
-
231
- attach_function :ddwaf_init, [:ddwaf_rule, :ddwaf_config, :ddwaf_ruleset_info], :ddwaf_handle
232
- attach_function :ddwaf_update, [:ddwaf_handle, :ddwaf_object, :ddwaf_ruleset_info], :ddwaf_handle
219
+ attach_function :ddwaf_init, [:ddwaf_rule, :ddwaf_config, :ddwaf_object], :ddwaf_handle
220
+ attach_function :ddwaf_update, [:ddwaf_handle, :ddwaf_object, :ddwaf_object], :ddwaf_handle
233
221
  attach_function :ddwaf_destroy, [:ddwaf_handle], :void
234
222
 
235
223
  attach_function :ddwaf_required_addresses, [:ddwaf_handle, UInt32Ptr], :charptrptr
@@ -250,15 +238,10 @@ module Datadog
250
238
  attach_function :ddwaf_context_init, [:ddwaf_handle], :ddwaf_context
251
239
  attach_function :ddwaf_context_destroy, [:ddwaf_context], :void
252
240
 
253
- class ResultActions < ::FFI::Struct
254
- layout :array, :charptrptr,
255
- :size, :uint32
256
- end
257
-
258
241
  class Result < ::FFI::Struct
259
- layout :timeout, :bool,
260
- :data, :string,
261
- :actions, ResultActions,
242
+ layout :timeout, :bool,
243
+ :events, Object,
244
+ :actions, Object,
262
245
  :total_runtime, :uint64
263
246
  end
264
247
 
@@ -479,7 +462,7 @@ module Datadog
479
462
  }
480
463
 
481
464
  class Handle
482
- attr_reader :handle_obj, :ruleset_info, :config
465
+ attr_reader :handle_obj, :diagnostics, :config
483
466
 
484
467
  def initialize(rule, limits: {}, obfuscator: {})
485
468
  rule_obj = Datadog::AppSec::WAF.ruby_to_object(rule)
@@ -501,24 +484,19 @@ module Datadog
501
484
 
502
485
  @config = config_obj
503
486
 
504
- ruleset_info = LibDDWAF::RuleSetInfo.new
487
+ diagnostics_obj = Datadog::AppSec::WAF::LibDDWAF::Object.new
505
488
 
506
- @handle_obj = Datadog::AppSec::WAF::LibDDWAF.ddwaf_init(rule_obj, config_obj, ruleset_info)
489
+ @handle_obj = Datadog::AppSec::WAF::LibDDWAF.ddwaf_init(rule_obj, config_obj, diagnostics_obj)
507
490
 
508
- @ruleset_info = {
509
- loaded: ruleset_info[:loaded],
510
- failed: ruleset_info[:failed],
511
- errors: WAF.object_to_ruby(ruleset_info[:errors]),
512
- version: ruleset_info[:version],
513
- }
491
+ @diagnostics = Datadog::AppSec::WAF.object_to_ruby(diagnostics_obj)
514
492
 
515
493
  if @handle_obj.null?
516
- fail LibDDWAF::Error.new('Could not create handle', ruleset_info: @ruleset_info)
494
+ fail LibDDWAF::Error.new('Could not create handle', diagnostics: @diagnostics)
517
495
  end
518
496
 
519
497
  validate!
520
498
  ensure
521
- Datadog::AppSec::WAF::LibDDWAF.ddwaf_ruleset_info_free(ruleset_info) if ruleset_info
499
+ Datadog::AppSec::WAF::LibDDWAF.ddwaf_object_free(diagnostics_obj) if diagnostics_obj
522
500
  Datadog::AppSec::WAF::LibDDWAF.ddwaf_object_free(rule_obj) if rule_obj
523
501
  end
524
502
 
@@ -541,29 +519,24 @@ module Datadog
541
519
 
542
520
  def merge(data)
543
521
  data_obj = Datadog::AppSec::WAF.ruby_to_object(data, coerce: false)
544
- ruleset_info = LibDDWAF::RuleSetInfo.new
545
- new_handle = Datadog::AppSec::WAF::LibDDWAF.ddwaf_update(handle_obj, data_obj, ruleset_info)
522
+ diagnostics_obj = LibDDWAF::Object.new
523
+ new_handle = Datadog::AppSec::WAF::LibDDWAF.ddwaf_update(handle_obj, data_obj, diagnostics_obj)
546
524
 
547
525
  return if new_handle.null?
548
526
 
549
- info = {
550
- loaded: ruleset_info[:loaded],
551
- failed: ruleset_info[:failed],
552
- errors: WAF.object_to_ruby(ruleset_info[:errors]),
553
- version: ruleset_info[:version],
554
- }
555
- new_from_handle(new_handle, info, config)
527
+ diagnostics = Datadog::AppSec::WAF.object_to_ruby(diagnostics_obj)
528
+ new_from_handle(new_handle, diagnostics, config)
556
529
  ensure
557
530
  Datadog::AppSec::WAF::LibDDWAF.ddwaf_object_free(data_obj) if data_obj
558
- Datadog::AppSec::WAF::LibDDWAF.ddwaf_ruleset_info_free(ruleset_info) if ruleset_info
531
+ Datadog::AppSec::WAF::LibDDWAF.ddwaf_object_free(diagnostics_obj) if diagnostics_obj
559
532
  end
560
533
 
561
534
  private
562
535
 
563
- def new_from_handle(handle_object, info, config)
536
+ def new_from_handle(handle_object, diagnostics, config)
564
537
  obj = self.class.allocate
565
538
  obj.instance_variable_set(:@handle_obj, handle_object)
566
- obj.instance_variable_set(:@ruleset_info, info)
539
+ obj.instance_variable_set(:@diagnostics, diagnostics)
567
540
  obj.instance_variable_set(:@config, config)
568
541
  obj
569
542
  end
@@ -588,11 +561,11 @@ module Datadog
588
561
  end
589
562
 
590
563
  class Result
591
- attr_reader :status, :data, :total_runtime, :timeout, :actions
564
+ attr_reader :status, :events, :total_runtime, :timeout, :actions
592
565
 
593
- def initialize(status, data, total_runtime, timeout, actions)
566
+ def initialize(status, events, total_runtime, timeout, actions)
594
567
  @status = status
595
- @data = data
568
+ @events = events
596
569
  @total_runtime = total_runtime
597
570
  @timeout = timeout
598
571
  @actions = actions
@@ -651,18 +624,12 @@ module Datadog
651
624
 
652
625
  code = Datadog::AppSec::WAF::LibDDWAF.ddwaf_run(@context_obj, input_obj, result_obj, timeout)
653
626
 
654
- actions = if result_obj[:actions][:size] > 0
655
- result_obj[:actions][:array].get_array_of_string(0, result_obj[:actions][:size])
656
- else
657
- []
658
- end
659
-
660
627
  result = Result.new(
661
628
  RESULT_CODE[code],
662
- (JSON.parse(result_obj[:data]) if result_obj[:data] != nil),
629
+ Datadog::AppSec::WAF.object_to_ruby(result_obj[:events]),
663
630
  result_obj[:total_runtime],
664
631
  result_obj[:timeout],
665
- actions,
632
+ Datadog::AppSec::WAF.object_to_ruby(result_obj[:actions]),
666
633
  )
667
634
 
668
635
  [RESULT_CODE[code], result]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libddwaf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.0.0.0
4
+ version: 1.11.0.0.0
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Datadog, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-28 00:00:00.000000000 Z
11
+ date: 2023-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -42,7 +42,7 @@ files:
42
42
  - lib/datadog/appsec/waf.rb
43
43
  - lib/datadog/appsec/waf/version.rb
44
44
  - lib/libddwaf.rb
45
- - vendor/libddwaf/libddwaf-1.10.0-linux-x86_64/lib/libddwaf.so
45
+ - vendor/libddwaf/libddwaf-1.11.0-linux-x86_64/lib/libddwaf.so
46
46
  homepage: https://github.com/DataDog/libddwaf-rb
47
47
  licenses:
48
48
  - BSD-3-Clause