Skip to content

Commit

Permalink
Merge branch 'main' into james/presence-detection-callback
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Pickett authored Jan 30, 2025
2 parents 947fc17 + 6ebf35f commit bad7164
Show file tree
Hide file tree
Showing 73 changed files with 356 additions and 105 deletions.
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ linters-settings:
msg: use gowrapper.Go() instead of raw goroutines for proper panic handling
- p: \.Cmd\.(Run|Start|Output|CombinedOutput)
msg: "Do not call embedded exec.Cmd methods directly on TracedCmd; call TracedCmd.Run(), TracedCmd.Start(), etc. instead"
- p: ^table\.NewPlugin.*$
msg: use ee/tables/tablewrapper to enforce timeouts on table queries
sloglint:
kv-only: true
context: "all"
Expand Down
3 changes: 2 additions & 1 deletion ee/katc/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"log/slog"

"github.com/kolide/launcher/ee/indexeddb"
"github.com/kolide/launcher/ee/tables/tablewrapper"
"github.com/osquery/osquery-go"
"github.com/osquery/osquery-go/plugin/table"
)
Expand Down Expand Up @@ -144,7 +145,7 @@ func ConstructKATCTables(config map[string]string, slogger *slog.Logger) []osque
}

t, columns := newKatcTable(tableName, cfg, slogger)
plugins = append(plugins, table.NewPlugin(tableName, columns, t.generate))
plugins = append(plugins, tablewrapper.New(slogger, tableName, columns, t.generate))
}

return plugins
Expand Down
3 changes: 2 additions & 1 deletion ee/tables/airport/table_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/kolide/launcher/ee/dataflatten"
"github.com/kolide/launcher/ee/tables/dataflattentable"
"github.com/kolide/launcher/ee/tables/tablehelpers"
"github.com/kolide/launcher/ee/tables/tablewrapper"
"github.com/kolide/launcher/pkg/traces"
"github.com/osquery/osquery-go/plugin/table"
)
Expand All @@ -41,7 +42,7 @@ func TablePlugin(slogger *slog.Logger) *table.Plugin {
slogger: slogger.With("name", tableName),
}

return table.NewPlugin(t.name, columns, t.generate)
return tablewrapper.New(slogger, t.name, columns, t.generate)
}

