Skip to content

Commit 23a725d

Browse files
committed
Fix Hub parsing, decisions & docs
Add debug notes and fixes for multiple issues: strip preamble text before JSON parsing in hub handlers to avoid broken Hub Browser; add missing Hub categories (appsec-configs, appsec-rules, contexts) in frontend types/tabs/parse logic; implement fallback parsing for manually-added (flat) decisions so they appear in Decisions UI; correct notifications YAML formatting (use block sequences and 1-space indent). Also update README and docs to a simplified stable 1.0.0 onboarding flow (compose examples, networks, volumes, quick-start), add DEBUG_FINDINGS.md, and apply related frontend/backend file edits (hub handlers, hub API, HubBrowser/HubCategory, docs site files and minor package-lock cleanups). These changes address parsing bugs and improve documentation for the stable release.
1 parent 0c23c5c commit 23a725d

16 files changed

Lines changed: 319 additions & 1103 deletions

File tree

DEBUG_FINDINGS.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Debug Findings
2+
3+
## Issue 1: Hub Browser Blank Page
4+
5+
**Root Cause:** `cscli hub list -o json` outputs informational preamble lines to stdout before the JSON:
6+
7+
```
8+
Loaded: 161 parsers, 11 postoverflows, 774 scenarios, 9 contexts, 5 appsec-configs, 187 appsec-rules, 160 collections
9+
Unmanaged items: 1 local, 0 tainted
10+
{
11+
"appsec-configs": [...],
12+
"collections": [...],
13+
...
14+
}
15+
```
16+
17+
The backend `ListHubItems` handler tried to `json.Unmarshal` the full output (including preamble), which failed. It then returned the raw string as `Data`. The frontend `parseHubItems` attempted `JSON.parse` on it, which also failed due to the preamble text, resulting in `rawParseError: true` and empty items — a blank page.
18+
19+
Additionally, the frontend `HUB_TABS` only listed 4 categories (`scenarios`, `parsers`, `collections`, `postoverflows`) but CrowdSec now returns 7 categories (adding `appsec-configs`, `appsec-rules`, `contexts`).
20+
21+
**Fix (Backend):** `internal/api/handlers/hub.go` — Strip any text before the first `{` character in `ListHubItems` and `ListHubItemsByCategory` before attempting JSON parse.
22+
23+
**Fix (Frontend):**
24+
- `web/src/pages/HubBrowser.tsx` — Added `appsec-configs`, `appsec-rules`, `contexts` to `HubItemType`, `HUB_TABS`, `EMPTY_HUB_ITEMS`, and `parseHubItems`.
25+
- `web/src/lib/api/hub.ts` — Added `contexts` to `HubCategoryKey` type.
26+
- `web/src/pages/HubCategory.tsx` — Added `contexts` to `categoryMeta`.
27+
28+
## Issue 2: Manual Decisions Not Showing in Decisions UI
29+
30+
**Root Cause:** Manual decisions added via `cscli decisions add` produce a different JSON structure. Regular decisions are nested inside alerts (`alert.decisions[]`), but manual decisions appear as flat top-level objects without a `decisions` sub-array. The `GetDecisions` handler only parsed nested decisions, missing the flat ones.
31+
32+
**Fix:** Added fallback parsing in `GetDecisions` and `GetDecisionsAnalysis` — if no nested `decisions` array is found within an alert, check if the top-level item itself has decision fields (e.g. `type`). If so, parse it as a standalone decision. The shared `parseDecisionNode` helper in `common.go` is used for both paths.
33+
34+
## Issue 3: Notification Profiles YAML Formatting
35+
36+
**Root Cause:** `updateProfilesYaml` in `notifications_yaml.go` used `yaml.FlowStyle` for the notifications sequence node, producing `notifications: [discord]` instead of block style. Also used `encoder.SetIndent(2)` instead of matching CrowdSec's default 1-space indent.
37+
38+
**Fix:** Removed `FlowStyle` from sequence nodes and changed `encoder.SetIndent(1)` to match CrowdSec profiles.yaml format.

0 commit comments

Comments
 (0)