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

@ -21,6 +21,13 @@ from ...Result import Result
from .Base import Base
from .layout import FT_SECRET, FT_SECRET_FILE, FT_SECRET_KEY
# -- SERVICE_SECRET[1] ... entries are used for secret rotation by
# downstream software. That software is specific to janware
# workflows, so the regex should be made configurable, at the
# latest when the need arises, but for now hard-coding it here
# is the safest variant from a security perspective.
UNENCRYPTED_ANNOTATION_REGEX = 'SERVICE_SECRET'
def _sops_dotenv_norm(content: bytes) -> bytes:
# -- The form sops' dotenv serialization produces: blank
# lines dropped, a single trailing newline, everything
@ -263,6 +270,9 @@ class Sops(Base):
'--encrypt',
'--age',
recipient,
'--unencrypted-regex',
UNENCRYPTED_ANNOTATION_REGEX,
'--mac-only-encrypted',
'--output',
path,
tmp,