Skip to content

libddwaf update 1.24.1 - #159

Merged
sezen-datadog merged 13 commits into
masterfrom
sezen.leblay/APPSEC-55502-libddwaf-update-1.23.0
May 20, 2025
Merged

libddwaf update 1.24.1#159
sezen-datadog merged 13 commits into
masterfrom
sezen.leblay/APPSEC-55502-libddwaf-update-1.23.0

Conversation

@sezen-datadog

@sezen-datadogsezen-datadog commented Feb 24, 2025

Copy link
Copy Markdown
Contributor

This commit provides the new WafBuilder class for libddwaf configuration manipulations. This new class holds a pointer to the c object ddwaf_builder and the operations are handled in waf_jni.c via the new binding of NativeWafhandle (ddwaf_handle)

RuleSetInfo is also modified with the new field, error and updated to contain all possible fields

Waf.run is eliminated as it is deprecated for a while now

@sezen-datadog
sezen-datadogforce-pushed the sezen.leblay/APPSEC-55502-libddwaf-update-1.23.0 branch from 12afcd8 to 64c099eCompareFebruary 24, 2025 10:00
Comment threadsrc/main/c/powerwaf_jni.c Outdated
@sezen-datadog
sezen-datadogforce-pushed the sezen.leblay/APPSEC-55502-libddwaf-update-1.23.0 branch 4 times, most recently from 6a83170 to 007bd4dCompareMarch 3, 2025 10:22
@sezen-datadog
sezen-datadogforce-pushed the sezen.leblay/APPSEC-55502-libddwaf-update-1.23.0 branch 5 times, most recently from 6709b88 to 4279333CompareMarch 10, 2025 09:12
@sezen-datadog
sezen-datadogforce-pushed the sezen.leblay/APPSEC-55502-libddwaf-update-1.23.0 branch 5 times, most recently from 162b628 to 430f81cCompareMarch 17, 2025 10:58
@sezen-datadog
sezen-datadogforce-pushed the sezen.leblay/APPSEC-55502-libddwaf-update-1.23.0 branch from 815d2d6 to fe106a4CompareMarch 17, 2025 13:59
@codecov-commenter

codecov-commenter commented Mar 18, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 76.71233% with 68 lines in your changes missing coverage. Please review.

Project coverage is 55.96%. Comparing base (47c2db6) to head (7642f64).
Report is 57 commits behind head on master.

Files with missing linesPatch %Lines
src/main/c/waf_jni.c64.94%21 Missing and 13 partials ⚠️
src/main/c/output.c52.94%8 Missing and 8 partials ⚠️
...rc/main/java/com/datadog/ddwaf/WafDiagnostics.java88.46%5 Missing and 7 partials ⚠️
src/main/java/com/datadog/ddwaf/WafBuilder.java89.28%1 Missing and 2 partials ⚠️
src/main/java/com/datadog/ddwaf/WafHandle.java83.33%1 Missing and 2 partials ⚠️
Additional details and impacted files
@@ Coverage Diff @@## master #159 +/- ##
============================================
- Coverage 58.55% 55.96% -2.60% - Complexity 134 167 +33 
============================================
Files 34 34 Lines 3458 3479 +21 Branches 780 782 +2 ============================================
- Hits 2025 1947 -78 - Misses 900 993 +93 - Partials 533 539 +6 
FlagCoverage Δ
helper55.96% <76.71%> (-2.60%)⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sezen-datadog
sezen-datadogforce-pushed the sezen.leblay/APPSEC-55502-libddwaf-update-1.23.0 branch 2 times, most recently from f682a5e to 0599dceCompareMarch 28, 2025 15:43
@sezen-datadog
sezen-datadog marked this pull request as ready for review April 1, 2025 13:26
@sezen-datadog
sezen-datadog requested a review from a team as a code ownerApril 1, 2025 13:27
@sezen-datadog
sezen-datadogforce-pushed the sezen.leblay/APPSEC-55502-libddwaf-update-1.23.0 branch 2 times, most recently from a9fc49c to d512f46CompareApril 2, 2025 15:34
@sezen-datadog
sezen-datadog marked this pull request as draft April 2, 2025 15:43
@sezen-datadog
sezen-datadogforce-pushed the sezen.leblay/APPSEC-55502-libddwaf-update-1.23.0 branch from 80f403e to b2512f4CompareApril 3, 2025 08:29
@sezen-datadog
sezen-datadog marked this pull request as ready for review April 3, 2025 09:12
Comment threadsrc/main/c/waf_jni.c Outdated
Comment threadsrc/main/c/waf_jni.c Outdated
Comment threadsrc/main/c/waf_jni.c Outdated
Comment threadsrc/main/c/waf_jni.c Outdated
@smola
smola requested a review from CopilotApril 30, 2025 12:55

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates libddwaf to version 1.24.1 by introducing a new WafBuilder class for managing configuration, updating exception handling by replacing RuleSetInfo with WafDiagnostics, and removing the deprecated Waf.run method. It also updates various JNI bindings, logging, and benchmark usage to reflect these changes.

  • Introduces WafBuilder with new native bindings and config update methods.
  • Updates exception handling and configuration (regex visibility) while removing legacy classes.
  • Adjusts JNI and benchmark usage and updates version numbers in build workflow.

