age keystore: support stream reading#2163
Open
Dexmachi wants to merge 8 commits intogetsops:mainfrom
Open
Conversation
Contributor
|
Thanks for your contribution! Can you please make sure to sign-off your commits (otherwise this cannot be merged), and to remove all unrelated code changes (reformatting) from the PR? Thanks. |
Author
oh, damn, ofc, I am sorry |
Signed-off-by: Caio Rocha de Oliveira <caiorocoli@gmail.com>
Signed-off-by: Caio Rocha de Oliveira <caiorocoli@gmail.com>
Author
|
I'm kinda stupid, rolled back my changes only to forget to declare 1 variable and 1 dep lmao (and the signoff) |
Signed-off-by: Caio Rocha de Oliveira <caiorocoli@gmail.com>
Signed-off-by: Caio Rocha de Oliveira <caiorocoli@gmail.com>
Signed-off-by: Caio Rocha de Oliveira <caiorocoli@gmail.com>
felixfontein
reviewed
May 3, 2026
Signed-off-by: Caio Rocha de Oliveira <caiorocoli@gmail.com>
Contributor
|
Please note that your PR has a conflict. |
1 task
Signed-off-by: Caio Rocha de Oliveira <caiorocoli@gmail.com>
Author
Trying to resolve it right now |
Signed-off-by: Caio Rocha de Oliveira <caiorocoli@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #2162
closes #1303
Why
Currently, sops fails to read multiple age keys passed via process substitution or named pipes (like /dev/fd/X) because these are read-once streams without "seek" support, throwing an EOF when it attempts to read it more than once during
loadIdentities()(which happens when there are multiple recipients or during parsing retries).Passing keys via file descriptors is a fairly common security pattern to prevent decrypted secrets from ever touching the disk or leaking into child processes via /prox/PPID/environ.
How
Added a
fileStreamCache(sync.Map) and areadStreamSafe(path string) ([]byte, error)helper function in age/keysource.go.When loading identities,
readStreamSafechecks if the path points to a stream with a.HasPrefix, checking for /dev/fd/ or /proc/if it is a stream: It reads it into memory and caches the
[]bytefor subsequent calls within the same process.if it is not a stream: It bypasses the cache and reads from the disk, as it was originally.
a exportable
ClearFileStreamCache()was created in order to zero out cached memory.All unit tests passing.
Locally tested intended behavior, works as intended.