1
0
mirror of https://github.com/getsops/sops.git synced 2026-02-05 12:45:21 +01:00
Commit Graph

107 Commits

Author SHA1 Message Date
Felix Fontein
6d4c21860e Remove reserved keyword check from YAML store's LoadPlainFile().
This check hid the better check in cmd/sops/encrypt.go.

Signed-off-by: Felix Fontein <felix@fontein.de>
2025-04-13 15:18:09 +02:00
Felix Fontein
72cebfd8a1 Run 'gofmt -w' on all .go files.
Signed-off-by: Felix Fontein <felix@fontein.de>
2025-03-28 20:11:33 +01:00
Charlie Getzen
496b40e2c9 Merge branch 'main' into cg/minimum-sops-config 2025-03-27 23:04:20 -07:00
Felix Fontein
54196f028b Adjust new test.
Signed-off-by: Felix Fontein <felix@fontein.de>
2025-02-15 14:25:29 +01:00
Felix Fontein
d9d35e999f Merge branch 'main' into eof-newline 2025-02-15 14:22:01 +01:00
Felix Fontein
233deecdd0 Merge branch 'main' into fixes 2025-02-15 14:06:42 +01:00
Felix Fontein
424416c9e5 Merge branch 'main' into ini-store-duplicate-sections 2025-02-15 13:58:44 +01:00
Felix Fontein
50b6afc9c2 Merge branch 'main' into eof-newline 2025-02-15 13:54:00 +01:00
Felix Fontein
2463a6f96f Correctly handle comments during JSON serialization.
Signed-off-by: Felix Fontein <felix@fontein.de>
2024-12-01 09:19:22 +01:00
Martin Holst Swende
adad27e2d4 stores: test for duplicate keys, reseve keyword (yaml only now)
stores/json: use assert
stores/yaml: fix failing test (empty data)
stores/yaml: use assert in tests
unfix error handling and ignore error

Signed-off-by: Martin Holst Swende <martin@swende.se>
2024-09-27 15:58:34 +02:00
Sebastien Duthil
fa545b142d outputs: add trailing \n at the end of json files
Signed-off-by: Sebastien Duthil <duthils@duthils.net>
2024-09-14 09:25:19 -04:00
Tobias Reindl
4249ec2e47 add duplicate section support to ini store
Signed-off-by: Tobias Reindl <tobias.reindl@s7-rail.com>
2024-08-27 08:32:46 +02:00
Charlie Getzen
246efde338 chore: omitempty optional metadata to reduce the size of stored config
Signed-off-by: Charlie Getzen <charlie_g@regrello.com>
2024-07-31 17:02:42 -05:00
Mitar
f63e844206 Support using comments to select parts to encrypt
Signed-off-by: Mitar <mitar.git@tnode.com>
2024-06-27 09:21:08 +02:00
Felix Fontein
daabd14700 Do not use DotEnv store for exec-env.
This avoids quoting problems, fixes #784, and also better handles
various problems that can arise, like '=' in keys and non-string
keys and values.

Signed-off-by: Felix Fontein <felix@fontein.de>
2024-06-15 17:53:38 +02:00
Felix Fontein
00de085c34 Improve comment.
Co-authored-by: Devin Stein <devstein@alumni.upenn.edu>
Signed-off-by: Felix Fontein <felix@fontein.de>
2023-12-29 23:22:25 +01:00
Felix Fontein
618b60e99c Create a constant for the 'sops' metadata key.
Signed-off-by: Felix Fontein <felix@fontein.de>
2023-12-29 22:55:57 +01:00
Felix Fontein
1bda828b69 Make check whether file contains invalid keys for encryption dependent on output store.
Signed-off-by: Felix Fontein <felix@fontein.de>
2023-12-29 22:22:01 +01:00
Felix Fontein
56d765a46b shamir_threshold is an integer.
Signed-off-by: Felix Fontein <felix@fontein.de>
2023-12-28 17:37:41 +01:00
Lance Rushing
7d90cf2e97 Add comments for new functions
Signed-off-by: Lance Rushing <lance@lancerushing.com>
2023-12-28 15:56:07 +01:00
Lance Rushing
c2852846f5 Update comment for more clarity
Signed-off-by: Lance Rushing <lance@lancerushing.com>
2023-12-28 15:56:07 +01:00
Lance Rushing
b67a83d408 Move non-string and newline function calls outside of encode/decode
Signed-off-by: Lance Rushing <lance@lancerushing.com>
2023-12-28 15:56:07 +01:00
Lance Rushing
32dbc6be13 Add dedicated functions for \n and non string encoding
Signed-off-by: Lance Rushing <lance@lancerushing.com>
2023-12-28 15:56:07 +01:00
Lance Rushing
1161ec17a1 Consolidate Flatten/Unflatten pre/post processing
Fixes #1353

