libddwaf 1.3.0.1.0.beta1-aarch64-linux → 1.3.0.2.0-aarch64-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: ac32125f2aa6f6632a5b8e6bab87f6e37ffb8248da2d0c0f59abe95eeb3eb765
4
- data.tar.gz: e702dadb52d3aa9e0aa8be62417a71db815afdf4f27aa1966cd06ed7b364b6b0
3
+ metadata.gz: 5293c5bc6df07ebd804c6b8ed8786ab449da414aeb01b22b35122251b66292b8
4
+ data.tar.gz: 00024f90e5e86a1ea4ef91deb4c4ec44c8c9aa47ba3295f6421bb95c27b855bc
5
5
  SHA512:
6
- metadata.gz: a15ea409175ce2616dab6a851ac1a4e6d8264c483006680af3e04562753ed5ecbb722fed1bf406b95a02a049e77936d4d3d9b1c8b41d2c28c560aad640e0c28e
7
- data.tar.gz: cb9a77becb1fdf0c66aa78cf0a7fdadaf22c3afccafc9eb79fa6ee21a815f29e16c6340cc23381ebb46a47f2fc7623dee736a70202d452208b7878bdc424ee0d
6
+ metadata.gz: 7ab46d9a467f64d90b2fb4a375ed0b13beb2524307dcaa484271415537ba5abe37806d308908cc48fa97a4af7897ccea274e6cff163607b07fb121dfd6a78d3e
7
+ data.tar.gz: c526cc10522017fda8c6b7b3ae6fd1d59d93f914696e34432949ecdb2f0f3b3fea76d8460cbd3891ab7228472d3ee21441432be511407bb74d3d1905240aeb17
@@ -3,7 +3,7 @@ module Datadog
3
3
  module WAF
4
4
  module VERSION
5
5
  BASE_STRING = '1.3.0'
6
- STRING = "#{BASE_STRING}.1.0.beta1"
6
+ STRING = "#{BASE_STRING}.2.0"
7
7
  MINIMUM_RUBY_VERSION = '2.1'
8
8
  end
9
9
  end
@@ -32,12 +32,22 @@ module Datadog
32
32
  Gem::Platform.local.os
33
33
  end
34
34
 
35
+ def self.local_version
36
+ return nil unless local_os == 'linux'
37
+
38
+ # Old rubygems don't handle non-gnu linux correctly
39
+ return $1 if RUBY_PLATFORM =~ /linux-(.+)$/
40
+
41
+ 'gnu'
42
+ end
43
+
35
44
  def self.local_cpu
36
45
  if RUBY_ENGINE == 'jruby'
37
46
  os_arch = java.lang.System.get_property('os.arch')
38
47
 
39
48
  cpu = case os_arch
40
49
  when 'amd64' then 'x86_64'
50
+ when 'aarch64' then 'aarch64'
41
51
  else raise Error, "unsupported JRuby os.arch: #{os_arch.inspect}"
42
52
  end
43
53
 
@@ -47,12 +57,28 @@ module Datadog
47
57
  Gem::Platform.local.cpu
48
58
  end
49
59
 
60
+ def self.vendor_dir
61
+ File.join(__dir__, '../../../vendor')
62
+ end
63
+
64
+ def self.libddwaf_vendor_dir
65
+ File.join(vendor_dir, 'libddwaf')
66
+ end
67
+
68
+ def self.shared_lib_triplet
69
+ local_version ? "#{local_os}-#{local_version}-#{local_cpu}" : "#{local_os}-#{local_cpu}"
70
+ end
71
+
72
+ def self.libddwaf_dir
73
+ File.join(libddwaf_vendor_dir, "libddwaf-#{Datadog::AppSec::WAF::VERSION::BASE_STRING}-#{shared_lib_triplet}")
74
+ end
75
+
50
76
  def self.shared_lib_extname
51
77
  Gem::Platform.local.os == 'darwin' ? '.dylib' : '.so'
