feat: UniFi switch, access point and Network controller drivers, read paths (NetOrk/netork#2787) #1

Open
christianmanivong wants to merge 21 commits from feature/unifi-read-paths into main
pull from: feature/unifi-read-paths
21 Commits
Author SHA1 Message Date
Christian Manivong 921062d7dd fix(ssh): say why the SSH command is no injection (bandit B601)
driver / standard (pull_request) Successful in 15s
driver / lint (pull_request) Successful in 15s
driver / lowest (pull_request) Successful in 38s
driver / types (pull_request) Successful in 59s
driver / test (3.13) (pull_request) Successful in 1m1s
driver / test (3.12) (pull_request) Successful in 1m17s
driver / build (pull_request) Successful in 26s
driver / security (pull_request) Successful in 1m4s
CI / driver (pull_request) Successful in 1m58s
driver / publish (pull_request) Skipped
Only the source's two fixed commands reach exec_command.
2026-12-05 18:04:08 +01:00
Christian Manivong 1f85a419b7 refactor: keep the VLAN and encryption parsers under the complexity limit
driver / lint (pull_request) Successful in 16s
driver / standard (pull_request) Successful in 19s
driver / types (pull_request) Successful in 1m0s
driver / lowest (pull_request) Successful in 46s
driver / test (3.12) (pull_request) Successful in 1m12s
driver / test (3.13) (pull_request) Successful in 1m11s
driver / build (pull_request) Successful in 31s
driver / security (pull_request) Failing after 55s
CI / driver (pull_request) Failing after 2m0s
driver / publish (pull_request) Skipped
The standard's ratchet counted 12 for parse_vlans_detail_classic and 11 for
_encryption. Placing one port in its VLANs and naming a PSK's encryption are
functions of their own now; nothing changes in what they return.
2026-12-05 17:26:51 +01:00
Christian Manivong cad167389e feat: the controller names each device's driver and the way to it
driver / standard (pull_request) Failing after 19s
driver / lint (pull_request) Successful in 16s
driver / test (3.12) (pull_request) Failing after 17s
driver / test (3.13) (pull_request) Failing after 15s
driver / types (pull_request) Failing after 32s
driver / lowest (pull_request) Failing after 22s
driver / build (pull_request) Successful in 39s
driver / security (pull_request) Failing after 45s
CI / driver (pull_request) Failing after 1m27s
driver / publish (pull_request) Skipped
An adopted switch or access point carries driver (unifi_switch, unifi_ap)
and driver_args (controller transport, URL, site, MAC; no secret), so netOrk
can add it with the controller's credential. A device waiting for adoption
and a gateway get none. The end-to-end test opens an access point with
exactly what the controller reported.
2026-12-05 17:17:49 +01:00
Christian Manivong 978f3a52b5 docs: the simulator in the README and the changelog
driver / standard (pull_request) Failing after 15s
driver / lint (pull_request) Successful in 17s
driver / types (pull_request) Failing after 23s
driver / test (3.12) (pull_request) Failing after 21s
driver / test (3.13) (pull_request) Failing after 13s
driver / lowest (pull_request) Failing after 27s
driver / security (pull_request) Failing after 41s
driver / build (pull_request) Successful in 45s
CI / driver (pull_request) Failing after 1m23s
driver / publish (pull_request) Skipped
2026-12-05 17:12:25 +01:00
Christian Manivong 0886ea80c6 feat: a simulated controller and switch, and the drivers against them
sim/unifi_sim plays a UniFi Network controller on HTTPS (UniFi OS or
standalone, Integration API by version, classic API, logins with CSRF, API
keys, MFA, rate limit, wrong site, redirects, port override writes) and a
switch on SSH, from the fixtures. The end-to-end tests run all three drivers
against it over real TLS and SSH, certificate and host key checks included.
A command line and a Dockerfile run it by hand or on a test server.
2026-12-05 17:12:10 +01:00
Christian Manivong 0485caa7d8 fix: tell UniFi OS and a standalone controller apart by their home page
The client took a 404 on /api/auth/login for a standalone controller, but a
standalone controller may well answer an unknown API path with 401 and the
login was then refused. Like aiounifi, it now asks / first: UniFi OS serves
its page, the standalone application redirects to /manage. A login that
redirects is refused instead of taken for a success.
2026-12-05 17:12:10 +01:00
Christian Manivong e040280ce9 fix: a switch or access point is read once at open
With an API key and a known MAC, opening sent no request at all: a refused
key, a redirect or a device the controller does not know showed only at the
first getter. Open now reads the device and closes again when that fails.
2026-12-05 17:07:27 +01:00
Christian Manivong 7c8895909a docs: README, changelog, and where the fixtures come from
The fixtures' sources and licences: aiounifi (MIT, its licence alongside),
abates/napalm-unifi (Apache-2.0) and the Integration API's published schemas.
2026-12-05 17:05:34 +01:00
Christian Manivong b887fe3b17 feat: unifi_network driver for the controller itself
UnifiNetworkDriver names the devices a controller manages: through the
Integration API, with the devices still waiting for adoption on Network 10,
and through the classic API on controllers without it. Its own ports are
none of its devices'. Every entry point is checked against its driver.
2026-12-05 17:04:20 +01:00
Christian Manivong e08f5bb28e feat: unifi_switch and unifi_ap drivers
UnifiSwitchDriver adds PoE and VLANs (with their ports, and NAPALM's
get_vlans from them); UnifiAccessPointDriver adds SSIDs, radios and wireless
clients. Discovery knows Ubiquiti's OUIs from the IEEE registry.
2026-12-05 17:02:49 +01:00
Christian Manivong ff5c1a910d feat: one base for a UniFi switch and access point
UnifiDevice reads a device through its controller (found by MAC or by its
address, in any site) or over SSH (a separate SSH profile, or the driver's own
login with a key file): facts, ports, management address, LLDP and MAC table.
2026-12-05 17:01:20 +01:00
Christian Manivong 1aaa8587d0 feat: open a controller with its certificate pinned
The controller's certificate is trusted on first use and pinned for the
session before any login. An api_token profile's secret is the API key;
otherwise a local admin's login, separate or the driver's own.
2026-12-05 16:59:54 +01:00
Christian Manivong 49f21e0fa2 feat: SSH shell with a verified host key
paramiko through HostKeyCheck: trust on first use, a changed key refused
before any login. Only the password or key given is offered, never an agent
or a key file; Ed25519, ECDSA and RSA keys are read.
2026-12-05 16:58:36 +01:00
Christian Manivong 1b1c574656 style: format the client tests 2026-12-05 16:57:18 +01:00
Christian Manivong f77524cd44 feat: device sources, through the controller or over SSH
ControllerSource reads a device's stat/device entry, its networks and port
profiles, the stations and the WLANs from its controller; SshSource reads the
device's own mca-dump and running.cfg. Both hand the drivers the same record,
read once per connection.
2026-12-05 16:57:16 +01:00
Christian Manivong d4dac1e3c7 feat: controller client for UniFi OS and the standalone Network application
API key or local login, CSRF token, no redirects followed, a login rate
limit that backs off, MFA accounts refused with the way in, a wrong site
told apart from an empty one, paged Integration lists.

Refs NetOrk/netork#2787
2026-12-05 16:55:02 +01:00
Christian Manivong 380759ae50 feat: a switch's VLANs with their ports, from the controller and from running.cfg
Refs NetOrk/netork#2787
2026-12-05 16:53:30 +01:00
Christian Manivong 4b171d154b feat: managed devices from the Integration and the classic API
Integration fixtures are assembled from the shapes of Ubiquiti's published
OpenAPI spec (10.6.106), which carries no whole-response examples.

Refs NetOrk/netork#2787
2026-12-05 16:52:01 +01:00
Christian Manivong 596698970c feat: SSIDs, radios and wireless clients of an access point
Refs NetOrk/netork#2787
2026-12-05 16:50:58 +01:00
Christian Manivong 25df5c6a34 docs: how a switch port's VLANs are stored, per controller version 2026-12-05 16:49:51 +01:00
Christian Manivong 0d0fa905c6 feat: device record parsers and anonymised fixtures
Facts, ports, management address, LLDP (per-port and top-level shapes),
MAC table and PoE from a UniFi device record, which a controller's
stat/device and the device's own mca-dump share. Fixtures from aiounifi
(MIT) and abates/napalm-unifi (Apache-2.0), anonymised with
tools/sanitize.py.

Refs NetOrk/netork#2787
2026-12-05 14:11:50 +01:00