type airportExecutor struct {
Expand Down
6 changes: 4 additions & 2 deletions ee/tables/app-icons/app_icons_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ import (
"context"
"encoding/base64"
"errors"
"log/slog"

"fmt"
"hash/crc64"
"image"
"image/png"
"unsafe"

"github.com/kolide/launcher/ee/tables/tablewrapper"
"github.com/kolide/launcher/pkg/traces"
"github.com/nfnt/resize"
"github.com/osquery/osquery-go/plugin/table"
Expand All @@ -43,13 +45,13 @@ import (

var crcTable = crc64.MakeTable(crc64.ECMA)

func AppIcons() *table.Plugin {
func AppIcons(slogger *slog.Logger) *table.Plugin {
columns := []table.ColumnDefinition{
table.TextColumn("path"),
table.TextColumn("icon"),
table.TextColumn("hash"),
}
return table.NewPlugin("kolide_app_icons", columns, generateAppIcons)
return tablewrapper.New(slogger, "kolide_app_icons", columns, generateAppIcons)
}

func generateAppIcons(ctx context.Context, queryContext table.QueryContext) ([]map[string]string, error) {
Expand Down
3 changes: 2 additions & 1 deletion ee/tables/apple_silicon_security_policy/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/kolide/launcher/ee/dataflatten"
"github.com/kolide/launcher/ee/tables/dataflattentable"
"github.com/kolide/launcher/ee/tables/tablehelpers"
"github.com/kolide/launcher/ee/tables/tablewrapper"
"github.com/kolide/launcher/pkg/traces"
"github.com/osquery/osquery-go/plugin/table"
)
Expand All @@ -32,7 +33,7 @@ func TablePlugin(slogger *slog.Logger) *table.Plugin {
slogger: slogger.With("table", tableName),
}

return table.NewPlugin(tableName, columns, t.generate)
return tablewrapper.New(slogger, tableName, columns, t.generate)
}

func (t *Table) generate(ctx context.Context, queryContext table.QueryContext) ([]map[string]string, error) {
Expand Down
3 changes: 2 additions & 1 deletion ee/tables/crowdstrike/falcon_kernel_check/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/kolide/launcher/ee/allowedcmd"
"github.com/kolide/launcher/ee/tables/tablehelpers"
"github.com/kolide/launcher/ee/tables/tablewrapper"
"github.com/kolide/launcher/pkg/traces"
"github.com/osquery/osquery-go/plugin/table"
)
Expand All @@ -32,7 +33,7 @@ func TablePlugin(slogger *slog.Logger) *table.Plugin {
slogger: slogger.With("table", tableName),
}

return table.NewPlugin(tableName, columns, t.generate)
return tablewrapper.New(slogger, tableName, columns, t.generate)
}

func (t *Table) generate(ctx context.Context, queryContext table.QueryContext) ([]map[string]string, error) {
Expand Down
5 changes: 3 additions & 2 deletions ee/tables/crowdstrike/falconctl/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/kolide/launcher/ee/dataflatten"
"github.com/kolide/launcher/ee/tables/dataflattentable"
"github.com/kolide/launcher/ee/tables/tablehelpers"
"github.com/kolide/launcher/ee/tables/tablewrapper"
"github.com/kolide/launcher/pkg/traces"
"github.com/osquery/osquery-go/plugin/table"
)
Expand Down Expand Up @@ -58,11 +59,11 @@ func NewFalconctlOptionTable(slogger *slog.Logger) *table.Plugin {
execFunc: tablehelpers.RunSimple,
}

return table.NewPlugin(t.tableName, columns, t.generate)
return tablewrapper.New(slogger, t.tableName, columns, t.generate)
}

func (t *falconctlOptionsTable) generate(ctx context.Context, queryContext table.QueryContext) ([]map[string]string, error) {
ctx, span := traces.StartSpan(ctx, "table_name", "kolide_falconctl_options")
ctx, span := traces.StartSpan(ctx, "table_name", t.tableName)
defer span.End()

var results []map[string]string
Expand Down
3 changes: 2 additions & 1 deletion ee/tables/cryptoinfotable/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/kolide/launcher/ee/dataflatten"
"github.com/kolide/launcher/ee/tables/dataflattentable"
"github.com/kolide/launcher/ee/tables/tablehelpers"
"github.com/kolide/launcher/ee/tables/tablewrapper"
"github.com/kolide/launcher/pkg/traces"
"github.com/osquery/osquery-go/plugin/table"
)
Expand All @@ -32,7 +33,7 @@ func TablePlugin(slogger *slog.Logger) *table.Plugin {
slogger: slogger.With("table", "kolide_cryptinfo"),
}

return table.NewPlugin("kolide_cryptoinfo", columns, t.generate)
return tablewrapper.New(slogger, "kolide_cryptinfo", columns, t.generate)
}

func (t *Table) generate(ctx context.Context, queryContext table.QueryContext) ([]map[string]string, error) {
Expand Down
3 changes: 2 additions & 1 deletion ee/tables/cryptsetup/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/kolide/launcher/ee/dataflatten"
"github.com/kolide/launcher/ee/tables/dataflattentable"
"github.com/kolide/launcher/ee/tables/tablehelpers"
"github.com/kolide/launcher/ee/tables/tablewrapper"
"github.com/kolide/launcher/pkg/traces"
"github.com/osquery/osquery-go/plugin/table"
)
Expand All @@ -34,7 +35,7 @@ func TablePlugin(slogger *slog.Logger) *table.Plugin {
name: "kolide_cryptsetup_status",
}

