Skip to content

Commit

Permalink
Rename to KATC
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaMahany committed Jun 25, 2024
1 parent 5404575 commit b2d7b96
Show file tree
Hide file tree
Showing 14 changed files with 66 additions and 66 deletions.
10 changes: 5 additions & 5 deletions cmd/launcher/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const (
serverDataSubsystemName = "kolide_server_data"
desktopMenuSubsystemName = "kolide_desktop_menu"
authTokensSubsystemName = "auth_tokens"
atcConfigSubsystemName = "kolide_atc_config"
katcSubsystemName = "katc_config" // Kolide ATC
)

// runLauncher is the entry point into running launcher. It creates a
Expand Down Expand Up @@ -401,10 +401,10 @@ func runLauncher(ctx context.Context, cancel func(), multiSlogger, systemMultiSl
controlService.RegisterConsumer(serverDataSubsystemName, keyvalueconsumer.New(k.ServerProvidedDataStore()))
// agentFlagConsumer handles agent flags pushed from the control server
controlService.RegisterConsumer(agentFlagsSubsystemName, keyvalueconsumer.New(flagController))
// atcConfigConsumer handles updates to Kolide's custom ATC tables
controlService.RegisterConsumer(atcConfigSubsystemName, keyvalueconsumer.New(k.AtcConfigStore()))
controlService.RegisterSubscriber(atcConfigSubsystemName, osqueryRunner)
controlService.RegisterSubscriber(atcConfigSubsystemName, startupSettingsWriter)
// katcConfigConsumer handles updates to Kolide's custom ATC tables
controlService.RegisterConsumer(katcSubsystemName, keyvalueconsumer.New(k.KatcConfigStore()))
controlService.RegisterSubscriber(katcSubsystemName, osqueryRunner)
controlService.RegisterSubscriber(katcSubsystemName, startupSettingsWriter)

runner, err = desktopRunner.New(
k,
Expand Down
4 changes: 2 additions & 2 deletions ee/agent/knapsack/knapsack.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ func (k *knapsack) AgentFlagsStore() types.KVStore {
return k.getKVStore(storage.AgentFlagsStore)
}

func (k *knapsack) AtcConfigStore() types.KVStore {
return k.getKVStore(storage.AtcConfigStore)
func (k *knapsack) KatcConfigStore() types.KVStore {
return k.getKVStore(storage.KatcConfigStore)
}

func (k *knapsack) AutoupdateErrorsStore() types.KVStore {
Expand Down
14 changes: 7 additions & 7 deletions ee/agent/startupsettings/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func OpenWriter(ctx context.Context, knapsack types.Knapsack) (*startupSettingsW
}

// Ping satisfies the control.subscriber interface -- the runner subscribes to changes to
// the kolide_atc_config subsystem.
// the katc_config subsystem.
func (s *startupSettingsWriter) Ping() {
if err := s.WriteSettings(); err != nil {
s.knapsack.Slogger().Log(context.TODO(), slog.LevelWarn,
Expand Down Expand Up @@ -80,13 +80,13 @@ func (s *startupSettingsWriter) WriteSettings() error {
updatedFlags["auto_table_construction"] = atcConfig
}

if kolideAtcConfig, err := s.extractKolideAutoTableConstructionConfig(); err != nil {
if katcConfig, err := s.extractKATCConstructionConfig(); err != nil {
s.knapsack.Slogger().Log(context.TODO(), slog.LevelDebug,
"extracting kolide_atc_config",
"extracting katc_config",
"err", err,
)
} else {
updatedFlags["kolide_atc_config"] = kolideAtcConfig
updatedFlags["katc_config"] = katcConfig
}

if _, err := s.kvStore.Update(updatedFlags); err != nil {
Expand Down Expand Up @@ -140,9 +140,9 @@ func (s *startupSettingsWriter) extractAutoTableConstructionConfig() (string, er
return string(atcJson), nil
}

func (s *startupSettingsWriter) extractKolideAutoTableConstructionConfig() (string, error) {
func (s *startupSettingsWriter) extractKATCConstructionConfig() (string, error) {
kolideCfg := make(map[string]string)
if err := s.knapsack.AtcConfigStore().ForEach(func(k []byte, v []byte) error {
if err := s.knapsack.KatcConfigStore().ForEach(func(k []byte, v []byte) error {
kolideCfg[string(k)] = string(v)
return nil
}); err != nil {
Expand All @@ -151,7 +151,7 @@ func (s *startupSettingsWriter) extractKolideAutoTableConstructionConfig() (stri

atcJson, err := json.Marshal(kolideCfg)
if err != nil {
return "", fmt.Errorf("could not marshal kolide_atc_config: %w", err)
return "", fmt.Errorf("could not marshal katc_config: %w", err)
}

return string(atcJson), nil
Expand Down
6 changes: 3 additions & 3 deletions ee/agent/startupsettings/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestOpenWriter_NewDatabase(t *testing.T) {
k.On("PinnedOsquerydVersion").Return("5.11.0")
k.On("ConfigStore").Return(inmemory.NewStore())
k.On("Slogger").Return(multislogger.NewNopLogger())
k.On("AtcConfigStore").Return(inmemory.NewStore())
k.On("KatcConfigStore").Return(inmemory.NewStore())

// Set up storage db, which should create the database and set all flags
s, err := OpenWriter(context.TODO(), k)
Expand Down Expand Up @@ -83,7 +83,7 @@ func TestOpenWriter_DatabaseAlreadyExists(t *testing.T) {
// Set up dependencies
k := typesmocks.NewKnapsack(t)
k.On("RootDirectory").Return(testRootDir)
k.On("AtcConfigStore").Return(inmemory.NewStore())
k.On("KatcConfigStore").Return(inmemory.NewStore())
k.On("RegisterChangeObserver", mock.Anything, keys.UpdateChannel)
k.On("RegisterChangeObserver", mock.Anything, keys.PinnedLauncherVersion)
k.On("RegisterChangeObserver", mock.Anything, keys.PinnedOsquerydVersion)
Expand Down Expand Up @@ -128,7 +128,7 @@ func TestFlagsChanged(t *testing.T) {
testRootDir := t.TempDir()
k := typesmocks.NewKnapsack(t)
k.On("RootDirectory").Return(testRootDir)
k.On("AtcConfigStore").Return(inmemory.NewStore())
k.On("KatcConfigStore").Return(inmemory.NewStore())
k.On("RegisterChangeObserver", mock.Anything, keys.UpdateChannel)
k.On("RegisterChangeObserver", mock.Anything, keys.PinnedLauncherVersion)
k.On("RegisterChangeObserver", mock.Anything, keys.PinnedOsquerydVersion)
Expand Down
2 changes: 1 addition & 1 deletion ee/agent/storage/bbolt/stores_bbolt.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func MakeStores(ctx context.Context, slogger *slog.Logger, db *bbolt.DB) (map[st

var storeNames = []storage.Store{
storage.AgentFlagsStore,
storage.AtcConfigStore,
storage.KatcConfigStore,
storage.AutoupdateErrorsStore,
storage.ConfigStore,
storage.ControlStore,
Expand Down
2 changes: 1 addition & 1 deletion ee/agent/storage/ci/stores_ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
func MakeStores(t *testing.T, slogger *slog.Logger, db *bbolt.DB) (map[storage.Store]types.KVStore, error) {
var storeNames = []storage.Store{
storage.AgentFlagsStore,
storage.AtcConfigStore,
storage.KatcConfigStore,
storage.AutoupdateErrorsStore,
storage.ConfigStore,
storage.ControlStore,
Expand Down
2 changes: 1 addition & 1 deletion ee/agent/storage/stores.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type Store string

const (
AgentFlagsStore Store = "agent_flags" // The store used for agent control flags.
AtcConfigStore Store = "kolide_atc_config" // The store used for Kolide custom ATC configuration
KatcConfigStore Store = "katc_config" // The store used for Kolide custom ATC configuration
AutoupdateErrorsStore Store = "tuf_autoupdate_errors" // The store used for tracking new autoupdater errors.
ConfigStore Store = "config" // The store used for launcher configuration.
ControlStore Store = "control_service_data" // The store used for control service caching data.
Expand Down
32 changes: 16 additions & 16 deletions ee/agent/types/mocks/knapsack.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ee/agent/types/stores.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "github.com/kolide/launcher/ee/agent/storage"
type Stores interface {
Stores() map[storage.Store]KVStore
AgentFlagsStore() KVStore
AtcConfigStore() KVStore
KatcConfigStore() KVStore
AutoupdateErrorsStore() KVStore
ConfigStore() KVStore
ControlStore() KVStore
Expand Down
4 changes: 2 additions & 2 deletions pkg/osquery/interactive/interactive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ func TestProc(t *testing.T) {
mockSack.On("OsqueryFlags").Return(tt.osqueryFlags)
mockSack.On("Slogger").Return(multislogger.NewNopLogger())
mockSack.On("RootDirectory").Maybe().Return("whatever_the_root_launcher_dir_is")
store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.AtcConfigStore.String())
store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.KatcConfigStore.String())
require.NoError(t, err)
mockSack.On("AtcConfigStore").Return(store)
mockSack.On("KatcConfigStore").Return(store)

proc, _, err := StartProcess(mockSack, rootDir)

Expand Down
2 changes: 1 addition & 1 deletion pkg/osquery/runtime/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (r *Runner) FlagsChanged(flagKeys ...keys.FlagKey) {
}

// Ping satisfies the control.subscriber interface -- the runner subscribes to changes to
// the kolide_atc_config subsystem.
// the katc_config subsystem.
func (r *Runner) Ping() {
r.slogger.Log(context.TODO(), slog.LevelDebug,
"Kolide ATC configuration changed, restarting instance to apply",
Expand Down
8 changes: 4 additions & 4 deletions pkg/osquery/runtime/runtime_posix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ func TestOsquerySlowStart(t *testing.T) {
slogger := multislogger.New(slog.NewJSONHandler(&logBytes, &slog.HandlerOptions{Level: slog.LevelDebug}))
k.On("Slogger").Return(slogger.Logger)
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryDirectory)
store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.AtcConfigStore.String())
store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.KatcConfigStore.String())
require.NoError(t, err)
k.On("AtcConfigStore").Return(store)
k.On("KatcConfigStore").Return(store)

runner := New(
k,
Expand Down Expand Up @@ -100,9 +100,9 @@ func TestExtensionSocketPath(t *testing.T) {
k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything)
k.On("Slogger").Return(multislogger.NewNopLogger())
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryDirectory)
store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.AtcConfigStore.String())
store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.KatcConfigStore.String())
require.NoError(t, err)
k.On("AtcConfigStore").Return(store)
k.On("KatcConfigStore").Return(store)

extensionSocketPath := filepath.Join(rootDirectory, "sock")
runner := New(
Expand Down
24 changes: 12 additions & 12 deletions pkg/osquery/runtime/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,9 @@ func TestWithOsqueryFlags(t *testing.T) {
k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything)
k.On("Slogger").Return(multislogger.NewNopLogger())
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryDirectory)
store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.AtcConfigStore.String())
store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.KatcConfigStore.String())
require.NoError(t, err)
k.On("AtcConfigStore").Return(store)
k.On("KatcConfigStore").Return(store)

runner := New(
k,
Expand Down Expand Up @@ -371,9 +371,9 @@ func TestFlagsChanged(t *testing.T) {
k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything)
k.On("Slogger").Return(multislogger.NewNopLogger())
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryDirectory)
store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.AtcConfigStore.String())
store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.KatcConfigStore.String())
require.NoError(t, err)
k.On("AtcConfigStore").Return(store)
k.On("KatcConfigStore").Return(store)

// Start the runner
runner := New(
Expand Down Expand Up @@ -467,9 +467,9 @@ func TestSimplePath(t *testing.T) {
k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything)
k.On("Slogger").Return(multislogger.NewNopLogger())
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryDirectory)
store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.AtcConfigStore.String())
store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.KatcConfigStore.String())
require.NoError(t, err)
k.On("AtcConfigStore").Return(store)
k.On("KatcConfigStore").Return(store)

runner := New(
k,
Expand Down Expand Up @@ -498,9 +498,9 @@ func TestMultipleShutdowns(t *testing.T) {
k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything)
k.On("Slogger").Return(multislogger.NewNopLogger())
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryDirectory)
store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.AtcConfigStore.String())
store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.KatcConfigStore.String())
require.NoError(t, err)
k.On("AtcConfigStore").Return(store)
k.On("KatcConfigStore").Return(store)

runner := New(
k,
Expand Down Expand Up @@ -528,9 +528,9 @@ func TestOsqueryDies(t *testing.T) {
k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything)
k.On("Slogger").Return(multislogger.NewNopLogger())
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryDirectory)
store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.AtcConfigStore.String())
store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.KatcConfigStore.String())
require.NoError(t, err)
k.On("AtcConfigStore").Return(store)
k.On("KatcConfigStore").Return(store)

runner := New(
k,
Expand Down Expand Up @@ -625,9 +625,9 @@ func setupOsqueryInstanceForTests(t *testing.T) (runner *Runner, teardown func()
k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Maybe()
k.On("Slogger").Return(multislogger.NewNopLogger())
k.On("LatestOsquerydPath", mock.Anything).Return(testOsqueryBinaryDirectory)
store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.AtcConfigStore.String())
store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.KatcConfigStore.String())
require.NoError(t, err)
k.On("AtcConfigStore").Return(store)
k.On("KatcConfigStore").Return(store)

runner = New(
k,
Expand Down
20 changes: 10 additions & 10 deletions pkg/osquery/table/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ func PlatformTables(k types.Knapsack, slogger *slog.Logger, currentOsquerydBinar
// and others.
func kolideCustomAtcTables(k types.Knapsack, slogger *slog.Logger) []osquery.OsqueryPlugin {
// Fetch tables from KVStore or from startup settings
config, err := kolideAtcConfigFromDb(k)
config, err := katcFromDb(k)
if err != nil {
slogger.Log(context.TODO(), slog.LevelDebug,
"could not retrieve Kolide ATC config from store, may not have access -- falling back to startup settings",
"err", err,
)

config, err = kolideAtcConfigFromStartupSettings(k)
config, err = katcFromStartupSettings(k)
if err != nil {
slogger.Log(context.TODO(), slog.LevelWarn,
"could not retrieve Kolide ATC config from startup settings",
Expand All @@ -108,12 +108,12 @@ func kolideCustomAtcTables(k types.Knapsack, slogger *slog.Logger) []osquery.Osq
return nil
}

func kolideAtcConfigFromDb(k types.Knapsack) (map[string]string, error) {
if k == nil || k.AtcConfigStore() == nil {
func katcFromDb(k types.Knapsack) (map[string]string, error) {
if k == nil || k.KatcConfigStore() == nil {
return nil, errors.New("stores in knapsack not available")
}
loggableConfig := make(map[string]string)
if err := k.AtcConfigStore().ForEach(func(k []byte, v []byte) error {
if err := k.KatcConfigStore().ForEach(func(k []byte, v []byte) error {
loggableConfig[string(k)] = string(v)
return nil
}); err != nil {
Expand All @@ -123,21 +123,21 @@ func kolideAtcConfigFromDb(k types.Knapsack) (map[string]string, error) {
return loggableConfig, nil
}

func kolideAtcConfigFromStartupSettings(k types.Knapsack) (map[string]string, error) {
func katcFromStartupSettings(k types.Knapsack) (map[string]string, error) {
r, err := startupsettings.OpenReader(context.TODO(), k.RootDirectory())
if err != nil {
return nil, fmt.Errorf("error opening startup settings reader: %w", err)
}
defer r.Close()

atcConfig, err := r.Get("kolide_atc_config")
katcConfig, err := r.Get("katc_config")
if err != nil {
return nil, fmt.Errorf("error getting kolide_atc_config from startup settings: %w", err)
return nil, fmt.Errorf("error getting katc_config from startup settings: %w", err)
}

var loggableConfig map[string]string
if err := json.Unmarshal([]byte(atcConfig), &loggableConfig); err != nil {
return nil, fmt.Errorf("unmarshalling kolide_atc_config: %w", err)
if err := json.Unmarshal([]byte(katcConfig), &loggableConfig); err != nil {
return nil, fmt.Errorf("unmarshalling katc_config: %w", err)
}

return loggableConfig, nil
Expand Down

0 comments on commit b2d7b96

Please sign in to comment.