Skip to content

Add alerts and collections pages#177

Open
stephdl wants to merge 21 commits into
mainfrom
feature/alerts-collections
Open

Add alerts and collections pages#177
stephdl wants to merge 21 commits into
mainfrom
feature/alerts-collections

Conversation

@stephdl

@stephdl stephdl commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Add three new pages to the CrowdSec module: Alerts, Collections, and Central API (CAPI). Also extend the existing backend to support these views.

Alerts page

  • Table with columns: Date, Scenario, Source IP, Country, Decision, Events count
  • Decision column shows a red "Ban" tag or "-" when no decision
  • Tooltip on the page title explaining what alerts are
  • Search by IP or scenario
  • Inspect alert: overflow menu per row opens a detail modal showing message, source IP, scenario + version, attack window, events/capacity/leakspeed, decision, remediation flag, simulated flag, and a paginated event log (timestamp + service)
  • Delete all alerts: danger button with confirmation modal — calls cscli alerts delete --all

Collections page

  • Table with columns: Name, Status (green/gray tag), Version (local_version), Description
  • Tainted collections show an info tooltip on the version cell
  • Tooltip on the page title explaining what collections are
  • Link to CrowdSec Hub for browsing available collections
  • Enable/disable per row with a confirmation modal — calls cscli collections install|remove then sends SIGHUP to reload
  • Uses --all flag to list both enabled and disabled collections

Central API (CAPI) page

  • Reload button to refresh CAPI connection status
  • Connection status indicator (connected / disconnected)
  • When connected: subscription tier, signal sharing status, and community blocklist pull status shown as tags
  • IP count from the community blocklist (skipped when pull is disabled)
  • Warning banner when CAPI is disabled at the module configuration level
  • IP search: validates IPv4 (strict 0–255 octet range) and IPv6; queries cscli decisions list against the CAPI blocklist
  • Search results show matching decisions (scenario, type, duration) with links to CrowdSec CTI and IP removal request

Backend actions (new)

  • list-alertscscli alerts list --output json
  • inspect-alertcscli alerts inspect <id> --output json
  • delete-alertscscli alerts delete --all
  • list-collectionscscli collections list --all --output json
  • toggle-collectioncscli collections install|remove <name> + kill -HUP 1
  • get-capi-status — parses cscli capi status plain-text output (JSON flag ignored by cscli)
  • get-capi-count — counts CAPI decisions via cscli decisions list --origin CAPI
  • search-capi-decision — searches CAPI decisions for a given IP

Backend changes (existing)

  • configure-module: added 79cleanup-capi step that purges CAPI decisions when the Central API or community blocklist pull is disabled
  • get-configuration: exposes enable_online_api flag derived from the DISABLE_ONLINE_API env var

Settings page

  • Added inline notification when smarthost is not configured, with a direct link to the Smarthost settings page

Side menu

Reordered: Status → Settings → Collections → Alerts → Banned IP → About

i18n

All new keys added to the English locale (en/translation.json).

@stephdl stephdl force-pushed the feature/alerts-collections branch 4 times, most recently from 1dbda7b to 8885e39 Compare June 24, 2026 15:12
@stephdl stephdl requested a review from Copilot June 24, 2026 16:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds two new UI pages to the NS8 CrowdSec module (Alerts and Collections) and introduces the corresponding backend actions to list/inspect/delete alerts and list/toggle collections.

Changes:

  • Added Alerts page with listing, inspection modal, and “delete all alerts” flow.
  • Added Collections page with list + enable/disable (toggle) flow and confirmation modal.
  • Added backend actions (with JSON schema validation where applicable) to support the new UI.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
