Skip to content

Conversation

felixfontein
Copy link
Contributor

It happened more than once that someone "encrypted" a file using the binary store, which resulted in simply base64 encoding the source since encryption was essentially disabled since some encryption selection option prevented the data key to be encrypted.

This PR allows to identify input stores that yield a single key (without comments), and disables all selection options in this case. It also prints warnings for options that potentially disable encryption.

Regarding the warnings: we could also simply not print any warning (might be less annoying to users who simply want to use the same config everywhere), or make the warnings more specific (if they match the data key; for that we need to provide the key name as well). @getsops/maintainers what do you think?

Fixes #1822.

@felixfontein felixfontein requested a review from a team August 30, 2025 09:17
sops.go Outdated
Comment on lines 729 to 733
// SingleValueStore is the interface for determining whether a store uses only
// one single key and no comments. This is basically identifying the binary store.
type SingleValueStore interface {
IsSingleValueStore() bool
}
Copy link
Member

@hiddeco hiddeco Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be slightly more logical to "inverse" this into:

Suggested change
// SingleValueStore is the interface for determining whether a store uses only
// one single key and no comments. This is basically identifying the binary store.
type SingleValueStore interface {
IsSingleValueStore() bool
}
// SingleValueStore is the interface for determining whether a store uses only
// one single key and no comments. This is basically identifying the binary store.
type SingleValueStore interface {
Store
IsSingleValueStore() bool
}

By doing this, a Store which is not a "single value" Store can forget about implementing the method. This also allows you to simply type-check the Store against the SingleValueStore interface (instead of calling the method).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in f4b4c04.

@felixfontein felixfontein force-pushed the binary-store-encryption-opts branch from 0dd11c8 to 0d9b77c Compare September 27, 2025 08:42
@felixfontein
Copy link
Contributor Author

(Rebased first to resolve the conflicts; will now look at the review comments.)

…hey are used).

Signed-off-by: Felix Fontein <felix@fontein.de>
Signed-off-by: Felix Fontein <felix@fontein.de>
@felixfontein felixfontein force-pushed the binary-store-encryption-opts branch from f4b4c04 to 6bb6621 Compare September 27, 2025 18:17
@felixfontein felixfontein merged commit e783741 into getsops:main Sep 27, 2025
15 checks passed
@felixfontein felixfontein deleted the binary-store-encryption-opts branch September 27, 2025 18:31
@felixfontein
Copy link
Contributor Author

@hiddeco thanks for reviewing and your comments!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Files that are encrypted and were read by the binary store should not use encryption configuration settings
2 participants