lib.ec.secret_store.Sops: Don't encrypt annotations
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 5m28s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 5m7s
CI / Packaging test (pull_request) Successful in 0s

SERVICE_SECRET[n] keys of an entry are used as rotation metadata by
downstream software, and their values don't need to be kept secret: they
name the macro and the account that owns it. Encrypting them buys nothing,
and it forces every annotation tool to decrypt and re-encrypt the whole
entry for a one-line read or edit.

Run sops encrypt with --unencrypted-regex SERVICE_SECRET, so the annotation
keys stay plain text in the repository file and the store stays greppable
without the age key, and with --mac-only-encrypted, so the MAC covers the
encrypted values only and the annotation lines can be edited as plain text
without invalidating the file.

Signed-off-by: Jan Lindemann <jan@janware.com>
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.0
This commit is contained in:
Jan Lindemann 2026-11-06 22:04:24 +01:00
commit 3f29084790
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -541,6 +541,26 @@ async def run_tests() -> None:
await store.put('etc/nlc.jw-secret', b'k=1\n', ftype = FT_SECRET)
with open(repo_file, 'rb') as fb:
assert fb.read() == first
# -- The house annotation convention: the SERVICE_SECRET[n]
# keys of an entry are rotation metadata, stored
# unencrypted in the repository file so it stays greppable
# without the age key, while the values stay encrypted
ann = b'__PW__ = hunter2\nSERVICE_SECRET[1] = "__PW__ -> root@localhost"\n'
await store.put('etc/ann.jw-secret', ann, ftype = FT_SECRET)
assert (await store.get('etc/ann.jw-secret')).stdout == ann
repo_file = os.path.join(repo, 'com/example/host/etc/ann.jw-secret')
with open(repo_file) as f:
raw = f.read()
assert 'SERVICE_SECRET[1] = "__PW__ -> root@localhost"' in raw
assert '__PW__ =ENC[' in raw
# -- A key put merges through the stored content: the
# annotation survives the round trip, with the key
# spacing normalized as for all keys of the merge
await store.put('etc/ann.jw-secret/k', b'v', ftype = FT_SECRET_KEY)
with open(repo_file) as f:
raw = f.read()
assert 'SERVICE_SECRET[1]' in raw
assert '"__PW__ -> root@localhost"' in raw
# -- A blob is byte-exact: dropping the trailing newline is
# a change, not a no-op
repo_file = os.path.join(repo, 'com/example/host/etc/nlb.pem.jw-secret-file')