Граф коммитов

29 Коммитов

Автор SHA1 Сообщение Дата
Boris Kreitchman c822b55290 Sort masterkeys according to decryption-order
Co-authored-by: Gabriel Martinez <19713226+GMartinez-Sisti@users.noreply.github.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Bastien Wermeille <bastien.wermeille@gmail.com>
Co-authored-by: Hidde Beydals <hiddeco@users.noreply.github.com>
Signed-off-by: Boris Kreitchman <bkreitch@gmail.com>
2023-12-18 08:38:43 +01:00
Boris Kreitchman 2b97ff222b use getUserConfigDir also in tests
Signed-off-by: Boris Kreitchman <bkreitch@gmail.com>
2023-11-13 09:45:18 +02:00
Felix Fontein a27ea2013e On macOS, prefer XDG_CONFIG_HOME over os.UserConfigDir()
Signed-off-by: Felix Fontein <felix@fontein.de>
2023-09-21 08:31:46 +02:00
Hidde Beydals 6ec0312ffe
keyservices: address logging regression
Replace the logging of failed encryption and decryption attempts from
error to info level.

This to address a regression in which an encryption or decryption
attempt with a series of keys would result in a list of failed attempts
logged to stderr even when the operation itself eventually succeeded.

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-09-13 07:44:08 +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
Hidde Beydals d54c1286e1 Revert intro of `WithError` for most key sources
Most of the rewritten key sources introduced `WithError` calls, which
does not appear to go well with the UX of the CLI. This reverts it to
be the semi equal to current `master`.

During the diff, I noticed the current age implementation in master
does make use of `WithError`. Which makes me wonder if errors are not
returned twice at present in the CLI.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2023-07-11 23:13:11 +02:00
Hidde Beydals 02a866f27d age: improve identity loading, add tests, tidy
This adds improvements to identity loading, extensive test coverage
and a general tidying of bits of code. The improvements are based on a
fork of the age key source in the Flux project's kustomize-controller,
which was built due to SOPS' limitations around identity management
without relying on runtime environment variables.

- It introduces a `ParsedIdentity` type which contains a slice of age
  identities, and can be applied to the `MasterKey`. When applied,
  further loading of identities from the runtime environment is skipped
  for `Decrypt` operations. This is most useful when working with SOPS
  as an SDK, in combination with e.g. a local key service server
  implementation.
- The `Identity` field has been deprecated in the `MasterKey` struct.
  Presence of the field was misleading, as it is not actually used.
- Any detected identity reference is now loaded, instead of it assuming
  a priority order. This makes more sense, as age is able to work with
  a set of loaded identities. If no environment variables are defined,
  the existence of the keys.txt in the user's config directory is
  required.
- Decrypt logs have been added to match other key sources.
- Extensive test coverage.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-06-03 00:43:05 +02:00
Cedric Kienzler 1dc90ad1ab Add tests for single key
Adding tests to verify we do not break the usage of a single AGE key