return table.NewPlugin(t.name, columns, t.generate)
return tablewrapper.New(slogger, t.name, columns, t.generate)
}

func (t *Table) generate(ctx context.Context, queryContext table.QueryContext) ([]map[string]string, error) {
Expand Down
3 changes: 2 additions & 1 deletion ee/tables/dataflattentable/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/kolide/launcher/ee/allowedcmd"
"github.com/kolide/launcher/ee/dataflatten"
"github.com/kolide/launcher/ee/tables/tablehelpers"
"github.com/kolide/launcher/ee/tables/tablewrapper"
"github.com/kolide/launcher/pkg/traces"
"github.com/osquery/osquery-go/plugin/table"
"github.com/pkg/errors"
Expand Down Expand Up @@ -42,7 +43,7 @@ func TablePluginExec(slogger *slog.Logger, tableName string, dataSourceType Data

t.flattenBytesFunc = dataSourceType.FlattenBytesFunc(t.keyValueSeparator)

return table.NewPlugin(t.tableName, columns, t.generateExec)
return tablewrapper.New(slogger, t.tableName, columns, t.generateExec)
}

func (t *Table) generateExec(ctx context.Context, queryContext table.QueryContext) ([]map[string]string, error) {
Expand Down
3 changes: 2 additions & 1 deletion ee/tables/dataflattentable/exec_and_parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/kolide/launcher/ee/allowedcmd"
"github.com/kolide/launcher/ee/dataflatten"
"github.com/kolide/launcher/ee/tables/tablehelpers"
"github.com/kolide/launcher/ee/tables/tablewrapper"
"github.com/kolide/launcher/pkg/traces"
"github.com/osquery/osquery-go/plugin/table"
"github.com/pkg/errors"
Expand Down Expand Up @@ -66,7 +67,7 @@ func NewExecAndParseTable(slogger *slog.Logger, tableName string, p parser, cmd
opt(t)
}

return table.NewPlugin(t.tableName, Columns(), t.generate)
return tablewrapper.New(slogger, t.tableName, Columns(), t.generate)
}

func (t *execTableV2) generate(ctx context.Context, queryContext table.QueryContext) ([]map[string]string, error) {
Expand Down
3 changes: 2 additions & 1 deletion ee/tables/dataflattentable/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/kolide/launcher/ee/allowedcmd"
"github.com/kolide/launcher/ee/dataflatten"
"github.com/kolide/launcher/ee/tables/tablehelpers"
"github.com/kolide/launcher/ee/tables/tablewrapper"
"github.com/kolide/launcher/pkg/traces"
"github.com/osquery/osquery-go"
"github.com/osquery/osquery-go/plugin/table"
Expand Down Expand Up @@ -125,7 +126,7 @@ func TablePlugin(slogger *slog.Logger, dataSourceType DataSourceType) osquery.Os

t.slogger = slogger.With("table", t.tableName)

return table.NewPlugin(t.tableName, columns, t.generate)
return tablewrapper.New(slogger, t.tableName, columns, t.generate)

}

Expand Down
6 changes: 4 additions & 2 deletions ee/tables/desktopprocs/desktopprocs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@ package desktopprocs
import (
"context"
"fmt"
"log/slog"

"github.com/kolide/launcher/ee/desktop/runner"
"github.com/kolide/launcher/ee/tables/tablewrapper"
"github.com/kolide/launcher/pkg/traces"
"github.com/osquery/osquery-go/plugin/table"
)

func TablePlugin() *table.Plugin {
func TablePlugin(slogger *slog.Logger) *table.Plugin {
columns := []table.ColumnDefinition{
table.TextColumn("uid"),
table.TextColumn("pid"),
table.TextColumn("start_time"),
table.TextColumn("last_health_check"),
}
return table.NewPlugin("kolide_desktop_procs", columns, generate())
return tablewrapper.New(slogger, "kolide_desktop_procs", columns, generate())
}

func generate() table.GenerateFunc {
Expand Down
3 changes: 2 additions & 1 deletion ee/tables/dev_table_tooling/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/kolide/launcher/ee/allowedcmd"
"github.com/kolide/launcher/ee/tables/tablehelpers"
"github.com/kolide/launcher/ee/tables/tablewrapper"
"github.com/kolide/launcher/pkg/traces"
"github.com/osquery/osquery-go/plugin/table"
)
Expand Down Expand Up @@ -37,7 +38,7 @@ func TablePlugin(slogger *slog.Logger) *table.Plugin {
slogger: slogger.With("table", tableName),
}

return table.NewPlugin(tableName, columns, t.generate)
return tablewrapper.New(slogger, tableName, columns, t.generate)
}

func (t *Table) generate(ctx context.Context, queryContext table.QueryContext) ([]map[string]string, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/kolide/launcher/ee/dataflatten"
"github.com/kolide/launcher/ee/tables/dataflattentable"
"github.com/kolide/launcher/ee/tables/tablehelpers"
"github.com/kolide/launcher/ee/tables/tablewrapper"
"github.com/kolide/launcher/pkg/traces"
"github.com/osquery/osquery-go/plugin/table"
)
Expand All @@ -33,7 +34,7 @@ func TablePlugin(slogger *slog.Logger) *table.Plugin {
slogger: slogger.With("table", "kolide_dsim_default_associations"),
}

return table.NewPlugin("kolide_dsim_default_associations", columns, t.generate)
return tablewrapper.New(slogger, "kolide_dsim_default_associations", columns, t.generate)
}