52
78
  end
53
79
 
54
80
  def self.shared_lib_path
55
- File.join(__dir__, "../../../vendor/libddwaf/libddwaf-#{Datadog::AppSec::WAF::VERSION::BASE_STRING}-#{local_os}-#{local_cpu}/lib/libddwaf#{shared_lib_extname}")
81
+ File.join(libddwaf_dir, 'lib', "libddwaf#{shared_lib_extname}")
56
82
  end
57
83
 
58
84
  ffi_lib [shared_lib_path]
@@ -265,7 +291,7 @@ module Datadog
265
291
  end
266
292
 
267
293
  val.each do |k, v|
268
- res = LibDDWAF.ddwaf_object_map_addl(obj, k.to_s, k.to_s.size, ruby_to_object(v))
294
+ res = LibDDWAF.ddwaf_object_map_addl(obj, k.to_s, k.to_s.bytesize, ruby_to_object(v))
269
295
  unless res
270
296
  fail LibDDWAF::Error, "Could not add to map object: #{k.inspect} => #{v.inspect}"
271
297
  end
@@ -274,7 +300,7 @@ module Datadog
274
300
  obj
275
301
  when String
276
302
  obj = LibDDWAF::Object.new
277
- res = LibDDWAF.ddwaf_object_stringl(obj, val, val.size)
303
+ res = LibDDWAF.ddwaf_object_stringl(obj, val, val.bytesize)
278
304
  if res.null?
279
305
  fail LibDDWAF::Error, "Could not convert into object: #{val}"
280
306
  end
@@ -282,7 +308,8 @@ module Datadog
282
308
  obj
283
309
  when Symbol
284
310
  obj = LibDDWAF::Object.new
285
- res = LibDDWAF.ddwaf_object_stringl(obj, val.to_s, val.size)
311
+ str = val.to_s
312
+ res = LibDDWAF.ddwaf_object_stringl(obj, str, str.bytesize)
286
313
  if res.null?
287
314
  fail LibDDWAF::Error, "Could not convert into object: #{val}"
288
315
  end
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.3.0.1.0.beta1
4
+ version: 1.3.0.2.0
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - Datadog, Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-22 00:00:00.000000000 Z
11
+ date: 1980-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -41,14 +41,14 @@ files:
41
41
  - lib/datadog/appsec/waf.rb
42
42
  - lib/datadog/appsec/waf/version.rb
43
43
  - lib/libddwaf.rb
44
- - vendor/libddwaf/libddwaf-1.3.0-linux-aarch64/include/ddwaf.h
45
- - vendor/libddwaf/libddwaf-1.3.0-linux-aarch64/lib/libddwaf.so
44
+ - vendor/libddwaf/libddwaf-1.3.0-linux-gnu-aarch64/lib/libddwaf.so
45
+ - vendor/libddwaf/libddwaf-1.3.0-linux-musl-aarch64/lib/libddwaf.so
46
46
  homepage: https://github.com/DataDog/libddwaf
47
47
  licenses:
48
48
  - BSD-3-Clause
49
49
  metadata:
50
50
  allowed_push_host: https://rubygems.org
51
- post_install_message:
51
+ post_install_message:
52
52
  rdoc_options: []
53
53
  require_paths:
54
54
  - lib
@@ -63,8 +63,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
63
  - !ruby/object:Gem::Version
64
64
  version: 2.0.0
65
65
  requirements: []
66
- rubygems_version: 3.1.2
67
- signing_key:
66
+ rubygems_version: 3.2.26
67
+ signing_key:
68
68
  specification_version: 4
69
69
  summary: Datadog WAF
70
70
  test_files: []
