Skip to content

Commit 8d3e778

Browse files
chore(aap): add ddwaf_builder_get_config_paths to waf interface (#13842)
- add ddwaf_builder_get_config_paths function to libbddwaf interface. - also add unit test. - update [libddwaf to 1.26.0](https://github.com/DataDog/libddwaf/releases/tag/1.26.0) to benefit from the related fix. ## Checklist - [x] PR author has checked that all the criteria below are met - The PR description includes an overview of the change - The PR description articulates the motivation for the change - The change includes tests OR the PR description describes a testing strategy - The PR description notes risks associated with the change, if any - Newly-added code is easy to change - The change follows the [library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) - The change includes or references documentation updates if necessary - Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [x] Reviewer has checked that all the criteria below are met - Title is accurate - All changes are related to the pull request's stated goal - Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - Testing strategy adequately addresses listed risks - Newly-added code is easy to change - Release note makes sense to a user of the library - If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment - Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
1 parent dae0e85 commit 8d3e778

File tree

28 files changed

+45
-26
lines changed

28 files changed

+45
-26
lines changed

ddtrace/appsec/_ddwaf/ddwaf_types.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,23 @@ def py_ddwaf_builder_build_instance(builder: ddwaf_builder_capsule) -> ddwaf_han
406406
return ddwaf_handle_capsule(ddwaf_builder_build_instance(builder.builder), ddwaf_destroy)
407407

408408

409+
ddwaf_builder_get_config_paths = ctypes.CFUNCTYPE(
410+
ctypes.c_uint32, ddwaf_builder, ddwaf_object_p, ctypes.c_char_p, ctypes.c_uint32
411+
)(
412+
("ddwaf_builder_get_config_paths", ddwaf),
413+
(
414+
(1, "builder"),
415+
(1, "paths"),
416+
(1, "filter"),
417+
(1, "filter_len"),
418+
),
419+
)
420+
421+
422+
def py_ddwaf_builder_get_config_paths(builder: ddwaf_builder_capsule, filter_str: str) -> int:
423+
return ddwaf_builder_get_config_paths(builder.builder, None, filter_str.encode(), len(filter_str))
424+
425+
409426
ddwaf_builder_destroy = ctypes.CFUNCTYPE(None, ddwaf_builder)(
410427
("ddwaf_builder_destroy", ddwaf),
411428
((1, "builder"),),

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181

8282
CURRENT_OS = platform.system()
8383

84-
LIBDDWAF_VERSION = "1.25.1"
84+
LIBDDWAF_VERSION = "1.26.0"
8585

8686
# DEV: update this accordingly when src/native upgrades libdatadog dependency.
8787
# libdatadog v15.0.0 requires rust 1.78.

tests/appsec/appsec/test_processor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from ddtrace.appsec._constants import FINGERPRINTING
1313
from ddtrace.appsec._constants import WAF_DATA_NAMES
1414
from ddtrace.appsec._ddwaf import DDWaf
15+
from ddtrace.appsec._ddwaf.ddwaf_types import py_ddwaf_builder_get_config_paths
1516
from ddtrace.appsec._processor import AppSecSpanProcessor
1617
from ddtrace.appsec._processor import _transform_headers
1718
from ddtrace.appsec._utils import get_triggers
@@ -261,6 +262,7 @@ def test_ip_update_rules_and_block(tracer):
261262
assert get_waf_addresses("http.request.remote_ip") == rules._IP.BLOCKED
262263
assert is_blocked(span1)
263264
assert (span._local_root or span).get_tag(APPSEC.RC_PRODUCTS) == "[ASM:1] u:1 r:2"
265+
assert py_ddwaf_builder_get_config_paths(tracer._appsec_processor._ddwaf._builder, "ASM/data") == 1
264266

265267

266268
def test_ip_update_rules_expired_no_block(tracer):

tests/snapshots/tests.appsec.appsec.test_processor.test_appsec_body_no_collection_snapshot.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"meta": {
1111
"_dd.appsec.event_rules.version": "1.14.2",
1212
"_dd.appsec.json": "{\"triggers\":[\n {\n \"rule\": {\n \"id\": \"nfd-000-006\",\n \"name\": \"Detect failed attempt to fetch sensitive files\",\n \"tags\": {\n \"capec\": \"1000/118/169\",\n \"category\": \"attack_attempt\",\n \"confidence\": \"1\",\n \"cwe\": \"200\",\n \"type\": \"security_scanner\"\n }\n },\n \"rule_matches\": [\n {\n \"operator\": \"match_regex\",\n \"operator_value\": \"^404$\",\n \"parameters\": [\n {\n \"address\": \"server.response.status\",\n \"highlight\": [\n \"404\"\n ],\n \"key_path\": [],\n \"value\": \"404\"\n }\n ]\n },\n {\n \"operator\": \"match_regex\",\n \"operator_value\": \"\\\\.(cgi|bat|dll|exe|key|cert|crt|pem|der|pkcs|pkcs|pkcs[0-9]*|nsf|jsa|war|java|class|vb|vba|so|git|svn|hg|cvs)([^a-zA-Z0-9_]|$)\",\n \"parameters\": [\n {\n \"address\": \"server.request.uri.raw\",\n \"highlight\": [\n \".git\"\n ],\n \"key_path\": [],\n \"value\": \"/.git\"\n }\n ]\n }\n ]\n }\n]}",
13-
"_dd.appsec.waf.version": "1.25.1",
13+
"_dd.appsec.waf.version": "1.26.0",
1414
"_dd.origin": "appsec",
1515
"_dd.p.dm": "-5",
1616
"_dd.p.ts": "02",

tests/snapshots/tests.appsec.appsec.test_processor.test_appsec_cookies_no_collection_snapshot.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"meta": {
1111
"_dd.appsec.event_rules.version": "1.14.2",
1212
"_dd.appsec.json": "{\"triggers\":[\n {\n \"rule\": {\n \"id\": \"nfd-000-006\",\n \"name\": \"Detect failed attempt to fetch sensitive files\",\n \"tags\": {\n \"capec\": \"1000/118/169\",\n \"category\": \"attack_attempt\",\n \"confidence\": \"1\",\n \"cwe\": \"200\",\n \"type\": \"security_scanner\"\n }\n },\n \"rule_matches\": [\n {\n \"operator\": \"match_regex\",\n \"operator_value\": \"^404$\",\n \"parameters\": [\n {\n \"address\": \"server.response.status\",\n \"highlight\": [\n \"404\"\n ],\n \"key_path\": [],\n \"value\": \"404\"\n }\n ]\n },\n {\n \"operator\": \"match_regex\",\n \"operator_value\": \"\\\\.(cgi|bat|dll|exe|key|cert|crt|pem|der|pkcs|pkcs|pkcs[0-9]*|nsf|jsa|war|java|class|vb|vba|so|git|svn|hg|cvs)([^a-zA-Z0-9_]|$)\",\n \"parameters\": [\n {\n \"address\": \"server.request.uri.raw\",\n \"highlight\": [\n \".git\"\n ],\n \"key_path\": [],\n \"value\": \"/.git\"\n }\n ]\n }\n ]\n }\n]}",
13-
"_dd.appsec.waf.version": "1.25.1",
13+
"_dd.appsec.waf.version": "1.26.0",
1414
"_dd.origin": "appsec",
1515
"_dd.p.dm": "-5",
1616
"_dd.p.ts": "02",

tests/snapshots/tests.appsec.appsec.test_processor.test_appsec_span_tags_snapshot.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"meta": {
1111
"_dd.appsec.event_rules.version": "1.14.2",
1212
"_dd.appsec.json": "{\"triggers\":[\n {\n \"rule\": {\n \"id\": \"nfd-000-006\",\n \"name\": \"Detect failed attempt to fetch sensitive files\",\n \"tags\": {\n \"capec\": \"1000/118/169\",\n \"category\": \"attack_attempt\",\n \"confidence\": \"1\",\n \"cwe\": \"200\",\n \"type\": \"security_scanner\"\n }\n },\n \"rule_matches\": [\n {\n \"operator\": \"match_regex\",\n \"operator_value\": \"^404$\",\n \"parameters\": [\n {\n \"address\": \"server.response.status\",\n \"highlight\": [\n \"404\"\n ],\n \"key_path\": [],\n \"value\": \"404\"\n }\n ]\n },\n {\n \"operator\": \"match_regex\",\n \"operator_value\": \"\\\\.(cgi|bat|dll|exe|key|cert|crt|pem|der|pkcs|pkcs|pkcs[0-9]*|nsf|jsa|war|java|class|vb|vba|so|git|svn|hg|cvs)([^a-zA-Z0-9_]|$)\",\n \"parameters\": [\n {\n \"address\": \"server.request.uri.raw\",\n \"highlight\": [\n \".git\"\n ],\n \"key_path\": [],\n \"value\": \"/.git\"\n }\n ]\n }\n ]\n }\n]}",
13-
"_dd.appsec.waf.version": "1.25.1",
13+
"_dd.appsec.waf.version": "1.26.0",
1414
"_dd.base_service": "tests.appsec.appsec",
1515
"_dd.origin": "appsec",
1616
"_dd.p.dm": "-5",

tests/snapshots/tests.appsec.appsec.test_processor.test_appsec_span_tags_snapshot_with_errors.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"meta": {
1111
"_dd.appsec.event_rules.errors": "{\"missing key 'conditions'\": [\"crs-913-110\"], \"missing key 'tags'\": [\"crs-942-100\"]}",
1212
"_dd.appsec.event_rules.version": "5.5.5",
13-
"_dd.appsec.waf.version": "1.25.1",
13+
"_dd.appsec.waf.version": "1.26.0",
1414
"_dd.base_service": "tests.appsec.appsec",
1515
"_dd.p.dm": "-0",
1616
"_dd.runtime_family": "python",

tests/snapshots/tests.contrib.django.test_django_appsec_snapshots.test_appsec_enabled.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"error": 0,
1111
"meta": {
1212
"_dd.appsec.event_rules.version": "1.14.2",
13-
"_dd.appsec.waf.version": "1.25.1",
13+
"_dd.appsec.waf.version": "1.26.0",
1414
"_dd.base_service": "",
1515
"_dd.p.dm": "-0",
1616
"_dd.p.tid": "654a694400000000",

tests/snapshots/tests.contrib.django.test_django_appsec_snapshots.test_appsec_enabled_attack.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"meta": {
1212
"_dd.appsec.event_rules.version": "1.14.2",
1313
"_dd.appsec.json": "{\"triggers\":[\n {\n \"rule\": {\n \"id\": \"nfd-000-006\",\n \"name\": \"Detect failed attempt to fetch sensitive files\",\n \"tags\": {\n \"capec\": \"1000/118/169\",\n \"category\": \"attack_attempt\",\n \"confidence\": \"1\",\n \"cwe\": \"200\",\n \"type\": \"security_scanner\"\n }\n },\n \"rule_matches\": [\n {\n \"operator\": \"match_regex\",\n \"operator_value\": \"^404$\",\n \"parameters\": [\n {\n \"address\": \"server.response.status\",\n \"highlight\": [\n \"404\"\n ],\n \"key_path\": [],\n \"value\": \"404\"\n }\n ]\n },\n {\n \"operator\": \"match_regex\",\n \"operator_value\": \"\\\\.(cgi|bat|dll|exe|key|cert|crt|pem|der|pkcs|pkcs|pkcs[0-9]*|nsf|jsa|war|java|class|vb|vba|so|git|svn|hg|cvs)([^a-zA-Z0-9_]|$)\",\n \"parameters\": [\n {\n \"address\": \"server.request.uri.raw\",\n \"highlight\": [\n \".git\"\n ],\n \"key_path\": [],\n \"value\": \"/.git\"\n }\n ]\n }\n ]\n }\n]}",
14-
"_dd.appsec.waf.version": "1.25.1",
14+
"_dd.appsec.waf.version": "1.26.0",
1515
"_dd.base_service": "",
1616
"_dd.origin": "appsec",
1717
"_dd.p.dm": "-5",

tests/snapshots/tests.contrib.django.test_django_appsec_snapshots.test_request_ipblock_match_403.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"meta": {
1212
"_dd.appsec.event_rules.version": "rules_good",
1313
"_dd.appsec.json": "{\"triggers\":[{\"rule\":{\"id\":\"blk-001-001\",\"name\":\"Block IP addresses\",\"on_match\":[\"block\"],\"tags\":{\"category\":\"blocking\",\"type\":\"ip_addresses\"}},\"rule_matches\":[{\"operator\":\"ip_match\",\"operator_value\":\"\",\"parameters\":[{\"address\":\"http.client_ip\",\"key_path\":[],\"value\":\"8.8.4.4\",\"highlight\":[\"8.8.4.4\"]}]}],\"span_id\":10192376353237234254}]}",
14-
"_dd.appsec.waf.version": "1.25.1",
14+
"_dd.appsec.waf.version": "1.26.0",
1515
"_dd.base_service": "",
1616
"_dd.origin": "appsec",
1717
"_dd.p.dm": "-5",

0 commit comments

Comments
 (0)