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

gopass insert [name] [key] fails to handle multiline YAML entries #1940

Closed
innovate-invent opened this issue Jun 4, 2021 · 2 comments · Fixed by #2244
Closed

gopass insert [name] [key] fails to handle multiline YAML entries #1940

innovate-invent opened this issue Jun 4, 2021 · 2 comments · Fixed by #2244
Assignees
Milestone

Comments

@innovate-invent
Copy link

innovate-invent commented Jun 4, 2021

Summary

With a secret of the format:

pass
key1: |
  text
  moretext

inserting a new key will yield

pass
key1: |
key2: content
  text
  moretext

gopass insert also fails to properly handle inserting multiline YAML strings

even manually adding the entries, gopass show fails to output the content:

gopass show secret key1
key1: |

Steps To Reproduce

echo "|\n  text\n  moretext" | gopass insert secret key1
echo "content" | gopass insert secret key2

### Expected behavior
The secret should respect the YAML

pass
key1: |
text
moretext
key2: content


### Environment
<!--
Please complete the following information (see note below)
-->

uname -a
Linux manjaro 5.11.19-1-MANJARO #1 SMP PREEMPT Fri May 7 17:34:25 UTC 2021 x86_64 GNU/Linux
gopass --version
gopass 1.12.6 (2021-05-11 15:27:04) go1.16.4 linux amd64


- Installation method: pacman

<!--
**PLEASE NOTE**

There is a package named gopass in the official Debian repository.
This package is not related to this project in any way. If you
installed gopass from the Debian archives report any bugs in
the Debian BTS.
-->

### Additional context
<!--
Add any other context about the problem here.
-->
@dominikschulz
Copy link
Member

Hmm, I don't think I've ever tried inserting multi-line keys.
If you want to help fix this contributing a test case would be appreciated.

@innovate-invent
Copy link
Author

I dug into the code and it appears to be a documentation issue:

// YAML is a gopass secret that contains a parsed YAML data structure.
// This is a legacy data type that is discouraged for new users as YAML
// is neither trivial nor intuitive for users manually editing secrets (e.g.
// unquoted phone numbers being parsed as octal and such).
//
// Format
// ------
// Line | Description
// 0 | Password
// 1-n | Body
// n+1 | Separator ("---")
// n+2 | YAML content

// KV is a secret that contains a password line (maybe empty), any number of
// lines of key-value pairs (defined as: contains a colon) and any number of
// free text lines. This is the default secret format gopass uses and encourages.
// It should be compatible with most other password store implementations and
// works well with our vanity features (e.g. accessing single entries in secret).
//
// Format
// ------
// Line | Description
// ---- | -----------
// 0 | Password. Must contain the "password" or be empty. Can not be omitted.
// 1-n | Key-Value pairs, e.g. "key: value". Can be omitted but the secret
// | might get parsed as a "Plain" secret if zero key-value pairs are found.
// n+1 | Body. Can contain any number of characters that will be parsed as
// | UTF-8 and appended to an internal string. Note: Technically this can
// | be any kind of binary data but we neither support nor test this with
// | non-text data. Also we do not intent do support any kind of streaming
// | access, i.e. this is not intended for huge files.
//
// Example
// -------
// Line | Content
// ---- | -------
// 0 | foobar
// 1 | hello: world
// 2 | gopass: secret
// 3 | Yo
// 4 | Hi
//
// This would be parsed as a KV secret that contains:
// - password: "foobar"
// - key-value pairs:
// - "hello": "world"
// - "gopass": "secret"
// - body: "Yo\nHi"

YAML format explicitly requires the "---" or it will be parsed as KV

@dominikschulz dominikschulz added this to the 1.12.7 milestone Jul 1, 2021
@AnomalRoil AnomalRoil modified the milestones: 1.12.7, 1.13.0 Jul 9, 2021
@dominikschulz dominikschulz modified the milestones: 1.13.0, 1.x.x May 3, 2022
@dominikschulz dominikschulz self-assigned this May 3, 2022
AnomalRoil added a commit that referenced this issue May 30, 2022
RELEASE_NOTES=[DOCUMENTATION] Adding documentation about YAML entries and unsafe-keys

Fixes #1940

Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com>
AnomalRoil added a commit that referenced this issue May 30, 2022
RELEASE_NOTES=[DOCUMENTATION] Adding documentation about YAML entries and unsafe-keys

Fixes #1940

Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com>
AnomalRoil added a commit that referenced this issue May 31, 2022
RELEASE_NOTES=[DOCUMENTATION] Adding doc about YAML entries and unsafe-keys

Fixes #1940

Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com>
kpitt pushed a commit to kpitt/gopass that referenced this issue Jul 21, 2022
RELEASE_NOTES=[DOCUMENTATION] Adding doc about YAML entries and unsafe-keys

Fixes gopasspw#1940

Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants