Skip to content

Commit

Permalink
Use SOPS DefaultDecryptionOrder
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Prodan <[email protected]>
  • Loading branch information
stefanprodan committed Aug 1, 2024
1 parent a21e977 commit 782c9b7
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions internal/decryptor/decryptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"io/fs"
"os"
"path/filepath"
"sort"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -287,14 +286,7 @@ func (d *Decryptor) SopsDecryptWithFormat(data []byte, inputFormat, outputFormat
return nil, sopsUserErr(fmt.Sprintf("failed to load encrypted %s data", sopsFormatToString[inputFormat]), err)
}

for _, group := range tree.Metadata.KeyGroups {
// Sort MasterKeys in the group so offline ones are tried first
sort.SliceStable(group, func(i, j int) bool {
return intkeyservice.IsOfflineMethod(group[i]) && !intkeyservice.IsOfflineMethod(group[j])
})
}

metadataKey, err := tree.Metadata.GetDataKeyWithKeyServices(d.keyServiceServer(), nil)
metadataKey, err := tree.Metadata.GetDataKeyWithKeyServices(d.keyServiceServer(), sops.DefaultDecryptionOrder)
if err != nil {
return nil, sopsUserErr("cannot get sops data key", err)
}
Expand Down

0 comments on commit 782c9b7

Please sign in to comment.