fix(vlans): set_vlan and set_interface refuse values with line breaks (#17) #18

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

What was wrong: set_vlan() put the name into name "<name>", set_interface() the description into description <text>; each block is sent line by line in config mode and saved. A line break ended the line and the switch ran the rest as commands; a double quote ended the VLAN name. netOrk replays VLAN names other devices reported (NetOrk/netork#2455).

Fix: _check_cli_values() before anything is sent: set_vlan() raises ValueError for a name containing \r, \n or ", set_interface() for a description containing \r or \n.

Tests: tests/unit/test_cli_values.py — refused values with nothing sent (red before the fix), a plain name sent quoted, a one-line description sent.

Closes #17

**What was wrong:** `set_vlan()` put the name into `name "<name>"`, `set_interface()` the description into `description <text>`; each block is sent line by line in config mode and saved. A line break ended the line and the switch ran the rest as commands; a double quote ended the VLAN name. netOrk replays VLAN names other devices reported (NetOrk/netork#2455). **Fix:** `_check_cli_values()` before anything is sent: `set_vlan()` raises `ValueError` for a name containing `\r`, `\n` or `"`, `set_interface()` for a description containing `\r` or `\n`. **Tests:** `tests/unit/test_cli_values.py` — refused values with nothing sent (red before the fix), a plain name sent quoted, a one-line description sent. Closes #17
christianmanivong added 1 commit 2026-11-12 21:26:26 +00:00
fix(vlans): set_vlan and set_interface refuse values with line breaks (#17)
driver / standard (pull_request) Failing after 17s
driver / lint (pull_request) Successful in 16s
driver / types (pull_request) Successful in 59s
driver / test (3.12) (pull_request) Successful in 1m1s
driver / test (3.13) (pull_request) Successful in 53s
driver / lowest (pull_request) Successful in 27s
driver / build (pull_request) Successful in 32s
driver / security (pull_request) Successful in 1m19s
CI / driver (pull_request) Failing after 2m53s
driver / publish (pull_request) Skipped
ea001751cb
The VLAN name went into `name "<name>"`, a port's description into
`description <text>`, each one line of a block sent line by line in
config mode and then saved: a line break ended the line and the switch
ran the rest as commands, a double quote ended the VLAN name. netOrk
replays VLAN names other devices reported here (NetOrk/netork#2455).

set_vlan() now raises ValueError for a name containing \r, \n or ",
set_interface() for a description containing \r or \n, before anything
is sent.
christianmanivong added 1 commit 2026-11-13 07:59:31 +00:00
refactor: CLI value checks in their own module, uptime parser in parsers.py (#17)
driver / standard (pull_request) Successful in 16s
driver / lint (pull_request) Successful in 13s
driver / types (pull_request) Successful in 52s
driver / test (3.12) (pull_request) Successful in 55s
driver / test (3.13) (pull_request) Successful in 45s
driver / lowest (pull_request) Successful in 25s
driver / build (pull_request) Successful in 26s
driver / security (pull_request) Successful in 58s
CI / driver (pull_request) Successful in 2m22s
driver / publish (pull_request) Skipped
a689c50ee1
The checks against line breaks and double quotes made the driver module
27 lines longer than the quality ratchet allows (2014, recorded 1987) and
set_interface 53 lines long (limit 50).

The checks move to cli_values.py (check_cli_values); the uptime parser,
a pure parser without the driver, moves to parsers.py as
parse_uptime_seconds and reads its four units in one loop; set_vlan and
set_interface say in one docstring line what they refuse. Behaviour is
unchanged; the uptime test gains a string without days and an empty one.
The baseline is lowered to what is measured now (1971).
christianmanivong merged commit d4cf39a4e1 into main 2026-11-13 08:55:06 +00:00
christianmanivong deleted branch fix/vlan-name-2455 2026-11-13 08:55:06 +00:00
Sign in to join this conversation.