1
0
mirror of https://github.com/getsops/sops.git synced 2026-02-05 03:45:44 +01:00

54 Commits

Author SHA1 Message Date
Defelo
e86db7cf72 Pass SOPS_AGE_RECIPIENT environment variable to SOPS_AGE_KEY_CMD
Signed-off-by: Defelo <mail@defelo.de>
2026-01-23 00:26:10 +01:00
Matthias Ahouansou
2dc62b8182 Support hybrid (post-quantum) age identities
Signed-off-by: Matthias Ahouansou <matthias@ahouansou.cz>
2026-01-11 20:44:03 +00:00
Felix Fontein
11f0d51021 Adjust age tests.
Signed-off-by: Felix Fontein <felix@fontein.de>
2025-12-29 11:52:52 +01:00
Felix Fontein
e311a4f7d5 Fix grammar.
Co-authored-by: Andrew Block <andy.block@gmail.com>
Signed-off-by: Felix Fontein <felix@fontein.de>
2025-09-11 19:05:31 +02:00
Felix Fontein
e1995e1c78 Always load age identities from all locations, and report unused locations in error messages.
Signed-off-by: Felix Fontein <felix@fontein.de>
2025-09-11 19:05:31 +02:00
Felix Fontein
c122e0c1a7 Collect age identity loading errors and only report if decryption failed.
Signed-off-by: Felix Fontein <felix@fontein.de>
2025-08-06 20:06:04 +02:00
Felix Fontein
511bebb4a4 Merge branch 'main' into SOPS_AGE_KEY_CMD 2025-03-28 06:58:14 +01:00
Felix Fontein
92e63d0910 Remove dead code.
Signed-off-by: Felix Fontein <felix@fontein.de>
2025-03-25 20:34:48 +01:00
Felix Fontein
aaf6590f45 Replace testing-only environment variable with regular variable.
Signed-off-by: Felix Fontein <felix@fontein.de>
2025-03-25 20:34:48 +01:00
Danilo Bürger
6c88a9d9a8 Use shlex instead of shellquote
Signed-off-by: Danilo Bürger <danilo.buerger@helsing.ai>
2025-03-24 20:22:24 +01:00
Danilo Bürger
eea4b7bb76 Added SOPS_AGE_KEY_CMD option to age, fixes #1323
Signed-off-by: Danilo Bürger <danilo.buerger@helsing.ai>
2025-03-24 15:16:50 +01:00
Felix Fontein
10c103bfbb Consolidate passphrase reading functionality.
Basically readPassphrase was replaced by readSecret in c0e80ef2c9
so we can just use that and stick to the latest version of cmd/age/tui.go.

Signed-off-by: Felix Fontein <felix@fontein.de>
2025-03-01 20:39:23 +01:00
Brian McGee
6157d86d75 feat: add age plugin support
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2025-02-27 09:06:21 +00:00
Tomasz Duda
1d3eefaaf8 fix review comments
Signed-off-by: Tomasz Duda <tomaszduda23@gmail.com>
2025-02-23 21:34:28 +01:00
Tomasz Duda
0ba8bd19bc fix review comments
Signed-off-by: Tomasz Duda <tomaszduda23@gmail.com>
2025-02-23 21:30:30 +01:00
tomaszduda23
c5b59c769e Merge branch 'main' into pass 2025-02-22 13:55:26 +01:00
Tomasz Duda
2d144cd25c use common function to read password
Signed-off-by: Tomasz Duda <tomaszduda23@gmail.com>
2025-02-22 13:55:12 +01:00
Tomasz Duda
6baf3b4c75 Merge remote-tracking branch 'origin/main' into pass
Signed-off-by: Tomasz Duda <tomaszduda23@gmail.com>
2025-02-22 12:13:01 +01:00
Tomasz Duda
19f37824ac make sure that tests do not pick keys.txt from user's HOME dir
Signed-off-by: Tomasz Duda <tomaszduda23@gmail.com>
2025-02-22 12:02:18 +01:00
haoqixu
1efd20358c move functions into ssh_parse.go
Signed-off-by: haoqixu <hq.xu0o0@gmail.com>
2025-02-19 12:52:51 +08:00
haoqixu
5332127f2a replace SopsAgeSshPrivateKeyEnv in comments
Signed-off-by: haoqixu <hq.xu0o0@gmail.com>
2025-02-19 12:52:51 +08:00
haoqixu
bbcfa1a862 update license header as suggested
Signed-off-by: haoqixu <hq.xu0o0@gmail.com>
2025-02-19 12:52:51 +08:00
haoqixu
4cf34eb958 Rename SopsAgeSshPrivateKeyEnv to SopsAgeSshPrivateKeyFileEnv
Signed-off-by: haoqixu <hq.xu0o0@gmail.com>
2025-02-19 12:52:51 +08:00
Marvin Strangfeld
b888daa244 feat: add ssh support for age
Signed-off-by: Marvin Strangfeld <marvin@strangfeld.io>
2025-02-19 12:52:49 +08:00
Felix Fontein
5381112096 Merge pull request #1743 from getsops/dependabot/go_modules/go-dfc8ceccf9
build(deps): Bump the go group with 7 updates
2025-02-01 17:29:48 +01:00
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