From a88e02ea56b50b83bb4b5486046609553ea59d36 Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Sun, 1 Nov 2026 00:53:10 +0100 Subject: [PATCH] fix: rfc4716_blob within the complexity limit (quality ratchet) The RFC 4716 body moves into _rfc4716_body; rfc4716_blob only tells the two key forms apart. main's ratchet job failed on complexity 11. --- napalm_openmediavault/_local_accounts.py | 25 ++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/napalm_openmediavault/_local_accounts.py b/napalm_openmediavault/_local_accounts.py index 988517b..cb5b556 100644 --- a/napalm_openmediavault/_local_accounts.py +++ b/napalm_openmediavault/_local_accounts.py @@ -44,22 +44,27 @@ def rfc4716_blob(text: str) -> str | None: """The base64 of a public key, in OMV's RFC 4716 form or OpenSSH's one line.""" lines = [line.strip() for line in text.strip().splitlines()] if lines and lines[0].startswith("---- BEGIN SSH2 PUBLIC KEY"): - body: list[str] = [] - header = False - for line in lines[1:]: - if line.startswith("---- END SSH2 PUBLIC KEY"): - return "".join(body) or None - if header or ":" in line: - header = line.endswith("\\") # a header continues on the next line - continue - body.append(line) - return None + return _rfc4716_body(lines[1:]) words = text.split() if len(words) >= 2 and words[0].startswith(("ssh-", "ecdsa-", "sk-")): return words[1] return None +def _rfc4716_body(lines: list[str]) -> str | None: + """The base64 between the headers and the END line; None without an END line.""" + body: list[str] = [] + header = False + for line in lines: + if line.startswith("---- END SSH2 PUBLIC KEY"): + return "".join(body) or None + if header or ":" in line: + header = line.endswith("\\") # a header continues on the next line + continue + body.append(line) + return None + + def _holds(keys: list[str] | None, blob: str | None) -> bool: return blob is not None and any(rfc4716_blob(line) == blob for line in keys or []) -- 2.54.1