mirror of
https://github.com/gopasspw/gopass.git
synced 2025-12-08 19:24:54 +00:00
* Maintain secret structure when parsing
This commit introduces a new KV secret type ("AKV") that fully maintains
the secret format when parsing. As such it obsoletes the old KV and
Plain formats and the need for the core.parsing option.
Fixes #2431
RELEASE_NOTES=[ENHANCEMENT] Maintain secret structure when parsing
Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
* Update internal/action/edit.go
Co-authored-by: Yolan Romailler <AnomalRoil@users.noreply.github.com>
* Address review comments
This brings back the noparsing flag since we need this to cover some
corners cases.
RELEASE_NOTES=n/a
Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
Co-authored-by: Yolan Romailler <AnomalRoil@users.noreply.github.com>
43 lines
1.0 KiB
Go
43 lines
1.0 KiB
Go
package leaf
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/gopasspw/gopass/internal/out"
|
|
"github.com/gopasspw/gopass/internal/store"
|
|
"github.com/gopasspw/gopass/pkg/ctxutil"
|
|
"github.com/gopasspw/gopass/pkg/debug"
|
|
"github.com/gopasspw/gopass/pkg/gopass"
|
|
"github.com/gopasspw/gopass/pkg/gopass/secrets"
|
|
"github.com/gopasspw/gopass/pkg/gopass/secrets/secparse"
|
|
)
|
|
|
|
// Get returns the plaintext of a single key.
|
|
func (s *Store) Get(ctx context.Context, name string) (gopass.Secret, error) {
|
|
p := s.Passfile(name)
|
|
|
|
ciphertext, err := s.storage.Get(ctx, p)
|
|
if err != nil {
|
|
debug.Log("File %s not found: %s", p, err)
|
|
|
|
return nil, store.ErrNotFound
|
|
}
|
|
|
|
content, err := s.crypto.Decrypt(ctx, ciphertext)
|
|
if err != nil {
|
|
out.Errorf(ctx, "Decryption failed: %s\n%s", err, string(content))
|
|
|
|
return nil, store.ErrDecrypt
|
|
}
|
|
|
|
if !ctxutil.IsShowParsing(ctx) {
|
|
debug.Log("secrets parsing is disabled. parsing as AKV")
|
|
|
|
return secrets.ParseAKV(content), nil
|
|
}
|
|
|
|
debug.Log("secrets parsing is enabled")
|
|
|
|
return secparse.Parse(content)
|
|
}
|