Skip to content

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

fix

Justin D'Souza0f086b7f18de
diff --git a/cli/beacon/internal/endpoint/dashboard/detections.go b/cli/beacon/internal/endpoint/dashboard/detections.go
index 9b873f93..6154bfa7 100644
--- a/cli/beacon/internal/endpoint/dashboard/detections.go
+++ b/cli/beacon/internal/endpoint/dashboard/detections.go
@@ -93,6 +93,9 @@ func RunScan(userMode bool, logPath, rulesDir, session, minSeverity string) (Fin
if err != nil {
return FindingsResponse{}, fmt.Errorf("load rules: %w", err)
}
+ if len(loaded) == 0 {
+ return FindingsResponse{}, fmt.Errorf("no rules to run (store is empty and baseline missing)")
+ }
compiled := make([]*threatrules.CompiledRule, 0, len(loaded))
for _, lr := range loaded {
c, err := threatrules.Compile(lr.Rule)
diff --git a/cli/beacon/internal/endpoint/dashboard/server_test.go b/cli/beacon/internal/endpoint/dashboard/server_test.go
index 68c7875c..8c40eae6 100644
--- a/cli/beacon/internal/endpoint/dashboard/server_test.go
+++ b/cli/beacon/internal/endpoint/dashboard/server_test.go
@@ -319,6 +319,17 @@ func TestFindingsEndpointReturnsHitsLinkedToRules(t *testing.T) {
}
}
+func TestRunScanRejectsEmptyRuleSet(t *testing.T) {
+ t.Setenv("HOME", t.TempDir())
+ _, err := RunScan(true, filepath.Join(t.TempDir(), "runtime.jsonl"), t.TempDir(), "", "")
+ if err == nil {
+ t.Fatal("expected empty rule set to be rejected")
+ }
+ if !strings.Contains(err.Error(), "no rules to run") {
+ t.Fatalf("error = %q, want no rules to run", err)
+ }
+}
+
func TestStaticDashboardPagesServe(t *testing.T) {
handler, err := Handler(Options{UserMode: true, LogPath: filepath.Join(t.TempDir(), "runtime.jsonl")})
if err != nil {
diff --git a/cli/beacon/internal/endpoint/dashboard/static/app.js b/cli/beacon/internal/endpoint/dashboard/static/app.js
index 98870d28..27572091 100644
--- a/cli/beacon/internal/endpoint/dashboard/static/app.js
+++ b/cli/beacon/internal/endpoint/dashboard/static/app.js
@@ -7,6 +7,7 @@ const state = {
error: null,
currentQuery: "",
newEventCount: 0,
+ lastDetectionHashScroll: "",
};
const $ = (selector) => document.querySelector(selector);
@@ -900,6 +901,22 @@ function renderDetections(resp) {
</tr>
`)
.join("");
+ scrollDetectionHashIntoView();
+}
+
+function scrollDetectionHashIntoView({ force = false } = {}) {
+ if (!isDetectionsPage || !window.location.hash) return;
+ let targetID = window.location.hash.slice(1);
+ try {
+ targetID = decodeURIComponent(targetID);
+ } catch (_) {
+ // Use the raw hash when the browser exposes a malformed escape sequence.
+ }
+ if (!targetID || (!force && state.lastDetectionHashScroll === targetID)) return;
+ const target = document.getElementById(targetID);
+ if (!target) return;
+ target.scrollIntoView({ block: "start" });
+ state.lastDetectionHashScroll = targetID;
}
async function loadFindings() {
@@ -978,6 +995,7 @@ $("#filters")?.addEventListener("submit", (event) => {
$("#clear-search")?.addEventListener("click", clearSearch);
$("#close-drawer")?.addEventListener("click", closeDrawer);
$("#new-events")?.addEventListener("click", showNewEvents);
+window.addEventListener("hashchange", () => scrollDetectionHashIntoView({ force: true }));
$$("[data-preset]").forEach((button) => {
button.addEventListener("click", () => applyPreset(button.dataset.preset));
});