@@ -1,624 +0,0 @@
1
- // Unless explicitly stated otherwise all files in this repository are
2
- // dual-licensed under the Apache-2.0 License or BSD-3-Clause License.
3
- //
4
- // This product includes software developed at Datadog (https://www.datadoghq.com/).
5
- // Copyright 2021 Datadog, Inc.
6
-
7
- #ifndef pw_h
8
- #define pw_h
9
-
10
- #ifdef __cplusplus
11
- extern "C"
12
- {
13
- #endif
14
-
15
- #include <stdbool.h>
16
- #include <stdint.h>
17
- #include <stddef.h>
18
-
19
- #define DDWAF_MAX_STRING_LENGTH 4096
20
- #define DDWAF_MAX_CONTAINER_DEPTH 20
21
- #define DDWAF_MAX_CONTAINER_SIZE 256
22
- #define DDWAF_RUN_TIMEOUT 5000
23
-
24
- /**
25
- * @enum DDWAF_OBJ_TYPE
26
- *
27
- * Specifies the type of a ddwaf::object.
28
- **/
29
- typedef enum
30
- {
31
- DDWAF_OBJ_INVALID = 0,
32
- /** Value shall be decoded as a int64_t (or int32_t on 32bits platforms). **/
33
- DDWAF_OBJ_SIGNED = 1 << 0,
34
- /** Value shall be decoded as a uint64_t (or uint32_t on 32bits platforms). **/
35
- DDWAF_OBJ_UNSIGNED = 1 << 1,
36
- /** Value shall be decoded as a UTF-8 string of length nbEntries. **/
37
- DDWAF_OBJ_STRING = 1 << 2,
38
- /** Value shall be decoded as an array of ddwaf_object of length nbEntries, each item having no parameterName. **/
39
- DDWAF_OBJ_ARRAY = 1 << 3,
40
- /** Value shall be decoded as an array of ddwaf_object of length nbEntries, each item having a parameterName. **/
41
- DDWAF_OBJ_MAP = 1 << 4,
42
- } DDWAF_OBJ_TYPE;
43
-
44
- /**
45
- * @enum DDWAF_RET_CODE
46
- *
47
- * Codes returned by ddwaf_run.
48
- **/
49
- typedef enum
50
- {
51
- DDWAF_ERR_INTERNAL = -3,
52
- DDWAF_ERR_INVALID_OBJECT = -2,
53
- DDWAF_ERR_INVALID_ARGUMENT = -1,
54
- DDWAF_GOOD = 0,
55
- DDWAF_MONITOR = 1,
56
- DDWAF_BLOCK = 2
57
- } DDWAF_RET_CODE;
58
-
59
- /**
60
- * @enum DDWAF_LOG_LEVEL
61
- *
62
- * Internal WAF log levels, to be used when setting the minimum log level and cb.
63
- **/
64
- typedef enum
65
- {
66
- DDWAF_LOG_TRACE,
67
- DDWAF_LOG_DEBUG,
68
- DDWAF_LOG_INFO,
69
- DDWAF_LOG_WARN,
70
- DDWAF_LOG_ERROR,
71
- DDWAF_LOG_OFF,
72
- } DDWAF_LOG_LEVEL;
73
-
74
- #ifdef __cplusplus
75
- class PowerWAF;
76
- class PWAdditive;
77
- using ddwaf_handle = PowerWAF *;
78
- using ddwaf_context = PWAdditive *;
79
- #else
80
- typedef struct _ddwaf_handle* ddwaf_handle;
81
- typedef struct _ddwaf_context* ddwaf_context;
82
- #endif
83
-
84
- typedef struct _ddwaf_object ddwaf_object;
85
- typedef struct _ddwaf_config ddwaf_config;
86
- typedef struct _ddwaf_result ddwaf_result;
87
- typedef struct _ddwaf_version ddwaf_version;
88
- typedef struct _ddwaf_ruleset_info ddwaf_ruleset_info;
89
- /**
90
- * @struct ddwaf_object
91
- *
92
- * Generic object used to pass data and rules to the WAF.
93
- **/
94
- struct _ddwaf_object
95
- {
96
- const char* parameterName;
97
- uint64_t parameterNameLength;
98
- // uintValue should be at least as wide as the widest type on the platform.
99
- union
100
- {
101
- const char* stringValue;
102
- uint64_t uintValue;
103
- int64_t intValue;
104
- ddwaf_object* array;
105
- };
106
- uint64_t nbEntries;
107
- DDWAF_OBJ_TYPE type;
108
- };
109
-
110
- /**
111
- * @struct ddwaf_config
112
- *
113
- * Configuration to be provided to the WAF
114
- **/
115
- struct _ddwaf_config
116
- {
117
- struct {
118
- /** Maximum size of ddwaf::object containers. */
119
- uint32_t max_container_size;
120
- /** Maximum depth of ddwaf::object containers. */
121
- uint32_t max_container_depth;
122
- /** Maximum length of ddwaf::object strings. */
123
- uint32_t max_string_length;
124
- } limits;
125
-
126
- /** Obfuscator regexes - the strings are owned by the caller */
127
- struct {
128
- /** Regular expression for key-based obfuscation */
129
- const char *key_regex;
130
- /** Regular expression for value-based obfuscation */
131
- const char *value_regex;
132
- } obfuscator;
133
- };
134
-
135
- /**
136
- * @struct ddwaf_result
137
- *
138
- * Structure containing the result of a WAF run.
139
- **/
140
- struct _ddwaf_result
141
- {
142
- /** Whether there has been a timeout during the operation **/
143
- bool timeout;
144
- /** Run result in JSON format **/
145
- const char* data;
146
- /** Total WAF runtime in nanoseconds **/
147
- uint64_t total_runtime;
148
- };
149
-
150
- /**
151
- * @ddwaf_version
152
- *
153
- * Structure containing the version of the WAF following semver.
154
- **/
155
- struct _ddwaf_version
156
- {
157
- uint16_t major;
158
- uint16_t minor;
159
- uint16_t patch;
160
- };
161
-
162
- /**
163
- * @ddwaf_ruleset_info
164
- *
165
- * Structure containing diagnostics on the provided ruleset.
166
- * */
167
- struct _ddwaf_ruleset_info
168
- {
169
- /** Number of rules successfully loaded **/
170
- uint16_t loaded;
171
- /** Number of rules which failed to parse **/
172
- uint16_t failed;
173
- /** Map from an error string to an array of all the rule ids for which
174
- * that error was raised. {error: [rule_ids]} **/
175
- ddwaf_object errors;
176
- /** Ruleset version **/
177
- const char *version;
178
- };
179
-
180
- /**
181
- * @typedef ddwaf_object_free_fn
182
- *
183
- * Type of the function to free ddwaf::objects.
184
- **/
185
- typedef void (*ddwaf_object_free_fn)(ddwaf_object *object);
186
-
187
- /**
188
- * @typedef ddwaf_log_cb
189
- *
190
- * Callback that powerwaf will call to relay messages to the binding.
191
- *
192
- * @param level The logging level.
193
- * @param function The native function that emitted the message. (nonnull)
194
- * @param file The file of the native function that emmitted the message. (nonnull)
195
- * @param line The line where the message was emmitted.
196
- * @param message The size of the logging message. NUL-terminated
197
- * @param message_len The length of the logging message (excluding NUL terminator).
198
- */
199
- typedef void (*ddwaf_log_cb)(
200
- DDWAF_LOG_LEVEL level, const char* function, const char* file, unsigned line,
201
- const char* message, uint64_t message_len);
202
-
203
- /**
204
- * ddwaf_init
205
- *
206
- * Initialize a ddwaf instance
207
- *
208
- * @param rule ddwaf::object containing the patterns to be used by the WAF. (nonnull)
209
- * @param config Optional configuration of the WAF. (nullable)
210
- * @param info Optional ruleset parsing diagnostics. (nullable)
211
- *
212
- * @return Handle to the WAF instance.
213
- **/
214
- ddwaf_handle ddwaf_init(const ddwaf_object *rule,
215
- const ddwaf_config* config, ddwaf_ruleset_info *info);
216
-
217
- /**
218
- * ddwaf_destroy
219
- *
220
- * Destroy a WAF instance.
221
- *
222
- * @param Handle to the WAF instance.
223
- */
224
- void ddwaf_destroy(ddwaf_handle handle);
225
- /**
226
- * ddwaf_ruleset_info_free
227
- *
228
- * Free the memory associated with the ruleset info structure.
229
- *
230
- * @param info Ruleset info to free.
231
- * */
232
- void ddwaf_ruleset_info_free(ddwaf_ruleset_info *info);
233
- /**
234
- * ddwaf_required_addresses
235
- *
236
- * Get a list of required (root) addresses. The memory is owned by the WAF and
237
- * should not be freed.
238
- *
239
- * @param Handle to the WAF instance.
240
- * @param size Output parameter in which the size will be returned. The value of
241
- * size will be 0 if the return value is nullptr.
242
- * @return NULL if error, otherwise a pointer to an array with size elements.
243
- **/
244
- const char* const* ddwaf_required_addresses(const ddwaf_handle handle, uint32_t *size);
245
- /**
246
- * ddwaf_context_init
247
- *
248
- * Context object to perform matching using the provided WAF instance.
249
- *
250
- * @param handle Handle of the WAF instance containing the ruleset definition. (nonnull)
251
- * @param obj_free Function to free the ddwaf::object provided to the context
252
- * during calls to ddwaf_run. If the value of this function is
253
- * NULL, the objects will not be freed. By default the value of
254
- * this parameter should be ddwaf_object_free.
255
- *
256
- * @return Handle to the context instance.
257
- *
258
- * @note The WAF instance needs to be valid for the lifetime of the context.
259
- **/
260
- ddwaf_context ddwaf_context_init(const ddwaf_handle handle, ddwaf_object_free_fn obj_free);
261
-
262
- /**
263
- * ddwaf_run
264
- *
265
- * Perform a matching operation on the provided data
266
- *
267
- * @param context WAF context to be used in this run, this will determine the
268
- * ruleset which will be used and it will also ensure that
269
- * parameters are taken into account across runs (nonnull)
270
- * @param data Data on which to perform the pattern matching. This data will be
271
- * stored by the context and used across multiple calls to this
272
- * function. Once the context is destroyed, the used-defined free
273
- * function will be used to free the data provided. Note that the
274
- * data passed must be valid until the destruction of the context.
275
- * (nonull)
276
- * @param result Structure containing the result of the operation. (nullable)
277
- * @param timeout Maximum time budget in microseconds.
278
- *
279
- * @return Return code of the operation, also contained in the result structure.
280
- * @error DDWAF_ERR_INVALID_ARGUMENT The context is invalid, the data will not
281
- * be freed.
282
- * @error DDWAF_ERR_INVALID_OBJECT The data provided didn't match the desired
283
- * structure or contained invalid objects, the
284
- * data will be freed by this function.
285
- * @error DDWAF_ERR_TIMEOUT The operation timed out, the data will be owned by
286
- * the context and freed during destruction.
287
- * @error DDWAF_ERR_INTERNAL There was an unexpected error and the operation did
288
- * not succeed. The state of the WAF is undefined if
289
- * this error is produced and the ownership of the
290
- * data is unknown. The result structure will not be
291
- * filled if this error occurs.
292
- **/
293
- DDWAF_RET_CODE ddwaf_run(ddwaf_context context, ddwaf_object *data,
294
- ddwaf_result *result, uint64_t timeout);
295
-
296
- /**
297
- * ddwaf_context_destroy
298
- *
299
- * Performs the destruction of the context, freeing the data passed to it through
300
- * ddwaf_run using the used-defined free function.
301
- *
302
- * @param context Context to destroy. (nonnull)
303
- **/
304
- void ddwaf_context_destroy(ddwaf_context context);
305
-
306
- /**
307
- * ddwaf_result_free
308
- *
309
- * Free a ddwaf_result structure.
310
- *
311
- * @param result Structure to free. (nonnull)
312
- **/
313
- void ddwaf_result_free(ddwaf_result *result);
314
-
315
- /**
316
- * ddwaf_object_invalid
317
- *
318
- * Creates an invalid object.
319
- *
320
- * @param object Object to perform the operation on. (nonnull)
321
- *
322
- * @return A pointer to the passed object or NULL if the operation failed.
323
- **/
324
- ddwaf_object* ddwaf_object_invalid(ddwaf_object *object);
325
-
326
- /**
327
- * ddwaf_object_string
328
- *
329
- * Creates an object from a string.
330
- *
331
- * @param object Object to perform the operation on. (nonnull)
332
- * @param string String to initialise the object with, this string will be copied
333
- * and its length will be calculated using strlen(string). (nonnull)
334
- *
335
- * @return A pointer to the passed object or NULL if the operation failed.
336
- **/
337
- ddwaf_object* ddwaf_object_string(ddwaf_object *object, const char *string);
338
-
339
- /**
340
- * ddwaf_object_stringl
341
- *
342
- * Creates an object from a string and its length.
343
- *
344
- * @param object Object to perform the operation on. (nonnull)
345
- * @param string String to initialise the object with, this string will be
346
- * copied. (nonnull)
347
- * @param length Length of the string.
348
- *
349
- * @return A pointer to the passed object or NULL if the operation failed.
350
- **/
351
- ddwaf_object* ddwaf_object_stringl(ddwaf_object *object, const char *string, size_t length);
352
-
353
- /**
354
- * ddwaf_object_stringl_nc
355
- *
356
- * Creates an object with the string pointer and length provided.
357
- *
358
- * @param object Object to perform the operation on. (nonnull)
359
- * @param string String pointer to initialise the object with.
360
- * @param length Length of the string.
361
- *
362
- * @return A pointer to the passed object or NULL if the operation failed.
363
- **/
364
- ddwaf_object* ddwaf_object_stringl_nc(ddwaf_object *object, const char *string, size_t length);
365
-
366
- /**
367
- * ddwaf_object_unsigned
368
- *
369
- * Creates an object using an unsigned integer (64-bit). The resulting object
370
- * will contain a string created using the integer provided. This is the
371
- * preferred method for passing an unsigned integer to the WAF.
372
- *
373
- * @param object Object to perform the operation on. (nonnull)
374
- * @param value Integer to initialise the object with.
375
- *
376
- * @return A pointer to the passed object or NULL if the operation failed.
377
- **/
378
- ddwaf_object* ddwaf_object_unsigned(ddwaf_object *object, uint64_t value);
379
-
380
- /**
381
- * ddwaf_object_signed
382
- *
383
- * Creates an object using a signed integer (64-bit). The resulting object
384
- * will contain a string created using the integer provided. This is the
385
- * preferred method for passing a signed integer to the WAF.
386
- *
387
- * @param object Object to perform the operation on. (nonnull)
388
- * @param value Integer to initialise the object with.
389
- *
390
- * @return A pointer to the passed object or NULL if the operation failed.
391
- **/
392
- ddwaf_object* ddwaf_object_signed(ddwaf_object *object, int64_t value);
393
-
394
- /**
395
- * ddwaf_object_unsigned_force
396
- *
397
- * Creates an object using an unsigned integer (64-bit). The resulting object
398
- * will contain an unsigned integer as opposed to a string.
399
- *
400
- * @param object Object to perform the operation on. (nonnull)
401
- * @param value Integer to initialise the object with.
402
- *
403
- * @return A pointer to the passed object or NULL if the operation failed.
404
- **/
405
- ddwaf_object* ddwaf_object_unsigned_force(ddwaf_object *object, uint64_t value);
406
-
407
- /**
408
- * ddwaf_object_signed_force
409
- *
410
- * Creates an object using a signed integer (64-bit). The resulting object
411
- * will contain a signed integer as opposed to a string.
412
- *
413
- * @param object Object to perform the operation on. (nonnull)
414
- * @param value Integer to initialise the object with.
415
- *
416
- * @return A pointer to the passed object or NULL if the operation failed.
417
- **/
418
- ddwaf_object* ddwaf_object_signed_force(ddwaf_object *object, int64_t value);
419
-
420
- /**
421
- * ddwaf_object_array
422
- *
423
- * Creates an array object, for sequential storage.
424
- *
425
- * @param object Object to perform the operation on. (nonnull)
426
- *
427
- * @return A pointer to the passed object or NULL if the operation failed.
428
- **/
429
- ddwaf_object* ddwaf_object_array(ddwaf_object *object);
430
-
431
- /**
432
- * ddwaf_object_map
433
- *
434
- * Creates a map object, for key-value storage.
435
- *
436
- * @param object Object to perform the operation on. (nonnull)
437
- *
438
- * @return A pointer to the passed object or NULL if the operation failed.
439
- **/
440
- ddwaf_object* ddwaf_object_map(ddwaf_object *object);
441
-
442
- /**
443
- * ddwaf_object_array_add
444
- *
445
- * Inserts an object into an array object.
446
- *
447
- * @param array Array in which to insert the object. (nonnull)
448
- * @param object Object to insert into the array. (nonnull)
449
- *
450
- * @return The success or failure of the operation.
451
- **/
452
- bool ddwaf_object_array_add(ddwaf_object *array, ddwaf_object *object);
453
-
454
- /**
455
- * ddwaf_object_map_add
456
- *
457
- * Inserts an object into an map object, using a key.
458
- *
459
- * @param map Map in which to insert the object. (nonnull)
460
- * @param key The key for indexing purposes, this string will be copied and its
461
- * length will be calcualted using strlen(key). (nonnull)
462
- * @param object Object to insert into the array. (nonnull)
463
- *
464
- * @return The success or failure of the operation.
465
- **/
466
- bool ddwaf_object_map_add(ddwaf_object *map, const char *key, ddwaf_object *object);
467
-
468
- /**
469
- * ddwaf_object_map_addl
470
- *
471
- * Inserts an object into an map object, using a key and its length.
472
- *
473
- * @param map Map in which to insert the object. (nonnull)
474
- * @param key The key for indexing purposes, this string will be copied (nonnull)
475
- * @param length Length of the key.
476
- * @param object Object to insert into the array. (nonnull)
477
- *
478
- * @return The success or failure of the operation.
479
- **/
480
- bool ddwaf_object_map_addl(ddwaf_object *map, const char *key, size_t length, ddwaf_object *object);
481
-
482
- /**
483
- * ddwaf_object_map_addl_nc
484
- *
485
- * Inserts an object into an map object, using a key and its length, but without
486
- * creating a copy of the key.
487
- *
488
- * @param map Map in which to insert the object. (nonnull)
489
- * @param key The key for indexing purposes, this string will be copied (nonnull)
490
- * @param length Length of the key.
491
- * @param object Object to insert into the array. (nonnull)
492
- *
493
- * @return The success or failure of the operation.
494
- **/
495
- bool ddwaf_object_map_addl_nc(ddwaf_object *map, const char *key, size_t length, ddwaf_object *object);
496
-
497
- /**
498
- * ddwaf_object_type
499
- *
500
- * Returns the type of the object.
501
- *
502
- * @param object The object from which to get the type.
503
- *
504
- * @return The object type of DDWAF_OBJ_INVALID if NULL.
505
- **/
506
- DDWAF_OBJ_TYPE ddwaf_object_type(ddwaf_object *object);
507
-
508
- /**
509
- * ddwaf_object_size
510
- *
511
- * Returns the size of the container object.
512
- *
513
- * @param object The object from which to get the size.
514
- *
515
- * @return The object size or 0 if the object is not a container (array, map).
516
- **/
517
- size_t ddwaf_object_size(ddwaf_object *object);
518
-
519
- /**
520
- * ddwaf_object_length
521
- *
522
- * Returns the length of the string object.
523
- *
524
- * @param object The object from which to get the length.
525
- *
526
- * @return The string length or 0 if the object is not a string.
527
- **/
528
- size_t ddwaf_object_length(ddwaf_object *object);
529
-
530
- /**
531
- * ddwaf_object_get_key
532
- *
533
- * Returns the key contained within the object.
534
- *
535
- * @param object The object from which to get the key.
536
- * @param length Output parameter on which to return the length of the key,
537
- * this parameter is optional / nullable.
538
- *
539
- * @return The key of the object or NULL if the object doesn't contain a key.
540
- **/
541
- const char* ddwaf_object_get_key(ddwaf_object *object, size_t *length);
542
-
543
- /**
544
- * ddwaf_object_get_string
545
- *
546
- * Returns the string contained within the object.
547
- *
548
- * @param object The object from which to get the string.
549
- * @param length Output parameter on which to return the length of the string,
550
- * this parameter is optional / nullable.
551
- *
552
- * @return The string of the object or NULL if the object is not a string.
553
- **/
554
- const char* ddwaf_object_get_string(ddwaf_object *object, size_t *length);
555
-
556
- /**
557
- * ddwaf_object_get_unsigned
558
- *
559
- * Returns the uint64 contained within the object.
560
- *
561
- * @param object The object from which to get the integer.
562
- *
563
- * @return The integer or 0 if the object is not an unsigned.
564
- **/
565
- uint64_t ddwaf_object_get_unsigned(ddwaf_object *object);
566
-
567
- /**
568
- * ddwaf_object_get_signed
569
- *
570
- * Returns the int64 contained within the object.
571
- *
572
- * @param object The object from which to get the integer.
573
- *
574
- * @return The integer or 0 if the object is not a signed.
575
- **/
576
- int64_t ddwaf_object_get_signed(ddwaf_object *object);
577
-
578
- /**
579
- * ddwaf_object_get_index
580
- *
581
- * Returns the object contained in the container at the given index.
582
- *
583
- * @param object The container from which to extract the object.
584
- * @param index The position of the required object within the container.
585
- *
586
- * @return The requested object or NULL if the index is out of bounds or the
587
- * object is not a container.
588
- **/
589
- ddwaf_object* ddwaf_object_get_index(ddwaf_object *object, size_t index);
590
-
591
-
592
- /**
593
- * ddwaf_object_free
594
- *
595
- * @param object Object to free. (nonnull)
596
- **/
597
- void ddwaf_object_free(ddwaf_object *object);
598
-
599
- /**
600
- * ddwaf_get_version
601
- *
602
- * Return the version of the library
603
- *
604
- * @param version Version structure following semver
605
- **/
606
- void ddwaf_get_version(ddwaf_version *version);
607
-
608
- /**
609
- * ddwaf_set_log_cb
610
- *
611
- * Sets the callback to relay logging messages to the binding
612
- *
613
- * @param cb The callback to call, or NULL to stop relaying messages
614
- * @param min_level The minimum logging level for which to relay messages
615
- *
616
- * @return whether the operation succeeded or not
617
- **/
618
- bool ddwaf_set_log_cb(ddwaf_log_cb cb, DDWAF_LOG_LEVEL min_level);
619
-
620
- #ifdef __cplusplus
621
- }
622
- #endif /* __cplusplus */
623
-
624
- #endif /* pw_h */