Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: pipe cleartext into agenix -e #154

Merged
merged 1 commit into from
Feb 20, 2023
Merged

feature: pipe cleartext into agenix -e #154

merged 1 commit into from
Feb 20, 2023

Conversation

ryantm
Copy link
Owner

@ryantm ryantm commented Feb 19, 2023

If STDIN is not interactive, change EDITOR to cp /dev/stdin.

Also updates tests somewhat.

fixes #33

If STDIN is not interactive, change EDITOR to `cp /dev/stdin`.

fixes #33
@ryantm ryantm requested a review from n8henrie February 19, 2023 18:22
@n8henrie n8henrie merged commit 5f66c8a into main Feb 20, 2023
@n8henrie n8henrie deleted the rtm-2-19-pipe branch February 20, 2023 16:30
@whentze
Copy link
Contributor

whentze commented Feb 20, 2023

Oh yikes, this breaks another hack of mine where I set EDITOR to something else to get plaintext secrets out 😬

(Yes, this is a bit of a spacebar-heating moment, I realize.)

@ryantm
Copy link
Owner Author

ryantm commented Feb 20, 2023

@whentze Can you describe your hack more?

@whentze
Copy link
Contributor

whentze commented Feb 20, 2023

Yes. I have a program like this

#!/bin/sh
cp "$2" "$1"

and by calling agenix as EDITOR="that-script.sh /proc/self/fd/3" agenix -e foo.age 3>| ... I can use it in a pipe.
I know I can call age directly, but it doesn't have the same logic for finding private keys, so it doesn't work in every case.

@whentze
Copy link
Contributor

whentze commented Feb 20, 2023

Just to be clear, I'm aware this is an awful hack, and I'm not asking you to keep it supported.
But maybe another way to get the plaintext secrets out would be nice.

@ryantm
Copy link
Owner Author

ryantm commented Feb 20, 2023

This editor program puts the cleartext into a file called cleartext even with these changes.

#!/bin/sh
cp "$1" cleartext

@whentze
Copy link
Contributor

whentze commented Feb 20, 2023

Huh, even when STDIN is not interactive?

@ryantm
Copy link
Owner Author

ryantm commented Feb 20, 2023

Oh, no STDIN was interactive. I misunderstood what you are doing. Or maybe you edited it to add more after I saw it... 🤷

@whentze
Copy link
Contributor

whentze commented Feb 20, 2023

Sorry for the edits, I had realized my minimal example was too minimal and didn't actually work.

What the hack is really solving for me is the ability to use agenix secrets in a script - locally while working on a repo.

@whentze
Copy link
Contributor

whentze commented Feb 20, 2023

Would you be open to the addition of agenix --decrypt or something, that does specifically that without requiring a hack?

I can try my hand at an implementation.

@ryantm
Copy link
Owner Author

ryantm commented Feb 20, 2023

Yes, definitely. We're using EDITOR=cat hack a bunch in the tests in lieu of this feature too.

@n8henrie
Copy link
Collaborator

@whentze can you provide a sample codeblock for how one would interact with this, to make sure I understand?

Is this it?

$ agenix [-i /tmp/id_rsa] --decrypt myfile.age
mysecret

@whentze
Copy link
Contributor

whentze commented Feb 21, 2023

@n8henrie yes, exactly like that :)

See #158 for my attempt at it.

@fmnxl fmnxl mentioned this pull request Aug 11, 2024
This pull request was closed.
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.

pipe (generated) key to agenix
3 participants