Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
3a72e26
chore: version bump
Tbaile Nov 2, 2026
f114356
build: debian update
Tbaile Nov 2, 2026
43ba233
bumped binaries
Tbaile Nov 2, 2026
585d7f8
fixed patches
Tbaile Nov 3, 2026
cddc68e
fix: updating telegraf configuration for banip
Tbaile Nov 3, 2026
f351d1b
feat: added storage monitoring
Tbaile Nov 3, 2026
a88d119
refactor: making victoria-logs save persistent data
Tbaile Nov 5, 2026
0342739
feat(setup): add root password action
filippocarletti Nov 3, 2026
cfb3ad1
feat(setup): toggle WAN UI access
gsanchietti Nov 4, 2026
fb25b46
feat(firewall): disable WAN UI access by default
gsanchietti Nov 4, 2026
610cafd
fix(setup): report root password change result
gsanchietti Nov 4, 2026
d99349e
fix(setup): use Success and Error dialog titles
gsanchietti Nov 4, 2026
8f7bbd2
feat: added proxying of victoria-logs
Tbaile Nov 4, 2026
a389743
build: added ulogd
Tbaile Nov 4, 2026
4175338
ui bump
Tbaile Nov 4, 2026
b2b1918
build: enabled DCO for openvpn
Tbaile Nov 4, 2026
a2c1577
fix: adjusted some log levels
Tbaile Nov 4, 2026
d36232f
fix(ns-binding): limit log rate for DROP messages in binding tables (…
m-dilorenzi Nov 5, 2026
ba2a5ab
fix(adblock): hide feed credentials in logs
gsanchietti Nov 5, 2026
6268935
fix(dpi): making scripts behave using syslog
Tbaile Nov 6, 2026
ece00fc
feat(logs): per-package pre log processor (#2004)
Tbaile Nov 6, 2026
0629da1
feat(threat_shield): fail2ban brute force bans (#1977)
gsanchietti Nov 6, 2026
bac939f
ui bump
Tbaile Nov 6, 2026
551187c
ci: fixed issue with deduping sarif checks
Tbaile Nov 6, 2026
a7eb859
build: removed image builder
Tbaile Nov 9, 2026
c958549
fix(api-server): avoid panic on invalid logout (#1999)
gsanchietti Nov 9, 2026
89ca2bb
fix(restore-extra-packages): stop respawn loop (#1997)
gsanchietti Nov 9, 2026
d7819a6
fix(vmalert): start after VictoriaMetrics (#1998)
gsanchietti Nov 9, 2026
582c64f
fix(ns-plug): show ns-plug as controller in alerts (#1993)
gsanchietti Nov 9, 2026
11d412b
fix(ovpnrw): list disabled accounts of deleted remote users (#1981)
m-dilorenzi Nov 9, 2026
fbe780d
fix(wireguard): enable mtu_fix on new tunnel zones (#1994)
m-dilorenzi Nov 10, 2026
e1e94a0
fix(openvpn): refuse connection of users removed from remote database…
m-dilorenzi Nov 10, 2026
535e177
fix(nat): list real devices with bound interfaces in NAT rules device…
m-dilorenzi Nov 10, 2026
1109f53
feat: added monitoring for user-facing or demanding processes
Tbaile Nov 10, 2026
c9f44ed
build: adding ice firmware support (#2012)
Tbaile Nov 11, 2026
6a455e9
refactor(logs): now all logs pass through our transformation layer (#…
Tbaile Nov 12, 2026
a2f3b29
feat: moving nft logs out of the kernel log (#2010)
Tbaile Nov 12, 2026
8d2f59c
feat(python3-nethsec): report custom IP lists
gsanchietti Nov 11, 2026
3e3b535
feat(ns-api): custom allow and block lists
gsanchietti Nov 11, 2026
ddd9a58
feat(threat_shield): build banIP lists from UCI
gsanchietti Nov 11, 2026
6945071
fix(banip): refresh custom feeds on upgrade
gsanchietti Nov 11, 2026
a424378
feat(ns-api): list blocklist bans
gsanchietti Nov 12, 2026
ee47b15
chore(ns-ui): build UI from release-8.9.0
gsanchietti Nov 12, 2026
b318402
feat(netifyd): added monitoring for statistics
Tbaile Nov 12, 2026
dec3443
fix(ns-api-server): using syslog correctly, with locking and connecting
Tbaile Nov 12, 2026
1182e0d
fix: removing from log even more sensible informations (#2015)
Tbaile Nov 13, 2026
8e1826c
fix: addressing service issues on close role switches (#1930)
Tbaile Nov 13, 2026
310b80e
refactor: making subscription caching if success (#2013)
Tbaile Nov 16, 2026
affd356
fix(ovpn): DCO status hang and disable toggle (#2018)
Tbaile Nov 17, 2026
bca55e1
fix: adjusted file limits for victoria, added new proxy to logs
Tbaile Nov 17, 2026
ecd8564
feat(dpi): add support for source objects in DPI rules and address gr…
m-dilorenzi Nov 19, 2026
fd809bc
feat(firewall): disable HTTPS access from WAN by default (#2020)
m-dilorenzi Nov 19, 2026
a9e5252
chore: ui bump
Tbaile Nov 20, 2026
154d382
feat: added background management skill
Tbaile Oct 14, 2026
f27b1c6
feat: added another skill for state and persistence
Tbaile Oct 14, 2026
87a4fcb
feat: added fw4 integration, added references to state
Tbaile Oct 14, 2026
865dcc1
feat: added logic on code placement
Tbaile Oct 14, 2026
72c3997
feat: added platform integration skill
Tbaile Oct 20, 2026
219cfad
made the harness force print the proposed issue
Tbaile Oct 20, 2026
4351361
feat: added user calling the function to python handlers
Tbaile Oct 20, 2026
0437503
fix(inventory): removing nethsupport from user count
Tbaile Oct 20, 2026
a7a82e6
feat: added first checks for permissions in api
Tbaile Oct 20, 2026
fcf2c26
feat: added admin informations from the ns.account
Tbaile Oct 20, 2026
ca10a70
feat: added ns.ssh management and token removal on delete of users
Tbaile Oct 20, 2026
923ca3c
feat: added more restrictions to backups, migrations and updates
Tbaile Oct 21, 2026
d19cd0c
chore: ui pin
Tbaile Nov 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .agents/skills/create-issue/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ Presentation matters (per handbook): use code fences for logs and commands, list

### 4. Show the draft, then get go-ahead

**Showing the draft means printing, in chat: the title, the complete body, the type, the milestone and the assignee.** Printing the `gh` command instead of the body is not showing the draft. Neither is describing what the body says.
**Showing the draft means printing, in chat: the title, the complete body, the type, the milestone and the assignee.** Printing the `gh` command instead of the body is not showing the draft. Neither is describing what the body says. Text printed in the same response as an `AskUserQuestion` call is hidden behind the dialog, so the draft goes in a response of its own: print it and end the turn, with the question in plain text at the bottom.

Fields first, permission second — they are separate exchanges:

1. Resolve the field candidates: `gh api repos/NethServer/nethsecurity/milestones --jq '.[].title'` and `gh api user --jq '.login'`. Ask milestone and assignee in one question, offering the nearest open milestone and the user's own login as the suggested answers (both may legitimately be "none"). Ask about type here too if it was ambiguous in step 1.
2. Re-show the corrected draft in full, then ask separately whether to file it.
2. Re-show the corrected draft in full and end the turn, asking in plain text whether to file it.

**Never write to GitHub without explicit confirmation for that specific write.** This gate covers every write: `gh issue create`, `gh issue edit`, `gh issue comment`, `gh pr edit`, and any label/milestone/assignee change. Permission to file is not permission to then edit, comment, or touch a PR — each one is asked for on its own. Issues are public and notify subscribers.

Expand Down
23 changes: 22 additions & 1 deletion .agents/skills/netifyd/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ until the next reload and then vanishes. Change the generator or its UCI input i
| `table inet netifyd` (nftables) | `/usr/sbin/ns-netifyd-configure` (on start and reload) | `/etc/config/netifyd` → `ns_config` |
| `netify-application-catalog.json` and the other catalog/category files | `dpi-data-update` (nightly cron) | Netify's data service |
| `/usr/share/nftables.d/table-pre/` DPI chains | `/usr/sbin/dpi-nft` | `/etc/config/dpi` |
| `address-groups.d/30-*.conf` | `nethsec.dpi.write_address_groups` (on commit, by `ns.ovpnrw`, by `/usr/sbin/dpi`) | `/etc/config/objects`, `dhcp`, `users` |

`/usr/sbin/dpi` is the whole DPI apply path: `dpi-config` → `dpi-nft` → `/etc/init.d/netifyd reload`.
`/usr/sbin/dpi` is the whole DPI apply path: `dpi-migrate` → `write-address-groups` → `dpi-config` → `dpi-nft` →
`/etc/init.d/netifyd reload`.
Run it after changing `/etc/config/dpi`; don't reproduce its steps by hand.

---
Expand Down Expand Up @@ -204,6 +206,25 @@ Two operational facts:

MAC members only match via `mac ==`, so don't put them in a group a `local_ip` rule references.

The `30-` prefix belongs to `nethsec.dpi.write_address_groups`: one `30-<database>_<id>.conf` group
per firewall object resolving to addresses, used by a DPI rule or not, with a `# <object name>` and a
`# <id>, generated from the firewall objects: do not edit` header, and every other `30-*.conf` file is
removed. It runs from the `update-address-groups.py` post-commit hook (`objects`, `dhcp`, `users`), from
`ns.ovpnrw` (reserved IP of a VPN user) and from `/usr/sbin/dpi`, before `dpi-config`: at boot the `dpi`
service (`START=40`) runs it before netifyd (`START=99`); `dpi-config` only references the groups. The `30-*.conf` files are in
`/lib/upgrade/keep.d/ns-dpi`, so backups and the HA sync carry them. The agent keeps the groups it loaded
in memory, a reload doesn't drop the ones whose file was removed (it drops their single addresses, not
their networks), and on stop it saves all of them back, without comments: that's why ownership goes by
prefix. The group of a deleted object therefore comes back as a file on the next agent restart
(unreferenced, so harmless) until the next write removes it; the boot write runs between the stop that
saved it and the start that would load it, so after a reboot it is gone from memory too. The
`flush-address-group` socket command drops a group from memory and deletes its file. A `kill -9` saves nothing. Verified on a device with agent 5.2.9: a reload re-reads the groups
without restarting the agent; a range line is silently ignored, so ranges are written as CIDR blocks;
a `/0` matches nothing (in a group and inline), so it is written as two `/1`; an IPv4-mapped IPv6 address
never matches an IPv4 flow; an empty group or a missing tag matches nothing without errors. IPv6
literals written inline in a criteria, especially the ones starting with `::`, were seen to trigger an
intermittent `criteria parse error` that takes the agent down: a group reference never does.

---

## Verify on a live device
Expand Down
262 changes: 262 additions & 0 deletions .agents/skills/ns-background-work/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,262 @@
---
name: ns-background-work
description: Pick and write the right mechanism for code that runs on its own on a NethSecurity device — a procd daemon, a procd one-shot job, a cron job, a hotplug handler or a uci-default. Use whenever a task needs something to run periodically, at boot, on a config change, on an interface event, persistently in the background, or once after install/upgrade, even when the user just says "schedule", "keep running", "every N minutes", "on startup", "when the WAN comes up" or "service". Also use it when editing any `/etc/init.d` procd script or `/etc/hotplug.d` handler, or when looking up `procd_set_param` params, procd triggers, or hotplug `ACTION`/environment variables. Covers the decision, canonical templates, package install/upgrade/remove behavior, full procd and hotplug references, and on-device checks.
metadata:
domain: nethsecurity-packages
type: runtime
---

## Pick the mechanism

| Need | Mechanism |
|---|---|
| Process that stays up (server, listener, forwarder) | procd daemon |
| Job that must run at boot and/or when a UCI config changes, maybe also periodically | procd one-shot, kicked by cron when periodic |
| Periodic housekeeping only (cleanup, rotation), no boot or config-change run | cron calling the script directly |
| React to an interface going up/down | hotplug handler in `/etc/hotplug.d/iface/` |
| One-time setup or migration after install, upgrade or first boot | uci-default |

When unsure between cron-direct and one-shot: if the job ever needs to run outside its schedule (boot, config change, API trigger), it's a one-shot.

Going through procd for periodic jobs gives syslog output for free and no overlapping runs: `/etc/init.d/X start` on a still-running instance with unchanged params is a no-op (procd `instance_update`).

Keepalived/HA events are not covered here.

## References

The templates below cover the common case. For anything they don't show, read the matching reference before writing code instead of guessing a `procd_*` helper or a hotplug variable:

- `references/procd-init.md` — every init action and what it really does, all `procd_set_param` params, all trigger helpers (UCI, interface, mount, data, raw), signals, extra commands, jails, debugging. Read it for multiple instances, reload via signal, interface- or mount-bound services, running as a non-root user, or custom actions.
- `references/hotplug.md` — how iface and other subsystems dispatch scripts, every `ACTION` and environment variable per subsystem, debugging. Read it for any event other than `iface` `ifup`/`ifdown`.

Both list the upstream sources (OpenWrt wiki and source files pinned to the release tag). Prefer those over memory when something isn't covered.

## Package lifecycle facts (OpenWrt v25.12, apk)

These come from `default_postinst`/`default_prerm` in `package/base-files/files/lib/functions.sh` and `include/package-pack.mk`. Re-check them if `OWRT_VERSION` in `build.conf.defaults` changes.

- **Fresh install**: package uci-defaults run (then `uci commit`), then every shipped init script is **enabled and started**, then the Makefile `postinst` body runs.
- **Upgrade**: same, with `PKG_UPGRADE=1`. Uci-defaults run again. Init scripts are **started but not enabled** — an init script that's new in this version stays disabled unless a uci-default enables it.
- **Image build**: init scripts get enabled in the rootfs; uci-defaults run at first boot (`/etc/init.d/boot`, `START=10`, before cron at 50).
- **Image upgrade (sysupgrade)**: `/etc/crontabs/` and `/etc/config/` are kept; uci-defaults run again on first boot.
- **Remove**: `default_prerm` stops and disables shipped init scripts, then the Makefile `prerm` body runs. Prerm does not run on upgrade.
- A running daemon is **not restarted** by an upgrade: `start` with unchanged params is a no-op, so the old binary keeps running. Restart it in `postinst`.

So every uci-default must be idempotent, and anything the package adds outside its own files (cron lines) must be removed in `prerm`.

## Cron rules

- Add the line from a package uci-default, remove it in `prerm`.
- Always write through `crontab -`. It drops `cron.update`, which busybox crond picks up within a minute. A plain `echo >> /etc/crontabs/root` is **ignored** until crond restarts (tested on a live device).
- Jitter with `sleep $(( RANDOM % N ))` when the job contacts a remote endpoint (controller, my, update servers, any public API). Local housekeeping runs at a fixed time, no jitter.
- Match the line by the command path, not the whole line, so a schedule change in a later release replaces the old line.

## Templates

All files carry the license header. Shell init and hotplug scripts use the procd helpers shown; don't hand-roll pid files or `start-stop-daemon`.

### procd daemon

`packages/ns-foo/files/ns-foo.init`, installed with `$(INSTALL_BIN)` to `/etc/init.d/ns-foo`:

```sh
#!/bin/sh /etc/rc.common

#
# Copyright (C) <YEAR> Nethesis S.r.l.
# SPDX-License-Identifier: GPL-2.0-only
#

USE_PROCD=1
START=99

start_service() {
config_load ns-foo

local enabled
config_get_bool enabled daemon enabled 0
[ "$enabled" -eq 0 ] && return 0

local log_level
config_get log_level daemon log_level "info"

procd_open_instance
procd_set_param command "/usr/sbin/ns-foo"
procd_append_param command "-log-level"
procd_append_param command "$log_level"
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param respawn 3600 5 0
procd_close_instance
}

service_triggers()
{
procd_add_reload_trigger "ns-foo"
}

reload_service()
{
stop
start
}
```

- On/off is the UCI `enabled` option; the init script itself stays enabled. Turning it on or off is a UCI change, and the reload trigger applies it on `ns.commit`.
- `reload_service` is `stop; start` because the default reload is just `start`, which procd ignores while the command line is unchanged. A config value the daemon reads itself would never be applied. If the daemon re-reads config on a signal, use `procd_set_param reload_signal HUP` and drop `reload_service` instead.
- `START`: 99 unless something depends on it starting earlier.
- Add other configs the daemon reads to `procd_add_reload_trigger` (e.g. `"ns-foo" "ns-plug"`).
- Never put secrets on the command line (visible in `ps`). Write them to a `umask 077` file under `/var/run/ns-foo/` and pass the path, as `vmalert.initd` does.
- Makefile:

```makefile
define Package/ns-foo/postinst
#!/bin/sh
[ -z "$${IPKG_INSTROOT}" ] && /etc/init.d/ns-foo restart
exit 0
endef
```

### procd one-shot (optionally periodic)

`packages/ns-foo/files/ns-foo-update.init` → `/etc/init.d/ns-foo-update`:

```sh
#!/bin/sh /etc/rc.common

#
# Copyright (C) <YEAR> Nethesis S.r.l.
# SPDX-License-Identifier: GPL-2.0-only
#

USE_PROCD=1
START=50

start_service() {
procd_open_instance
procd_set_param command "/usr/sbin/ns-foo-update"
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
}

reload_service()
{
start
}

service_triggers() {
procd_add_reload_trigger "ns-foo"
}
```

- No `respawn`: the command runs to completion and exits.
- The script (`/usr/sbin/ns-foo-update`) exits 0 quickly when there's nothing to do (feature disabled, no subscription), since it runs on every boot, upgrade and config change.
- When periodic, cron calls `/etc/init.d/ns-foo-update start`, not the script.

uci-default `packages/ns-foo/files/99-ns-foo-update-cron` → `/etc/uci-defaults/99-ns-foo-update-cron`:

```sh
#!/bin/sh

#
# Copyright (C) <YEAR> Nethesis S.r.l.
# SPDX-License-Identifier: GPL-2.0-only
#

(crontab -l | grep -v '/etc/init.d/ns-foo-update'; echo '8 4 * * * sleep $(( RANDOM % 3600 )); /etc/init.d/ns-foo-update start') | crontab -

# new init scripts are not enabled on package upgrade
/etc/init.d/ns-foo-update enabled || /etc/init.d/ns-foo-update enable
```

Makefile:

```makefile
define Package/ns-foo/prerm
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
crontab -l | grep -v '/etc/init.d/ns-foo-update' | crontab -
fi
exit 0
endef
```

### cron calling the script directly

Same uci-default and prerm as above, matching on the script path:

```sh
(crontab -l | grep -v '/usr/sbin/ns-foo-cleanup'; echo '4 0 * * * /usr/sbin/ns-foo-cleanup') | crontab -
```

No init script, no enable line.

### hotplug handler (interface events)

`packages/ns-foo/files/hotplug` → `/etc/hotplug.d/iface/90-ns-foo`, installed with `$(INSTALL_DATA)` (it's sourced, not executed):

```sh
#!/bin/sh

#
# Copyright (C) <YEAR> Nethesis S.r.l.
# SPDX-License-Identifier: GPL-2.0-only
#

[ "$ACTION" = "ifup" ] || exit 0

. /lib/functions/network.sh
network_flush_cache
network_find_wan wan_if
[ "$INTERFACE" = "$wan_if" ] || exit 0

config_load ns-foo
config_get_bool enabled config enabled 0
[ "$enabled" -eq 1 ] || exit 0

/etc/init.d/ns-foo-update start
```

- `hotplug-call` sources each script in a subshell, in name order, and netifd waits for the whole run before dispatching the next interface event. `exit` is fine, but anything slow delays mwan3, the firewall and every later handler. Hand real work to a one-shot (`/etc/init.d/X start`) instead of doing it inline.
- Filter on `ACTION` and `INTERFACE` first, then read config.
- Output goes nowhere useful; log with `logger -t ns-foo`.

### uci-default (one-time setup)

Use for UCI seeding, migrations and the cron/enable lines above. Never for recurring work. It runs on install, every package upgrade and first boot after sysupgrade, so guard every change:

```sh
if ! uci -q get ns-foo.config > /dev/null; then
uci -q import ns-foo << EOI
config main 'config'
option enabled '0'
EOI
fi
```

One concern per file: don't mix cron registration into a config-import uci-default.

## Don't copy

These exist in the tree but are not the current pattern:

- `packages/ns-dpi/files/99-dpi-*-cron.uci-defaults` — the "temporary fix" block deletes and re-adds the line on every run via `echo >>`, which crond ignores.
- `packages/ns-dpi/files/20_dpi` — cron line mixed into a config import (its own TODO says so).
- `packages/ns-plug/files/20_ns-plug`, `packages/ns-objects/files/20_ns_objects` — `echo >> /etc/crontabs/root`, no cleanup in `prerm`, mixed with other setup.
- `packages/ns-storage/files/ns-storage-check.init` — plain `rc.common` without procd, writes UCI and the crontab from the init script.
- `mwan3`, `keepalived`, `adblock`, `banip` — forks of upstream OpenWrt packages that follow upstream style. Keep upstream style when editing them, but don't use them as templates for `ns-*` packages.

Good references: `ns-monitoring/files/ns-flows.init` (daemon with enable flag), `victoria-metrics/files/vmalert.initd` (daemon with a secret), `ns-dpi/files/dpi-data-update.init` (one-shot).

## Verify on a device

```sh
/etc/init.d/ns-foo enabled && echo enabled
ubus call service list '{"name":"ns-foo"}' # instance, running, command line
logread -e ns-foo # procd stdout/stderr
crontab -l | grep ns-foo
ls /etc/uci-defaults/ # a leftover file means the uci-default exited non-zero
```

Install the package, upgrade it over itself, then remove it, and check after each step that the cron line and service state are what the lifecycle facts above predict.
Loading
Loading