Skip to content

feat(threat_shield): custom allow and block lists - #2003

Merged
gsanchietti merged 5 commits into
release-8.9.0from
custom_allowlist_blocklist
Nov 12, 2026
Merged

gsanchietti merged 5 commits into
release-8.9.0from
custom_allowlist_blocklist

Conversation

@gsanchietti

@gsanchietti gsanchietti commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Threat Shield IP only accepts the Nethesis feeds and the banIP built-in feeds. Administrators asked to add their own remote lists of IP addresses to block or to never block. Refs #2005.

This adds custom allowlists and custom blocklists, both downloaded from a URL. They work with or without a subscription. The Nethesis global allowlist is shown as a fixed row in the allowlists: enabled with a subscription, disabled without one, and it can't be changed or deleted. Existing configurations keep working: old hand-made allowlist URLs become custom allowlist rows on upgrade.

  • ns.threatshield: new methods to list, add, edit and delete allowlist URLs and custom blocklists. Only http/https URLs with safe characters are accepted.
  • ts-ip rebuilds the banIP allowlist and feed settings from the configuration, so changes apply right after saving.
  • Phonehome reports how many custom allowlists and blocklists are enabled.
  • New method list-blocklist-bans: the addresses dropped by banIP lists in the last hour, read from VictoriaLogs, one row per address, most hits first (at most 500). The Threat Shield IP page shows them in a new tab, so it no longer looks empty when nothing triggers fail2ban.

How to test

  1. Add a custom allowlist and a custom blocklist from the Threat Shield IP page, turn the blocklist on, and save. Check that nft list set inet banIP allowlist.v4 and nft list set inet banIP <name>.v4 contain the list addresses.
  2. Change a URL or turn a list off and save: the sets update at once.
  3. Check the Nethesis allowlist row: enabled and locked with a subscription, disabled without one.
  4. Upgrade a machine with a hand-made ban_allowurl entry: it shows up as a custom allowlist named allow1.
  5. On a unit reachable from the internet, run ubus call ns.threatshield list-blocklist-bans: it lists the banned addresses with their list, direction, hits and last seen time.

See also

The chore(ns-ui): TEMP commit builds the UI from NethServer/nethsecurity-ui#852: drop it before merging.


Generated by Claude Code:claude-haiku-5-5 with nethserver-pr

@gsanchietti gsanchietti self-assigned this Nov 6, 2026
@gsanchietti
gsanchietti force-pushed the custom_allowlist_blocklist branch 4 times, most recently from 719973b to 9f6e2c3 Compare November 10, 2026 10:12
@gsanchietti
gsanchietti force-pushed the custom_allowlist_blocklist branch 3 times, most recently from f140bd5 to d207ca2 Compare November 11, 2026 10:16
@gsanchietti
gsanchietti marked this pull request as ready for review November 11, 2026 10:29
@gsanchietti
gsanchietti force-pushed the custom_allowlist_blocklist branch from d207ca2 to 26756b5 Compare November 11, 2026 11:26
The threat_shield inventory fact reports the number of enabled
custom allowlist URLs and custom blocklists.

Refs #2005

Assisted-by: Claude Code:claude-opus-5-5
ns.threatshield manages remote allowlist URLs and custom blocklists,
and lists the Nethesis global allowlist as a read-only built-in row,
enabled only with a subscription. Edits replace the whole entry.
Custom list names can't clash with builtin feeds, and a custom list
is always listed as custom. Threat Shield IP status no longer depends
on the Nethesis allowlist URL.

Refs #2005

Assisted-by: Claude Code:claude-opus-5-5
ts-ip rebuilds ban_allowurl and banip.custom.feeds from the
ns_allowurl and ns_blockfeed sections. Legacy ban_allowurl entries
are moved once to ns_allowurl sections, also on upgrade. The
post-commit hook runs ts-ip and drops the banIP backups of lists
whose URL changed; ts-fail2ban runs once per commit. On upgrade
the feed copy is refreshed without starting fail2ban.

Refs #2005

Assisted-by: Claude Code:claude-opus-5-5
A non-empty banip.custom.feeds holds a copy of banip.feeds and banIP
reads only that file, so rerun ts-ip after a banip upgrade to pick
up new or changed upstream feeds.

Refs #2005

Assisted-by: Claude Code:claude-opus-5-5
@gsanchietti
gsanchietti force-pushed the custom_allowlist_blocklist branch 2 times, most recently from a1d2a45 to eef7242 Compare November 11, 2026 17:01
@gsanchietti
gsanchietti force-pushed the custom_allowlist_blocklist branch 4 times, most recently from 13fcde6 to 8d7bd3a Compare November 12, 2026 08:07

@Tbaile Tbaile left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There's no way to have some sort of notice if a list fails the download? Making them look into the logs is going to hurt us in the end 😢

The Threat Shield IP page had nothing to show when fail2ban banned
nobody, even while banIP lists dropped traffic all the time.

New method list-blocklist-bans: the addresses dropped by banIP lists
in the last hour, read from VictoriaLogs, one row per address, list
and direction, most hits first, at most 500 rows. It returns an
empty list when VictoriaLogs can't be reached.

Assisted-by: Claude Code:Opus 5.5
@gsanchietti
gsanchietti force-pushed the custom_allowlist_blocklist branch from 8d7bd3a to e4f07d9 Compare November 12, 2026 09:50
@gsanchietti

Copy link
Copy Markdown
Member Author

There's no way to have some sort of notice if a list fails the download? Making them look into the logs is going to hurt us in the end 😢

Yes, only if we drop banip 😈

@gsanchietti
gsanchietti force-pushed the custom_allowlist_blocklist branch from e4f07d9 to 7e926a1 Compare November 12, 2026 09:58
@gsanchietti
gsanchietti force-pushed the custom_allowlist_blocklist branch from 27c682e to 8cf53a8 Compare November 12, 2026 13:25
@gsanchietti
gsanchietti merged commit 20bd8a1 into release-8.9.0 Nov 12, 2026
@gsanchietti
gsanchietti deleted the custom_allowlist_blocklist branch November 12, 2026 13:26
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.

3 participants