fix(vlans): set_vlan refuses a name with line breaks or double quotes (#28) #29

Merged
christianmanivong merged 3 commits from fix/vlan-name-2455 into main 2026-11-13 08:55:04 +00:00
Owner

What was wrong: over SSH, set_vlan() put config["name"] into name "<name>" in config mode; the block is sent line by line, then write memory. A line break in the name ended the line and the switch ran the rest as commands; a double quote ended the name. netOrk replays VLAN names other devices reported (NetOrk/netork#2455), so a compromised device could set a manager password on the switch.

Fix: set_vlan() raises ValueError for a name, set_interface() for a description, containing \r, \n or ", before anything is sent, over every transport (as the SNMP writes already refuse such values). _cli_set_interface put the description into name "<desc>" the same way (second commit).

Tests: tests/unit/test_cli_values.py — the injected VLAN name and each character refused over SSH and REST with nothing sent, the same for a description (both red before their fix), a plain name and a one-line description still sent quoted, a VLAN without a name and an empty description still sent.

Closes #28

**What was wrong:** over SSH, `set_vlan()` put `config["name"]` into `name "<name>"` in config mode; the block is sent line by line, then `write memory`. A line break in the name ended the line and the switch ran the rest as commands; a double quote ended the name. netOrk replays VLAN names other devices reported (NetOrk/netork#2455), so a compromised device could set a manager password on the switch. **Fix:** `set_vlan()` raises `ValueError` for a name, `set_interface()` for a description, containing `\r`, `\n` or `"`, before anything is sent, over every transport (as the SNMP writes already refuse such values). `_cli_set_interface` put the description into ` name "<desc>"` the same way (second commit). **Tests:** `tests/unit/test_cli_values.py` — the injected VLAN name and each character refused over SSH and REST with nothing sent, the same for a description (both red before their fix), a plain name and a one-line description still sent quoted, a VLAN without a name and an empty description still sent. Closes #28
christianmanivong added 1 commit 2026-11-12 21:26:25 +00:00
fix(vlans): set_vlan refuses a name with line breaks or double quotes (#28)
driver / standard (pull_request) Failing after 17s
driver / lint (pull_request) Successful in 13s
driver / types (pull_request) Successful in 58s
driver / test (3.12) (pull_request) Successful in 57s
driver / test (3.13) (pull_request) Successful in 52s
driver / lowest (pull_request) Successful in 29s
driver / build (pull_request) Successful in 30s
driver / security (pull_request) Successful in 1m4s
CI / driver (pull_request) Failing after 2m32s
driver / publish (pull_request) Skipped
c4cd0bbdf3
Over SSH the name went into `name "<name>"` in config mode, one line of a
block sent line by line before `write memory`: a line break ended the
line and the switch ran the rest as commands, a double quote ended the
name. netOrk replays VLAN names other devices reported here
(NetOrk/netork#2455).

set_vlan() now raises ValueError for a name containing \r, \n or ",
before anything is sent, over every transport.
christianmanivong added 1 commit 2026-11-12 22:01:39 +00:00
fix(interfaces): set_interface refuses a description with line breaks or double quotes (#28)
driver / lint (pull_request) Successful in 15s
driver / standard (pull_request) Failing after 17s
driver / types (pull_request) Successful in 1m2s
driver / test (3.13) (pull_request) Successful in 56s
driver / test (3.12) (pull_request) Successful in 1m3s
driver / lowest (pull_request) Successful in 29s
driver / build (pull_request) Successful in 30s
driver / security (pull_request) Successful in 1m8s
CI / driver (pull_request) Failing after 2m21s
driver / publish (pull_request) Skipped
e06811de50
Over SSH the description went into `  name "<desc>"` under
`interface <port>`, one line of a block sent line by line before
`write memory`: a line break ran the rest as commands, a double quote
ended the value. It is the same injection as set_vlan's name
(NetOrk/netork#2455).

set_interface() now raises ValueError for a description containing \r,
\n or ", before anything is sent, over every transport, through the same
check as set_vlan (_check_cli_value). The tests move to
test_cli_values.py, which covers both.
christianmanivong added 1 commit 2026-11-13 07:57:42 +00:00
refactor(ping): the ping output parser lives with the other CLI parsers (#28)
driver / standard (pull_request) Successful in 16s
driver / lint (pull_request) Successful in 16s
driver / test (3.13) (pull_request) Successful in 46s
driver / types (pull_request) Successful in 57s
driver / test (3.12) (pull_request) Successful in 57s
driver / lowest (pull_request) Successful in 24s
driver / build (pull_request) Successful in 27s
driver / security (pull_request) Successful in 1m0s
CI / driver (pull_request) Successful in 2m13s
driver / publish (pull_request) Skipped
23e799ee8d
The checks against line breaks and double quotes made procurve.py 20
lines longer than the quality ratchet allows (1365, recorded 1345). The
module-level ping parser moves to parsers.py, which holds every other
pure CLI parser, as parse_ping_output; its two result dicts become one
helper, so it is no longer over 50 lines. Behaviour is unchanged; tests
for an unreachable target and an unknown answer are added. The baseline
is lowered to what is measured now (procurve.py 1300, the ping entry
gone).
christianmanivong merged commit 8c13ad96da into main 2026-11-13 08:55:04 +00:00
christianmanivong deleted branch fix/vlan-name-2455 2026-11-13 08:55:04 +00:00
Sign in to join this conversation.