mirror of
https://github.com/fleetdm/fleet
synced 2026-05-05 22:39:17 +00:00
> Related issue: #19886 # Checklist for submitter If some of the following don't apply, delete the relevant line. <!-- Note that API documentation changes are now addressed by the product design team. --> - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://fleetdm.com/docs/contributing/committing-changes#changes-files) for more information. - [x] Added/updated tests - [x] Manual QA for all new/changed functionality - For Orbit and Fleet Desktop changes: - [x] Manual QA must be performed in the three main OSs, macOS, Windows and Linux. - [x] Auto-update manual QA, from released version of component to new version (see [tools/tuf/test](../tools/tuf/test/README.md)).
55 lines
1.4 KiB
Go
55 lines
1.4 KiB
Go
//go:build windows
|
|
|
|
package table
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
cisaudit "github.com/fleetdm/fleet/v4/orbit/pkg/table/cis_audit"
|
|
mdmbridge "github.com/fleetdm/fleet/v4/orbit/pkg/table/mdm"
|
|
"github.com/fleetdm/fleet/v4/orbit/pkg/table/windowsupdatetable"
|
|
"github.com/rs/zerolog/log"
|
|
"golang.org/x/sys/windows/registry"
|
|
|
|
"github.com/osquery/osquery-go"
|
|
"github.com/osquery/osquery-go/plugin/table"
|
|
)
|
|
|
|
func PlatformTables(_ PluginOpts) ([]osquery.OsqueryPlugin, error) {
|
|
plugins := []osquery.OsqueryPlugin{
|
|
// Fleet tables
|
|
table.NewPlugin("cis_audit", cisaudit.Columns(), cisaudit.Generate),
|
|
|
|
windowsupdatetable.TablePlugin(windowsupdatetable.UpdatesTable, log.Logger), // table name is "windows_updates"
|
|
}
|
|
|
|
windowsServer, err := IsWindowsServer()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if !windowsServer {
|
|
plugins = append(plugins, table.NewPlugin("mdm_bridge", mdmbridge.Columns(), mdmbridge.Generate))
|
|
}
|
|
|
|
return plugins, nil
|
|
}
|
|
|
|
func IsWindowsServer() (bool, error) {
|
|
k, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows NT\CurrentVersion`, registry.QUERY_VALUE)
|
|
if err != nil {
|
|
return false, fmt.Errorf("windows server check: %w", err)
|
|
}
|
|
defer k.Close()
|
|
|
|
s, _, err := k.GetStringValue("InstallationType")
|
|
if err != nil {
|
|
return false, fmt.Errorf("windows server check: %w", err)
|
|
}
|
|
|
|
if s == "Server" {
|
|
return true, nil
|
|
}
|
|
|
|
return false, nil
|
|
}
|