fix(system-hub): Fix get_denoise_stats RPCD returning no response

- Replace jsonfilter with grep for CrowdSec decision counting
- Add ipset existence check before listing blocked IPs
- Add safety fallbacks for empty/invalid counts
- Bump version to 0.5.2-r2

The jsonfilter -e '@[*]' approach failed with CrowdSec's
multi-line JSON output, causing exit code 251 errors.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
CyberMind-FR 2026-02-21 07:05:24 +01:00
parent cec4893db9
commit f9f2be9252
146 changed files with 302 additions and 263 deletions

View File

@ -2677,3 +2677,12 @@ git checkout HEAD -- index.html
- Attack categories: 18 (Brute-Force), 21 (Web App Attack)
- Files: `luci-app-crowdsec-dashboard/root/usr/sbin/crowdsec-reporter.sh`,
`luci-app-crowdsec-dashboard/htdocs/luci-static/resources/view/crowdsec-dashboard/reporter.js`
30. **Log Denoising RPCD Fix (2026-02-21)**
- Fixed `get_denoise_stats` RPCD method returning "No response" (exit code 251)
- Root cause: `jsonfilter -e '@[*]'` doesn't work with CrowdSec JSON output
- Solution: Use `grep -c '"id":'` to count CrowdSec decisions instead
- Added fallback safety checks for empty/invalid counts
- Added missing ipset existence check before trying to list IPs
- Version bumped to 0.5.2-r2
- Files modified: `luci-app-system-hub/root/usr/libexec/rpcd/luci.system-hub`

View File

@ -377,7 +377,9 @@
"Bash(npx terser:*)",
"Bash(read)",
"Bash(/home/reepost/CyberMindStudio/secubox-openwrt/secubox-tools/c3box-vm-builder.sh:*)",
"Bash(__NEW_LINE_ba6f66f0b013f58d__ echo \"\")"
"Bash(__NEW_LINE_ba6f66f0b013f58d__ echo \"\")",
"WebFetch(domain:cf.gk2.secubox.in)",
"WebFetch(domain:streamlit.gk2.secubox.in)"
]
}
}

View File

@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-system-hub
PKG_VERSION:=0.5.2
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_ARCH:=all
PKG_LICENSE:=Apache-2.0
PKG_MAINTAINER:=CyberMind <contact@cybermind.fr>

View File

@ -667,16 +667,20 @@ get_denoise_stats() {
# Count blocked IPs
local blocked_count=0
if command -v nft >/dev/null 2>&1 && nft list set inet fw4 "$ipset_name" >/dev/null 2>&1; then
blocked_count=$(nft list set inet fw4 "$ipset_name" 2>/dev/null | grep -oE '([0-9]{1,3}\.){3}[0-9]{1,3}' | wc -l)
elif command -v ipset >/dev/null 2>&1; then
blocked_count=$(ipset list "$ipset_name" 2>/dev/null | grep -c '^[0-9]' || echo 0)
blocked_count=$(nft list set inet fw4 "$ipset_name" 2>/dev/null | grep -oE '([0-9]{1,3}\.){3}[0-9]{1,3}' | wc -l 2>/dev/null || echo 0)
elif command -v ipset >/dev/null 2>&1 && ipset list "$ipset_name" >/dev/null 2>&1; then
blocked_count=$(ipset list "$ipset_name" 2>/dev/null | grep -c '^[0-9]' 2>/dev/null || echo 0)
fi
# Ensure it's a valid number
[ -z "$blocked_count" ] && blocked_count=0
# Count CrowdSec decisions
# Count CrowdSec decisions (count unique decision IDs)
local crowdsec_count=0
if command -v cscli >/dev/null 2>&1; then
crowdsec_count=$(cscli decisions list -o json 2>/dev/null | jsonfilter -e '@[*]' 2>/dev/null | wc -l || echo 0)
crowdsec_count=$(cscli decisions list -o json 2>/dev/null | grep -c '"id":' 2>/dev/null || echo 0)
fi
# Ensure it's a valid number
[ -z "$crowdsec_count" ] && crowdsec_count=0
# Check if ipblocklist is enabled
local ipblocklist_enabled

Some files were not shown because too many files have changed in this diff Show More