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

new(pkg,tests): allow to pass Falco config path as argument. #40

Merged
merged 1 commit into from
Feb 15, 2024
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
6 changes: 5 additions & 1 deletion pkg/falco/tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var (
"/proc:/host/proc:ro",
"/var/run/docker.sock:/host/var/run/docker.sock",
}
FalcoConfig = DefaultConfigFile
)

const (
Expand All @@ -44,7 +45,7 @@ const (
// DefaultExecutable is the default path of the Falco executable
DefaultExecutable = "/usr/bin/falco"
//
// DefaultConfig is the default path of the Falco config file
// DefaultConfigFile is the default path of the Falco config file
DefaultConfigFile = "/etc/falco/falco.yaml"
)

Expand Down Expand Up @@ -84,6 +85,9 @@ func Test(runner run.Runner, options ...TestOption) *TestOutput {
return res
}

// enforce Falco config path
res.opts.args = append(res.opts.args, "-c", FalcoConfig)

// enforce logging everything on stdout
res.opts.args = append(res.opts.args, "-o", "log_level=debug")
res.opts.args = append(res.opts.args, "-o", "log_stderr=true")
Expand Down
10 changes: 5 additions & 5 deletions tests/falco/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const (

func TestFalco_Cmd_Version(t *testing.T) {
t.Parallel()
checkDefaultConfig(t)
checkConfig(t)
runner := tests.NewFalcoExecutableRunner(t)
t.Run("text-output", func(t *testing.T) {
t.Parallel()
Expand Down Expand Up @@ -105,7 +105,7 @@ func TestFalco_Cmd_Version(t *testing.T) {

func TestFalco_Cmd_ListPlugins(t *testing.T) {
t.Parallel()
checkDefaultConfig(t)
checkConfig(t)
checkNotStaticExecutable(t)
res := falco.Test(
tests.NewFalcoExecutableRunner(t),
Expand Down Expand Up @@ -136,7 +136,7 @@ func TestFalco_Cmd_ListPlugins(t *testing.T) {

func TestFalco_Cmd_PluginInfo(t *testing.T) {
t.Parallel()
checkDefaultConfig(t)
checkConfig(t)
checkNotStaticExecutable(t)
res := falco.Test(
tests.NewFalcoExecutableRunner(t),
Expand All @@ -160,7 +160,7 @@ func TestFalco_Cmd_PluginInfo(t *testing.T) {

func TestFalco_Print_IgnoredEvents(t *testing.T) {
t.Parallel()
checkDefaultConfig(t)
checkConfig(t)
bytearr, err := outputs.EventData.Content()
if err != nil {
panic(err)
Expand All @@ -181,7 +181,7 @@ func TestFalco_Print_IgnoredEvents(t *testing.T) {

func TestFalco_Print_Rules(t *testing.T) {
t.Parallel()
checkDefaultConfig(t)
checkConfig(t)
runner := tests.NewFalcoExecutableRunner(t)

t.Run("invalid-rules", func(t *testing.T) {
Expand Down
Loading
Loading