ui/src/views/Collections.vue New Collections page with list + toggle flow and Hub link notification
ui/src/views/Alerts.vue New Alerts page with list, inspect modal, and delete-all flow
ui/src/router/index.js Adds routes for /alerts and /collections
ui/src/components/InspectAlertModal.vue New modal to show alert details and event list
ui/src/components/ConfirmToggleCollectionModal.vue New confirmation modal for collection enable/disable
ui/src/components/ConfirmDeleteAlertsModal.vue New confirmation modal for deleting all alerts
ui/src/components/AppSideMenuContent.vue Adds side menu links for Collections and Alerts
ui/public/i18n/en/translation.json Adds i18n keys for Alerts/Collections UI and new action names
imageroot/actions/toggle-collection/validate-input.json Input schema for toggle-collection action
imageroot/actions/toggle-collection/10toggle-collection Backend action to install/remove a collection and reload
imageroot/actions/list-collections/validate-output.json Output schema for list-collections action
imageroot/actions/list-collections/10list-collections Backend action to list collections (JSON)
imageroot/actions/list-alerts/validate-output.json Output schema for list-alerts action
imageroot/actions/list-alerts/10list-alerts Backend action to list alerts (JSON)
imageroot/actions/inspect-alert/validate-input.json Input schema for inspect-alert action
imageroot/actions/inspect-alert/10inspect-alert Backend action to inspect an alert by id (JSON)
imageroot/actions/delete-alerts/validate-output.json Output schema for delete-alerts action
imageroot/actions/delete-alerts/10flush-alerts Backend action to delete all alerts

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ui/src/components/ConfirmDeleteAlertsModal.vue
Comment thread ui/src/views/Collections.vue Outdated
Comment thread ui/src/views/Collections.vue
Comment thread ui/src/components/ConfirmToggleCollectionModal.vue
Comment thread imageroot/actions/list-collections/10list-collections
Comment thread imageroot/actions/list-alerts/10list-alerts
Comment thread imageroot/actions/toggle-collection/10toggle-collection Outdated
@stephdl stephdl force-pushed the feature/alerts-collections branch from a6c7a66 to a321087 Compare June 25, 2026 08:53
@stephdl stephdl requested a review from Copilot June 26, 2026 07:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 34 out of 35 changed files in this pull request and generated 12 comments.

Comment thread ui/src/views/Collections.vue
Comment thread ui/src/views/Collections.vue
Comment thread ui/src/views/Collections.vue
Comment thread ui/src/components/InspectAlertModal.vue Outdated
Comment thread ui/src/views/Capi.vue
Comment thread imageroot/actions/list-collections/10list-collections
Comment thread imageroot/actions/list-alerts/10list-alerts
Comment thread imageroot/actions/toggle-collection/10toggle-collection Outdated
Comment thread imageroot/actions/inspect-alert/10inspect-alert Outdated
Comment thread imageroot/actions/delete-alerts/10flush-alerts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 34 out of 35 changed files in this pull request and generated 10 comments.

Comment thread ui/src/views/Collections.vue
Comment thread ui/src/views/Collections.vue
Comment thread ui/src/views/Alerts.vue
Comment thread ui/src/views/Alerts.vue
Comment thread imageroot/actions/get-capi-status/10get-capi-status Outdated
Comment thread imageroot/actions/get-capi-count/10get-capi-count
Comment thread imageroot/actions/search-capi-decision/10search-capi-decision
Comment thread imageroot/templates/config.yaml.local Outdated
Comment thread ui/src/components/AppSideMenuContent.vue
Comment thread ui/src/views/Status.vue
stephdl added 16 commits June 26, 2026 10:29
… for confirming deletion and toggling collections
…bles

- Implemented the Alerts view with a data table for displaying alerts, including functionalities for listing, inspecting, and deleting alerts.
- Created the Capi view to show the status of CAPI connections, including search functionality for IP addresses and displaying relevant notifications.
- Developed the Collections view to manage collections with a data table, allowing users to enable/disable collections and view their statuses.
- Added modals for confirming actions in both the Collections and Alerts views.
- Enhanced the Settings view to include a toggle for pulling the community blocklist.
- Updated the Status view to improve service status display and added a computed property for failed services.
@stephdl stephdl force-pushed the feature/alerts-collections branch from f0766ff to 09e7f06 Compare June 26, 2026 08:31
stephdl added 4 commits June 26, 2026 10:41
When CAPI is fully disabled, cscli exits non-zero with 'no configuration'.
Capture output with || true so set -e does not abort the script.
Also match 'no configuration' in the config_disabled check.
@stephdl stephdl force-pushed the feature/alerts-collections branch from 862422b to e156158 Compare June 26, 2026 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants