fix: SSH only with the given credentials, quote the snippet path (#48, #47) #49

Merged
christianmanivong merged 2 commits from fix/bugs-2026-11-02b into main 2026-11-02 09:40:50 +00:00
Owner

Two fixes, one commit each.

#48: only the given credentials log in

_node_ssh now passes look_for_keys=False and allow_agent=False to connect(). Before this, paramiko left both at True and also tried the keys in the running process's own ~/.ssh and any SSH agent it could reach. That goes against the driver standard (§5, "Secrets"). The key (ssh_private_key_str), ssh_password and the API password work as before.

#47: the cloud-init snippet path in its root command

_write_snippet put the snippet storage's path and the snippet's file name unquoted into the command that writes the snippet as root on the node.

  • Both now go through shlex.quote.
  • A snippet file name that is not one plain name raises ValueError before anything runs on the node. This covers a path, .., a space or a shell character. The name is not sanitised instead, because cicustom refers to the snippet by this name.
  • The names the driver builds itself (<vmid>-user-data.yaml, <vmid>-network-config.yaml) are unaffected.

Tests

Fixtures only. Red first:

  • test_only_the_given_credentials_log_in[*]
  • test_a_snippet_storage_path_stays_one_argument: the command runs through a local sh with a storage path a b;reboot;$(reboot).
  • test_a_snippet_name_that_is_not_a_plain_file_name_is_refused[*]

Results:

  • pytest: 515 passed.
  • ruff format/check, bandit, napalm-standard check and napalm-standard ratchet: green.

Closes #48
Closes #47

Two fixes, one commit each. ## #48: only the given credentials log in `_node_ssh` now passes `look_for_keys=False` and `allow_agent=False` to `connect()`. Before this, paramiko left both at `True` and also tried the keys in the running process's own `~/.ssh` and any SSH agent it could reach. That goes against the driver standard (§5, "Secrets"). The key (`ssh_private_key_str`), `ssh_password` and the API password work as before. ## #47: the cloud-init snippet path in its root command `_write_snippet` put the snippet storage's path and the snippet's file name unquoted into the command that writes the snippet as root on the node. - Both now go through `shlex.quote`. - A snippet file name that is not one plain name raises `ValueError` before anything runs on the node. This covers a path, `..`, a space or a shell character. The name is not sanitised instead, because `cicustom` refers to the snippet by this name. - The names the driver builds itself (`<vmid>-user-data.yaml`, `<vmid>-network-config.yaml`) are unaffected. ## Tests Fixtures only. Red first: - `test_only_the_given_credentials_log_in[*]` - `test_a_snippet_storage_path_stays_one_argument`: the command runs through a local `sh` with a storage path `a b;reboot;$(reboot)`. - `test_a_snippet_name_that_is_not_a_plain_file_name_is_refused[*]` Results: - pytest: 515 passed. - ruff format/check, bandit, `napalm-standard check` and `napalm-standard ratchet`: green. Closes #48 Closes #47
christianmanivong added 2 commits 2026-11-02 08:25:54 +00:00
paramiko's look_for_keys and allow_agent stayed at their default True,
so the node login also tried every key in the running process's own
~/.ssh and any SSH agent it could reach. The driver standard lets a
driver authenticate only with what it was handed; both are now False
on every connect.

Closes #48
fix(vm-provision): quote the cloud-init snippet path in its root command
driver / standard (pull_request) Successful in 17s
driver / lint (pull_request) Successful in 14s
driver / types (pull_request) Successful in 1m4s
driver / test (3.12) (pull_request) Successful in 1m8s
driver / test (3.13) (pull_request) Successful in 1m4s
driver / lowest (pull_request) Successful in 39s
driver / build (pull_request) Successful in 33s
driver / security (pull_request) Successful in 1m21s
CI / driver (pull_request) Successful in 3m1s
driver / publish (pull_request) Skipped
dffb19e3df
_write_snippet put the snippet storage's path and the snippet's file
name unquoted into the command that writes the snippet as root on the
node; a space, ; or $(...) in either was acted on by the shell. Both now
go through shlex.quote, and a file name that is not one plain name
(a path, a shell character) is refused before anything runs.

Closes #47
christianmanivong merged commit a73dcf79fe into main 2026-11-02 09:40:50 +00:00
christianmanivong deleted branch fix/bugs-2026-11-02b 2026-11-02 09:40:50 +00:00
Sign in to join this conversation.