Skip to content

armgit / AiSOC

Public Imported from GitHub
0

Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.

fix(marketplace): the card counting playbooks was labelled Executable (#1012)

Beenu Arorac8c01fbfbbe3
diff --git a/apps/web/src/components/marketplace/MarketplaceGridHeaderParity.test.tsx b/apps/web/src/components/marketplace/MarketplaceGridHeaderParity.test.tsx
index 8cf31b648..575dc9c75 100644
--- a/apps/web/src/components/marketplace/MarketplaceGridHeaderParity.test.tsx
+++ b/apps/web/src/components/marketplace/MarketplaceGridHeaderParity.test.tsx
@@ -104,7 +104,7 @@ function renderedCardCount(container: HTMLElement): number {
* type filter also has a button labelled `All`.
*/
function runsFilter(container: HTMLElement) {
- const group = container.querySelector('[title^="Executable = loaded by the detection engine"]');
+ const group = container.querySelector('[title^="Installable = every entry"]');
if (!group) throw new Error('runs filter group not found');
return within(group as HTMLElement);
}
@@ -129,7 +129,7 @@ describe('the grid agrees with its own header under every filter', () => {
expect(renderedCardCount(container)).toBe(headerShowingCount());
// `Executable` — the two playbooks plus the one loadable rule.
- await user.click(runsFilter(container).getByRole('button', { name: /^Executable\s*\(\d+\)$/ }));
+ await user.click(runsFilter(container).getByRole('button', { name: /^Installable\s*\(\d+\)$/ }));
expect(renderedCardCount(container)).toBe(headerShowingCount());
// `Reference only` — the filter where the orphaned children showed up as
diff --git a/apps/web/src/components/marketplace/MarketplaceHonesty.test.tsx b/apps/web/src/components/marketplace/MarketplaceHonesty.test.tsx
index c66d3b735..9f834889b 100644
--- a/apps/web/src/components/marketplace/MarketplaceHonesty.test.tsx
+++ b/apps/web/src/components/marketplace/MarketplaceHonesty.test.tsx
@@ -125,7 +125,7 @@ describe('the catalogue distinguishes what runs from what does not', () => {
render(<MarketplaceView />);
// `Total` is not the only number a reader sees: both halves of the split
// are stat cards of their own, each with its count.
- const cards = screen.getAllByText('Executable').map((label) => label.closest('div'));
+ const cards = screen.getAllByText('Installable').map((label) => label.closest('div'));
const statCard = cards.find((card) => card?.className.includes('text-center'));
expect(statCard).toBeTruthy();
expect(within(statCard as HTMLElement).getByText('1')).toBeInTheDocument();
@@ -142,7 +142,7 @@ describe('the catalogue distinguishes what runs from what does not', () => {
const user = userEvent.setup();
render(<MarketplaceView />);
- await user.click(screen.getByRole('button', { name: /Executable\s*\(1\)/ }));
+ await user.click(screen.getByRole('button', { name: /Installable\s*\(1\)/ }));
expect(screen.getByText('AWS root console login')).toBeInTheDocument();
expect(screen.queryByText('a_scheduled_task_was_created')).toBeNull();
diff --git a/apps/web/src/components/marketplace/MarketplaceView.tsx b/apps/web/src/components/marketplace/MarketplaceView.tsx
index 01379299e..b52d9328e 100644
--- a/apps/web/src/components/marketplace/MarketplaceView.tsx
+++ b/apps/web/src/components/marketplace/MarketplaceView.tsx
@@ -843,7 +843,7 @@ export function MarketplaceView() {
// count rows carrying a `quarantine_reason` — 4,213 against the 4,388 the
// engine does not load — so the published figure and the truth table's
// were two numbers nothing compared.
- const executableCount = useMemo(
+ const installableCount = useMemo(
() => catalogue.filter((i) => i.executable !== false).length,
[catalogue],
);
@@ -949,14 +949,24 @@ export function MarketplaceView() {
)}
{/* Stats.
- `Executable` and `Reference only` lead, and they partition the
+ `Installable` and `Reference only` lead, and they partition the
catalogue: every entry is one or the other and the two sum to
`Total`. `Total` alone was the headline for a long time, over a
- catalogue where 85% of the entries cannot fire. */}
+ catalogue where 85% of the entries cannot fire.
+
+ The left card says `Installable`, not `Executable`, and the
+ distinction is not pedantry. It counts every entry the engine loads
+ *plus* the playbooks and plugins, which are shipped installable
+ content but are not engine rules and carry no `executable` field.
+ Labelled `Executable` it read 2,767 under a tooltip saying "loaded
+ by the detection engine" — false for the 164 that are not rules, and
+ 164 above the 2,603 the truth table and the README publish for
+ exactly that claim. Two live surfaces disagreeing about the same
+ word is the tell; `Detections` below carries the rule figure. */}
{stats && (
<div className="grid grid-cols-2 gap-3 sm:grid-cols-6">
{[
- { label: 'Executable', value: executableCount, color: 'text-emerald-400', title: 'Loaded by the detection engine — these can fire.' },
+ { label: 'Installable', value: installableCount, color: 'text-emerald-400', title: 'Detection rules the engine loads, plus every playbook and plugin — everything here can be installed — these can fire.' },
{ label: 'Reference only', value: referenceOnlyCount, color: 'text-amber-400', title: 'Present on disk and not loaded by the engine. They cannot fire; they are here for provenance and for porting.' },
{ label: 'Total', value: stats.total, color: 'text-zinc-100', title: 'Every entry in the catalogue, executable or not.' },
{ label: 'Playbooks', value: stats.playbooks, color: 'text-purple-300' },
@@ -1022,11 +1032,11 @@ export function MarketplaceView() {
capability, and the two disagree in both directions. */}
<div
className="flex gap-1 rounded-lg border border-zinc-700 bg-zinc-800 p-1"
- title="Executable = loaded by the detection engine. Reference only = present on disk and not loaded, so it cannot fire."
+ title="Installable = every entry you can install: the detection rules the engine loads, plus the playbooks and plugins, which are not rules. Reference only = present on disk and not loaded by the engine, so it cannot fire."
>
{([
['all', 'All', undefined],
- ['executable', 'Executable', executableCount],
+ ['executable', 'Installable', installableCount],
['reference', 'Reference only', referenceOnlyCount],
] as const).map(([value, label, count]) => (
<button
diff --git a/tests/test_executable_count_agreement.py b/tests/test_executable_count_agreement.py
new file mode 100644
index 000000000..a1096f5e1
--- /dev/null
+++ b/tests/test_executable_count_agreement.py
@@ -0,0 +1,85 @@
+"""Two surfaces must not publish different numbers under the same word.
+
+The marketplace stat card read **2,767 Executable** under a tooltip saying
+"loaded by the detection engine", while the truth table, the corpus stats and
+the README all publish **2,603** for that claim. Both numbers were correct
+about what they counted and the word was wrong about one of them: the
+marketplace figure is every installable entry, which is the 2,603 rules the
+engine loads *plus* 87 playbooks and 77 plugins that are not engine rules at
+all and carry no `executable` field.
+
+ 2603 + 87 + 77 = 2767
+
+So 164 entries were being described as loaded by an engine that has never
+seen them, and a reader comparing the marketplace with the detections page
+found a 164-rule discrepancy with nothing explaining it.
+
+This gate does not force the two figures to be equal — they measure different
+things and should. It forces the arithmetic between them to hold, so if the
+catalogue grows the relationship is checked rather than assumed, and it
+refuses the label that caused the confusion.
+"""
+
+from __future__ import annotations
+
+import json
+import pathlib
+import re
+
+import pytest
+
+REPO = pathlib.Path(__file__).resolve().parents[1]
+INDEX = REPO / "marketplace" / "index.json"
+VIEW = REPO / "apps" / "web" / "src" / "components" / "marketplace" / "MarketplaceView.tsx"
+
+
[email protected](scope="module")
+def stats() -> dict:
+ return json.loads(INDEX.read_text(encoding="utf-8"))["stats"]
+
+
+class TestTheTwoFiguresReconcile:
+ def test_installable_is_rules_plus_playbooks_and_plugins(self, stats: dict) -> None:
+ """The relationship, asserted rather than assumed.
+
+ `executable` in the index counts every entry the engine loads plus the
+ content that is installable but is not a rule. If that stops being
+ true the two published figures have drifted apart for a new reason,
+ and this says so instead of leaving a reader to find it.
+ """
+ from_engine = stats["executable"] - stats["playbooks"] - stats["plugins"]
+ truth_table = REPO / "docs" / "detections" / "truth-table.md"
+ if not truth_table.is_file():
+ pytest.skip("no truth table to reconcile against")
+ published = re.search(r"(\d[\d,]*)\s+executable", truth_table.read_text(encoding="utf-8"))
+ assert published, "the truth table no longer publishes an executable count in a form this reads"
+ assert from_engine == int(published.group(1).replace(",", "")), (
+ f"the marketplace's installable figure implies {from_engine} engine rules, but the truth table publishes {published.group(1)}"
+ )
+
+ def test_the_partition_still_sums(self, stats: dict) -> None:
+ assert stats["executable"] + stats["quarantined"] == stats["total"]
+
+
+class TestTheLabelMatchesWhatItCounts:
+ def test_the_card_does_not_call_non_rules_executable(self) -> None:
+ """`Installable`, not `Executable`.
+
+ The number includes playbooks and plugins, so a label promising the
+ detection engine loaded them is false for 164 entries — and reads as
+ contradicting the figure every other surface publishes.
+ """
+ source = VIEW.read_text(encoding="utf-8")
+ # Matches the identifier in either spelling, so this fails on the
+ # *label* against the pre-fix tree rather than on the rename — a test
+ # that only knows the new name reports "symbol absent", which proves
+ # nothing about the defect.
+ card = re.search(r"\{\s*label:\s*'([^']+)',\s*value:\s*(?:installableCount|executableCount)", source)
+ assert card, "the mixed-count stat card is gone; re-point this gate"
+ assert card.group(1) == "Installable", f"the card counting playbooks and plugins is labelled {card.group(1)!r}"
+
+ def test_no_tooltip_claims_the_engine_loads_all_of_them(self) -> None:
+ source = VIEW.read_text(encoding="utf-8")
+ # The phrase is fine beside `Detections`, which really is rules only.
+ offending = re.findall(r"title:\s*'Loaded by the detection engine[^']*'", source)
+ assert not offending, f"a tooltip still claims engine execution for the mixed count: {offending}"