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

Test For command falco -i (ignore default events) #8

Merged
merged 8 commits into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from 7 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
4 changes: 2 additions & 2 deletions pkg/run/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ func WithArgs(args ...string) RunnerOption {
return func(ro *runOpts) { ro.args = append(ro.args, args...) }
}

// WithArgs is an option for running Falco by writing stdout on a given writer
// WithStdout is an option for running Falco by writing stdout on a given writer
func WithStdout(writer io.Writer) RunnerOption {
return func(ro *runOpts) { ro.stdout = writer }
}

// WithArgs is an option for running Falco by writing stderr on a given writer
// WithStderr is an option for running Falco by writing stderr on a given writer
func WithStderr(writer io.Writer) RunnerOption {
return func(ro *runOpts) { ro.stderr = writer }
}
Expand Down
11 changes: 11 additions & 0 deletions tests/data/outputs/event.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package outputs

import (
_ "embed"

"github.com/falcosecurity/testing/pkg/run"
)

//go:embed events.txt
var s string
var EventData = run.NewStringFileAccessor("eventData", s)
1 change: 1 addition & 0 deletions tests/data/outputs/events.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sendfile,recvfrom,readv,sendto,send,read,recvmmsg,write,recvmsg,pwrite,sendmmsg,sendmsg,pread,writev,recv,pwritev,prea
Rohith-Raju marked this conversation as resolved.
Show resolved Hide resolved
23 changes: 23 additions & 0 deletions tests/falco/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ package testfalco

import (
"regexp"
"strings"
"testing"

"github.com/falcosecurity/testing/pkg/falco"
"github.com/falcosecurity/testing/tests"
"github.com/falcosecurity/testing/tests/data/outputs"

"github.com/stretchr/testify/assert"
)
Expand Down Expand Up @@ -132,3 +134,24 @@ func TestFalco_Cmd_PluginInfo(t *testing.T) {
`No suggested open params available.*`),
res.Stdout())
}

func TestFalco_Print_IgnoredEvents(t *testing.T) {
t.Parallel()
checkDefaultConfig(t)
bytearr, err := outputs.EventData.Content()
if err != nil {
panic(err)
}
events := strings.Split(string(bytearr), ",")
runner := tests.NewFalcoExecutableRunner(t)
res := falco.Test(
runner,
falco.WithArgs("-i"),
)
assert.Contains(t, res.Stdout(), "Ignored I/O syscall(s)")
for _, event := range events {
assert.Contains(t, res.Stdout(), event)
}
assert.NoError(t, res.Err(), "%s", res.Stderr())
assert.Equal(t, res.ExitCode(), 0)
}