From 707142c6bbb63ec9577cf1b61abf864449230ef2 Mon Sep 17 00:00:00 2001 From: CyberMind-FR Date: Fri, 20 Mar 2026 16:16:32 +0100 Subject: [PATCH] fix(crowdsec-dashboard): Fix JSON parsing bug in overview cache grep -c returns exit code 1 when count is 0, which triggered the `|| echo 0` fallback to also output "0", resulting in: "waf_threats_today":0 0, This broke JSON parsing and caused the dashboard to show CrowdSec as "STOPPED" even when running. Fix: Use `|| :` (no-op) and set defaults with `: "${var:=0}"` Co-Authored-By: Claude Opus 4.5 --- .../root/usr/libexec/rpcd/luci.crowdsec-dashboard | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package/secubox/luci-app-crowdsec-dashboard/root/usr/libexec/rpcd/luci.crowdsec-dashboard b/package/secubox/luci-app-crowdsec-dashboard/root/usr/libexec/rpcd/luci.crowdsec-dashboard index 03eb3039..7537c3e3 100755 --- a/package/secubox/luci-app-crowdsec-dashboard/root/usr/libexec/rpcd/luci.crowdsec-dashboard +++ b/package/secubox/luci-app-crowdsec-dashboard/root/usr/libexec/rpcd/luci.crowdsec-dashboard @@ -2541,13 +2541,15 @@ refresh_overview_cache() { if [ -f "$threats_log" ]; then local today today=$(date -u +%Y-%m-%d) - waf_threats_today=$(grep -c "\"timestamp\": \"$today" "$threats_log" 2>/dev/null || echo 0) + waf_threats_today=$(grep -c "\"timestamp\": \"$today" "$threats_log" 2>/dev/null || :) + : "${waf_threats_today:=0}" fi local autoban_processed=0 local autoban_log="/srv/mitmproxy-in/autoban-processed.log" if [ -f "$autoban_log" ]; then - autoban_processed=$(wc -l < "$autoban_log" 2>/dev/null || echo 0) + autoban_processed=$(wc -l < "$autoban_log" 2>/dev/null || :) + : "${autoban_processed:=0}" fi local cache_timestamp