Consolidate the common json marshalling and \n handing to stores/flatten.go
Make existing functions unexported.
Add casts for MACOnlyEncrypted

Signed-off-by: Lance Rushing <lance@lancerushing.com>
2023-12-28 15:56:07 +01:00
Bastien
42018ef4a5 Add indentation settings for json_binary
Signed-off-by: Bastien <bastien.wermeille@gmail.com>
2023-11-24 07:41:14 +01:00
Bastien
8a63bb0d21 Add checks for indentation value
Signed-off-by: Bastien <bastien.wermeille@gmail.com>
2023-11-24 07:41:14 +01:00
Bastien Wermeille
755c16d49c Allow no indent at all for json store
Signed-off-by: Bastien Wermeille <bastien.wermeille@gmail.com>
2023-11-24 07:41:14 +01:00
Bastien Wermeille
c6dc5267e5 Indentation of json files
Signed-off-by: Bastien Wermeille <bastien.wermeille@gmail.com>
2023-11-24 07:41:14 +01:00
Bastien Wermeille
6ad2a82d22 Refactor duplicated code
Signed-off-by: Bastien Wermeille <bastien.wermeille@gmail.com>
2023-11-24 07:41:14 +01:00
Bastien Wermeille
d2ee8df5de Implement feedback
Co-authored-by: Felix Fontein <felix@fontein.de>
Signed-off-by: Bastien Wermeille <bastien.wermeille@gmail.com>
2023-11-24 07:41:14 +01:00
Bastien Wermeille
303fdd8f37 Add cli indent option for yaml store
Signed-off-by: Bastien Wermeille <bastien.wermeille@gmail.com>
2023-11-24 07:41:14 +01:00
James J. Goodhouse
e9e2346fdd Add configuration for stores
this will allow for setting of parameters specific to each store, such
as indentation level for YAML

Co-authored-by: Bastien Wermeille <bastien.wermeille@gmail.com>
Signed-off-by: James J. Goodhouse <jgoodhouse@newrelic.com>
2023-11-24 07:41:14 +01:00
Mitar
051ce028c9 Support computing MAC only over values which end up encrypted
Signed-off-by: Mitar <mitar.git@tnode.com>
2023-11-07 11:59:08 +01:00
Felix Fontein
38ec3f7a52 Handle unhandled errors.
Signed-off-by: Felix Fontein <felix@fontein.de>
2023-10-03 09:41:49 +02:00
Felix Fontein
a27e1bddf2 Ignore irrelevant return value (it is always nil).
Signed-off-by: Felix Fontein <felix@fontein.de>
2023-10-03 09:41:49 +02:00
Felix Fontein
72f11997d4 Handle return values of dec.Token() to improve error messages.
Signed-off-by: Felix Fontein <felix@fontein.de>
2023-09-28 22:16:45 +02:00
Felix Fontein
f258e6c1d1 Improve handling of errors when binary store handles bad data
Makes sure that the 'data' key refers to strings. Also
improves error messages, and on CLI hints at the --output-type
option.

Signed-off-by: Felix Fontein <felix@fontein.de>
2023-09-21 08:25:50 +02:00
Felix Fontein
8012cd6e9f Delete sops encrypted file we don't have keys for.
Signed-off-by: Felix Fontein <felix@fontein.de>
2023-09-20 21:09:29 +02:00
Hidde Beydals
eeaf9f76d5 *: address various simple staticcheck warnings
Deprecation of `io/ioutil`, removal of unused functions, possible nil
pointer dereference, and other tiny nits.

