Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

refactor(cmd): drive forwarding destinations from a registry

Claude4d651f6eb93a
diff --git a/cli/beacon/cmd/endpoint.go b/cli/beacon/cmd/endpoint.go
index ad4b0f4b..84265cb7 100644
--- a/cli/beacon/cmd/endpoint.go
+++ b/cli/beacon/cmd/endpoint.go
@@ -13,24 +13,16 @@ import (
"github.com/spf13/cobra"
- "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/cloudwatch"
endpointconfig "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/config"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/dashboard"
- "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/datadog"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/elastic"
- "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/gcs"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/harness"
endpointhooks "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/hooks"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/integrations/cowork"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/integrations/openclaw"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/integrations/vscode"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/lifecycle"
- "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/rapid7"
- "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/s3"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/schema"
- "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/sentinel"
- "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/sumo"
- "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/wazuh"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/writer"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/version"
)
@@ -168,51 +160,6 @@ var endpointDashboardCmd = &cobra.Command{
RunE: runEndpointDashboard,
}
-var endpointWazuhCmd = &cobra.Command{
- Use: "wazuh",
- Short: "Manage Wazuh integration content",
-}
-
-var endpointElasticCmd = &cobra.Command{
- Use: "elastic",
- Short: "Manage Elasticsearch integration content",
-}
-
-var endpointDatadogCmd = &cobra.Command{
- Use: "datadog",
- Short: "Manage Datadog integration content",
-}
-
-var endpointSumoCmd = &cobra.Command{
- Use: "sumo",
- Short: "Manage Sumo Logic integration content",
-}
-
-var endpointRapid7Cmd = &cobra.Command{
- Use: "rapid7",
- Short: "Manage Rapid7 InsightIDR integration content",
-}
-
-var endpointS3Cmd = &cobra.Command{
- Use: "s3",
- Short: "Manage AWS S3 forwarding content",
-}
-
-var endpointCloudWatchCmd = &cobra.Command{
- Use: "cloudwatch",
- Short: "Manage AWS CloudWatch Logs forwarding content",
-}
-
-var endpointGCSCmd = &cobra.Command{
- Use: "gcs",
- Short: "Manage Google Cloud Storage forwarding content",
-}
-
-var endpointSentinelCmd = &cobra.Command{
- Use: "sentinel",
- Short: "Manage Microsoft Sentinel integration content",
-}
-
var endpointIntegrationsCmd = &cobra.Command{
Use: "integrations",
Short: "Manage admin-configured endpoint integrations",
@@ -466,277 +413,6 @@ var endpointVSCodeValidateCmd = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) error { return runEndpointVSCodeValidate() },
}
-var endpointWazuhPrintConfigCmd = &cobra.Command{
- Use: "print-config",
- Short: "Print a Wazuh localfile snippet",
- Run: func(cmd *cobra.Command, args []string) {
- cfg := loadOrDefaultConfig()
- fmt.Print(wazuh.LocalfileSnippet(cfg.LogPath))
- },
-}
-
-var endpointWazuhInstallPackCmd = &cobra.Command{
- Use: "install-pack",
- Short: "Write Wazuh rules and config snippets to a directory",
- SilenceUsage: true,
- RunE: func(cmd *cobra.Command, args []string) error {
- if endpointOpts.outputDir == "" {
- return fmt.Errorf("--output is required")
- }
- cfg := loadOrDefaultConfig()
- if err := wazuh.InstallPack(endpointOpts.outputDir, cfg.LogPath); err != nil {
- return err
- }
- fmt.Printf("Wazuh content pack written to %s\n", endpointOpts.outputDir)
- return nil
- },
-}
-
-var endpointWazuhValidateCmd = &cobra.Command{
- Use: "validate",
- Short: "Write and describe a Wazuh validation event",
- SilenceUsage: true,
- RunE: runEndpointWazuhValidate,
-}
-
-var endpointElasticPrintConfigCmd = &cobra.Command{
- Use: "print-config",
- Short: "Print a Filebeat input for Beacon endpoint events",
- SilenceUsage: true,
- RunE: func(cmd *cobra.Command, args []string) error {
- cfg := loadOrDefaultConfig()
- snippet, err := elastic.InputSnippet(cfg.LogPath)
- if err != nil {
- return err
- }
- fmt.Print(snippet)
- return nil
- },
-}
-
-var endpointElasticInstallPackCmd = &cobra.Command{
- Use: "install-pack",
- Short: "Write Elasticsearch templates, pipeline, and Filebeat content to a directory",
- SilenceUsage: true,
- RunE: runEndpointElasticInstallPack,
-}
-
-var endpointElasticUpCmd = &cobra.Command{
- Use: "up",
- Short: "Start a local Elasticsearch, Kibana, and Filebeat stack",
- SilenceUsage: true,
- RunE: func(cmd *cobra.Command, args []string) error {
- return runEndpointElasticUp(cmd.Context())
- },
-}
-
-var endpointElasticDownCmd = &cobra.Command{
- Use: "down",
- Short: "Stop the local Elasticsearch stack",
- SilenceUsage: true,
- RunE: func(cmd *cobra.Command, args []string) error {
- return runEndpointElasticDown(cmd.Context())
- },
-}
-
-var endpointDatadogPrintConfigCmd = &cobra.Command{
- Use: "print-config",
- Short: "Print a Datadog Agent custom log config for Beacon endpoint events",
- SilenceUsage: true,
- RunE: func(cmd *cobra.Command, args []string) error {
- cfg := loadOrDefaultConfig()
- snippet, err := datadog.ConfigSnippet(cfg.LogPath)
- if err != nil {
- return err
- }
- fmt.Print(snippet)
- return nil
- },
-}
-
-var endpointDatadogInstallPackCmd = &cobra.Command{
- Use: "install-pack",
- Short: "Write Datadog Agent custom log integration content to a directory",
- SilenceUsage: true,
- RunE: runEndpointDatadogInstallPack,
-}
-
-var endpointDatadogValidateCmd = &cobra.Command{
- Use: "validate",
- Short: "Write and describe a Datadog validation event",
- SilenceUsage: true,
- RunE: runEndpointDatadogValidate,
-}
-
-var endpointSumoPrintConfigCmd = &cobra.Command{
- Use: "print-config",
- Short: "Print a Sumo HTTP Source smoke-test uploader for Beacon endpoint events",
- SilenceUsage: true,
- RunE: func(cmd *cobra.Command, args []string) error {
- cfg := loadOrDefaultConfig()
- snippet, err := sumo.UploadSmokeTest(cfg.LogPath)
- if err != nil {
- return err
- }
- fmt.Print(snippet)
- return nil
- },
-}
-
-var endpointSumoInstallPackCmd = &cobra.Command{
- Use: "install-pack",
- Short: "Write Sumo Logic HTTP Source forwarding content to a directory",
- SilenceUsage: true,
- RunE: runEndpointSumoInstallPack,
-}
-
-var endpointSumoValidateCmd = &cobra.Command{
- Use: "validate",
- Short: "Write and describe a Sumo Logic validation event",
- SilenceUsage: true,
- RunE: runEndpointSumoValidate,
-}
-
-var endpointRapid7PrintConfigCmd = &cobra.Command{
- Use: "print-config",
- Short: "Print a Rapid7 Custom Logs webhook smoke-test uploader for Beacon endpoint events",
- SilenceUsage: true,
- RunE: func(cmd *cobra.Command, args []string) error {
- cfg := loadOrDefaultConfig()
- snippet, err := rapid7.UploadSmokeTest(cfg.LogPath)
- if err != nil {
- return err
- }
- fmt.Print(snippet)
- return nil
- },
-}
-
-var endpointRapid7InstallPackCmd = &cobra.Command{
- Use: "install-pack",
- Short: "Write Rapid7 InsightIDR Custom Logs forwarding content to a directory",
- SilenceUsage: true,
- RunE: runEndpointRapid7InstallPack,
-}
-
-var endpointRapid7ValidateCmd = &cobra.Command{
- Use: "validate",
- Short: "Write and describe a Rapid7 InsightIDR validation event",
- SilenceUsage: true,
- RunE: runEndpointRapid7Validate,
-}
-
-var endpointS3PrintConfigCmd = &cobra.Command{
- Use: "print-config",
- Short: "Print an AWS CLI S3 smoke-test uploader for Beacon endpoint events",
- SilenceUsage: true,
- RunE: func(cmd *cobra.Command, args []string) error {
- cfg := loadOrDefaultConfig()
- snippet, err := s3.UploadSmokeTest(cfg.LogPath)
- if err != nil {
- return err
- }
- fmt.Print(snippet)
- return nil
- },
-}
-
-var endpointS3InstallPackCmd = &cobra.Command{
- Use: "install-pack",
- Short: "Write AWS S3 forwarding content to a directory",
- SilenceUsage: true,
- RunE: runEndpointS3InstallPack,
-}
-
-var endpointS3ValidateCmd = &cobra.Command{
- Use: "validate",
- Short: "Write and describe an AWS S3 validation event",
- SilenceUsage: true,
- RunE: runEndpointS3Validate,
-}
-
-var endpointCloudWatchPrintConfigCmd = &cobra.Command{
- Use: "print-config",
- Short: "Print a Vector config for AWS CloudWatch Logs forwarding",
- SilenceUsage: true,
- RunE: func(cmd *cobra.Command, args []string) error {
- cfg := loadOrDefaultConfig()
- snippet, err := cloudwatch.ConfigSnippet(cfg.LogPath)
- if err != nil {
- return err
- }
- fmt.Print(snippet)
- return nil
- },
-}
-
-var endpointCloudWatchInstallPackCmd = &cobra.Command{
- Use: "install-pack",
- Short: "Write AWS CloudWatch Logs forwarding content to a directory",
- SilenceUsage: true,
- RunE: runEndpointCloudWatchInstallPack,
-}
-
-var endpointCloudWatchValidateCmd = &cobra.Command{
- Use: "validate",
- Short: "Write and describe an AWS CloudWatch Logs validation event",
- SilenceUsage: true,
- RunE: runEndpointCloudWatchValidate,
-}
-
-var endpointGCSPrintConfigCmd = &cobra.Command{
- Use: "print-config",
- Short: "Print a Google Cloud Storage smoke-test uploader for Beacon endpoint events",
- SilenceUsage: true,
- RunE: func(cmd *cobra.Command, args []string) error {
- cfg := loadOrDefaultConfig()
- snippet, err := gcs.UploadSmokeTest(cfg.LogPath)
- if err != nil {
- return err
- }
- fmt.Print(snippet)
- return nil
- },
-}
-
-var endpointGCSInstallPackCmd = &cobra.Command{
- Use: "install-pack",
- Short: "Write Google Cloud Storage forwarding content to a directory",
- SilenceUsage: true,
- RunE: runEndpointGCSInstallPack,
-}
-
-var endpointGCSValidateCmd = &cobra.Command{
- Use: "validate",
- Short: "Write and describe a Google Cloud Storage validation event",
- SilenceUsage: true,
- RunE: runEndpointGCSValidate,
-}
-
-var endpointSentinelPrintConfigCmd = &cobra.Command{
- Use: "print-config",
- Short: "Print a Sentinel DCR transform for Beacon endpoint events",
- Run: func(cmd *cobra.Command, args []string) {
- cfg := loadOrDefaultConfig()
- fmt.Printf("# Azure Monitor Agent file pattern: %s\n", cfg.LogPath)
- fmt.Print(sentinel.DCRTransform())
- },
-}
-
-var endpointSentinelInstallPackCmd = &cobra.Command{
- Use: "install-pack",
- Short: "Write Microsoft Sentinel forwarding content to a directory",
- SilenceUsage: true,
- RunE: runEndpointSentinelInstallPack,
-}
-
-var endpointSentinelValidateCmd = &cobra.Command{
- Use: "validate",
- Short: "Write and describe a Microsoft Sentinel validation event",
- SilenceUsage: true,
- RunE: runEndpointSentinelValidate,
-}
-
func init() {
rootCmd.AddCommand(endpointCmd)
rootCmd.AddCommand(topLevelDoctorCmd)
@@ -753,49 +429,15 @@ func init() {
endpointCmd.AddCommand(endpointUninstallCmd)
endpointCmd.AddCommand(endpointRepairCmd)
endpointCmd.AddCommand(endpointDashboardCmd)
- endpointCmd.AddCommand(endpointWazuhCmd)
- endpointCmd.AddCommand(endpointElasticCmd)
- endpointCmd.AddCommand(endpointDatadogCmd)
- endpointCmd.AddCommand(endpointSumoCmd)
- endpointCmd.AddCommand(endpointRapid7Cmd)
- endpointCmd.AddCommand(endpointS3Cmd)
- endpointCmd.AddCommand(endpointCloudWatchCmd)
- endpointCmd.AddCommand(endpointGCSCmd)
- endpointCmd.AddCommand(endpointSentinelCmd)
+ for _, c := range buildDestinationCommands() {
+ endpointCmd.AddCommand(c)
+ }
endpointCmd.AddCommand(endpointIntegrationsCmd)
endpointCmd.AddCommand(endpointHooksCmd)
endpointCmd.AddCommand(endpointConfigCmd)
endpointConfigCmd.AddCommand(endpointConfigShowCmd)
endpointConfigCmd.AddCommand(endpointConfigValidateCmd)
endpointConfigCmd.AddCommand(endpointConfigSetRetentionCmd)
- endpointWazuhCmd.AddCommand(endpointWazuhPrintConfigCmd)
- endpointWazuhCmd.AddCommand(endpointWazuhInstallPackCmd)
- endpointWazuhCmd.AddCommand(endpointWazuhValidateCmd)
- endpointElasticCmd.AddCommand(endpointElasticPrintConfigCmd)
- endpointElasticCmd.AddCommand(endpointElasticInstallPackCmd)
- endpointElasticCmd.AddCommand(endpointElasticUpCmd)
- endpointElasticCmd.AddCommand(endpointElasticDownCmd)
- endpointDatadogCmd.AddCommand(endpointDatadogPrintConfigCmd)
- endpointDatadogCmd.AddCommand(endpointDatadogInstallPackCmd)
- endpointDatadogCmd.AddCommand(endpointDatadogValidateCmd)
- endpointSumoCmd.AddCommand(endpointSumoPrintConfigCmd)
- endpointSumoCmd.AddCommand(endpointSumoInstallPackCmd)
- endpointSumoCmd.AddCommand(endpointSumoValidateCmd)
- endpointRapid7Cmd.AddCommand(endpointRapid7PrintConfigCmd)
- endpointRapid7Cmd.AddCommand(endpointRapid7InstallPackCmd)
- endpointRapid7Cmd.AddCommand(endpointRapid7ValidateCmd)
- endpointS3Cmd.AddCommand(endpointS3PrintConfigCmd)
- endpointS3Cmd.AddCommand(endpointS3InstallPackCmd)
- endpointS3Cmd.AddCommand(endpointS3ValidateCmd)
- endpointCloudWatchCmd.AddCommand(endpointCloudWatchPrintConfigCmd)
- endpointCloudWatchCmd.AddCommand(endpointCloudWatchInstallPackCmd)
- endpointCloudWatchCmd.AddCommand(endpointCloudWatchValidateCmd)
- endpointGCSCmd.AddCommand(endpointGCSPrintConfigCmd)
- endpointGCSCmd.AddCommand(endpointGCSInstallPackCmd)
- endpointGCSCmd.AddCommand(endpointGCSValidateCmd)
- endpointSentinelCmd.AddCommand(endpointSentinelPrintConfigCmd)
- endpointSentinelCmd.AddCommand(endpointSentinelInstallPackCmd)
- endpointSentinelCmd.AddCommand(endpointSentinelValidateCmd)
endpointIntegrationsCmd.AddCommand(endpointIntegrationsValidateCmd)
endpointIntegrationsCmd.AddCommand(endpointCoworkCmd)
endpointIntegrationsCmd.AddCommand(endpointOpenClawCmd)
@@ -869,66 +511,6 @@ func init() {
endpointBundleDiagnosticsCmd.Flags().BoolVar(&endpointOpts.includeRawEvents, "include-raw-events", false, "Include raw runtime JSONL events")
endpointIntegrationsValidateCmd.Flags().BoolVar(&endpointOpts.allTargets, "all", false, "Validate all supported admin integrations")
endpointIntegrationsValidateCmd.Flags().BoolVar(&endpointOpts.jsonOutput, "json", false, "Print validation as JSON")
- endpointWazuhPrintConfigCmd.Flags().BoolVar(&endpointOpts.userMode, "user", true, "Use per-user endpoint paths")
- endpointWazuhPrintConfigCmd.Flags().BoolVar(&endpointOpts.systemMode, "system", false, "Use system endpoint paths and launch daemon")
- endpointWazuhPrintConfigCmd.Flags().StringVar(&endpointOpts.logPath, "log-path", "", "Runtime JSONL log path")
- endpointWazuhInstallPackCmd.Flags().StringVar(&endpointOpts.outputDir, "output", "", "Output directory for Wazuh content pack")
- endpointWazuhInstallPackCmd.Flags().BoolVar(&endpointOpts.userMode, "user", true, "Use per-user endpoint paths")
- endpointWazuhInstallPackCmd.Flags().BoolVar(&endpointOpts.systemMode, "system", false, "Use system endpoint paths and launch daemon")
- endpointWazuhInstallPackCmd.Flags().StringVar(&endpointOpts.logPath, "log-path", "", "Runtime JSONL log path")
- endpointWazuhValidateCmd.Flags().BoolVar(&endpointOpts.userMode, "user", true, "Use per-user endpoint paths")
- endpointWazuhValidateCmd.Flags().BoolVar(&endpointOpts.systemMode, "system", false, "Use system endpoint paths and launch daemon")
- endpointWazuhValidateCmd.Flags().StringVar(&endpointOpts.logPath, "log-path", "", "Runtime JSONL log path")
- for _, c := range []*cobra.Command{endpointElasticPrintConfigCmd, endpointElasticInstallPackCmd, endpointElasticUpCmd, endpointElasticDownCmd} {
- c.Flags().BoolVar(&endpointOpts.userMode, "user", true, "Use per-user endpoint paths")
- c.Flags().BoolVar(&endpointOpts.systemMode, "system", false, "Use system endpoint paths and launch daemon")
- c.Flags().StringVar(&endpointOpts.logPath, "log-path", "", "Runtime JSONL log path")
- }
- endpointElasticInstallPackCmd.Flags().StringVar(&endpointOpts.outputDir, "output", "", "Output directory for Elasticsearch content pack")
- endpointElasticUpCmd.Flags().StringVar(&endpointOpts.elasticPackDir, "pack-dir", elastic.DefaultOutputDir, "Elasticsearch pack directory")
- endpointElasticDownCmd.Flags().StringVar(&endpointOpts.elasticPackDir, "pack-dir", elastic.DefaultOutputDir, "Elasticsearch pack directory")
- for _, c := range []*cobra.Command{endpointDatadogPrintConfigCmd, endpointDatadogInstallPackCmd, endpointDatadogValidateCmd} {
- c.Flags().BoolVar(&endpointOpts.userMode, "user", true, "Use per-user endpoint paths")
- c.Flags().BoolVar(&endpointOpts.systemMode, "system", false, "Use system endpoint paths and launch daemon")
- c.Flags().StringVar(&endpointOpts.logPath, "log-path", "", "Runtime JSONL log path")
- }
- endpointDatadogInstallPackCmd.Flags().StringVar(&endpointOpts.outputDir, "output", "", "Output directory for Datadog content pack")
- for _, c := range []*cobra.Command{endpointSumoPrintConfigCmd, endpointSumoInstallPackCmd, endpointSumoValidateCmd} {
- c.Flags().BoolVar(&endpointOpts.userMode, "user", true, "Use per-user endpoint paths")
- c.Flags().BoolVar(&endpointOpts.systemMode, "system", false, "Use system endpoint paths and launch daemon")
- c.Flags().StringVar(&endpointOpts.logPath, "log-path", "", "Runtime JSONL log path")
- }
- endpointSumoInstallPackCmd.Flags().StringVar(&endpointOpts.outputDir, "output", "", "Output directory for Sumo Logic content pack")
- for _, c := range []*cobra.Command{endpointRapid7PrintConfigCmd, endpointRapid7InstallPackCmd, endpointRapid7ValidateCmd} {
- c.Flags().BoolVar(&endpointOpts.userMode, "user", true, "Use per-user endpoint paths")
- c.Flags().BoolVar(&endpointOpts.systemMode, "system", false, "Use system endpoint paths and launch daemon")
- c.Flags().StringVar(&endpointOpts.logPath, "log-path", "", "Runtime JSONL log path")
- }
- endpointRapid7InstallPackCmd.Flags().StringVar(&endpointOpts.outputDir, "output", "", "Output directory for Rapid7 InsightIDR content pack")
- for _, c := range []*cobra.Command{endpointS3PrintConfigCmd, endpointS3InstallPackCmd, endpointS3ValidateCmd} {
- c.Flags().BoolVar(&endpointOpts.userMode, "user", true, "Use per-user endpoint paths")
- c.Flags().BoolVar(&endpointOpts.systemMode, "system", false, "Use system endpoint paths and launch daemon")
- c.Flags().StringVar(&endpointOpts.logPath, "log-path", "", "Runtime JSONL log path")
- }
- endpointS3InstallPackCmd.Flags().StringVar(&endpointOpts.outputDir, "output", "", "Output directory for AWS S3 content pack")
- for _, c := range []*cobra.Command{endpointCloudWatchPrintConfigCmd, endpointCloudWatchInstallPackCmd, endpointCloudWatchValidateCmd} {
- c.Flags().BoolVar(&endpointOpts.userMode, "user", true, "Use per-user endpoint paths")
- c.Flags().BoolVar(&endpointOpts.systemMode, "system", false, "Use system endpoint paths and launch daemon")
- c.Flags().StringVar(&endpointOpts.logPath, "log-path", "", "Runtime JSONL log path")
- }
- endpointCloudWatchInstallPackCmd.Flags().StringVar(&endpointOpts.outputDir, "output", "", "Output directory for AWS CloudWatch Logs content pack")
- for _, c := range []*cobra.Command{endpointGCSPrintConfigCmd, endpointGCSInstallPackCmd, endpointGCSValidateCmd} {
- c.Flags().BoolVar(&endpointOpts.userMode, "user", true, "Use per-user endpoint paths")
- c.Flags().BoolVar(&endpointOpts.systemMode, "system", false, "Use system endpoint paths and launch daemon")
- c.Flags().StringVar(&endpointOpts.logPath, "log-path", "", "Runtime JSONL log path")
- }
- endpointGCSInstallPackCmd.Flags().StringVar(&endpointOpts.outputDir, "output", "", "Output directory for Google Cloud Storage content pack")
- for _, c := range []*cobra.Command{endpointSentinelPrintConfigCmd, endpointSentinelInstallPackCmd, endpointSentinelValidateCmd} {
- c.Flags().BoolVar(&endpointOpts.userMode, "user", true, "Use per-user endpoint paths")
- c.Flags().BoolVar(&endpointOpts.systemMode, "system", false, "Use system endpoint paths and launch daemon")
- c.Flags().StringVar(&endpointOpts.logPath, "log-path", "", "Runtime JSONL log path")
- }
- endpointSentinelInstallPackCmd.Flags().StringVar(&endpointOpts.outputDir, "output", "", "Output directory for Microsoft Sentinel content pack")
for _, c := range []*cobra.Command{endpointCoworkPrintConfigCmd, endpointCoworkSetupCmd, endpointCoworkStatusCmd, endpointCoworkValidateCmd} {
c.Flags().BoolVar(&endpointOpts.userMode, "user", true, "Use per-user endpoint paths")
c.Flags().BoolVar(&endpointOpts.systemMode, "system", false, "Use system endpoint paths and launch daemon")
@@ -1374,198 +956,6 @@ func runEndpointHooksStatus(cmd *cobra.Command, args []string) error {
return nil
}
-func runEndpointWazuhValidate(cmd *cobra.Command, args []string) error {
- cfg := loadOrDefaultConfig()
- path, err := writeValidationEvent(cfg, "wazuh")
- if err != nil {
- return err
- }
- fmt.Printf("Validation event written to %s\n", path)
- fmt.Println("Expected Wazuh fields: vendor=beacon product=endpoint-agent event.kind=agent_runtime")
- fmt.Println("Wazuh localfile snippet:")
- fmt.Print(wazuh.LocalfileSnippet(cfg.LogPath))
- fmt.Println("Expected base rule: 100500")
- return nil
-}
-
-func runEndpointDatadogInstallPack(cmd *cobra.Command, args []string) error {
- cfg := loadOrDefaultConfig()
- outputDir := endpointOpts.outputDir
- if outputDir == "" {
- outputDir = datadog.DefaultOutputDir
- }
- if err := datadog.InstallPack(outputDir, cfg.LogPath); err != nil {
- return err
- }
- fmt.Printf("Datadog content pack written to %s\n", outputDir)
- return nil
-}
-
-func runEndpointDatadogValidate(cmd *cobra.Command, args []string) error {
- cfg := loadOrDefaultConfig()
- path, err := writeValidationEvent(cfg, "datadog")
- if err != nil {
- return err
- }
- fmt.Printf("Validation event written to %s\n", path)
- fmt.Println("Expected Datadog fields: service=beacon-endpoint-agent vendor=beacon product=endpoint-agent")
- fmt.Println(`Expected validation query: service:beacon-endpoint-agent "Beacon endpoint datadog validation event"`)
- return nil
-}
-
-func runEndpointSumoInstallPack(cmd *cobra.Command, args []string) error {
- cfg := loadOrDefaultConfig()
- outputDir := endpointOpts.outputDir
- if outputDir == "" {
- outputDir = sumo.DefaultOutputDir
- }
- if err := sumo.InstallPack(outputDir, cfg.LogPath); err != nil {
- return err
- }
- fmt.Printf("Sumo Logic content pack written to %s\n", outputDir)
- return nil
-}
-
-func runEndpointSumoValidate(cmd *cobra.Command, args []string) error {
- cfg := loadOrDefaultConfig()
- path, err := writeValidationEvent(cfg, "sumo")
- if err != nil {
- return err
- }
- fmt.Printf("Validation event written to %s\n", path)
- fmt.Println("Expected Sumo fields: _sourceCategory=security/agentbeacon product=agentbeacon telemetry=ai_agent")
- fmt.Println(`Expected validation query: _sourceCategory=security/agentbeacon "Beacon endpoint Sumo validation event"`)
- return nil
-}
-
-func runEndpointRapid7InstallPack(cmd *cobra.Command, args []string) error {
- cfg := loadOrDefaultConfig()
- outputDir := endpointOpts.outputDir
- if outputDir == "" {
- outputDir = rapid7.DefaultOutputDir
- }
- if err := rapid7.InstallPack(outputDir, cfg.LogPath); err != nil {
- return err
- }
- fmt.Printf("Rapid7 InsightIDR content pack written to %s\n", outputDir)
- return nil
-}
-
-func runEndpointRapid7Validate(cmd *cobra.Command, args []string) error {
- cfg := loadOrDefaultConfig()
- path, err := writeValidationEvent(cfg, "rapid7")
- if err != nil {
- return err
- }
- fmt.Printf("Validation event written to %s\n", path)
- fmt.Println("Expected Rapid7 fields: vendor=beacon product=endpoint-agent destination.type=rapid7")
- fmt.Println(`Expected validation query: "Beacon endpoint Rapid7 validation event"`)
- return nil
-}
-
-func runEndpointS3InstallPack(cmd *cobra.Command, args []string) error {
- cfg := loadOrDefaultConfig()
- outputDir := endpointOpts.outputDir
- if outputDir == "" {
- outputDir = s3.DefaultOutputDir
- }
- if err := s3.InstallPack(outputDir, cfg.LogPath); err != nil {
- return err
- }
- fmt.Printf("AWS S3 content pack written to %s\n", outputDir)
- return nil
-}
-
-func runEndpointS3Validate(cmd *cobra.Command, args []string) error {
- cfg := loadOrDefaultConfig()
- path, err := writeValidationEvent(cfg, "s3")
- if err != nil {
- return err
- }
- fmt.Printf("Validation event written to %s\n", path)
- fmt.Println("Expected S3 fields: vendor=beacon product=endpoint-agent destination.type=s3 destination.mode=aws_s3_jsonl")
- fmt.Println(`Confirm delivery with AWS CLI: aws s3 ls "s3://${BEACON_S3_BUCKET}/${BEACON_S3_PREFIX}/" --recursive`)
- fmt.Println(`Inspect an object with AWS CLI: aws s3 cp "s3://${BEACON_S3_BUCKET}/${BEACON_S3_PREFIX}/date=<date>/<object>.jsonl.gz" - | gzip -dc | grep "Beacon endpoint S3 validation event"`)
- return nil
-}
-
-func runEndpointCloudWatchInstallPack(cmd *cobra.Command, args []string) error {
- cfg := loadOrDefaultConfig()
- outputDir := endpointOpts.outputDir
- if outputDir == "" {
- outputDir = cloudwatch.DefaultOutputDir
- }
- if err := cloudwatch.InstallPack(outputDir, cfg.LogPath); err != nil {
- return err
- }
- fmt.Printf("AWS CloudWatch Logs content pack written to %s\n", outputDir)
- return nil
-}
-
-func runEndpointCloudWatchValidate(cmd *cobra.Command, args []string) error {
- cfg := loadOrDefaultConfig()
- path, err := writeValidationEvent(cfg, "cloudwatch")
- if err != nil {
- return err
- }
- fmt.Printf("Validation event written to %s\n", path)
- fmt.Println("Expected AWS CloudWatch Logs fields: vendor=beacon product=endpoint-agent destination.type=cloudwatch destination.mode=aws_cloudwatch_logs")
- fmt.Println(`Confirm delivery with AWS CLI: aws logs filter-log-events --log-group-name "$BEACON_CLOUDWATCH_LOG_GROUP" --filter-pattern '"Beacon endpoint AWS CloudWatch Logs validation event"' --region "$AWS_REGION"`)
- fmt.Println(`CloudWatch Logs Insights query: fields @timestamp, vendor, product, destination.type, destination.mode, message | filter message like /Beacon endpoint AWS CloudWatch Logs validation event/ | sort @timestamp desc | limit 20`)
- return nil
-}
-
-func runEndpointGCSInstallPack(cmd *cobra.Command, args []string) error {
- cfg := loadOrDefaultConfig()
- outputDir := endpointOpts.outputDir
- if outputDir == "" {
- outputDir = gcs.DefaultOutputDir
- }
- if err := gcs.InstallPack(outputDir, cfg.LogPath); err != nil {
- return err
- }
- fmt.Printf("Google Cloud Storage content pack written to %s\n", outputDir)
- return nil
-}
-
-func runEndpointGCSValidate(cmd *cobra.Command, args []string) error {
- cfg := loadOrDefaultConfig()
- path, err := writeValidationEvent(cfg, "gcs")
- if err != nil {
- return err
- }
- fmt.Printf("Validation event written to %s\n", path)
- fmt.Println("Expected GCS fields: vendor=beacon product=endpoint-agent destination.type=gcs destination.mode=google_cloud_storage_jsonl")
- fmt.Println(`Confirm delivery with Google Cloud CLI: gcloud storage ls "gs://${BEACON_GCS_BUCKET}/${BEACON_GCS_PREFIX}/**"`)
- fmt.Println(`Inspect an object with Google Cloud CLI: gcloud storage cat "gs://${BEACON_GCS_BUCKET}/${BEACON_GCS_PREFIX}/date=<date>/<object>.jsonl.gz" | gzip -dc | grep "Beacon endpoint GCS validation event"`)
- return nil
-}
-
-func runEndpointSentinelInstallPack(cmd *cobra.Command, args []string) error {
- cfg := loadOrDefaultConfig()
- outputDir := endpointOpts.outputDir
- if outputDir == "" {
- outputDir = sentinel.DefaultOutputDir
- }
- if err := sentinel.InstallPack(outputDir, cfg.LogPath); err != nil {
- return err
- }
- fmt.Printf("Microsoft Sentinel content pack written to %s\n", outputDir)
- return nil
-}
-
-func runEndpointSentinelValidate(cmd *cobra.Command, args []string) error {
- cfg := loadOrDefaultConfig()
- path, err := writeValidationEvent(cfg, "sentinel")
- if err != nil {
- return err
- }
- fmt.Printf("Validation event written to %s\n", path)
- fmt.Println("Expected Sentinel table: BeaconRuntime_CL")
- fmt.Println(`Expected validation query: BeaconRuntime_CL | where Message has "Beacon endpoint Sentinel validation event"`)
- return nil
-}
-
func runEndpointOpenClawValidate() error {
cfg := loadOrDefaultConfig()
setup := func() {
@@ -1673,19 +1063,6 @@ func runEndpointVSCodeValidate() error {
return nil
}
-func runEndpointElasticInstallPack(cmd *cobra.Command, args []string) error {
- cfg := loadOrDefaultConfig()
- outputDir := endpointOpts.outputDir
- if outputDir == "" {
- outputDir = elastic.DefaultOutputDir
- }
- if err := elastic.InstallPack(outputDir, cfg.LogPath); err != nil {
- return err
- }
- fmt.Printf("Elasticsearch content pack written to %s\n", outputDir)
- return nil
-}
-
func runEndpointElasticUp(ctx context.Context) error {
if runtime.GOOS != "darwin" {
return fmt.Errorf("beacon endpoint elastic up is currently macOS-only")
diff --git a/cli/beacon/cmd/endpoint_destinations.go b/cli/beacon/cmd/endpoint_destinations.go
new file mode 100644
index 00000000..57e39622
--- /dev/null
+++ b/cli/beacon/cmd/endpoint_destinations.go
@@ -0,0 +1,418 @@
+package cmd
+
+import (
+ "fmt"
+
+ "github.com/spf13/cobra"
+
+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/cloudwatch"
+ endpointconfig "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/config"
+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/datadog"
+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/elastic"
+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/gcs"
+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/rapid7"
+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/s3"
+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/sentinel"
+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/sumo"
+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/wazuh"
+)
+
+// siemDestination describes one local/customer-managed forwarding destination
+// and the uniform `print-config` / `install-pack` / `validate` verbs it exposes
+// under `beacon endpoint <name>`. It is the single source of truth for the
+// destination command tree (built by buildDestinationCommands) and for the
+// synthetic validation-event metadata consumed by syntheticEvent.
+//
+// Adding a destination means adding a table row plus its content-pack package;
+// non-uniform verbs (such as elastic's local-stack up/down) attach through the
+// extra hook.
+type siemDestination struct {
+ // name is the canonical destination id. It is the command group's Use name
+ // and the destination passed to writeValidationEvent / syntheticEvent.
+ name string
+ short string
+
+ printConfig *destPrintConfig
+ installPack *destInstallPack
+ validate *destValidate
+
+ // extra attaches non-uniform subcommands to the group (e.g. elastic up/down).
+ extra func(group *cobra.Command)
+}
+
+type destPrintConfig struct {
+ short string
+ // render returns the snippet to print for `print-config`. Destinations whose
+ // underlying helper cannot fail wrap it to return a nil error.
+ render func(cfg endpointconfig.Config) (string, error)
+}
+
+type destInstallPack struct {
+ short string
+ // defaultOutputDir is used when --output is omitted. An empty value makes
+ // --output required.
+ defaultOutputDir string
+ // successLabel is printed verbatim followed by the resolved output directory.
+ successLabel string
+ outputFlagHelp string
+ install func(outputDir, logPath string) error
+}
+
+type destValidate struct {
+ short string
+ // mode and message populate the synthetic validation event for this
+ // destination (see syntheticEvent).
+ mode string
+ message string
+ // print emits the post-write guidance lines shown after the validation event
+ // is written.
+ print func(cfg endpointconfig.Config)
+}
+
+// siemDestinations is the registry of forwarding destinations. Order does not
+// affect help or generated docs (cobra sorts commands), but is kept stable for
+// readability.
+var siemDestinations = []siemDestination{
+ {
+ name: "wazuh",
+ short: "Manage Wazuh integration content",
+ printConfig: &destPrintConfig{
+ short: "Print a Wazuh localfile snippet",
+ render: func(cfg endpointconfig.Config) (string, error) {
+ return wazuh.LocalfileSnippet(cfg.LogPath), nil
+ },
+ },
+ installPack: &destInstallPack{
+ short: "Write Wazuh rules and config snippets to a directory",
+ successLabel: "Wazuh content pack written to ",
+ outputFlagHelp: "Output directory for Wazuh content pack",
+ install: wazuh.InstallPack,
+ },
+ validate: &destValidate{
+ short: "Write and describe a Wazuh validation event",
+ mode: "localfile",
+ message: "Beacon endpoint Wazuh validation event",
+ print: func(cfg endpointconfig.Config) {
+ fmt.Println("Expected Wazuh fields: vendor=beacon product=endpoint-agent event.kind=agent_runtime")
+ fmt.Println("Wazuh localfile snippet:")
+ fmt.Print(wazuh.LocalfileSnippet(cfg.LogPath))
+ fmt.Println("Expected base rule: 100500")
+ },
+ },
+ },
+ {
+ name: "elastic",
+ short: "Manage Elasticsearch integration content",
+ printConfig: &destPrintConfig{
+ short: "Print a Filebeat input for Beacon endpoint events",
+ render: func(cfg endpointconfig.Config) (string, error) { return elastic.InputSnippet(cfg.LogPath) },
+ },
+ installPack: &destInstallPack{
+ short: "Write Elasticsearch templates, pipeline, and Filebeat content to a directory",
+ defaultOutputDir: elastic.DefaultOutputDir,
+ successLabel: "Elasticsearch content pack written to ",
+ outputFlagHelp: "Output directory for Elasticsearch content pack",
+ install: elastic.InstallPack,
+ },
+ // elastic has no validate verb; it adds the local-stack up/down commands.
+ extra: func(group *cobra.Command) {
+ up := &cobra.Command{
+ Use: "up",
+ Short: "Start a local Elasticsearch, Kibana, and Filebeat stack",
+ SilenceUsage: true,
+ RunE: func(cmd *cobra.Command, args []string) error { return runEndpointElasticUp(cmd.Context()) },
+ }
+ down := &cobra.Command{
+ Use: "down",
+ Short: "Stop the local Elasticsearch stack",
+ SilenceUsage: true,
+ RunE: func(cmd *cobra.Command, args []string) error { return runEndpointElasticDown(cmd.Context()) },
+ }
+ addEndpointPathFlags(up)
+ addEndpointPathFlags(down)
+ up.Flags().StringVar(&endpointOpts.elasticPackDir, "pack-dir", elastic.DefaultOutputDir, "Elasticsearch pack directory")
+ down.Flags().StringVar(&endpointOpts.elasticPackDir, "pack-dir", elastic.DefaultOutputDir, "Elasticsearch pack directory")
+ group.AddCommand(up)
+ group.AddCommand(down)
+ },
+ },
+ {
+ name: "datadog",
+ short: "Manage Datadog integration content",
+ printConfig: &destPrintConfig{
+ short: "Print a Datadog Agent custom log config for Beacon endpoint events",
+ render: func(cfg endpointconfig.Config) (string, error) { return datadog.ConfigSnippet(cfg.LogPath) },
+ },
+ installPack: &destInstallPack{
+ short: "Write Datadog Agent custom log integration content to a directory",
+ defaultOutputDir: datadog.DefaultOutputDir,
+ successLabel: "Datadog content pack written to ",
+ outputFlagHelp: "Output directory for Datadog content pack",
+ install: datadog.InstallPack,
+ },
+ validate: &destValidate{
+ short: "Write and describe a Datadog validation event",
+ mode: "agent_file",
+ message: "Beacon endpoint datadog validation event",
+ print: func(cfg endpointconfig.Config) {
+ fmt.Println("Expected Datadog fields: service=beacon-endpoint-agent vendor=beacon product=endpoint-agent")
+ fmt.Println(`Expected validation query: service:beacon-endpoint-agent "Beacon endpoint datadog validation event"`)
+ },
+ },
+ },
+ {
+ name: "sumo",
+ short: "Manage Sumo Logic integration content",
+ printConfig: &destPrintConfig{
+ short: "Print a Sumo HTTP Source smoke-test uploader for Beacon endpoint events",
+ render: func(cfg endpointconfig.Config) (string, error) { return sumo.UploadSmokeTest(cfg.LogPath) },
+ },
+ installPack: &destInstallPack{
+ short: "Write Sumo Logic HTTP Source forwarding content to a directory",
+ defaultOutputDir: sumo.DefaultOutputDir,
+ successLabel: "Sumo Logic content pack written to ",
+ outputFlagHelp: "Output directory for Sumo Logic content pack",
+ install: sumo.InstallPack,
+ },
+ validate: &destValidate{
+ short: "Write and describe a Sumo Logic validation event",
+ mode: "http_source_jsonl",
+ message: "Beacon endpoint Sumo validation event",
+ print: func(cfg endpointconfig.Config) {
+ fmt.Println("Expected Sumo fields: _sourceCategory=security/agentbeacon product=agentbeacon telemetry=ai_agent")
+ fmt.Println(`Expected validation query: _sourceCategory=security/agentbeacon "Beacon endpoint Sumo validation event"`)
+ },
+ },
+ },
+ {
+ name: "rapid7",
+ short: "Manage Rapid7 InsightIDR integration content",
+ printConfig: &destPrintConfig{
+ short: "Print a Rapid7 Custom Logs webhook smoke-test uploader for Beacon endpoint events",
+ render: func(cfg endpointconfig.Config) (string, error) { return rapid7.UploadSmokeTest(cfg.LogPath) },
+ },
+ installPack: &destInstallPack{
+ short: "Write Rapid7 InsightIDR Custom Logs forwarding content to a directory",
+ defaultOutputDir: rapid7.DefaultOutputDir,
+ successLabel: "Rapid7 InsightIDR content pack written to ",
+ outputFlagHelp: "Output directory for Rapid7 InsightIDR content pack",
+ install: rapid7.InstallPack,
+ },
+ validate: &destValidate{
+ short: "Write and describe a Rapid7 InsightIDR validation event",
+ mode: "custom_logs_webhook_ndjson",
+ message: "Beacon endpoint Rapid7 validation event",
+ print: func(cfg endpointconfig.Config) {
+ fmt.Println("Expected Rapid7 fields: vendor=beacon product=endpoint-agent destination.type=rapid7")
+ fmt.Println(`Expected validation query: "Beacon endpoint Rapid7 validation event"`)
+ },
+ },
+ },
+ {
+ name: "s3",
+ short: "Manage AWS S3 forwarding content",
+ printConfig: &destPrintConfig{
+ short: "Print an AWS CLI S3 smoke-test uploader for Beacon endpoint events",
+ render: func(cfg endpointconfig.Config) (string, error) { return s3.UploadSmokeTest(cfg.LogPath) },
+ },
+ installPack: &destInstallPack{
+ short: "Write AWS S3 forwarding content to a directory",
+ defaultOutputDir: s3.DefaultOutputDir,
+ successLabel: "AWS S3 content pack written to ",
+ outputFlagHelp: "Output directory for AWS S3 content pack",
+ install: s3.InstallPack,
+ },
+ validate: &destValidate{
+ short: "Write and describe an AWS S3 validation event",
+ mode: "aws_s3_jsonl",
+ message: "Beacon endpoint S3 validation event",
+ print: func(cfg endpointconfig.Config) {
+ fmt.Println("Expected S3 fields: vendor=beacon product=endpoint-agent destination.type=s3 destination.mode=aws_s3_jsonl")
+ fmt.Println(`Confirm delivery with AWS CLI: aws s3 ls "s3://${BEACON_S3_BUCKET}/${BEACON_S3_PREFIX}/" --recursive`)
+ fmt.Println(`Inspect an object with AWS CLI: aws s3 cp "s3://${BEACON_S3_BUCKET}/${BEACON_S3_PREFIX}/date=<date>/<object>.jsonl.gz" - | gzip -dc | grep "Beacon endpoint S3 validation event"`)
+ },
+ },
+ },
+ {
+ name: "cloudwatch",
+ short: "Manage AWS CloudWatch Logs forwarding content",
+ printConfig: &destPrintConfig{
+ short: "Print a Vector config for AWS CloudWatch Logs forwarding",
+ render: func(cfg endpointconfig.Config) (string, error) { return cloudwatch.ConfigSnippet(cfg.LogPath) },
+ },
+ installPack: &destInstallPack{
+ short: "Write AWS CloudWatch Logs forwarding content to a directory",
+ defaultOutputDir: cloudwatch.DefaultOutputDir,
+ successLabel: "AWS CloudWatch Logs content pack written to ",
+ outputFlagHelp: "Output directory for AWS CloudWatch Logs content pack",
+ install: cloudwatch.InstallPack,
+ },
+ validate: &destValidate{
+ short: "Write and describe an AWS CloudWatch Logs validation event",
+ mode: "aws_cloudwatch_logs",
+ message: "Beacon endpoint AWS CloudWatch Logs validation event",
+ print: func(cfg endpointconfig.Config) {
+ fmt.Println("Expected AWS CloudWatch Logs fields: vendor=beacon product=endpoint-agent destination.type=cloudwatch destination.mode=aws_cloudwatch_logs")
+ fmt.Println(`Confirm delivery with AWS CLI: aws logs filter-log-events --log-group-name "$BEACON_CLOUDWATCH_LOG_GROUP" --filter-pattern '"Beacon endpoint AWS CloudWatch Logs validation event"' --region "$AWS_REGION"`)
+ fmt.Println(`CloudWatch Logs Insights query: fields @timestamp, vendor, product, destination.type, destination.mode, message | filter message like /Beacon endpoint AWS CloudWatch Logs validation event/ | sort @timestamp desc | limit 20`)
+ },
+ },
+ },
+ {
+ name: "gcs",
+ short: "Manage Google Cloud Storage forwarding content",
+ printConfig: &destPrintConfig{
+ short: "Print a Google Cloud Storage smoke-test uploader for Beacon endpoint events",
+ render: func(cfg endpointconfig.Config) (string, error) { return gcs.UploadSmokeTest(cfg.LogPath) },
+ },
+ installPack: &destInstallPack{
+ short: "Write Google Cloud Storage forwarding content to a directory",
+ defaultOutputDir: gcs.DefaultOutputDir,
+ successLabel: "Google Cloud Storage content pack written to ",
+ outputFlagHelp: "Output directory for Google Cloud Storage content pack",
+ install: gcs.InstallPack,
+ },
+ validate: &destValidate{
+ short: "Write and describe a Google Cloud Storage validation event",
+ mode: "google_cloud_storage_jsonl",
+ message: "Beacon endpoint GCS validation event",
+ print: func(cfg endpointconfig.Config) {
+ fmt.Println("Expected GCS fields: vendor=beacon product=endpoint-agent destination.type=gcs destination.mode=google_cloud_storage_jsonl")
+ fmt.Println(`Confirm delivery with Google Cloud CLI: gcloud storage ls "gs://${BEACON_GCS_BUCKET}/${BEACON_GCS_PREFIX}/**"`)
+ fmt.Println(`Inspect an object with Google Cloud CLI: gcloud storage cat "gs://${BEACON_GCS_BUCKET}/${BEACON_GCS_PREFIX}/date=<date>/<object>.jsonl.gz" | gzip -dc | grep "Beacon endpoint GCS validation event"`)
+ },
+ },
+ },
+ {
+ name: "sentinel",
+ short: "Manage Microsoft Sentinel integration content",
+ printConfig: &destPrintConfig{
+ short: "Print a Sentinel DCR transform for Beacon endpoint events",
+ render: func(cfg endpointconfig.Config) (string, error) {
+ return fmt.Sprintf("# Azure Monitor Agent file pattern: %s\n", cfg.LogPath) + sentinel.DCRTransform(), nil
+ },
+ },
+ installPack: &destInstallPack{
+ short: "Write Microsoft Sentinel forwarding content to a directory",
+ defaultOutputDir: sentinel.DefaultOutputDir,
+ successLabel: "Microsoft Sentinel content pack written to ",
+ outputFlagHelp: "Output directory for Microsoft Sentinel content pack",
+ install: sentinel.InstallPack,
+ },
+ validate: &destValidate{
+ short: "Write and describe a Microsoft Sentinel validation event",
+ mode: "azure_monitor_agent_custom_json_logs",
+ message: "Beacon endpoint Sentinel validation event",
+ print: func(cfg endpointconfig.Config) {
+ fmt.Println("Expected Sentinel table: BeaconRuntime_CL")
+ fmt.Println(`Expected validation query: BeaconRuntime_CL | where Message has "Beacon endpoint Sentinel validation event"`)
+ },
+ },
+ },
+}
+
+// buildDestinationCommands returns the `endpoint <name>` group command for every
+// registered forwarding destination.
+func buildDestinationCommands() []*cobra.Command {
+ groups := make([]*cobra.Command, 0, len(siemDestinations))
+ for _, d := range siemDestinations {
+ groups = append(groups, buildDestinationGroup(d))
+ }
+ return groups
+}
+
+func buildDestinationGroup(d siemDestination) *cobra.Command {
+ group := &cobra.Command{Use: d.name, Short: d.short}
+
+ if pc := d.printConfig; pc != nil {
+ cmd := &cobra.Command{
+ Use: "print-config",
+ Short: pc.short,
+ SilenceUsage: true,
+ RunE: func(cmd *cobra.Command, args []string) error {
+ cfg := loadOrDefaultConfig()
+ out, err := pc.render(cfg)
+ if err != nil {
+ return err
+ }
+ fmt.Print(out)
+ return nil
+ },
+ }
+ addEndpointPathFlags(cmd)
+ group.AddCommand(cmd)
+ }
+
+ if ip := d.installPack; ip != nil {
+ cmd := &cobra.Command{
+ Use: "install-pack",
+ Short: ip.short,
+ SilenceUsage: true,
+ RunE: func(cmd *cobra.Command, args []string) error {
+ cfg := loadOrDefaultConfig()
+ outputDir := endpointOpts.outputDir
+ if outputDir == "" {
+ if ip.defaultOutputDir == "" {
+ return fmt.Errorf("--output is required")
+ }
+ outputDir = ip.defaultOutputDir
+ }
+ if err := ip.install(outputDir, cfg.LogPath); err != nil {
+ return err
+ }
+ fmt.Printf("%s%s\n", ip.successLabel, outputDir)
+ return nil
+ },
+ }
+ addEndpointPathFlags(cmd)
+ cmd.Flags().StringVar(&endpointOpts.outputDir, "output", "", ip.outputFlagHelp)
+ group.AddCommand(cmd)
+ }
+
+ if v := d.validate; v != nil {
+ name := d.name
+ cmd := &cobra.Command{
+ Use: "validate",
+ Short: v.short,
+ SilenceUsage: true,
+ RunE: func(cmd *cobra.Command, args []string) error {
+ cfg := loadOrDefaultConfig()
+ path, err := writeValidationEvent(cfg, name)
+ if err != nil {
+ return err
+ }
+ fmt.Printf("Validation event written to %s\n", path)
+ v.print(cfg)
+ return nil
+ },
+ }
+ addEndpointPathFlags(cmd)
+ group.AddCommand(cmd)
+ }
+
+ if d.extra != nil {
+ d.extra(group)
+ }
+
+ return group
+}
+
+// addEndpointPathFlags attaches the standard per-user/system/log-path flags
+// shared by every destination subcommand.
+func addEndpointPathFlags(cmd *cobra.Command) {
+ cmd.Flags().BoolVar(&endpointOpts.userMode, "user", true, "Use per-user endpoint paths")
+ cmd.Flags().BoolVar(&endpointOpts.systemMode, "system", false, "Use system endpoint paths and launch daemon")
+ cmd.Flags().StringVar(&endpointOpts.logPath, "log-path", "", "Runtime JSONL log path")
+}
+
+// destinationValidationMeta returns the synthetic validation event mode and
+// message for a destination, if it is a registered forwarding destination with
+// a validate verb.
+func destinationValidationMeta(name string) (mode, message string, ok bool) {
+ for _, d := range siemDestinations {
+ if d.validate != nil && d.name == name {
+ return d.validate.mode, d.validate.message, true
+ }
+ }
+ return "", "", false
+}
diff --git a/cli/beacon/cmd/endpoint_diagnostics.go b/cli/beacon/cmd/endpoint_diagnostics.go
index 6c77128d..4c3409e0 100644
--- a/cli/beacon/cmd/endpoint_diagnostics.go
+++ b/cli/beacon/cmd/endpoint_diagnostics.go
@@ -1107,31 +1107,11 @@ func writeEventBundleFiles(out, logPath string, includeRaw bool) error {
func syntheticEvent(destination string) schema.Event {
mode := "local_jsonl"
message := "Beacon endpoint pipeline validation event"
- switch destination {
- case "wazuh":
- mode = "localfile"
- message = "Beacon endpoint Wazuh validation event"
- case "datadog":
- mode = "agent_file"
- message = "Beacon endpoint datadog validation event"
- case "sumo":
- mode = "http_source_jsonl"
- message = "Beacon endpoint Sumo validation event"
- case "rapid7":
- mode = "custom_logs_webhook_ndjson"
- message = "Beacon endpoint Rapid7 validation event"
- case "s3":
- mode = "aws_s3_jsonl"
- message = "Beacon endpoint S3 validation event"
- case "cloudwatch":
- mode = "aws_cloudwatch_logs"
- message = "Beacon endpoint AWS CloudWatch Logs validation event"
- case "gcs":
- mode = "google_cloud_storage_jsonl"
- message = "Beacon endpoint GCS validation event"
- case "sentinel":
- mode = "azure_monitor_agent_custom_json_logs"
- message = "Beacon endpoint Sentinel validation event"
+ // Forwarding-destination modes/messages come from the destination registry
+ // (see siemDestinations); everything else keeps the generic pipeline default.
+ if m, msg, ok := destinationValidationMeta(destination); ok {
+ mode = m
+ message = msg
}
event := schema.NewEvent(schema.NewEventOptions{
Action: "agent.detected",
diff --git a/cli/beacon/cmd/endpoint_test.go b/cli/beacon/cmd/endpoint_test.go
index f739cbc9..3efddfea 100644
--- a/cli/beacon/cmd/endpoint_test.go
+++ b/cli/beacon/cmd/endpoint_test.go
@@ -339,17 +339,17 @@ func TestEndpointElasticCommandsRegistered(t *testing.T) {
t.Fatalf("elastic command %v not registered: %#v", path, cmd)
}
}
- if endpointElasticInstallPackCmd.Flags().Lookup("output") == nil {
+ if findEndpointLeaf("elastic", "install-pack").Flags().Lookup("output") == nil {
t.Fatal("elastic install-pack command missing --output flag")
}
- if endpointElasticUpCmd.Flags().Lookup("pack-dir") == nil {
+ if findEndpointLeaf("elastic", "up").Flags().Lookup("pack-dir") == nil {
t.Fatal("elastic up command missing --pack-dir flag")
}
- if endpointElasticDownCmd.Flags().Lookup("pack-dir") == nil {
+ if findEndpointLeaf("elastic", "down").Flags().Lookup("pack-dir") == nil {
t.Fatal("elastic down command missing --pack-dir flag")
}
for _, name := range []string{"user", "system", "log-path"} {
- if endpointElasticDownCmd.Flags().Lookup(name) == nil {
+ if findEndpointLeaf("elastic", "down").Flags().Lookup(name) == nil {
t.Fatalf("elastic down command missing --%s flag", name)
}
}
@@ -374,7 +374,7 @@ func TestEndpointDatadogCommandsRegistered(t *testing.T) {
}
}
}
- if endpointDatadogInstallPackCmd.Flags().Lookup("output") == nil {
+ if findEndpointLeaf("datadog", "install-pack").Flags().Lookup("output") == nil {
t.Fatal("datadog install-pack command missing --output flag")
}
}
@@ -398,7 +398,7 @@ func TestEndpointSumoCommandsRegistered(t *testing.T) {
}
}
}
- if endpointSumoInstallPackCmd.Flags().Lookup("output") == nil {
+ if findEndpointLeaf("sumo", "install-pack").Flags().Lookup("output") == nil {
t.Fatal("sumo install-pack command missing --output flag")
}
}
@@ -422,7 +422,7 @@ func TestEndpointRapid7CommandsRegistered(t *testing.T) {
}
}
}
- if endpointRapid7InstallPackCmd.Flags().Lookup("output") == nil {
+ if findEndpointLeaf("rapid7", "install-pack").Flags().Lookup("output") == nil {
t.Fatal("rapid7 install-pack command missing --output flag")
}
}
@@ -446,7 +446,7 @@ func TestEndpointS3CommandsRegistered(t *testing.T) {
}
}
}
- if endpointS3InstallPackCmd.Flags().Lookup("output") == nil {
+ if findEndpointLeaf("s3", "install-pack").Flags().Lookup("output") == nil {
t.Fatal("s3 install-pack command missing --output flag")
}
}
@@ -470,7 +470,7 @@ func TestEndpointCloudWatchCommandsRegistered(t *testing.T) {
}
}
}
- if endpointCloudWatchInstallPackCmd.Flags().Lookup("output") == nil {
+ if findEndpointLeaf("cloudwatch", "install-pack").Flags().Lookup("output") == nil {
t.Fatal("cloudwatch install-pack command missing --output flag")
}
}
@@ -494,7 +494,7 @@ func TestEndpointGCSCommandsRegistered(t *testing.T) {
}
}
}
- if endpointGCSInstallPackCmd.Flags().Lookup("output") == nil {
+ if findEndpointLeaf("gcs", "install-pack").Flags().Lookup("output") == nil {
t.Fatal("gcs install-pack command missing --output flag")
}
}
@@ -518,7 +518,7 @@ func TestEndpointSentinelCommandsRegistered(t *testing.T) {
}
}
}
- if endpointSentinelInstallPackCmd.Flags().Lookup("output") == nil {
+ if findEndpointLeaf("sentinel", "install-pack").Flags().Lookup("output") == nil {
t.Fatal("sentinel install-pack command missing --output flag")
}
}
@@ -1083,11 +1083,9 @@ func TestEndpointS3ValidatePrintsAWSCLIInspectionGuidance(t *testing.T) {
endpointOpts.systemMode = oldSystemMode
})
- output, err := captureStdout(t, func() error {
- return runEndpointS3Validate(endpointS3ValidateCmd, nil)
- })
+ output, err := runEndpointLeaf(t, "s3", "validate")
if err != nil {
- t.Fatalf("runEndpointS3Validate returned error: %v", err)
+ t.Fatalf("s3 validate returned error: %v", err)
}
for _, want := range []string{
"Validation event written to",
@@ -1118,9 +1116,7 @@ func TestEndpointCloudWatchPrintConfigPrintsVectorConfig(t *testing.T) {
endpointOpts.systemMode = oldSystemMode
})
- output, err := captureStdout(t, func() error {
- return endpointCloudWatchPrintConfigCmd.RunE(endpointCloudWatchPrintConfigCmd, nil)
- })
+ output, err := runEndpointLeaf(t, "cloudwatch", "print-config")
if err != nil {
t.Fatalf("endpoint cloudwatch print-config returned error: %v", err)
}
@@ -1149,11 +1145,9 @@ func TestEndpointCloudWatchValidatePrintsAWSInspectionGuidance(t *testing.T) {
endpointOpts.systemMode = oldSystemMode
})
- output, err := captureStdout(t, func() error {
- return runEndpointCloudWatchValidate(endpointCloudWatchValidateCmd, nil)
- })
+ output, err := runEndpointLeaf(t, "cloudwatch", "validate")
if err != nil {
- t.Fatalf("runEndpointCloudWatchValidate returned error: %v", err)
+ t.Fatalf("cloudwatch validate returned error: %v", err)
}
for _, want := range []string{
"Validation event written to",
@@ -1184,11 +1178,9 @@ func TestEndpointGCSValidatePrintsGoogleCloudCLIInspectionGuidance(t *testing.T)
endpointOpts.systemMode = oldSystemMode
})
- output, err := captureStdout(t, func() error {
- return runEndpointGCSValidate(endpointGCSValidateCmd, nil)
- })
+ output, err := runEndpointLeaf(t, "gcs", "validate")
if err != nil {
- t.Fatalf("runEndpointGCSValidate returned error: %v", err)
+ t.Fatalf("gcs validate returned error: %v", err)
}
for _, want := range []string{
"Validation event written to",