The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
add sentinel support
Justin D'Souza95a35061c3e4
diff --git a/README.md b/README.mdindex a6104c2a..0f85d7d9 100644--- a/README.md+++ b/README.md@@ -100,6 +100,7 @@ enterprise-grade SIEMs.| [Datadog](https://docs.asymptotelabs.ai/cli/siem-forwarding-datadog) | Datadog Agent custom log collection over local JSONL || [Elastic](https://docs.asymptotelabs.ai/cli/siem-forwarding-elastic) | Filebeat or Elastic Agent content pack over local JSONL || [Local JSONL](https://docs.asymptotelabs.ai/cli/local-testing-logs) | Default endpoint log and local dashboard source |+| [Microsoft Sentinel](https://docs.asymptotelabs.ai/cli/siem-forwarding-microsoft-sentinel) | Azure Monitor Agent and Data Collection Rule content pack over local JSONL || [Rapid7 InsightIDR](https://docs.asymptotelabs.ai/cli/siem-forwarding-rapid7) | Custom Logs webhook content pack over local JSONL || [Splunk HEC](https://docs.asymptotelabs.ai/cli/siem-forwarding-splunk) | Optional endpoint forwarding during install or repair || [Sumo Logic](https://docs.asymptotelabs.ai/cli/siem-forwarding-sumo) | HTTP Logs & Metrics Source content pack over local JSONL |diff --git a/cli/beacon/README.md b/cli/beacon/README.mdindex f98f2420..8f81b29d 100644--- a/cli/beacon/README.md+++ b/cli/beacon/README.md@@ -103,6 +103,20 @@ The Rapid7 pack keeps Beacon as a local JSONL producer and documents forwardingwebhook URL in your customer-managed shipper or deployment tooling, not inBeacon endpoint configuration.+## Microsoft Sentinel++```bash+./beacon endpoint sentinel print-config+./beacon endpoint sentinel install-pack --output ./beacon-sentinel-pack+./beacon endpoint sentinel validate+```++The Sentinel pack keeps Beacon as a local JSONL producer and documents+forwarding `runtime.jsonl` through Azure Monitor Agent, a Data Collection Rule,+and a `BeaconRuntime_CL` custom Log Analytics table. Store Azure workspace,+DCR, endpoint, and credential details in Azure or customer-managed deployment+tooling, not in Beacon endpoint configuration.+## Optional Integrations```bashdiff --git a/cli/beacon/cmd/endpoint.go b/cli/beacon/cmd/endpoint.goindex aa9bf8a6..9080e1e2 100644--- a/cli/beacon/cmd/endpoint.go+++ b/cli/beacon/cmd/endpoint.go@@ -24,6 +24,7 @@ import ("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/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"@@ -182,6 +183,11 @@ var endpointRapid7Cmd = &cobra.Command{Short: "Manage Rapid7 InsightIDR integration 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",@@ -510,6 +516,30 @@ var endpointRapid7ValidateCmd = &cobra.Command{RunE: runEndpointRapid7Validate,}+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)@@ -531,6 +561,7 @@ func init() {endpointCmd.AddCommand(endpointDatadogCmd)endpointCmd.AddCommand(endpointSumoCmd)endpointCmd.AddCommand(endpointRapid7Cmd)+ endpointCmd.AddCommand(endpointSentinelCmd)endpointCmd.AddCommand(endpointIntegrationsCmd)endpointCmd.AddCommand(endpointHooksCmd)endpointCmd.AddCommand(endpointConfigCmd)@@ -553,6 +584,9 @@ func init() {endpointRapid7Cmd.AddCommand(endpointRapid7PrintConfigCmd)endpointRapid7Cmd.AddCommand(endpointRapid7InstallPackCmd)endpointRapid7Cmd.AddCommand(endpointRapid7ValidateCmd)+ endpointSentinelCmd.AddCommand(endpointSentinelPrintConfigCmd)+ endpointSentinelCmd.AddCommand(endpointSentinelInstallPackCmd)+ endpointSentinelCmd.AddCommand(endpointSentinelValidateCmd)endpointIntegrationsCmd.AddCommand(endpointIntegrationsValidateCmd)endpointIntegrationsCmd.AddCommand(endpointCoworkCmd)endpointIntegrationsCmd.AddCommand(endpointOpenClawCmd)@@ -653,6 +687,12 @@ func init() {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{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")@@ -1028,6 +1068,31 @@ func runEndpointRapid7Validate(cmd *cobra.Command, args []string) error {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() {diff --git a/cli/beacon/cmd/endpoint_test.go b/cli/beacon/cmd/endpoint_test.goindex 24082df7..fdb79f27 100644--- a/cli/beacon/cmd/endpoint_test.go+++ b/cli/beacon/cmd/endpoint_test.go@@ -215,6 +215,30 @@ func TestEndpointRapid7CommandsRegistered(t *testing.T) {}}+func TestEndpointSentinelCommandsRegistered(t *testing.T) {+ for _, path := range [][]string{+ {"sentinel", "print-config"},+ {"sentinel", "install-pack"},+ {"sentinel", "validate"},+ } {+ cmd, _, err := endpointCmd.Find(path)+ if err != nil {+ t.Fatalf("Find %v returned error: %v", path, err)+ }+ if cmd == nil || cmd.Use != path[len(path)-1] {+ t.Fatalf("sentinel command %v not registered: %#v", path, cmd)+ }+ for _, name := range []string{"user", "system", "log-path"} {+ if cmd.Flags().Lookup(name) == nil {+ t.Fatalf("sentinel command %v missing --%s flag", path, name)+ }+ }+ }+ if endpointSentinelInstallPackCmd.Flags().Lookup("output") == nil {+ t.Fatal("sentinel install-pack command missing --output flag")+ }+}+func TestEnsureElasticPackDoesNotOverwriteExistingPack(t *testing.T) {dir := t.TempDir()composePath := filepath.Join(dir, "docker-compose.yml")diff --git a/cli/beacon/internal/endpoint/sentinel/pack/README.md b/cli/beacon/internal/endpoint/sentinel/pack/README.mdnew file mode 100644index 00000000..bc2a8fe5--- /dev/null+++ b/cli/beacon/internal/endpoint/sentinel/pack/README.md@@ -0,0 +1,101 @@+# Beacon Endpoint Agent Microsoft Sentinel Pack++This pack forwards Beacon endpoint JSONL events into Microsoft Sentinel through+Azure Monitor Agent custom log collection. Beacon still writes one local source+of truth: `runtime.jsonl`. Azure tenant IDs, client secrets, workspace IDs, DCR+identifiers, and ingestion endpoints stay in Azure Monitor, deployment tooling,+or customer-managed forwarders, not in Beacon endpoint configuration.++## Prerequisites++- Beacon endpoint installed and writing local JSONL.+- A Log Analytics workspace with Microsoft Sentinel enabled.+- Azure Monitor Agent installed or deployed to the endpoint.+- A custom Log Analytics table named `BeaconRuntime_CL`.+- A Data Collection Rule associated with the endpoint and workspace.++For MDM or managed endpoint deployment, prefer Beacon system mode so Azure+Monitor Agent can tail `/var/log/beacon-agent/runtime.jsonl` without per-user+home directory ACLs.++## Install++Generate this pack:++```bash+beacon endpoint sentinel install-pack --output ./beacon-sentinel-pack+```++The generated `dcr-template.json` points at the Beacon log path selected by the+CLI:++- User mode: `~/.beacon/endpoint/logs/runtime.jsonl`+- System mode: `/var/log/beacon-agent/runtime.jsonl`+- Custom mode: the value passed with `--log-path`++## Sentinel Setup++1. Create the `BeaconRuntime_CL` custom table using `table-schema.json`.+2. Create or update an Azure Monitor Data Collection Rule using+ `dcr-template.json`.+3. Associate the DCR with endpoints that run Azure Monitor Agent.+4. Confirm the DCR uses the transform in `dcr-transform.kql`.+5. Wait for Azure Monitor Agent to tail new lines from `runtime.jsonl`.++The DCR uses a Custom Text Logs source because Beacon writes newline-delimited+JSON. The transform parses each `RawData` line with `todynamic(RawData)`,+projects stable columns for common hunting workflows, and preserves the original+Beacon event in `RawData`.++## Validate++Write a fresh Beacon validation event:++```bash+beacon endpoint sentinel validate+```++After Azure Monitor Agent ships the new line, validate in Microsoft Sentinel or+Log Analytics:++```kql+BeaconRuntime_CL+| where TimeGenerated > ago(24h)+| where Message has "Beacon endpoint Sentinel validation event"+| project TimeGenerated, HostName, UserName, HarnessName, EventAction, Message+```++If the validation query does not return data, check the DCR association, the+Azure Monitor Agent health state, the configured file path, and the table schema.+The target table must exist before the DCR can route transformed records to it.++## Hunting Content++Use `queries.kql` for validation and starter hunting queries. Use+`detections.kql` as example analytics rule logic; review and tune thresholds,+repository names, content retention policy, and severity mappings before+enabling alerts in production.++## CEF and Syslog++Microsoft Sentinel can also collect CEF and Syslog through Azure Monitor Agent.+That path is useful for SOCs standardized on `CommonSecurityLog`, but it is not+the default Beacon recommendation because Beacon events are rich structured JSON+with prompts, tool calls, commands, files, runtime metadata, and optional raw+fields. Flattening those events into CEF loses useful context.++## Direct Logs Ingestion API++The Azure Monitor Logs Ingestion API can be useful for a centralized,+customer-managed forwarder, but it should not be configured directly in Beacon+endpoint agent state. Direct API forwarding requires Microsoft Entra+credentials, DCR identifiers, ingestion endpoints, batching, retries, and+network failure handling. Keep those concerns outside Beacon's local endpoint+collector unless you are building a separate managed forwarder.++## Content Retention++Beacon content retention defaults to `full`, so prompt text, tool input, command+output, raw tool payloads, and other retained content may be forwarded to+Microsoft Sentinel. Use Beacon's `metadata` or `redacted` content retention+modes for stricter deployments.diff --git a/cli/beacon/internal/endpoint/sentinel/pack/dcr-template.json b/cli/beacon/internal/endpoint/sentinel/pack/dcr-template.jsonnew file mode 100644index 00000000..61063a05--- /dev/null+++ b/cli/beacon/internal/endpoint/sentinel/pack/dcr-template.json@@ -0,0 +1,69 @@+{+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",+ "contentVersion": "1.0.0.0",+ "parameters": {+ "dataCollectionRuleName": {+ "type": "string",+ "defaultValue": "dcr-beacon-runtime"+ },+ "workspaceResourceId": {+ "type": "string",+ "metadata": {+ "description": "Resource ID of the Log Analytics workspace enabled for Microsoft Sentinel."+ }+ },+ "location": {+ "type": "string",+ "defaultValue": "[resourceGroup().location]"+ }+ },+ "resources": [+ {+ "type": "Microsoft.Insights/dataCollectionRules",+ "apiVersion": "2023-03-11",+ "name": "[parameters('dataCollectionRuleName')]",+ "location": "[parameters('location')]",+ "properties": {+ "dataSources": {+ "logFiles": [+ {+ "streams": [+ "Custom-BeaconRuntime_CL"+ ],+ "filePatterns": [+ "{{LOG_PATH}}"+ ],+ "format": "text",+ "settings": {+ "text": {+ "recordStartTimestampFormat": "ISO 8601"+ }+ },+ "name": "beaconRuntimeJsonl"+ }+ ]+ },+ "destinations": {+ "logAnalytics": [+ {+ "workspaceResourceId": "[parameters('workspaceResourceId')]",+ "name": "sentinelWorkspace"+ }+ ]+ },+ "dataFlows": [+ {+ "streams": [+ "Custom-BeaconRuntime_CL"+ ],+ "destinations": [+ "sentinelWorkspace"+ ],+ "transformKql": "source | extend RawEvent = todynamic(RawData) | extend TimeGenerated = coalesce(todatetime(RawEvent.timestamp), TimeGenerated) | project TimeGenerated, Vendor = tostring(RawEvent.vendor), Product = tostring(RawEvent.product), SchemaVersion = tostring(RawEvent.schema_version), EventKind = tostring(RawEvent.event.kind), EventAction = tostring(RawEvent.event.action), EventCategory = tostring(RawEvent.event.category), Severity = tostring(RawEvent.severity), HostName = tostring(RawEvent.endpoint.hostname), UserName = tostring(RawEvent.user.name), HarnessName = tostring(RawEvent.harness.name), SessionId = tostring(RawEvent.session.id), ToolName = tostring(RawEvent.tool.name), CommandLine = coalesce(tostring(RawEvent.command.command), tostring(RawEvent.tool.command)), Repository = tostring(RawEvent.repository), Branch = tostring(RawEvent.branch), Message = tostring(RawEvent.message), ContentRetention = tostring(RawEvent.content.retention), RawData = RawEvent",+ "outputStream": "Custom-BeaconRuntime_CL"+ }+ ]+ }+ }+ ]+}diff --git a/cli/beacon/internal/endpoint/sentinel/pack/dcr-transform.kql b/cli/beacon/internal/endpoint/sentinel/pack/dcr-transform.kqlnew file mode 100644index 00000000..1faed924--- /dev/null+++ b/cli/beacon/internal/endpoint/sentinel/pack/dcr-transform.kql@@ -0,0 +1,23 @@+source+| extend RawEvent = todynamic(RawData)+| extend TimeGenerated = coalesce(todatetime(RawEvent.timestamp), TimeGenerated)+| project+ TimeGenerated,+ Vendor = tostring(RawEvent.vendor),+ Product = tostring(RawEvent.product),+ SchemaVersion = tostring(RawEvent.schema_version),+ EventKind = tostring(RawEvent.event.kind),+ EventAction = tostring(RawEvent.event.action),+ EventCategory = tostring(RawEvent.event.category),+ Severity = tostring(RawEvent.severity),+ HostName = tostring(RawEvent.endpoint.hostname),+ UserName = tostring(RawEvent.user.name),+ HarnessName = tostring(RawEvent.harness.name),+ SessionId = tostring(RawEvent.session.id),+ ToolName = tostring(RawEvent.tool.name),+ CommandLine = coalesce(tostring(RawEvent.command.command), tostring(RawEvent.tool.command)),+ Repository = tostring(RawEvent.repository),+ Branch = tostring(RawEvent.branch),+ Message = tostring(RawEvent.message),+ ContentRetention = tostring(RawEvent.content.retention),+ RawData = RawEventdiff --git a/cli/beacon/internal/endpoint/sentinel/pack/detections.kql b/cli/beacon/internal/endpoint/sentinel/pack/detections.kqlnew file mode 100644index 00000000..5b76611d--- /dev/null+++ b/cli/beacon/internal/endpoint/sentinel/pack/detections.kql@@ -0,0 +1,20 @@+// Detection idea: agent command execution in sensitive repositories.+BeaconRuntime_CL+| where TimeGenerated > ago(1h)+| where EventAction == "command.executed" or isnotempty(CommandLine)+| where Repository has_any ("production", "infra", "secrets", "security")+| project TimeGenerated, HostName, UserName, HarnessName, SessionId, CommandLine, Repository, Branch, Message++// Detection idea: Beacon event with retained full content in strict environments.+BeaconRuntime_CL+| where TimeGenerated > ago(1h)+| where ContentRetention == "full"+| project TimeGenerated, HostName, UserName, HarnessName, EventAction, ContentRetention, Message++// Detection idea: agent edits to credential-like files.+BeaconRuntime_CL+| where TimeGenerated > ago(1h)+| where EventAction startswith "file."+| extend FilePath = tostring(RawData.file.path)+| where FilePath matches regex @"(?i)(^|/)(\.env|id_rsa|credentials|secrets?|\.npmrc|\.pypirc|kubeconfig)(\.|$|/)"+| project TimeGenerated, HostName, UserName, HarnessName, SessionId, EventAction, FilePath, Repository, Branchdiff --git a/cli/beacon/internal/endpoint/sentinel/pack/queries.kql b/cli/beacon/internal/endpoint/sentinel/pack/queries.kqlnew file mode 100644index 00000000..e446c9b4--- /dev/null+++ b/cli/beacon/internal/endpoint/sentinel/pack/queries.kql@@ -0,0 +1,41 @@+// Recent Beacon events.+BeaconRuntime_CL+| where TimeGenerated > ago(24h)+| order by TimeGenerated desc+| take 50++// Validate the generated Beacon Sentinel validation event.+BeaconRuntime_CL+| where TimeGenerated > ago(24h)+| where Message has "Beacon endpoint Sentinel validation event" or tostring(RawData.message) has "Beacon endpoint Sentinel validation event"+| project TimeGenerated, HostName, UserName, HarnessName, EventAction, Message++// Agent shell commands.+BeaconRuntime_CL+| where TimeGenerated > ago(24h)+| where EventAction == "command.executed" or isnotempty(CommandLine)+| project TimeGenerated, HostName, UserName, HarnessName, SessionId, CommandLine, Repository, Branch+| order by TimeGenerated desc++// Sensitive file edits by local agent runtimes.+BeaconRuntime_CL+| where TimeGenerated > ago(7d)+| where EventAction startswith "file."+| extend FilePath = tostring(RawData.file.path)+| where FilePath matches regex @"(?i)(^|/)(\.env|id_rsa|credentials|secrets?|\.npmrc|\.pypirc|kubeconfig)(\.|$|/)"+| project TimeGenerated, HostName, UserName, HarnessName, EventAction, FilePath, Repository, Branch, Message++// Unusually high tool-call volume by session.+BeaconRuntime_CL+| where TimeGenerated > ago(1h)+| where isnotempty(ToolName)+| summarize ToolCalls = count(), Tools = make_set(ToolName, 20) by HostName, UserName, HarnessName, SessionId+| where ToolCalls >= 50+| order by ToolCalls desc++// New or rare agent runtimes observed in the last day.+BeaconRuntime_CL+| where TimeGenerated > ago(14d)+| summarize FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated), Events = count() by HarnessName+| where FirstSeen > ago(1d) or Events < 5+| order by FirstSeen descdiff --git a/cli/beacon/internal/endpoint/sentinel/pack/table-schema.json b/cli/beacon/internal/endpoint/sentinel/pack/table-schema.jsonnew file mode 100644index 00000000..49921816--- /dev/null+++ b/cli/beacon/internal/endpoint/sentinel/pack/table-schema.json@@ -0,0 +1,29 @@+{+ "name": "BeaconRuntime_CL",+ "properties": {+ "schema": {+ "name": "BeaconRuntime_CL",+ "columns": [+ { "name": "TimeGenerated", "type": "dateTime" },+ { "name": "Vendor", "type": "string" },+ { "name": "Product", "type": "string" },+ { "name": "SchemaVersion", "type": "string" },+ { "name": "EventKind", "type": "string" },+ { "name": "EventAction", "type": "string" },+ { "name": "EventCategory", "type": "string" },+ { "name": "Severity", "type": "string" },+ { "name": "HostName", "type": "string" },+ { "name": "UserName", "type": "string" },+ { "name": "HarnessName", "type": "string" },+ { "name": "SessionId", "type": "string" },+ { "name": "ToolName", "type": "string" },+ { "name": "CommandLine", "type": "string" },+ { "name": "Repository", "type": "string" },+ { "name": "Branch", "type": "string" },+ { "name": "Message", "type": "string" },+ { "name": "ContentRetention", "type": "string" },+ { "name": "RawData", "type": "dynamic" }+ ]+ }+ }+}diff --git a/cli/beacon/internal/endpoint/sentinel/sentinel.go b/cli/beacon/internal/endpoint/sentinel/sentinel.gonew file mode 100644index 00000000..361700d4--- /dev/null+++ b/cli/beacon/internal/endpoint/sentinel/sentinel.go@@ -0,0 +1,50 @@+package sentinel++import (+ "embed"+ "fmt"++ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/siempack"+)++//go:embed pack/*+var packFS embed.FS++const (+ DefaultLogPath = "/var/log/beacon-agent/runtime.jsonl"+ DefaultOutputDir = "beacon-sentinel-pack"+)++func Files() []siempack.File {+ return []siempack.File{+ {Name: "README.md", Content: mustRead("pack/README.md")},+ {Name: "dcr-transform.kql", Content: DCRTransform()},+ {Name: "table-schema.json", Content: mustRead("pack/table-schema.json")},+ {Name: "dcr-template.json", Content: mustRead("pack/dcr-template.json"), TemplateLogPath: true},+ {Name: "queries.kql", Content: mustRead("pack/queries.kql")},+ {Name: "detections.kql", Content: mustRead("pack/detections.kql")},+ {Name: "sample-event.jsonl", Content: mustRead("pack/sample-event.jsonl")},+ }+}++func DCRTransform() string {+ return mustRead("pack/dcr-transform.kql")+}++func InstallPack(outputDir, logPath string) error {+ if outputDir == "" {+ outputDir = DefaultOutputDir+ }+ if logPath == "" {+ logPath = DefaultLogPath+ }+ return siempack.Install(outputDir, Files(), logPath)+}++func mustRead(path string) string {+ data, err := siempack.ReadFile(packFS, path)+ if err != nil {+ panic(fmt.Sprintf("sentinel pack asset %s: %v", path, err))+ }+ return data+}diff --git a/cli/beacon/internal/endpoint/sentinel/sentinel_test.go b/cli/beacon/internal/endpoint/sentinel/sentinel_test.gonew file mode 100644index 00000000..a76af02f--- /dev/null+++ b/cli/beacon/internal/endpoint/sentinel/sentinel_test.go@@ -0,0 +1,132 @@+package sentinel++import (+ "bufio"+ "encoding/json"+ "os"+ "path/filepath"+ "strings"+ "testing"+)++func TestDCRTransformMentionsExpectedColumns(t *testing.T) {+ got := DCRTransform()+ for _, want := range []string{+ "RawEvent = todynamic(RawData)",+ "TimeGenerated = coalesce(todatetime(RawEvent.timestamp), TimeGenerated)",+ "EventAction = tostring(RawEvent.event.action)",+ "CommandLine = coalesce(tostring(RawEvent.command.command), tostring(RawEvent.tool.command))",+ "RawData = RawEvent",+ } {+ if !strings.Contains(got, want) {+ t.Fatalf("DCR transform missing %q: %s", want, got)+ }+ }+}++func TestInstallPackWritesExpectedFiles(t *testing.T) {+ dir := t.TempDir()+ if err := InstallPack(dir, "/tmp/beacon/runtime.jsonl"); err != nil {+ t.Fatalf("InstallPack returned error: %v", err)+ }+ for _, name := range []string{+ "README.md",+ "dcr-transform.kql",+ "table-schema.json",+ "dcr-template.json",+ "queries.kql",+ "detections.kql",+ "sample-event.jsonl",+ } {+ if _, err := os.Stat(filepath.Join(dir, name)); err != nil {+ t.Fatalf("expected %s: %v", name, err)+ }+ }+ dcrTemplate, err := os.ReadFile(filepath.Join(dir, "dcr-template.json"))+ if err != nil {+ t.Fatal(err)+ }+ if !strings.Contains(string(dcrTemplate), "/tmp/beacon/runtime.jsonl") {+ t.Fatalf("generated DCR template missing configured log path: %s", dcrTemplate)+ }+ if strings.Contains(string(dcrTemplate), "{{LOG_PATH}}") {+ t.Fatalf("generated DCR template still contains template token: %s", dcrTemplate)+ }+}++func TestPackJSONFilesAreValid(t *testing.T) {+ for _, path := range []string{+ "pack/table-schema.json",+ "pack/dcr-template.json",+ } {+ var doc map[string]interface{}+ if err := json.Unmarshal([]byte(mustRead(path)), &doc); err != nil {+ t.Fatalf("%s is not valid JSON: %v", path, err)+ }+ }+}++func TestSampleEventsCoverValidationHookAndOTelShapes(t *testing.T) {+ scanner := bufio.NewScanner(strings.NewReader(mustRead("pack/sample-event.jsonl")))+ var sawValidation, sawHook, sawOTel bool+ for scanner.Scan() {+ var doc map[string]interface{}+ if err := json.Unmarshal(scanner.Bytes(), &doc); err != nil {+ t.Fatalf("sample-event.jsonl is not valid JSONL: %v", err)+ }+ if destination, ok := doc["destination"].(map[string]interface{}); ok && destination["type"] == "sentinel" {+ sawValidation = true+ }+ if _, ok := doc["tool"].(map[string]interface{}); ok {+ sawHook = true+ }+ if raw, ok := doc["raw"].(map[string]interface{}); ok && raw["otel_signal"] != nil {+ sawOTel = true+ }+ }+ if err := scanner.Err(); err != nil {+ t.Fatal(err)+ }+ if !sawValidation || !sawHook || !sawOTel {+ t.Fatalf("sample events should include validation, hook-rich, and OTel shapes; validation=%t hook=%t otel=%t", sawValidation, sawHook, sawOTel)+ }+}++func TestPackREADMEMentionsSentinelSetupAndSecretBoundaries(t *testing.T) {+ readme := mustRead("pack/README.md")+ for _, want := range []string{+ "beacon endpoint sentinel validate",+ "Azure Monitor Agent",+ "Data Collection Rule",+ "BeaconRuntime_CL",+ "Microsoft Sentinel",+ "content retention",+ "/var/log/beacon-agent/runtime.jsonl",+ "not in Beacon endpoint configuration",+ "Direct Logs Ingestion API",+ "CEF and Syslog",+ } {+ if !strings.Contains(readme, want) {+ t.Fatalf("pack README missing %q", want)+ }+ }+}++func TestKQLAssetsMentionSentinelTableAndValidation(t *testing.T) {+ for _, path := range []string{+ "pack/queries.kql",+ "pack/detections.kql",+ "pack/dcr-transform.kql",+ } {+ got := mustRead(path)+ if !strings.Contains(got, "BeaconRuntime_CL") && path != "pack/dcr-transform.kql" {+ t.Fatalf("%s should mention BeaconRuntime_CL", path)+ }+ if strings.Contains(got, "{{LOG_PATH}}") {+ t.Fatalf("%s still contains template token", path)+ }+ }+ if !strings.Contains(mustRead("pack/queries.kql"), "Beacon endpoint Sentinel validation event") {+ t.Fatal("queries.kql should include the Sentinel validation phrase")+ }+}