From 480ff1f2d9837d0ddc0058cbb94201d16bc6b3c2 Mon Sep 17 00:00:00 2001 From: sextonAF <91710202+sextonAF@users.noreply.github.com> Date: Sat, 14 Nov 2026 21:52:30 -0600 Subject: [PATCH 1/6] Define long-term removable ban marker and consistent list filter --- client/src/lib/permanentBans.ts | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 client/src/lib/permanentBans.ts diff --git a/client/src/lib/permanentBans.ts b/client/src/lib/permanentBans.ts new file mode 100644 index 00000000..5aac9428 --- /dev/null +++ b/client/src/lib/permanentBans.ts @@ -0,0 +1,7 @@ +/** A removable, long-lived CrowdSec ban distinct from automated temporary decisions. + * CrowdSec requires an expiry; ten years is deliberately long, not infinite. + * The reason marker is used by the Banned IPs page and its dashboard count. + */ +export const MANAGED_BAN_REASON = 'permanent-ban'; +export const MANAGED_BAN_DURATION = '87600h'; // ~10 years +export const MANAGED_BAN_QUERY = 'type:ban AND status:active AND origin:cscli AND scenario:permanent-ban'; From 6b15c6a36024af56e7a122a3a653f8c7e26672cf Mon Sep 17 00:00:00 2001 From: sextonAF <91710202+sextonAF@users.noreply.github.com> Date: Sat, 14 Nov 2026 21:52:48 -0600 Subject: [PATCH 2/6] Provide dedicated long-term ban mode in existing modal --- client/src/components/AddDecisionModal.tsx | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/client/src/components/AddDecisionModal.tsx b/client/src/components/AddDecisionModal.tsx index 3edd0258..5af902a2 100644 --- a/client/src/components/AddDecisionModal.tsx +++ b/client/src/components/AddDecisionModal.tsx @@ -1,6 +1,7 @@ import { useEffect, useState, type FormEvent } from 'react'; import { AlertCircle, ShieldCheck } from 'lucide-react'; import { DEFAULT_MANUAL_DECISION_SCENARIO } from '../../../shared/contracts'; +import { MANAGED_BAN_DURATION, MANAGED_BAN_REASON } from '../lib/permanentBans'; import { addDecision, addDecisions, checkAllowlist } from '../lib/api'; import { useI18n } from '../lib/i18n'; import type { @@ -29,6 +30,8 @@ type SkippedBatch = BulkTarget & { entries: BulkAddDecisionResponse['allowlisted interface AddDecisionModalProps { /** In bulk mode (`values` set), `ip` is ignored. */ initialDecision: AddDecisionRequest; + /** Restrict this form to long-lived removable IP bans, not temporary decisions. */ + managedBan?: boolean; /** Adds the same decision for each of these values instead of the single `ip`. */ values?: string[]; instances: InstanceSummary[]; @@ -75,6 +78,7 @@ interface ErrorInfo { export function AddDecisionModal({ initialDecision, + managedBan = false, values, instances, multipleInstances, @@ -239,6 +243,7 @@ export function AddDecisionModal({ const payload: AddDecisionRequest = { ...decision, scenario: selectedScenario, + ...(managedBan ? { type: 'ban' as const, duration: MANAGED_BAN_DURATION, reason: MANAGED_BAN_REASON } : {}), ...(bypassAllowlist ? { bypass_allowlist: true } : {}), }; if (bulk) { @@ -302,8 +307,9 @@ export function AddDecisionModal({ }; return ( - +
+ {managedBan &&

This adds a long-term ban to the Banned IPs list. It can be removed using Unban. CrowdSec requires an expiration, so the ban is set for 10 years.

} {bulk ? (

{t('pages.decisions.bulkValues', { count: bulkValues.length })}

@@ -329,7 +335,7 @@ export function AddDecisionModal({ />
)} -
+ {!managedBan &&
-
-
+
} + {!managedBan &&
updateDecision({ duration: event.target.value })} />

{t('pages.decisions.durationHint')}

-
+
} {scenarioOptions.length > 1 && (
@@ -372,7 +378,7 @@ export function AddDecisionModal({
)} -
+ {!managedBan &&
updateDecision({ reason: event.target.value })} /> -
+
} {multipleInstances && (
From f810a3d56546e41582f21029956c294ce3f1b899 Mon Sep 17 00:00:00 2001 From: sextonAF <91710202+sextonAF@users.noreply.github.com> Date: Sat, 14 Nov 2026 21:53:09 -0600 Subject: [PATCH 3/6] Route Alerts Ban IP toolbar to managed ban mode --- client/src/pages/Alerts.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/client/src/pages/Alerts.tsx b/client/src/pages/Alerts.tsx index 21632b84..ec33d3bd 100644 --- a/client/src/pages/Alerts.tsx +++ b/client/src/pages/Alerts.tsx @@ -2890,6 +2890,7 @@ export function Alerts() { {showToolbarBanIp && ( Date: Sat, 14 Nov 2026 21:53:11 -0600 Subject: [PATCH 4/6] Show only managed long-term bans and use matching add workflow --- client/src/pages/BannedIPs.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/client/src/pages/BannedIPs.tsx b/client/src/pages/BannedIPs.tsx index fe5b9d0b..73541b6a 100644 --- a/client/src/pages/BannedIPs.tsx +++ b/client/src/pages/BannedIPs.tsx @@ -5,9 +5,10 @@ import { Card, CardContent, CardHeader, CardTitle } from '../components/ui/Card' import { Modal } from '../components/ui/Modal'; import { AddDecisionModal } from '../components/AddDecisionModal'; import type { DecisionListItem, InstanceSummary } from '../types'; +import { MANAGED_BAN_QUERY } from '../lib/permanentBans'; const PAGE_SIZE = 50; -const ACTIVE_BAN_QUERY = 'type:ban AND status:active AND origin:cscli'; +const ACTIVE_BAN_QUERY = MANAGED_BAN_QUERY; export function BannedIPs() { const [instances, setInstances] = useState([]); @@ -76,7 +77,7 @@ export function BannedIPs() {
{showAdd && 1} currentInstanceId={scope!=='all'?scope:undefined} From 577837e182f980e0fabdb0f2787350d8adafb954 Mon Sep 17 00:00:00 2001 From: sextonAF <91710202+sextonAF@users.noreply.github.com> Date: Sat, 14 Nov 2026 21:53:13 -0600 Subject: [PATCH 5/6] Count only managed bans on dashboard --- client/src/pages/Dashboard.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/src/pages/Dashboard.tsx b/client/src/pages/Dashboard.tsx index aaad70bd..242bf1f8 100644 --- a/client/src/pages/Dashboard.tsx +++ b/client/src/pages/Dashboard.tsx @@ -23,6 +23,7 @@ import { ShieldBan } from "lucide-react"; import { DASHBOARD_COLORS } from "../lib/dashboardColors"; +import { MANAGED_BAN_QUERY } from "../lib/permanentBans"; import { getCountryCodesMatchingName, getCountryName } from "../lib/utils"; import type { ConfigResponse, @@ -679,7 +680,7 @@ export function Dashboard() { useEffect(() => { let cancelled=false; // Count manually imposed bans shown in Banned IPs; automated decisions remain on Decisions. - void fetchDecisionsPaginated(1,1,{q:'type:ban AND status:active AND origin:cscli'}) + void fetchDecisionsPaginated(1,1,{q:MANAGED_BAN_QUERY}) .then(result=>{if(!cancelled)setActiveBanDecisions(result.pagination.total);}) .catch(()=>{if(!cancelled)setActiveBanDecisions(null);}); return ()=>{cancelled=true;}; @@ -1624,7 +1625,7 @@ export function Dashboard() {

Total banned IPs

{activeBanDecisions===null?'—':activeBanDecisions.toLocaleString()}

-

Manually imposed IP bans

+

Long-term managed IP bans

From e6b8634a1afbd39ad8d76f6c751b7e56791e44bd Mon Sep 17 00:00:00 2001 From: sextonAF <91710202+sextonAF@users.noreply.github.com> Date: Sat, 14 Nov 2026 21:53:43 -0600 Subject: [PATCH 6/6] Keep managed-ban dialog focused on IP and server only --- client/src/components/AddDecisionModal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/components/AddDecisionModal.tsx b/client/src/components/AddDecisionModal.tsx index 5af902a2..ff96b6fe 100644 --- a/client/src/components/AddDecisionModal.tsx +++ b/client/src/components/AddDecisionModal.tsx @@ -362,7 +362,7 @@ export function AddDecisionModal({ />

{t('pages.decisions.durationHint')}

} - {scenarioOptions.length > 1 && ( + {!managedBan && scenarioOptions.length > 1 && (