libddwaf 1.30.0.0.1-aarch64-linux → 1.30.0.1.0-aarch64-linux

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '02594612a51764ecbe10e415981518b68d928835b504fcba490421973b0e1385'
4
- data.tar.gz: 214f7da6173c96939c0a4ce7da4e1b9b699355c31bd1ecc1505d16c72c9ebb8b
3
+ metadata.gz: 9de78da9a9a968ff60082db468c27dc6fe91ce75935a0bbc4743095450b51a5e
4
+ data.tar.gz: 9d572b8dc18d6fa5d3a930e5da0434973a73155cbfbdd96fe7f4a69e2f7aedec
5
5
  SHA512:
6
- metadata.gz: 9a0194383210d47924469879e4f5c2b4cef81bc874dbe165a6d75f89545a94e9ac817817ca4fe7088871eb4b858256acfcec77859591d6693825542926db3a7e
7
- data.tar.gz: 6e54c0473a6463fcb2ed395c08435fc1c7b60d08dc2d17a23327a622786cf4030297eb9a7f92e4493b71d52eff8de0b0a038191feeefffaa9c42a86e3bb65920
6
+ metadata.gz: f46193c941b2e1f53fc86d9fa9b30bfe33be6f88e446de94e8268842c2da36d860df8606112d3877eae32751abc8452f1ca3ee591c3edb818b4b7a2db3c7e139
7
+ data.tar.gz: 50189195de9d2805ee21fa7669cfa57c838d37f7ad20f1e3e53156feb21c050288e090396e91fda9ccdaad425a69a904f589d479c976be0d96fbef4b873cb82c
@@ -6,6 +6,7 @@ module Datadog
6
6
  # Module responsible for Ruby-to-C and C-to-Ruby conversions
7
7
  module Converter
8
8
  INT64_MIN = -(2**63)
9
+ UINT32_MAX = 2**32 - 1
9
10
  UINT64_MAX = 2**64 - 1
10
11
 
11
12
  module_function
@@ -14,8 +15,8 @@ module Datadog
14
15
  def ruby_to_object(val, max_container_size: nil, max_container_depth: nil, max_string_length: nil, top_obj: nil, coerce: true)
15
16
  case val
16
17
  when Array
17
- obj = LibDDWAF::Object.new
18
- res = LibDDWAF.ddwaf_object_array(obj)
18
+ container = LibDDWAF::Object.new
19
+ res = LibDDWAF.ddwaf_object_array(container)
19
20
  raise ConversionError, "Could not convert into object: #{val}" if res.null?
20
21
 
21
22
  if max_container_depth == 0
@@ -23,7 +24,7 @@ module Datadog
23
24
  else
24
25
  val.each.with_index do |e, i|
25
26
  if max_container_size && i >= max_container_size
26
- (top_obj || obj).mark_truncated!
27
+ (top_obj || container).mark_truncated!
27
28
  break val
28
29
  end
29
30
 
@@ -32,18 +33,19 @@ module Datadog
32
33
  max_container_size: max_container_size,
33
34
  max_container_depth: (max_container_depth - 1 if max_container_depth),
34
35
  max_string_length: max_string_length,
35
- top_obj: top_obj || obj,
36
+ top_obj: top_obj || container,
36
37
  coerce: coerce
37
38
  )
38
- e_res = LibDDWAF.ddwaf_object_array_add(obj, member)
39
+ e_res = LibDDWAF.ddwaf_object_array_add(container, member)
39
40
  raise ConversionError, "Could not add to array object: #{e.inspect}" unless e_res
40
41
  end
41
42
  end
42
43
 
43
- obj
44
+ container_complete = true
45
+ container
44
46
  when Hash
45
- obj = LibDDWAF::Object.new
46
- res = LibDDWAF.ddwaf_object_map(obj)
47
+ container = LibDDWAF::Object.new
48
+ res = LibDDWAF.ddwaf_object_map(container)
47
49
  raise ConversionError, "Could not convert into object: #{val}" if res.null?
48
50
 
49
51
  if max_container_depth == 0
@@ -51,7 +53,7 @@ module Datadog
51
53
  else
52
54
  val.each.with_index do |e, i|
53
55
  if max_container_size && i >= max_container_size
54
- (top_obj || obj).mark_truncated!
56
+ (top_obj || container).mark_truncated!
55
57
  break val
56
58
  end
57
59
 
@@ -61,21 +63,32 @@ module Datadog
61
63
 
62
64
  if max_string_length && k.length > max_string_length
63
65
  k = k[0, max_string_length]
64
- (top_obj || obj).mark_truncated!
66
+ (top_obj || container).mark_truncated!
65
67
  end
66
68
  member = Converter.ruby_to_object(
67
69
  v,
68
70
  max_container_size: max_container_size,
69
71
  max_container_depth: (max_container_depth - 1 if max_container_depth),
70
72
  max_string_length: max_string_length,
71
- top_obj: top_obj || obj,
73
+ top_obj: top_obj || container,
72
74
  coerce: coerce
73
75
  )
