Skip to content

fix(sops): writ encrypts and decrypts every secret as its bytes, so token.sops deploys as its plaintext - #1148

Merged
David-Noble-at-work merged 5 commits into
developfrom
fix/977-secret-with-no-format-before
Oct 24, 2026
Merged

David-Noble-at-work merged 5 commits into
developfrom
fix/977-secret-with-no-format-before

Conversation

@David-Noble-at-work

@David-Noble-at-work David-Noble-at-work commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Lane 47 of #949.

  • One mode for every secret (A secret with no format before .sops deploys as a JSON wrapper: token.sops lands as {"data": "..."}, not the token #977; ruled 2026-10-22). Writ chose one of sops's modes from a secret's name: structured for .yaml, .yml, .json, .env and .ini, where sops parses the document and encrypts each value, and binary for anything else. Decrypting a name with no format, it looked at the ciphertext instead, saw the { every binary document begins with, and read it as JSON, so token.sops deployed as {"data": "..."}. Writ now encrypts and decrypts every secret in sops's binary mode, whatever the file is called, and deploys the bytes that were encrypted. detectFormat and storeForFormat are deleted; Client.Decrypt takes the data alone. Ruled: "I don't like doing things two ways when one way works. as long as i have sops edit, why do i care about structured".
  • What went with the detection. Measured at 0e7bcdd4: YAML and JSON secrets came back rewritten (comments moved, quotes dropped, indentation changed); text named .yaml that is not YAML was refused at encryption; and .env and .ini secrets encrypted to documents IsEncrypted did not recognize, which decryption would have passed through as ciphertext.
  • Tests compare what they observe with what they expect, entire (ruled 2026-10-22). Nine test files in pkg/sops/testdata/roundtrip, among them token, blob (a NUL and bytes that are not UTF-8), YAML with comments, JSON, dotenv, INI, a PEM and text named .yaml that is not YAML, go through writ's encrypter and back and are compared byte for byte; all nine failed at 0e7bcdd4 and all nine pass. The deploy test adds token.sops, and its checks, and the encryption provider's, compare whole outputs instead of fragments; their ciphertext is made by writ's own encrypter.
  • The documents. writ secret encrypt's help, two doc comments and the writ guide say each file is encrypted as its bytes, .sops.yaml giving the recipients; the guide says sops decrypt shows a secret and sops edit changes one. A secret encrypted before in structured mode would need encrypting again; none exists in any of the three layers.
  • Not here: how writ finds .sops.yaml, which differs from sops's way, is writ finds and applies .sops.yaml differently from sops: from the secret's directory, through a chain with a devlore fallback, SOPS_CONFIG ignored, a malformed file skipped silently #1144.
  • Plan: docs/plans/fix/977-secret-with-no-format-before.md.

Resolves #977

Test plan

  • The round trip and the deploy row fail at 0e7bcdd4 and pass with the fix; make test
  • This script's pre-flight: make check-all
  • CI on this pull request, every leg

Written with AI assistance.

Signed-off-by: David Noble [email protected]
Assisted-by: Claude Code

Time

Marker UTC Elapsed
opened (first commit) 2026-10-23T21:57:32Z —
submitted (PR opened) 2026-10-24T00:51:59Z 2.9 h after opened
merged 2026-10-24T01:07:33Z 0.3 h after submitted; 3.2 h in all

Computed by the algorithm of noblefactor-ops#188 at merge.

… so token.sops deploys as its plaintext (#977)

Lane 47 of #949. One mode, sops's binary store, in both directions; the format detection deleted. Every test compares
what it observes with what it expects, entire, and a round trip of test files comes back byte for byte. How writ
finds .sops.yaml is #1144, elsewhere. Reviewed with the owner 2026-10-22.
…decrypted output is compared entire (#977)

Lane 47 of #949, Phase 2. Nine test files in pkg/sops/testdata/roundtrip go through writ's encrypter and back under
their names plus .sops, each compared with the file byte for byte; the deploy test adds token.sops, encrypted by
writ's encrypter; the encryption provider's and the deploy test's fragment checks compare the whole output. Against
today's code all nine files fail, and the deploy test fails on token.sops; the plan records how each fails.
…oken.sops deploys as its plaintext (#977)

Lane 47 of #949, Phase 3, ruled 2026-10-22: one mode, sops's binary store, in both directions, whatever the file is
called. detectFormat and storeForFormat are deleted, and with them the JSON wrapper a name with no format deployed as,
the reformatting of YAML and JSON secrets, the refusal of text named .yaml that is not YAML, and the .env and .ini
documents IsEncrypted did not recognize. Client.Decrypt takes the data alone. The encryption provider's and the
deploy test's ciphertext is made by writ's own encrypter. writ secret encrypt's help, two doc comments and the writ
guide no longer say the format comes from the name or from .sops.yaml. All nine round-trip files come back byte for
byte.
@David-Noble-at-work
David-Noble-at-work merged commit fcc4354 into develop Oct 24, 2026
21 checks passed
@David-Noble-at-work
David-Noble-at-work deleted the fix/977-secret-with-no-format-before branch October 24, 2026 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A secret with no format before .sops deploys as a JSON wrapper: token.sops lands as {"data": "..."}, not the token

1 participant