_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).
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
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
_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
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Two fixes, one commit each.
#48: only the given credentials log in
_node_sshnow passeslook_for_keys=Falseandallow_agent=Falsetoconnect(). Before this, paramiko left both atTrueand also tried the keys in the running process's own~/.sshand any SSH agent it could reach. That goes against the driver standard (§5, "Secrets"). The key (ssh_private_key_str),ssh_passwordand the API password work as before.#47: the cloud-init snippet path in its root command
_write_snippetput the snippet storage's path and the snippet's file name unquoted into the command that writes the snippet as root on the node.shlex.quote.ValueErrorbefore anything runs on the node. This covers a path,.., a space or a shell character. The name is not sanitised instead, becausecicustomrefers to the snippet by this name.<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 localshwith a storage patha b;reboot;$(reboot).test_a_snippet_name_that_is_not_a_plain_file_name_is_refused[*]Results:
napalm-standard checkandnapalm-standard ratchet: green.Closes #48
Closes #47