Reviewed Changes

Copilot reviewed 35 out of 38 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
src/main/java/com/datadog/ddwaf/exception/InvalidRuleSetException.javaUpdated exception to use WafDiagnostics instead of RuleSetInfo.
src/main/java/com/datadog/ddwaf/WafMetrics.javaChanged constructor visibility from package-private to public.
src/main/java/com/datadog/ddwaf/WafHandle.javaRevised handle creation, native handle management, and closing logic.
src/main/java/com/datadog/ddwaf/WafConfig.javaMade DEFAULT_KEY_REGEX and DEFAULT_VALUE_REGEX public for external access.
src/main/java/com/datadog/ddwaf/WafBuilder.javaIntroduced new builder to add/update configurations and build a new WafHandle.
src/main/java/com/datadog/ddwaf/Waf.javaUpdated library version and removed deprecated methods.
Removed FilesRemoved RuleSetInfo.java and NativeWafHandle.java as part of the update.
src/main/c/*.c & JNI headersUpdated native signatures and JNI bindings to match Java changes.
src/jmh/java/com/datadog/ddwaf/WafHandleRunRulesBenchmark.javaUpdated benchmark to use the new WafContext run method.
.github/workflows/actions.ymlUpdated build configuration with the new libddwafVersion.
Files not reviewed (3)
  • libddwaf: Language not supported
  • src/test/groovy/com/datadog/ddwaf/BadRuleTests.groovy: Language not supported
  • src/test/groovy/com/datadog/ddwaf/BasicTests.groovy: Language not supported
Comments suppressed due to low confidence (4)

src/main/java/com/datadog/ddwaf/exception/InvalidRuleSetException.java:16

  • Ensure all callers of InvalidRuleSetException are updated to use the new WafDiagnostics-based constructors, and update the related documentation to explain the change in error reporting.
public InvalidRuleSetException(WafDiagnostics wafDiagnostics, String message) {

src/main/java/com/datadog/ddwaf/WafMetrics.java:21

  • The constructor visibility has been changed to public; please confirm that this change exposes only intended behaviors and is adequately covered by tests.
public WafMetrics() {

src/main/java/com/datadog/ddwaf/WafConfig.java:12

  • Changing the regex constants to public exposes internal patterns; please verify that this design decision aligns with the intended public API and that any security considerations are addressed.
public final static String DEFAULT_KEY_REGEX =

.github/workflows/actions.yml:14

  • Ensure that the updated libddwafVersion in the build configuration is consistent with all other version settings across the project to avoid potential build discrepancies.
libddwafVersion: 1.24.1

Comment threadsrc/main/java/com/datadog/ddwaf/WafHandle.java Outdated
Comment threadsrc/main/java/com/datadog/ddwaf/WafBuilder.java Outdated
@sezen-datadog
sezen-datadogforce-pushed the sezen.leblay/APPSEC-55502-libddwaf-update-1.23.0 branch from 1f7aa73 to b265ea6CompareMay 2, 2025 08:07
@smola
smola self-requested a review May 12, 2025 10:26
Comment threadsrc/main/c/waf_jni.c Outdated
Comment threadsrc/main/c/waf_jni.c Outdated
Comment threadsrc/main/c/waf_jni.c Outdated
@smola
smolaforce-pushed the sezen.leblay/APPSEC-55502-libddwaf-update-1.23.0 branch from da7711f to eca759bCompareMay 13, 2025 08:27
@datadog-datadog-prod-us1

datadog-datadog-prod-us1Bot commented May 13, 2025

Copy link
Copy Markdown

Datadog Summary

✅ Code Quality✅ Code Security✅ Dependencies


Was this helpful? Give us feedback!

Comment threadsrc/main/c/waf_jni.c Outdated
Comment threadsrc/main/c/waf_jni.c Outdated
@sezen-datadog
sezen-datadog merged commit b07a8c7 into masterMay 20, 2025
@sezen-datadog
sezen-datadog deleted the sezen.leblay/APPSEC-55502-libddwaf-update-1.23.0 branch May 20, 2025 16:11
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancementNew feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@sezen-datadog@codecov-commenter@cataphract@smola@manuel-alvarez-alvarez