func (t *Table) generate(ctx context.Context, queryContext table.QueryContext) ([]map[string]string, error) {
Expand Down
3 changes: 2 additions & 1 deletion ee/tables/filevault/filevault.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/kolide/launcher/ee/allowedcmd"
"github.com/kolide/launcher/ee/tables/tablehelpers"
"github.com/kolide/launcher/ee/tables/tablewrapper"
"github.com/kolide/launcher/pkg/traces"
"github.com/osquery/osquery-go/plugin/table"
"github.com/pkg/errors"
Expand All @@ -30,7 +31,7 @@ func TablePlugin(slogger *slog.Logger) *table.Plugin {
slogger: slogger.With("table", "kolide_filevault"),
}

return table.NewPlugin("kolide_filevault", columns, t.generate)
return tablewrapper.New(slogger, "kolide_filevault", columns, t.generate)
}

func (t *Table) generate(ctx context.Context, queryContext table.QueryContext) ([]map[string]string, error) {
Expand Down
3 changes: 2 additions & 1 deletion ee/tables/firefox_preferences/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/kolide/launcher/ee/dataflatten"
"github.com/kolide/launcher/ee/tables/dataflattentable"
"github.com/kolide/launcher/ee/tables/tablehelpers"
"github.com/kolide/launcher/ee/tables/tablewrapper"
"github.com/kolide/launcher/pkg/traces"
"github.com/osquery/osquery-go/plugin/table"
)
Expand Down Expand Up @@ -44,7 +45,7 @@ func TablePlugin(slogger *slog.Logger) *table.Plugin {
slogger: slogger.With("table", tableName),
}

return table.NewPlugin(t.name, columns, t.generate)
return tablewrapper.New(slogger, t.name, columns, t.generate)
}

func (t *Table) generate(ctx context.Context, queryContext table.QueryContext) ([]map[string]string, error) {
Expand Down
3 changes: 2 additions & 1 deletion ee/tables/firmwarepasswd/firmwarepasswd.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/kolide/launcher/ee/agent"
"github.com/kolide/launcher/ee/allowedcmd"
"github.com/kolide/launcher/ee/tables/tablehelpers"
"github.com/kolide/launcher/ee/tables/tablewrapper"
"github.com/kolide/launcher/pkg/traces"
"github.com/osquery/osquery-go/plugin/table"
)
Expand All @@ -36,7 +37,7 @@ func TablePlugin(slogger *slog.Logger) *table.Plugin {

t := New(slogger.With("table", "kolide_firmwarepasswd"))

return table.NewPlugin("kolide_firmwarepasswd", columns, t.generate)
return tablewrapper.New(slogger, "kolide_firmwarepasswd", columns, t.generate)

}

