Skip to content

Commit 5da8da6

Browse files
authored
(chore): upgrade libddwaf to v1.17 (#92)
JIRA: APPSEC-52726 ## Changes - The WAF result actions are now a mapping from action type to action parameters, instead of a slice of action IDs - Added `skip-smoke-tests` label for such API breaking changes where smoke-tests are expected to fail
1 parent 7df0fc1 commit 5da8da6

File tree

10 files changed

+16
-14
lines changed

10 files changed

+16
-14
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
name: Containerized
2121
uses: ./.github/workflows/_test_containerized.yml
2222
smoke-tests:
23+
if: "!contains(github.event.pull_request.labels.*.name, 'skip-smoke-tests')"
2324
name: Smoke Tests
2425
uses: DataDog/dd-trace-go/.github/workflows/smoke-tests.yml@main
2526
with:
@@ -37,10 +38,10 @@ jobs:
3738
if: '!cancelled()'
3839
steps:
3940
- name: Done
40-
if: needs.bare-metal.result == 'success' && needs.containerized.result == 'success' && needs.smoke-tests.result == 'success'
41+
if: needs.bare-metal.result == 'success' && needs.containerized.result == 'success' && (needs.smoke-tests.result == 'success' || needs.smoke-tests.result == 'skipped')
4142
run: echo "Done!"
4243
- name: Done
43-
if: needs.bare-metal.result != 'success' || needs.containerized.result != 'success' || needs.smoke-tests.result != 'success'
44+
if: needs.bare-metal.result != 'success' || needs.containerized.result != 'success' || (needs.smoke-tests.result != 'success' && needs.smoke-tests.result != 'skipped')
4445
run: |-
4546
echo "Failed!"
4647
exit 1

context.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,7 @@ func unwrapWafResult(ret bindings.WafReturnCode, result *bindings.WafResult) (re
276276
return res, err
277277
}
278278
if size := result.Actions.NbEntries; size > 0 {
279-
// using ruleIdArray cause it decodes string array (I think)
280-
res.Actions, err = decodeStringArray(&result.Actions)
281-
// TODO: use decode array, and eventually genericize the function
279+
res.Actions, err = decodeMap(&result.Actions)
282280
if err != nil {
283281
return res, err
284282
}

internal/lib/.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.16.1
1+
1.17.0
90.9 KB
Binary file not shown.
73.2 KB
Binary file not shown.

internal/lib/libddwaf-linux-amd64.so

84.1 KB
Binary file not shown.

internal/lib/libddwaf-linux-arm64.so

75.6 KB
Binary file not shown.

internal/log/ddwaf.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,9 @@ struct _ddwaf_result
162162
bool timeout;
163163
/** Array of events generated, this is guaranteed to be an array **/
164164
ddwaf_object events;
165-
/** Array of actions generated, this is guaranteed to be an array **/
165+
/** Map of actions generated, this is guaranteed to be a map in the format:
166+
* {action type: { <parameter map> }, ...}
167+
**/
166168
ddwaf_object actions;
167169
/** Map containing all derived objects in the format (address, value) **/
168170
ddwaf_object derivatives;

waf.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ type Result struct {
8888
Derivatives map[string]any
8989

9090
// Actions is the set of actions the WAF decided on when evaluating rules
91-
// against the provided address data.
92-
Actions []string
91+
// against the provided address data. It maps action types to their dynamic parameter values
92+
Actions map[string]any
9393

9494
// TimeSpent is the time the WAF self-reported as spent processing the call to ddwaf_run
9595
TimeSpent time.Duration

waf_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ func TestMatchingEphemeralOnly(t *testing.T) {
676676
}
677677

678678
func TestActions(t *testing.T) {
679-
testActions := func(expectedActions []string) func(t *testing.T) {
679+
testActions := func(expectedActions []string, expectedActionsTypes []string) func(t *testing.T) {
680680
return func(t *testing.T) {
681681

682682
waf, err := newDefaultHandle(newArachniTestRule([]ruleInput{{Address: "my.input"}}, expectedActions))
@@ -698,13 +698,14 @@ func TestActions(t *testing.T) {
698698
res, err := wafCtx.Run(RunAddressData{Persistent: values, Ephemeral: ephemeral}, time.Second)
699699
require.NoError(t, err)
700700
require.NotEmpty(t, res.Events)
701-
// FIXME: check with libddwaf why the order of returned actions is not kept the same
702-
require.ElementsMatch(t, expectedActions, res.Actions)
701+
for _, aType := range expectedActionsTypes {
702+
require.Contains(t, res.Actions, aType)
703+
}
703704
}
704705
}
705706

706-
t.Run("single", testActions([]string{"block"}))
707-
t.Run("multiple-actions", testActions([]string{"action 1", "action 2", "action 3"}))
707+
t.Run("single", testActions([]string{"block"}, []string{"block_request"}))
708+
t.Run("multiple-actions", testActions([]string{"block", "extract_schema"}, []string{"block_request", "generate_schema"}))
708709
}
709710

710711
func TestAddresses(t *testing.T) {

0 commit comments

Comments
 (0)