mirror of
https://github.com/getsops/sops.git
synced 2026-02-05 12:45:21 +01:00
Reject completely empty documents.
This only affects empty YAML files, since only these can contain zero documents. Signed-off-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
@@ -21,6 +21,7 @@ const (
|
||||
ConfigFileNotFound int = 61
|
||||
KeyboardInterrupt int = 85
|
||||
InvalidTreePathFormat int = 91
|
||||
NeedAtLeastOneDocument int = 92
|
||||
NoFileSpecified int = 100
|
||||
CouldNotRetrieveKey int = 128
|
||||
NoEncryptionKeyFound int = 111
|
||||
|
||||
@@ -64,6 +64,9 @@ func encrypt(opts encryptOpts) (encryptedFile []byte, err error) {
|
||||
if err != nil {
|
||||
return nil, common.NewExitError(fmt.Sprintf("Error unmarshalling file: %s", err), codes.CouldNotReadInputFile)
|
||||
}
|
||||
if len(branches) < 1 {
|
||||
return nil, common.NewExitError("File cannot be completely empty, it must contain at least one document", codes.NeedAtLeastOneDocument)
|
||||
}
|
||||
if err := ensureNoMetadata(opts, branches[0]); err != nil {
|
||||
return nil, common.NewExitError(err, codes.FileAlreadyEncrypted)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user