There are (many) more, but these would require their own (commit)
context.

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-08-17 00:16:40 +02:00
Hidde Beydals
ca0e15eda3 *: solve go vet errors
```
stores/dotenv/store.go:74:12: github.com/getsops/sops/v3.Comment struct literal uses unkeyed fields
stores/dotenv/store_test.go:29:10: github.com/getsops/sops/v3.Comment struct literal uses unkeyed fields
keyservice/server.go:149:9: assignment copies lock value to key: github.com/getsops/sops/v3/keyservice.Key contains google.golang.org/protobuf/internal/impl.MessageState contains sync.Mutex
keyservice/server.go:206:20: call of ks.prompt copies lock value: github.com/getsops/sops/v3/keyservice.Key contains google.golang.org/protobuf/internal/impl.MessageState contains sync.Mutex
keyservice/server.go:214:22: keyToString passes lock by value: github.com/getsops/sops/v3/keyservice.Key contains google.golang.org/protobuf/internal/impl.MessageState contains sync.Mutex
keyservice/server.go:231:29: prompt passes lock by value: github.com/getsops/sops/v3/keyservice.Key contains google.golang.org/protobuf/internal/impl.MessageState contains sync.Mutex
keyservice/server.go:232:27: call of keyToString copies lock value: github.com/getsops/sops/v3/keyservice.Key contains google.golang.org/protobuf/internal/impl.MessageState contains sync.Mutex
keyservice/server.go:251:9: assignment copies lock value to key: github.com/getsops/sops/v3/keyservice.Key contains google.golang.org/protobuf/internal/impl.MessageState contains sync.Mutex
keyservice/server.go:308:20: call of ks.prompt copies lock value: github.com/getsops/sops/v3/keyservice.Key contains google.golang.org/protobuf/internal/impl.MessageState contains sync.Mutex
stores/yaml/store_test.go:27:11: github.com/getsops/sops/v3.Comment struct literal uses unkeyed fields
stores/yaml/store_test.go:39:11: github.com/getsops/sops/v3.Comment struct literal uses unkeyed fields
stores/yaml/store_test.go:107:5: github.com/getsops/sops/v3.Comment struct literal uses unkeyed fields
stores/yaml/store_test.go:139:13: github.com/getsops/sops/v3.Comment struct literal uses unkeyed fields
decrypt/example_test.go:34:1: ExampleDecryptFile refers to unknown identifier: DecryptFile
```

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-08-17 00:14:20 +02:00
Andraz Bajt
700eea7119 Add a test for dotenv output ordering
Signed-off-by: Andraz Bajt <andraz@bajt.me>
2023-08-16 11:21:13 +02:00
Jason Banich
e25c1d9c2d Sort sops parameters in dotenv file 2023-08-16 11:19:55 +02:00
Hidde Beydals
f2a1d4c782 Rename Go module to github.com/getsops/sops/v3
This commit renames the Go module from `go.mozilla.org/sops/v3` to
`github.com/getsops/sops/v3` without a major version bump, to align
with new stewardship.

For more information around this change, refer to
https://github.com/getsops/sops/issues/1246.

For a one-liner to change the `go.mod` and any import paths in your
Go project making use of this module, run:

```
find /path/to/repo -type f \( -name "*.go" -o -name "go.mod" \) -exec sed -i 's|go.mozilla.org/sops/v3|github.com/getsops/sops/v3|g' {} \;
find /path/to/repo -type f \( -name "*.go" -o -name "go.mod" \) -exec sed -i '' 's|go.mozilla.org/sops/v3|github.com/getsops/sops/v3|g' {} \;
```

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-07-31 22:51:36 +02:00
Felix Fontein
b2d5f08258 Fix comment jumping. 2022-05-31 21:26:49 +02:00
ikedam
108b211cfb Allow empty maps for yaml (#907) 2021-07-24 15:37:49 +09:00
ikedam
75cd389509 Add a test to reproduce #907 2021-07-24 15:29:15 +09:00
Felix Fontein
5af8e63ad5 Prevent comment duplication. (#866) 2021-05-08 19:43:55 +02:00
Felix Fontein
e2d6d0fdc3 Use yaml.v3 instead of modified yaml.v2 for handling YAML files (#791)
* Add another test (that currently fails).

* First shot at using yaml.v3 for reading YAML files with comments.

* Allow parsing multi-document YAML files.

* Use Decoder to parse multi-part documents.

* Use yaml.v3 for config and audit.

* First step of serializing YAML using yaml.v3.

* Always serialize with yaml.v3.

* Remove debug prints.

* Remove traces of github.com/mozilla-services/yaml.

* Improve serialization of documents consisting only of comments.

* Improve handling of some empty documents.

* Adjust to latest changes in go-yaml/yaml#684.

* Bump yaml.v3 version, temporarily disable failing tests.

* Run go mod tidy.

* Fix CI.
2021-02-21 18:48:23 +01:00
Felix Fontein
47cf265067 Forgot to remove no longer used import. 2021-01-06 22:57:34 +01:00
Felix Fontein
88b05654b2 Remove dead code that fails compiling (#774). 2021-01-06 22:57:34 +01:00