Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ebpf security e2e trigger #1843

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions test/engine/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ func ScenarioInitializer(ctx *godog.ScenarioContext) {
ctx.When(`^generate \{(\d+)\} delimiter logs to file \{(.*)\}, with interval \{(\d+)\}ms$`, trigger.DelimiterSingle)
ctx.When(`^query through \{(.*)\}`, control.SetQuery)
ctx.When(`^begin trigger`, trigger.BeginTrigger)
ctx.When(`^execute \{(\d+)\} commands to generate process security events`, trigger.TrigerProcessSecurityEvents)
ctx.When(`^execute \{(\d+)\} commands to generate network security events on url \{(.*)\}$`, trigger.TrigerNetworksSecurityEvents)
ctx.When(`^execute \{(\d+)\} commands to generate file security events on files \{(.*)\}$`, trigger.TrigerFileSecurityEvents)
ctx.When(`^generate random nginx logs to file, speed \{(\d+)\}MB/s, total \{(\d+)\}min, to file \{(.*)\}`, trigger.GenerateRandomNginxLogToFile)
ctx.When(`^start monitor \{(\S+)\}`, monitor.StartMonitor)
Expand Down
51 changes: 51 additions & 0 deletions test/engine/trigger/ebpf_trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,57 @@ import (
"github.com/alibaba/ilogtail/test/engine/setup"
)

/*
********************
input_process_security
********************
*/
func TrigerProcessSecurityEvents(ctx context.Context, commandCnt int) (context.Context, error) {
time.Sleep(5 * time.Second)
if err := execveCommands(ctx, commandCnt); err != nil {
return ctx, err
}
return ctx, nil
}

func execveCommands(ctx context.Context, commandCnt int) error {
execveCommand := "ps -ef | grep loongcollector-e2e-test"
for i := 0; i < commandCnt; i++ {
if err := setup.Env.ExecOnSource(ctx, execveCommand); err != nil {
return err
}
}
return nil
}

/*
********************
input_network_security
********************
*/
func TrigerNetworksSecurityEvents(ctx context.Context, commandCnt int, url string) (context.Context, error) {
time.Sleep(5 * time.Second)
if err := curlURL(ctx, commandCnt, url); err != nil {
return ctx, err
}
return ctx, nil
}

func curlURL(ctx context.Context, commandCnt int, url string) error {
curlCommand := "curl --connect-timeout 1 " + url + ";"
for i := 0; i < commandCnt; i++ {
if err := setup.Env.ExecOnSource(ctx, curlCommand); err != nil {
return err
}
}
return nil
}

/*
********************
input_file_security
********************
*/
const triggerFileSecurityTemplate = "cd {{.WorkDir}} && COMMAND_CNT={{.CommandCnt}} FILE_NAME={{.FileName}} {{.Command}}"

func TrigerFileSecurityEvents(ctx context.Context, commandCnt int, filenames string) (context.Context, error) {
Expand Down
Loading