Skip to content

Commit 5aa8d36

Browse files
committed
fixup! fixup! feat(tests): add io_uring tests
1 parent f00283e commit 5aa8d36

6 files changed

Lines changed: 76 additions & 65 deletions

File tree

.github/workflows/pr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ env:
6666
BPF_ATTACH
6767
CONTAINERS_DATA_SOURCE
6868
PROCTREE_DATA_SOURCE
69-
IO_URING_SUBMIT_REQ
69+
IO_ISSUE_SQE
7070
IO_WRITE
7171
jobs:
7272
#
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/docker/docker/pkg/parsers/kernel"
7+
8+
"github.com/aquasecurity/tracee/types/detect"
9+
"github.com/aquasecurity/tracee/types/protocol"
10+
"github.com/aquasecurity/tracee/types/trace"
11+
)
12+
13+
type e2eIoIssueSqe struct {
14+
cb detect.SignatureHandler
15+
}
16+
17+
func (sig *e2eIoIssueSqe) Init(ctx detect.SignatureContext) error {
18+
sig.cb = ctx.Callback
19+
return nil
20+
}
21+
22+
func (sig *e2eIoIssueSqe) GetMetadata() (detect.SignatureMetadata, error) {
23+
return detect.SignatureMetadata{
24+
ID: "IO_ISSUE_SQE",
25+
EventName: "IO_ISSUE_SQE",
26+
Version: "0.1.0",
27+
Name: "io_uring issue request Test",
28+
Description: "Instrumentation events E2E Tests: io_uring issue request",
29+
Tags: []string{"e2e", "instrumentation"},
30+
}, nil
31+
}
32+
33+
func (sig *e2eIoIssueSqe) GetSelectedEvents() ([]detect.SignatureEventSelector, error) {
34+
return []detect.SignatureEventSelector{
35+
{Source: "tracee", Name: "io_issue_sqe"},
36+
}, nil
37+
}
38+
39+
func (sig *e2eIoIssueSqe) OnEvent(event protocol.Event) error {
40+
eventObj, ok := event.Payload.(trace.Event)
41+
if !ok {
42+
return fmt.Errorf("failed to cast event's payload")
43+
}
44+
45+
m, _ := sig.GetMetadata()
46+
47+
// currently only supported for kernels >= v5.5
48+
if !kernel.CheckKernelVersion(5, 5, 0) {
49+
sig.cb(detect.Finding{
50+
SigMetadata: m,
51+
Event: event,
52+
Data: map[string]interface{}{},
53+
})
54+
return nil
55+
}
56+
57+
switch eventObj.EventName {
58+
case "io_issue_sqe":
59+
sig.cb(detect.Finding{
60+
SigMetadata: m,
61+
Event: event,
62+
Data: map[string]interface{}{},
63+
})
64+
}
65+
66+
return nil
67+
}
68+
69+
func (sig *e2eIoIssueSqe) OnSignal(s detect.Signal) error {
70+
return nil
71+
}
72+
73+
func (sig *e2eIoIssueSqe) Close() {}

tests/e2e-inst-signatures/e2e-io_uring_submit_req.go

Lines changed: 0 additions & 62 deletions
This file was deleted.

tests/e2e-inst-signatures/export.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ var ExportedSignatures = []detect.Signature{
1111
&e2eBpfAttach{},
1212
&e2eProcessTreeDataSource{},
1313
&e2eHookedSyscall{},
14-
&e2eIoUringSumitReq{},
14+
&e2eIoIssueSqe{},
1515
&e2eIoWrite{},
1616
}
File renamed without changes.

tests/e2e-inst-signatures/scripts/io_write.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ exit_err() {
1010
prog=io_uring_writev
1111
dir=tests/e2e-inst-signatures/scripts
1212
# compile prog
13-
# no compilation needed as it was done in io_uring_submit_req.sh
13+
# no compilation needed as it was done in io_issue_sqe.sh
1414
# run test
1515
./$dir/$prog || exit_err "could not run $prog"

0 commit comments

Comments
 (0)