Skip to content

Commit 1c0b237

Browse files
authored
Add some additional debug output for SOPS decryption (#36)
1 parent a95b480 commit 1c0b237

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [0.1.4] - 2023-03-16
10+
11+
### Added
12+
13+
- Add some additional debug output for SOPS decryption
14+
915
## [0.1.3] - 2023-02-15
1016

1117
### Fixed

crypt/sops.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package crypt
22

33
import (
44
"fmt"
5+
"log"
56
"os"
67
"strconv"
78

@@ -70,17 +71,24 @@ func (p *SOPSEncryptionProvider) Encrypt(data []byte) ([]byte, error) {
7071
// Decrypt will decrypt the data in buffer.
7172
func (p *SOPSEncryptionProvider) Decrypt(data []byte) ([]byte, error) {
7273
inputStore := &sopsjson.Store{}
73-
tree, _ := inputStore.LoadEncryptedFile(data)
74+
tree, err := inputStore.LoadEncryptedFile(data)
75+
if err != nil {
76+
return nil, err
77+
}
7478

7579
if tree.Metadata.Version == "" {
80+
log.Println("SOPS metadata version was not set, assuming state was not previously encrypted and returning as-is document")
7681
return data, nil
7782
}
7883

79-
_, _ = common.DecryptTree(common.DecryptTreeOpts{
84+
_, err = common.DecryptTree(common.DecryptTreeOpts{
8085
Cipher: aes.NewCipher(),
8186
Tree: &tree,
8287
KeyServices: []keyservice.KeyServiceClient{keyservice.NewLocalClient()},
8388
})
89+
if err != nil {
90+
return nil, err
91+
}
8492

8593
outputStore := &sopsjson.Store{}
8694
return outputStore.EmitPlainFile(tree.Branches)

0 commit comments

Comments
 (0)