[v2] Update interface and expose allocators#427
Conversation
Benchmarks clangBenchmark execution time: 2025-07-09 17:32:06 Comparing candidate commit 4ff9ed3 in PR branch Found 0 performance improvements and 1 performance regressions! Performance is the same for 0 metrics, 0 unstable metrics. scenario:global-benchmark.random.clang
|
Benchmarks gccBenchmark execution time: 2025-07-09 17:33:30 Comparing candidate commit 4ff9ed3 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 0 unstable metrics. |
7381270 to
ac33899
Compare
Benchmarks clang-pgoBenchmark execution time: 2025-07-09 15:27:41 Comparing candidate commit c699c1d in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 0 unstable metrics. |
d2b10ed to
cfea1e5
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## anilm3/v2 #427 +/- ##
=============================================
- Coverage 85.53% 85.18% -0.36%
=============================================
Files 178 178
Lines 9179 9211 +32
Branches 3983 3991 +8
=============================================
- Hits 7851 7846 -5
- Misses 491 529 +38
+ Partials 837 836 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Artifact Size Comparison 📦
|
b5a7b69 to
906577d
Compare
f63853b to
01232e3
Compare
08f1bbe to
d4c4c4a
Compare
49b6371 to
f12d0a6
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR systematically updates the DDWAF interface to expose and propagate allocator usage across object creation, mutation, and destruction, and replaces legacy APIs with their allocator‐aware counterparts.
- Swapped
ddwaf_object_free(and map/array/string initializers) forddwaf_object_destroyandddwaf_object_set_*/ddwaf_object_insert_*calls requiring an allocator. - Updated all
ddwaf_context_initcalls to accept addwaf_allocatorpointer. - Changed all direct field accessors and legacy getters (e.g.,
.type,ddwaf_object_length) toddwaf_object_get_type,ddwaf_object_get_length, andddwaf_object_get_size.
Reviewed Changes
Copilot reviewed 59 out of 60 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| validator/utils.cpp | Refactored YAML→ddwaf_object conversion to use allocator APIs. |
| validator/runner.cpp | Updated context init and result object destruction with allocators. |
| tools/waf_runner.cpp | Replaced map initializers and free calls with allocator-backed APIs. |
| tools/verify_ruleset.cpp | Swapped ddwaf_object_free for ddwaf_object_destroy using allocator. |
| tools/verify_rule.cpp | Rewrote convertRuleToRuleset to build maps/arrays with allocators. |
| tools/ip_match_benchmark.cpp | Updated object creation/destruction calls to use default allocator. |
| tools/infer_schema_bench.cpp | Replaced free calls with allocator-based destroy. |
| tools/infer_schema.cpp | Migrated map/string initializers and getters to allocator APIs. |
| tools/common/utils.cpp | Mirrored YAML→ddwaf_object refactor in common utils. |
| tests/… | Updated all tests to use ddwaf_object_destroy, allocator-based setters, and new getters. |
Comments suppressed due to low confidence (1)
tools/verify_rule.cpp:20
- [nitpick] The local pointer
versionshadows the earlierddwaf_object versionvariable name. Consider renaming toversion_objorversion_keyfor clarity.
auto *version = ddwaf_object_insert_key(&root, STRL("version"), alloc);
f12d0a6 to
9f960b4
Compare
9f960b4 to
c699c1d
Compare
* Object view: read only abstraction to ddwaf_object (#341) * [v2] Remove mingw builds (#381) * Writable objects: owned and borrowed object and object limits removal (#378, #382) * [v2] Refactor and improve object types (#387) * [v2] Update unit tests to use new abstractions (#389) * [v2] Update `raw_configuration` type to use `object_view` (#390) * [v2] Remove remaining uses of ddwaf_object in `src` and `tests/unit` (#391) * [v2] JWT Decoding Processor (#401) * [v2] First iteration of object layout changes (#394) * Split context data insertion from evaluation (#407) * [v2] Second iteration of object layout changes (#408) * [v2] Add new fingerprint and object view tests (#414) * Reenable attribute collector unit test (#415) * [v2] Container view types (#413) * Exclude assertions from coverage (#416) * [v2] Use allocators internally instead of malloc/free and stop generating zero-terminated strings (#418) * Add memory resource to owned and borrowed objects (#428) * [v2] Propagate allocators from context (#420) * [v2] Update interface and expose allocators (#427) * Refactor evaluation stages out of the context (#442) * Subcontext: replace ephemerals with a new scope with user-defined lifetime derived from the context (#443) * Validator: Add support for testing subcontexts and attributes (#451) * [v2] Pass allocator to context and subcontext eval and add new allocators (#452) * Update logger to avoid dependencies on ddwaf.h (#453) * [v2] Return DDWAF_MATCH when there are events, attributes or actions (#455) * [v2] Cleanup: remove exclusion namespace and some redundant references (#456)
This PR introduces the new object interface with the following changes:
ddwaf_object_set_*to make their purpose clear.ddwaf_get_default_allocator(). User and internal allocators will be provided in the next PR.ddwaf_object_is_*functions have been introduced to better assert for types.Remaining work (Next PRs):
Update objects to use allocators more effectively.Check for allocator compatibility where relevant.Propagate allocator from the context.Have a clear distinction between input , output and internal allocators.Removefrom_mutable_bufferuse case oncow_stringUpdate interface:
Pass input / ouput allocators tocontext_init/context_eval.Pass allocators to memory-allocatingddwaf_objectfunctions.