|
| 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() {} |
0 commit comments