Expand Down
3 changes: 2 additions & 1 deletion ee/tables/fscrypt_info/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package fscrypt_info
import (
"log/slog"

"github.com/kolide/launcher/ee/tables/tablewrapper"
"github.com/osquery/osquery-go/plugin/table"
)

Expand All @@ -29,5 +30,5 @@ func TablePlugin(slogger *slog.Logger) *table.Plugin {
t := &Table{
slogger: slogger.With("table", tableName),
}
return table.NewPlugin(tableName, columns, t.generate)
return tablewrapper.New(slogger, tableName, columns, t.generate)
}
3 changes: 2 additions & 1 deletion ee/tables/gsettings/gsettings.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/kolide/launcher/ee/agent"
"github.com/kolide/launcher/ee/allowedcmd"
"github.com/kolide/launcher/ee/tables/tablehelpers"
"github.com/kolide/launcher/ee/tables/tablewrapper"
"github.com/kolide/launcher/pkg/traces"
"github.com/osquery/osquery-go/plugin/table"
)
Expand Down Expand Up @@ -46,7 +47,7 @@ func Settings(slogger *slog.Logger) *table.Plugin {
getBytes: execGsettings,
}

return table.NewPlugin("kolide_gsettings", columns, t.generate)
return tablewrapper.New(slogger, "kolide_gsettings", columns, t.generate)
}

func (t *GsettingsValues) generate(ctx context.Context, queryContext table.QueryContext) ([]map[string]string, error) {
Expand Down
3 changes: 2 additions & 1 deletion ee/tables/gsettings/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/kolide/launcher/ee/agent"
"github.com/kolide/launcher/ee/allowedcmd"
"github.com/kolide/launcher/ee/tables/tablehelpers"
"github.com/kolide/launcher/ee/tables/tablewrapper"
"github.com/kolide/launcher/pkg/log/multislogger"
"github.com/kolide/launcher/pkg/traces"
"github.com/osquery/osquery-go/plugin/table"
Expand All @@ -43,7 +44,7 @@ func Metadata(slogger *slog.Logger) *table.Plugin {
cmdRunner: execGsettingsCommand,
}

return table.NewPlugin("kolide_gsettings_metadata", columns, t.generate)
return tablewrapper.New(slogger, "kolide_gsettings_metadata", columns, t.generate)
}

func (t *GsettingsMetadata) generate(ctx context.Context, queryContext table.QueryContext) ([]map[string]string, error) {
Expand Down
3 changes: 2 additions & 1 deletion ee/tables/homebrew/upgradeable.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/kolide/launcher/ee/dataflatten"
"github.com/kolide/launcher/ee/tables/dataflattentable"
"github.com/kolide/launcher/ee/tables/tablehelpers"
"github.com/kolide/launcher/ee/tables/tablewrapper"
"github.com/kolide/launcher/pkg/traces"
"github.com/osquery/osquery-go/plugin/table"
)
Expand All @@ -35,7 +36,7 @@ func TablePlugin(slogger *slog.Logger) *table.Plugin {
slogger: slogger.With("table", "kolide_brew_upgradeable"),
}

return table.NewPlugin("kolide_brew_upgradeable", columns, t.generate)
return tablewrapper.New(slogger, "kolide_brew_upgradeable", columns, t.generate)
}

func (t *Table) generate(ctx context.Context, queryContext table.QueryContext) ([]map[string]string, error) {
Expand Down
Loading

0 comments on commit bad7164

Please sign in to comment.