Skip to content

Commit

Permalink
Ensure k.slogger and k.systemSlogger are never nil
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaMahany committed Feb 22, 2024
1 parent d3beb3e commit 6482b59
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions ee/agent/knapsack/knapsack.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ type knapsack struct {
}

func New(stores map[storage.Store]types.KVStore, flags types.Flags, db *bbolt.DB, slogger, systemSlogger *multislogger.MultiSlogger) *knapsack {
if slogger == nil {
slogger = multislogger.New()
}
if systemSlogger == nil {
systemSlogger = multislogger.New()
}

k := &knapsack{
db: db,
flags: flags,
Expand Down Expand Up @@ -140,11 +147,7 @@ func (k *knapsack) getKVStore(storeType storage.Store) types.KVStore {
}

func (k *knapsack) LatestOsquerydPath(ctx context.Context) string {
slogger := k.Slogger()
if slogger == nil {
slogger = multislogger.New().Logger
}
latestBin, err := tuf.CheckOutLatest(ctx, "osqueryd", k.RootDirectory(), k.UpdateDirectory(), k.UpdateChannel(), slogger)
latestBin, err := tuf.CheckOutLatest(ctx, "osqueryd", k.RootDirectory(), k.UpdateDirectory(), k.UpdateChannel(), k.Slogger())
if err != nil {
return autoupdate.FindNewest(ctx, k.OsquerydPath())
}
Expand Down

0 comments on commit 6482b59

Please sign in to comment.