Skip to content

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

Fix Sentinel validation message and eliminate DCR transform duplication

Cursor Agent85622dc6dd65
diff --git a/cli/beacon/cmd/endpoint_diagnostics.go b/cli/beacon/cmd/endpoint_diagnostics.go
index 8b9803be..4858b0b6 100644
--- a/cli/beacon/cmd/endpoint_diagnostics.go
+++ b/cli/beacon/cmd/endpoint_diagnostics.go
@@ -567,6 +567,9 @@ func syntheticEvent(destination string) schema.Event {
case "rapid7":
mode = "custom_logs_webhook_ndjson"
message = "Beacon endpoint Rapid7 validation event"
+ case "sentinel":
+ mode = "azure_monitor_agent_custom_json_logs"
+ message = "Beacon endpoint Sentinel validation event"
}
event := schema.NewEvent(schema.NewEventOptions{
Action: "agent.detected",
diff --git a/cli/beacon/internal/endpoint/sentinel/pack/dcr-template.json b/cli/beacon/internal/endpoint/sentinel/pack/dcr-template.json
index 61063a05..7643bb10 100644
--- a/cli/beacon/internal/endpoint/sentinel/pack/dcr-template.json
+++ b/cli/beacon/internal/endpoint/sentinel/pack/dcr-template.json
@@ -59,7 +59,7 @@
"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",
+ "transformKql": "{{DCR_TRANSFORM}}",
"outputStream": "Custom-BeaconRuntime_CL"
}
]
diff --git a/cli/beacon/internal/endpoint/sentinel/sentinel.go b/cli/beacon/internal/endpoint/sentinel/sentinel.go
index 361700d4..2555e833 100644
--- a/cli/beacon/internal/endpoint/sentinel/sentinel.go
+++ b/cli/beacon/internal/endpoint/sentinel/sentinel.go
@@ -3,6 +3,7 @@ package sentinel
import (
"embed"
"fmt"
+ "strings"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/siempack"
)
@@ -20,7 +21,7 @@ func Files() []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: "dcr-template.json", Content: renderDCRTemplate(), 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")},
@@ -41,6 +42,23 @@ func InstallPack(outputDir, logPath string) error {
return siempack.Install(outputDir, Files(), logPath)
}
+func renderDCRTemplate() string {
+ tmpl := mustRead("pack/dcr-template.json")
+ return strings.ReplaceAll(tmpl, "{{DCR_TRANSFORM}}", minifyKQL(DCRTransform()))
+}
+
+func minifyKQL(kql string) string {
+ lines := strings.Split(kql, "\n")
+ parts := make([]string, 0, len(lines))
+ for _, line := range lines {
+ trimmed := strings.TrimSpace(line)
+ if trimmed != "" {
+ parts = append(parts, trimmed)
+ }
+ }
+ return strings.Join(parts, " ")
+}
+
func mustRead(path string) string {
data, err := siempack.ReadFile(packFS, path)
if err != nil {
diff --git a/cli/beacon/internal/endpoint/sentinel/sentinel_test.go b/cli/beacon/internal/endpoint/sentinel/sentinel_test.go
index a76af02f..6b42a7cf 100644
--- a/cli/beacon/internal/endpoint/sentinel/sentinel_test.go
+++ b/cli/beacon/internal/endpoint/sentinel/sentinel_test.go
@@ -66,6 +66,21 @@ func TestPackJSONFilesAreValid(t *testing.T) {
}
}
+func TestRenderedDCRTemplateContainsTransformFromKQL(t *testing.T) {
+ rendered := renderDCRTemplate()
+ if strings.Contains(rendered, "{{DCR_TRANSFORM}}") {
+ t.Fatal("rendered DCR template still contains {{DCR_TRANSFORM}} placeholder")
+ }
+ var doc map[string]interface{}
+ if err := json.Unmarshal([]byte(rendered), &doc); err != nil {
+ t.Fatalf("rendered DCR template is not valid JSON: %v", err)
+ }
+ transform := minifyKQL(DCRTransform())
+ if !strings.Contains(rendered, transform) {
+ t.Fatalf("rendered DCR template does not contain the minified dcr-transform.kql content")
+ }
+}
+
func TestSampleEventsCoverValidationHookAndOTelShapes(t *testing.T) {
scanner := bufio.NewScanner(strings.NewReader(mustRead("pack/sample-event.jsonl")))
var sawValidation, sawHook, sawOTel bool