From 5bd3710559efff872b34c7662ce18fe0253552f5 Mon Sep 17 00:00:00 2001 From: zackattack01 Date: Mon, 23 Dec 2024 11:24:25 -0500 Subject: [PATCH 1/4] rename testOsqueryBinary variable for clarity, fix extension for windows, and fix binary cleanup by removing defer --- pkg/osquery/runtime/osqueryinstance_test.go | 8 ++-- .../runtime/osqueryinstance_windows_test.go | 2 +- pkg/osquery/runtime/runtime_test.go | 37 +++++++++++-------- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/pkg/osquery/runtime/osqueryinstance_test.go b/pkg/osquery/runtime/osqueryinstance_test.go index 1a6a98478..dd8760ae0 100644 --- a/pkg/osquery/runtime/osqueryinstance_test.go +++ b/pkg/osquery/runtime/osqueryinstance_test.go @@ -50,7 +50,7 @@ func TestCreateOsqueryCommand(t *testing.T) { extensionAutoloadPath: "/foo/bar/osquery.autoload", } - osquerydPath := testOsqueryBinaryDirectory + osquerydPath := testOsqueryBinaryPath k := typesMocks.NewKnapsack(t) k.On("WatchdogEnabled").Return(true) @@ -86,7 +86,7 @@ func TestCreateOsqueryCommandWithFlags(t *testing.T) { i := newInstance(types.DefaultRegistrationID, k, mockServiceClient()) cmd, err := i.createOsquerydCommand( - testOsqueryBinaryDirectory, + testOsqueryBinaryPath, &osqueryFilePaths{}, ) require.NoError(t, err) @@ -120,7 +120,7 @@ func TestCreateOsqueryCommand_SetsEnabledWatchdogSettingsAppropriately(t *testin i := newInstance(types.DefaultRegistrationID, k, mockServiceClient()) cmd, err := i.createOsquerydCommand( - testOsqueryBinaryDirectory, + testOsqueryBinaryPath, &osqueryFilePaths{}, ) require.NoError(t, err) @@ -170,7 +170,7 @@ func TestCreateOsqueryCommand_SetsDisabledWatchdogSettingsAppropriately(t *testi i := newInstance(types.DefaultRegistrationID, k, mockServiceClient()) cmd, err := i.createOsquerydCommand( - testOsqueryBinaryDirectory, + testOsqueryBinaryPath, &osqueryFilePaths{}, ) require.NoError(t, err) diff --git a/pkg/osquery/runtime/osqueryinstance_windows_test.go b/pkg/osquery/runtime/osqueryinstance_windows_test.go index d97f00a62..ee641b5ee 100644 --- a/pkg/osquery/runtime/osqueryinstance_windows_test.go +++ b/pkg/osquery/runtime/osqueryinstance_windows_test.go @@ -16,7 +16,7 @@ import ( func TestCreateOsqueryCommandEnvVars(t *testing.T) { t.Parallel() - osquerydPath := testOsqueryBinaryDirectory + osquerydPath := testOsqueryBinaryPath k := typesMocks.NewKnapsack(t) k.On("WatchdogEnabled").Return(true) diff --git a/pkg/osquery/runtime/runtime_test.go b/pkg/osquery/runtime/runtime_test.go index 498cb22c3..7e48d75aa 100644 --- a/pkg/osquery/runtime/runtime_test.go +++ b/pkg/osquery/runtime/runtime_test.go @@ -40,7 +40,7 @@ import ( "github.com/stretchr/testify/require" ) -var testOsqueryBinaryDirectory string +var testOsqueryBinaryPath string // TestMain overrides the default test main function. This allows us to share setup/teardown. func TestMain(m *testing.M) { @@ -54,30 +54,37 @@ func TestMain(m *testing.M) { fmt.Println("Failed to make temp dir for test binaries") os.Exit(1) //nolint:forbidigo // Fine to use os.Exit in tests } - defer os.Remove(binDirectory) s, err := storageci.NewStore(nil, multislogger.NewNopLogger(), storage.OsqueryHistoryInstanceStore.String()) if err != nil { fmt.Println("Failed to make new store") - os.Exit(1) //nolint:forbidigo // Fine to use os.Exit in tests + os.Remove(binDirectory) // explicit removal as defer will not run when os.Exit is called + os.Exit(1) //nolint:forbidigo // Fine to use os.Exit in tests } if err := history.InitHistory(s); err != nil { fmt.Println("Failed to init history") - os.Exit(1) //nolint:forbidigo // Fine to use os.Exit in tests + os.Remove(binDirectory) // explicit removal as defer will not run when os.Exit is called + os.Exit(1) //nolint:forbidigo // Fine to use os.Exit in tests } - testOsqueryBinaryDirectory = filepath.Join(binDirectory, "osqueryd") + testOsqueryBinaryPath = filepath.Join(binDirectory, "osqueryd") + if runtime.GOOS == "windows" { + testOsqueryBinaryPath += ".exe" + } thrift.ServerConnectivityCheckInterval = 100 * time.Millisecond if err := downloadOsqueryInBinDir(binDirectory); err != nil { fmt.Printf("Failed to download osquery: %v\n", err) - os.Exit(1) //nolint:forbidigo // Fine to use os.Exit in tests + os.Remove(binDirectory) // explicit removal as defer will not run when os.Exit is called + os.Exit(1) //nolint:forbidigo // Fine to use os.Exit in tests } // Run the tests! retCode := m.Run() - os.Exit(retCode) //nolint:forbidigo // Fine to use os.Exit in tests + + os.Remove(binDirectory) // explicit removal as defer will not run when os.Exit is called + os.Exit(retCode) //nolint:forbidigo // Fine to use os.Exit in tests } // downloadOsqueryInBinDir downloads osqueryd. This allows the test @@ -163,7 +170,7 @@ func TestWithOsqueryFlags(t *testing.T) { k.On("WatchdogEnabled").Return(false) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) k.On("Slogger").Return(slogger) - k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryDirectory) + k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath) k.On("RootDirectory").Return(rootDirectory).Maybe() k.On("OsqueryFlags").Return([]string{"verbose=false"}) k.On("OsqueryVerbose").Return(false) @@ -197,7 +204,7 @@ func TestFlagsChanged(t *testing.T) { k.On("WatchdogDelaySec").Return(120) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) k.On("Slogger").Return(slogger) - k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryDirectory) + k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath) k.On("RootDirectory").Return(rootDirectory).Maybe() k.On("OsqueryFlags").Return([]string{"verbose=false"}) k.On("OsqueryVerbose").Return(false) @@ -328,7 +335,7 @@ func TestSimplePath(t *testing.T) { k.On("WatchdogEnabled").Return(false) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) k.On("Slogger").Return(slogger) - k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryDirectory) + k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath) k.On("RootDirectory").Return(rootDirectory).Maybe() k.On("OsqueryFlags").Return([]string{}) k.On("OsqueryVerbose").Return(true) @@ -364,7 +371,7 @@ func TestMultipleInstances(t *testing.T) { k.On("WatchdogEnabled").Return(false) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) k.On("Slogger").Return(slogger) - k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryDirectory) + k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath) k.On("RootDirectory").Return(rootDirectory).Maybe() k.On("OsqueryFlags").Return([]string{}) k.On("OsqueryVerbose").Return(true) @@ -423,7 +430,7 @@ func TestRunnerHandlesImmediateShutdownWithMultipleInstances(t *testing.T) { k.On("WatchdogEnabled").Return(false) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) k.On("Slogger").Return(slogger) - k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryDirectory) + k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath) k.On("RootDirectory").Return(rootDirectory).Maybe() k.On("OsqueryFlags").Return([]string{}) k.On("OsqueryVerbose").Return(true) @@ -474,7 +481,7 @@ func TestMultipleShutdowns(t *testing.T) { k.On("WatchdogEnabled").Return(false) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) k.On("Slogger").Return(slogger) - k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryDirectory) + k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath) k.On("RootDirectory").Return(rootDirectory).Maybe() k.On("OsqueryFlags").Return([]string{}) k.On("OsqueryVerbose").Return(true) @@ -506,7 +513,7 @@ func TestOsqueryDies(t *testing.T) { k.On("WatchdogEnabled").Return(false) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) k.On("Slogger").Return(slogger) - k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryDirectory) + k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath) k.On("RootDirectory").Return(rootDirectory) k.On("OsqueryFlags").Return([]string{}) k.On("OsqueryVerbose").Return(true) @@ -608,7 +615,7 @@ func setupOsqueryInstanceForTests(t *testing.T) (runner *Runner, logBytes *threa k.On("WatchdogDelaySec").Return(120) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Maybe() k.On("Slogger").Return(slogger) - k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryDirectory) + k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath) k.On("RootDirectory").Return(rootDirectory).Maybe() k.On("OsqueryFlags").Return([]string{}).Maybe() k.On("OsqueryVerbose").Return(true).Maybe() From 9f6e0cff370eacc6447111ccc099364bebddd5ee Mon Sep 17 00:00:00 2001 From: zackattack01 Date: Mon, 23 Dec 2024 11:46:18 -0500 Subject: [PATCH 2/4] rename global var to match agent reset test pattern --- pkg/osquery/runtime/osqueryinstance_test.go | 8 +++---- .../runtime/osqueryinstance_windows_test.go | 2 +- pkg/osquery/runtime/runtime_test.go | 22 +++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pkg/osquery/runtime/osqueryinstance_test.go b/pkg/osquery/runtime/osqueryinstance_test.go index dd8760ae0..0eaf27f7e 100644 --- a/pkg/osquery/runtime/osqueryinstance_test.go +++ b/pkg/osquery/runtime/osqueryinstance_test.go @@ -50,7 +50,7 @@ func TestCreateOsqueryCommand(t *testing.T) { extensionAutoloadPath: "/foo/bar/osquery.autoload", } - osquerydPath := testOsqueryBinaryPath + osquerydPath := testOsqueryBinary k := typesMocks.NewKnapsack(t) k.On("WatchdogEnabled").Return(true) @@ -86,7 +86,7 @@ func TestCreateOsqueryCommandWithFlags(t *testing.T) { i := newInstance(types.DefaultRegistrationID, k, mockServiceClient()) cmd, err := i.createOsquerydCommand( - testOsqueryBinaryPath, + testOsqueryBinary, &osqueryFilePaths{}, ) require.NoError(t, err) @@ -120,7 +120,7 @@ func TestCreateOsqueryCommand_SetsEnabledWatchdogSettingsAppropriately(t *testin i := newInstance(types.DefaultRegistrationID, k, mockServiceClient()) cmd, err := i.createOsquerydCommand( - testOsqueryBinaryPath, + testOsqueryBinary, &osqueryFilePaths{}, ) require.NoError(t, err) @@ -170,7 +170,7 @@ func TestCreateOsqueryCommand_SetsDisabledWatchdogSettingsAppropriately(t *testi i := newInstance(types.DefaultRegistrationID, k, mockServiceClient()) cmd, err := i.createOsquerydCommand( - testOsqueryBinaryPath, + testOsqueryBinary, &osqueryFilePaths{}, ) require.NoError(t, err) diff --git a/pkg/osquery/runtime/osqueryinstance_windows_test.go b/pkg/osquery/runtime/osqueryinstance_windows_test.go index ee641b5ee..d59d6582f 100644 --- a/pkg/osquery/runtime/osqueryinstance_windows_test.go +++ b/pkg/osquery/runtime/osqueryinstance_windows_test.go @@ -16,7 +16,7 @@ import ( func TestCreateOsqueryCommandEnvVars(t *testing.T) { t.Parallel() - osquerydPath := testOsqueryBinaryPath + osquerydPath := testOsqueryBinary k := typesMocks.NewKnapsack(t) k.On("WatchdogEnabled").Return(true) diff --git a/pkg/osquery/runtime/runtime_test.go b/pkg/osquery/runtime/runtime_test.go index 7e48d75aa..785c7830e 100644 --- a/pkg/osquery/runtime/runtime_test.go +++ b/pkg/osquery/runtime/runtime_test.go @@ -40,7 +40,7 @@ import ( "github.com/stretchr/testify/require" ) -var testOsqueryBinaryPath string +var testOsqueryBinary string // TestMain overrides the default test main function. This allows us to share setup/teardown. func TestMain(m *testing.M) { @@ -67,9 +67,9 @@ func TestMain(m *testing.M) { os.Exit(1) //nolint:forbidigo // Fine to use os.Exit in tests } - testOsqueryBinaryPath = filepath.Join(binDirectory, "osqueryd") + testOsqueryBinary = filepath.Join(binDirectory, "osqueryd") if runtime.GOOS == "windows" { - testOsqueryBinaryPath += ".exe" + testOsqueryBinary += ".exe" } thrift.ServerConnectivityCheckInterval = 100 * time.Millisecond @@ -170,7 +170,7 @@ func TestWithOsqueryFlags(t *testing.T) { k.On("WatchdogEnabled").Return(false) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) k.On("Slogger").Return(slogger) - k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath) + k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinary) k.On("RootDirectory").Return(rootDirectory).Maybe() k.On("OsqueryFlags").Return([]string{"verbose=false"}) k.On("OsqueryVerbose").Return(false) @@ -204,7 +204,7 @@ func TestFlagsChanged(t *testing.T) { k.On("WatchdogDelaySec").Return(120) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) k.On("Slogger").Return(slogger) - k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath) + k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinary) k.On("RootDirectory").Return(rootDirectory).Maybe() k.On("OsqueryFlags").Return([]string{"verbose=false"}) k.On("OsqueryVerbose").Return(false) @@ -335,7 +335,7 @@ func TestSimplePath(t *testing.T) { k.On("WatchdogEnabled").Return(false) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) k.On("Slogger").Return(slogger) - k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath) + k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinary) k.On("RootDirectory").Return(rootDirectory).Maybe() k.On("OsqueryFlags").Return([]string{}) k.On("OsqueryVerbose").Return(true) @@ -371,7 +371,7 @@ func TestMultipleInstances(t *testing.T) { k.On("WatchdogEnabled").Return(false) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) k.On("Slogger").Return(slogger) - k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath) + k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinary) k.On("RootDirectory").Return(rootDirectory).Maybe() k.On("OsqueryFlags").Return([]string{}) k.On("OsqueryVerbose").Return(true) @@ -430,7 +430,7 @@ func TestRunnerHandlesImmediateShutdownWithMultipleInstances(t *testing.T) { k.On("WatchdogEnabled").Return(false) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) k.On("Slogger").Return(slogger) - k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath) + k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinary) k.On("RootDirectory").Return(rootDirectory).Maybe() k.On("OsqueryFlags").Return([]string{}) k.On("OsqueryVerbose").Return(true) @@ -481,7 +481,7 @@ func TestMultipleShutdowns(t *testing.T) { k.On("WatchdogEnabled").Return(false) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) k.On("Slogger").Return(slogger) - k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath) + k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinary) k.On("RootDirectory").Return(rootDirectory).Maybe() k.On("OsqueryFlags").Return([]string{}) k.On("OsqueryVerbose").Return(true) @@ -513,7 +513,7 @@ func TestOsqueryDies(t *testing.T) { k.On("WatchdogEnabled").Return(false) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) k.On("Slogger").Return(slogger) - k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath) + k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinary) k.On("RootDirectory").Return(rootDirectory) k.On("OsqueryFlags").Return([]string{}) k.On("OsqueryVerbose").Return(true) @@ -615,7 +615,7 @@ func setupOsqueryInstanceForTests(t *testing.T) (runner *Runner, logBytes *threa k.On("WatchdogDelaySec").Return(120) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Maybe() k.On("Slogger").Return(slogger) - k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryPath) + k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinary) k.On("RootDirectory").Return(rootDirectory).Maybe() k.On("OsqueryFlags").Return([]string{}).Maybe() k.On("OsqueryVerbose").Return(true).Maybe() From da95bb3f720763928b5827d4a4d2b078b1096043 Mon Sep 17 00:00:00 2001 From: zackattack01 Date: Mon, 23 Dec 2024 11:50:01 -0500 Subject: [PATCH 3/4] fix up agent reset_test.go defers --- ee/agent/reset_test.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/ee/agent/reset_test.go b/ee/agent/reset_test.go index 4514f06f2..96595bee6 100644 --- a/ee/agent/reset_test.go +++ b/ee/agent/reset_test.go @@ -35,12 +35,12 @@ func TestMain(m *testing.M) { fmt.Printf("failed to make temp dir for test osquery binary: %v", err) os.Exit(1) //nolint:forbidigo // Fine to use os.Exit inside tests } - defer os.RemoveAll(downloadDir) target := packaging.Target{} if err := target.PlatformFromString(runtime.GOOS); err != nil { fmt.Printf("error parsing platform %s: %v", runtime.GOOS, err) - os.Exit(1) //nolint:forbidigo // Fine to use os.Exit inside tests + os.RemoveAll(downloadDir) // explicit removal as defer will not run when os.Exit is called + os.Exit(1) //nolint:forbidigo // Fine to use os.Exit inside tests } target.Arch = packaging.ArchFlavor(runtime.GOARCH) if runtime.GOOS == "darwin" { @@ -48,12 +48,13 @@ func TestMain(m *testing.M) { } ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) - defer cancel() dlPath, err := packaging.FetchBinary(ctx, downloadDir, "osqueryd", target.PlatformBinaryName("osqueryd"), "nightly", target) if err != nil { fmt.Printf("error fetching binary osqueryd binary: %v", err) - os.Exit(1) //nolint:forbidigo // Fine to use os.Exit inside tests + cancel() // explicit cancel as defer will not run when os.Exit is called + os.RemoveAll(downloadDir) // explicit removal as defer will not run when os.Exit is called + os.Exit(1) //nolint:forbidigo // Fine to use os.Exit inside tests } testOsqueryBinary = filepath.Join(downloadDir, filepath.Base(dlPath)) @@ -63,12 +64,17 @@ func TestMain(m *testing.M) { if err := fsutil.CopyFile(dlPath, testOsqueryBinary); err != nil { fmt.Printf("error copying osqueryd binary: %v", err) - os.Exit(1) //nolint:forbidigo // Fine to use os.Exit inside tests + cancel() // explicit cancel as defer will not run when os.Exit is called + os.RemoveAll(downloadDir) // explicit removal as defer will not run when os.Exit is called + os.Exit(1) //nolint:forbidigo // Fine to use os.Exit inside tests } // Run the tests retCode := m.Run() - os.Exit(retCode) //nolint:forbidigo // Fine to use os.Exit inside tests + + cancel() // explicit cancel as defer will not run when os.Exit is called + os.RemoveAll(downloadDir) // explicit removal as defer will not run when os.Exit is called + os.Exit(retCode) //nolint:forbidigo // Fine to use os.Exit inside tests } func TestDetectAndRemediateHardwareChange(t *testing.T) { From 00ab8af1f11b3813c4133e18c345d885a76b7186 Mon Sep 17 00:00:00 2001 From: zackattack01 Date: Mon, 23 Dec 2024 11:57:13 -0500 Subject: [PATCH 4/4] refactor with non windows tags --- pkg/osquery/runtime/runtime_posix_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/osquery/runtime/runtime_posix_test.go b/pkg/osquery/runtime/runtime_posix_test.go index e5e4b6051..fc00fc88c 100644 --- a/pkg/osquery/runtime/runtime_posix_test.go +++ b/pkg/osquery/runtime/runtime_posix_test.go @@ -50,7 +50,7 @@ func TestOsquerySlowStart(t *testing.T) { k.On("OsqueryFlags").Return([]string{}).Maybe() k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) k.On("Slogger").Return(slogger) - k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryDirectory) + k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinary) k.On("LoggingInterval").Return(5 * time.Minute).Maybe() k.On("LogMaxBytesPerBatch").Return(0).Maybe() k.On("Transport").Return("jsonrpc").Maybe() @@ -97,7 +97,7 @@ func TestExtensionSocketPath(t *testing.T) { k.On("RootDirectory").Return(rootDirectory).Maybe() k.On("OsqueryVerbose").Return(true).Maybe() k.On("OsqueryFlags").Return([]string{}).Maybe() - k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryDirectory) + k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinary) k.On("LoggingInterval").Return(5 * time.Minute).Maybe() k.On("LogMaxBytesPerBatch").Return(0).Maybe() k.On("Transport").Return("jsonrpc").Maybe()