Skip to content

Commit

Permalink
new(pkg,tests): alllow to pass Falco config path as argument.
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Di Pierro <[email protected]>
  • Loading branch information
FedeDP authored and poiana committed Feb 15, 2024
1 parent ae3950a commit b162291
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 158 deletions.
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

0 comments on commit b162291

Please sign in to comment.