Merge remote-tracking branch 'origin/main' into feat/ssh-hardening
driver / standard (pull_request) Successful in 16s
driver / lint (pull_request) Successful in 16s
driver / types (pull_request) Successful in 1m22s
driver / test (3.12) (pull_request) Successful in 1m27s
driver / test (3.13) (pull_request) Successful in 1m12s
driver / lowest (pull_request) Successful in 39s
driver / build (pull_request) Successful in 33s
driver / security (pull_request) Successful in 1m9s
CI / driver (pull_request) Successful in 3m7s
driver / publish (pull_request) Skipped

This commit is contained in:
christianmanivong committed 2026-11-02 12:02:12 +01:00
commit d4ed73c52b
5 files changed
+60 -3

No files matched your search

+4 -1
View File
@@ -369,10 +369,13 @@ class ProxmoxDriver(
import paramiko
if self._ssh_client is None:
# A key is tried first; paramiko falls back to the password.
# A key is tried first; paramiko falls back to the password. Only
# these: not the keys in the process's own ~/.ssh, nor an agent.
connect_kwargs: _JsonDict = {
"username": self._ssh_username or self.username,
"timeout": self.timeout,
"look_for_keys": False,
"allow_agent": False,
}
password = self._ssh_password or self.password
if password:
+10 -2
View File
@@ -91,6 +91,9 @@ _GUEST_VM_SETTINGS: dict[str, dict[str, str]] = {
"openbsd": {"ostype": "other", "agent": "1,type=isa", "serial0": "socket"},
}
# A snippet's file name: one plain name in the snippets directory, no path.
_SNIPPET_NAME = re.compile(r"[A-Za-z0-9][A-Za-z0-9._+=-]*")
# A NIC as Proxmox reports it: "virtio=BC:24:11:AA:BB:02,bridge=vmbr0".
_NIC_MAC = re.compile(r"^[a-z0-9]+=([0-9A-Fa-f:]{17})")
@@ -248,12 +251,17 @@ class ProxmoxVMProvisionMixin:
{iso, vztmpl, import} — "snippets" is rejected outright ("does not
have a value in the enumeration"). Snippets can only be written
directly to the filesystem, so this goes over SSH.
:raises ValueError: for a *filename* that is not one plain file name.
"""
if not _SNIPPET_NAME.fullmatch(filename):
raise ValueError(f"not a snippet file name: {filename!r}")
_logger.debug(f"Writing Cloud-Init snippet {filename} to {storage_path}/snippets")
encoded = base64.b64encode(content.encode("utf-8")).decode("ascii")
snippets = f"{storage_path}/snippets"
self._run_node_command(
f"mkdir -p {storage_path}/snippets && "
f"echo {encoded} | base64 -d > {storage_path}/snippets/{filename}",
f"mkdir -p {shlex.quote(snippets)} && echo {encoded} | base64 -d > "
f"{shlex.quote(f'{snippets}/{filename}')}",
timeout=30,
)