74
- kv_res = LibDDWAF.ddwaf_object_map_addl(obj, k, k.bytesize, member)
76
+ kv_res = LibDDWAF.ddwaf_object_map_addl(container, k, k.bytesize, member)
75
77
  raise ConversionError, "Could not add to map object: #{e[0].inspect} => #{v.inspect}" unless kv_res
76
78
  end
77
79
  end
78
80
 
81
+ container_complete = true
82
+ container
83
+ when JSONString
84
+ length = val.bytesize
85
+ raise ConversionError, "JSON string exceeds the native length limit" if length > UINT32_MAX
86
+
87
+ obj = LibDDWAF::Object.new
88
+ unless LibDDWAF.ddwaf_object_from_json(obj, val, length)
89
+ raise ConversionError, "Could not convert JSON string"
90
+ end
91
+
79
92
  obj
80
93
  when String
81
94
  obj = LibDDWAF::Object.new
@@ -146,6 +159,8 @@ module Datadog
146
159
  else
147
160
  Converter.ruby_to_object("")
148
161
  end
162
+ ensure
163
+ LibDDWAF.ddwaf_object_free(container) if container && !container_complete
149
164
  end
150
165
  # standard:enable Metrics/MethodLength,Metrics/CyclomaticComplexity
151
166
 
@@ -161,6 +161,7 @@ module Datadog
161
161
  attach_function :ddwaf_object_bool, [:ddwaf_object, :bool], :ddwaf_object
162
162
  attach_function :ddwaf_object_null, [:ddwaf_object], :ddwaf_object
163
163
  attach_function :ddwaf_object_float, [:ddwaf_object, :double], :ddwaf_object
164
+ attach_function :ddwaf_object_from_json, [:ddwaf_object, :charptr, :uint32], :bool
164
165
 
165
166
  attach_function :ddwaf_object_array, [:ddwaf_object], :ddwaf_object
166
167
  attach_function :ddwaf_object_array_add, [:ddwaf_object, :ddwaf_object], :bool
@@ -5,7 +5,7 @@ module Datadog
5
5
  BASE_STRING = "1.30.0"
6
6
  # NOTE: Every change to the `BASE_STRING` should be accompanied
7
7
  # by a reset of the patch version in the `STRING` below.
8
- STRING = "#{BASE_STRING}.0.1"
8
+ STRING = "#{BASE_STRING}.1.0"
9
9
  MINIMUM_RUBY_VERSION = "2.5"
10
10
  end
11
11
  end
@@ -13,6 +13,10 @@ require "datadog/appsec/waf/version"
13
13
  module Datadog
14
14
  module AppSec
15
15
  module WAF
16
+ # A marker class representing string containing JSON.
17
+ # If given as an address value will trigger parsing into native WAF objects
18
+ JSONString = Class.new(String)
19
+
16
20
  module_function
17
21
 
18
22
  def version
@@ -2,6 +2,12 @@ module Datadog
2
2
  module AppSec
3
3
  module WAF
4
4
  module Converter
5
+ INT64_MIN: Integer
6
+
7
+ UINT32_MAX: Integer
8
+
9
+ UINT64_MAX: Integer
10
+
5
11
  def self?.ruby_to_object: (
6
12
  top val,
7
13
  ?max_container_size: ::Integer?,
@@ -78,6 +78,7 @@ module Datadog
78
78
  def self.ddwaf_object_bool: (LibDDWAF::Object, bool) -> ::FFI::Pointer
79
79
  def self.ddwaf_object_float: (LibDDWAF::Object, ::Float) -> ::FFI::Pointer
80
80
  def self.ddwaf_object_null: (LibDDWAF::Object) -> ::FFI::Pointer
81
+ def self.ddwaf_object_from_json: (LibDDWAF::Object, String, Integer) -> bool
81
82
 
82
83
  def self.ddwaf_object_array: (LibDDWAF::Object) -> ::FFI::Pointer
83
84
  def self.ddwaf_object_array_add: (LibDDWAF::Object, LibDDWAF::Object) -> bool
@@ -42,6 +42,9 @@ module Datadog
42
42
  type attributes = ::Hash[::String, opaque]
43
43
  type opaque = nil | bool | ::String | ::Integer | ::Float | ::Array[opaque] | ::Hash[::String, opaque]
44
44
 
45
+ class JSONString < String
46
+ end
47
+
45
48
  self.@logger: ::Logger
46
49
 
47
50
  self.@log_callback: LibDDWAF::ddwaf_log_cb
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libddwaf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.30.0.0.1
4
+ version: 1.30.0.1.0
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - Datadog, Inc.
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-02-27 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: ffi
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  - !ruby/object:Gem::Version
83
83
  version: 2.0.0
84
84
  requirements: []
85
- rubygems_version: 3.6.2
85
+ rubygems_version: 4.0.20
86
86
  specification_version: 4
87
87
  summary: Datadog WAF
88
88
  test_files: []