cmds.secrets.Cmd: Fix errors on Kali 2026.1

Fix errors dug up by testing on Kali Linux 2026.1:

  - Nested class Cmds.Attrs is constructed without scope

  - "replace" falls back to empty list, not empty dictionary

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-03-09 18:12:41 +00:00
commit 699980c32e

View file

@ -49,7 +49,7 @@ class Cmd(Base): # export
if not re.match(r"^\s*#\s*conf\s*:", first_line): if not re.match(r"^\s*#\s*conf\s*:", first_line):
return None return None
ret = Attrs() ret = self.Attrs()
ret.conf = first_line ret.conf = first_line
@ -98,7 +98,7 @@ class Cmd(Base): # export
src: str, src: str,
dst: str, dst: str,
default_attrs: Attrs | None, default_attrs: Attrs | None,
replace: dict[str, str] = [], replace: dict[str, str] = {},
) -> None: ) -> None:
owner = "root" owner = "root"
@ -224,7 +224,7 @@ class Cmd(Base): # export
if default_attrs is None: if default_attrs is None:
default_attrs = attrs default_attrs = attrs
secret = target + '.jw-secret' secret = target + '.jw-secret'
replace = [] if not os.path.exists(secret) else self.__read_key_value_file(secret) replace = {} if not os.path.exists(secret) else self.__read_key_value_file(secret)
for ext in [ '.jw-secret-file', '.jw-tmpl' ]: for ext in [ '.jw-secret-file', '.jw-tmpl' ]:
src = target + ext src = target + ext
if os.path.exists(src): if os.path.exists(src):