Signed-off-by: Cedric Kienzler <github@cedric-kienzler.de>
2022-03-22 21:26:33 +01:00
Cedric Kienzler b5f5f28c3c Make `masterKeyFromRecipient` private
In [this](https://github.com/mozilla/sops/pull/966#discussion_r830294838) comment
it was proposed to make `masterKeyFromRecipient` private to avoid
reintroducing this bug in the future.
Since I agree with the Idea, this change will make the mehtod private
and update all unit-tests to use the `MasterKeysFromRecipients` method
instead.

Signed-off-by: Cedric Kienzler <github@cedric-kienzler.de>
2022-03-20 23:04:12 +01:00
Cedric Kienzler 7ebee3dc7b This fixes a bug with age encryption when specifying multiple age recipients
I encountered an issue when I tried so specify multiple age recipients
in the .sops.yaml config file of my repository.

I tried running `sops --age 'agePubKey1,agePubKey2' -e -i values.secret.yaml`
which produced an appropriate file with two entries in the `/sops/age/-`
part of the encrypted yaml file.

However, I then continued to set multiple recipients in my .sops.yaml
file to simplify handling:

```yaml
creation_rules:
  - encrypted_regex: '^(data|stringData|spec)$'
    age: 'agePubKey1,agePubKey2'
```

However, this resulted in encryption only being done for the first
specified agePubKey, not the second or third one.

After digging a bit trough the code, I think this should fix it.

I verified the fix locally on my machine and got it working. Also adding
some unit tests and extending the repository examples so they can be
decrypted using the age keys provided in `age/keys.txt`

Signed-off-by: Cedric Kienzler <github@cedric-kienzler.de>
2022-03-20 22:49:11 +01:00
AJ Bahnken dff9c31411
Merge branch 'develop' into sops-age-key-env 2022-03-01 10:22:01 -08:00
Christian Hoffmeister b7c58e4e56 Move age environment variable names to constants 2022-02-25 18:09:37 +01:00
AJ Bahnken 624c7d02b8
Merge pull request #842 from hiddeco/remove-unused-age-code
Remove unused age keysource code
2022-02-24 15:04:22 -08:00
Christian Hoffmeister 086c11d09b Support SOPS_AGE_KEY environment variable 2022-02-14 22:18:05 +01:00
Johan Fleury fdf4517ce8
Trim space from age keys 2021-04-03 22:17:45 -04:00
Hidde Beydals e98451e975 Remove unused age code
This removes two pieces of code in the age keysource that are not
actually used.

The `parsedIdentity` is technically a candidate to stay, but should
then be changed to a `[]*age.X25519Identity` type and be lazy-loaded
by `Decrypt` (with the result of `age.ParseIdentities`).

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-03-30 17:44:33 +02:00
Andreas 5d1376d56d
Use age/armor for encrypted data key (#819)
* Use age/armor for encrypted data key

Currently the encrypted data key is stored as a binary value, and this
results in SOPS encrypted DOTENV files having weird binary characters.

This changes the encrypt/decrypt methods to use the armor reader writer
provided by: filippo.io/age/armor

Signed-off-by: Andreas Amstutz <tullo@users.noreply.github.com>

* upgrade filippo.io/age to v1.0.0-beta7

Signed-off-by: Andreas Amstutz <tullo@users.noreply.github.com>

* add unit test

Signed-off-by: Andreas Amstutz <tullo@users.noreply.github.com>

Co-authored-by: Andreas Amstutz <tullo@users.noreply.github.com>
2021-02-21 09:06:40 +01:00
Mikhail Katychev 0f2ebcf7ff
added wrap verb to outputs (#817) 2021-02-17 22:21:20 +01:00
Jimmy Cuadra e9acafced7 Update to age 1.0.0-beta5. 2020-09-21 13:00:36 -07:00
Cole Mickens 8f6271f5c8 age: MasterKeysFromRecipients: gracefully handle empty string 2020-09-21 12:48:16 -07:00
Cole Mickens 50a89c8293 age: .sops.yaml support 2020-09-21 12:48:16 -07:00
Jimmy Cuadra 6a6a9363da Use more concise style for constructing map. 2020-09-21 12:47:15 -07:00
Jimmy Cuadra 7f7ecbc18e Try decrypting with all possible keys in the keyfile. 2020-09-21 12:47:15 -07:00
Jimmy Cuadra 617db437de Use a single keys.txt file for age private keys. 2020-09-21 12:47:15 -07:00
Jimmy Cuadra 5c171c800c Don't swallow potential errors from os.Stat. 2020-09-21 12:47:15 -07:00
Jimmy Cuadra d9b196c87c Determine age package path using current file rather than pwd. 2020-09-21 12:47:15 -07:00
Jimmy Cuadra 2741ab530a Use user config dir instead of home dir as the root for age keys. 2020-09-21 12:47:15 -07:00
Jimmy Cuadra 9e4cbc93cf Allow age key dir to be set with SOPS_AGE_KEY_DIR and add tests. 2020-09-21 12:47:15 -07:00
Jimmy Cuadra e8d00046e1 Add support for age. 2020-09-21 12:47:13 -07:00