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

Copying empty secret when multiline is inserted #2614

Closed
matus-cuper opened this issue Jun 30, 2023 · 0 comments · Fixed by #2625
Closed

Copying empty secret when multiline is inserted #2614

matus-cuper opened this issue Jun 30, 2023 · 0 comments · Fixed by #2625
Assignees
Labels
bug Defects
Milestone

Comments

@matus-cuper
Copy link

matus-cuper commented Jun 30, 2023

Summary

After adding multiline password (also when it is only one line) the first line is empty and there I am not able to copy password via gopass command. I have to edit it firstly and manually remove first empty line. Then it is working as expected.

Steps To Reproduce

$ gopass insert -m personal/test
# vim opens
pass1
# :wq to save and quit

$ gopass personal/test
Secret: personal/test


pass1

$ gopass -c personal/test

Error: empty secret. see https://go.gopass.pw/faq#empty-secret

Expected behavior

$ gopass personal/test
Secret: personal/test

pass1

$ gopass -c personal/test
✔ Copied personal/test to clipboard. Will clear in 45 seconds.

Environment

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.2 LTS"

$ uname -a
Linux mcuper-P14s 5.19.0-46-generic #47~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Jun 21 15:35:31 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

$ gopass version
gopass 1.15.5 go1.20.2 linux amd64

$go install github.com/gopasspw/gopass@latest

@dominikschulz dominikschulz self-assigned this Jul 10, 2023
@dominikschulz dominikschulz added the bug Defects label Jul 28, 2023
@dominikschulz dominikschulz added this to the 1.15.6 milestone Jul 28, 2023
dominikschulz added a commit to dominikschulz/gopass that referenced this issue Jul 30, 2023
This commit fixes as small issue in how multi-line secrets are handled.
Before they were always written in to the secret body completly ignoring
the first line that contains the password. Now we do respect that
correctly. To implement that properly we need to have some additional
code to satisfy the io.Writer assumptions around the AKV secret type.

Also this fixes some non-hermetic tests that showed up during testing of
this change.

Fixes gopasspw#2614

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
dominikschulz added a commit that referenced this issue Jul 30, 2023
* Correctly handle new multiline secrets

This commit fixes as small issue in how multi-line secrets are handled.
Before they were always written in to the secret body completly ignoring
the first line that contains the password. Now we do respect that
correctly. To implement that properly we need to have some additional
code to satisfy the io.Writer assumptions around the AKV secret type.

Also this fixes some non-hermetic tests that showed up during testing of
this change.

Fixes #2614

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>

* Fix typo

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>

* Ditch the MultiWriter approach in favor of a pass-through writer

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>

* Format

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>

---------

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Defects
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants