-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set SystemDrive env var on osquery command (#1960)
- Loading branch information
1 parent
8a91d13
commit e347130
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
//go:build windows | ||
// +build windows | ||
|
||
package runtime | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
typesMocks "github.com/kolide/launcher/ee/agent/types/mocks" | ||
"github.com/kolide/launcher/pkg/log/multislogger" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestCreateOsqueryCommandEnvVars(t *testing.T) { | ||
t.Parallel() | ||
|
||
osquerydPath := testOsqueryBinaryDirectory | ||
|
||
k := typesMocks.NewKnapsack(t) | ||
k.On("WatchdogEnabled").Return(true) | ||
k.On("WatchdogMemoryLimitMB").Return(150) | ||
k.On("WatchdogUtilizationLimitPercent").Return(20) | ||
k.On("WatchdogDelaySec").Return(120) | ||
k.On("OsqueryVerbose").Return(true) | ||
k.On("OsqueryFlags").Return([]string{}) | ||
k.On("Slogger").Return(multislogger.NewNopLogger()) | ||
|
||
i := newInstance(defaultRegistrationId, k, mockServiceClient()) | ||
|
||
cmd, err := i.createOsquerydCommand(osquerydPath, &osqueryFilePaths{ | ||
pidfilePath: "/foo/bar/osquery-abcd.pid", | ||
databasePath: "/foo/bar/osquery.db", | ||
extensionSocketPath: "/foo/bar/osquery.sock", | ||
extensionAutoloadPath: "/foo/bar/osquery.autoload", | ||
}) | ||
require.NoError(t, err) | ||
|
||
systemDriveEnvVarFound := false | ||
for _, envVar := range cmd.Env { | ||
if strings.Contains(envVar, "SystemDrive") { | ||
systemDriveEnvVarFound = true | ||
break | ||
} | ||
} | ||
|
||
require.True(t, systemDriveEnvVarFound, "SystemDrive env var missing from command") | ||
|
||
k.AssertExpectations(t) | ||
} |