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

68 Commits

Author SHA1 Message Date
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
Tanner Storment
165b4e63c3 explicitly set permissions on test tmpdir
Signed-off-by: Tanner Storment <tannerstorment@gmail.com>
2023-12-09 11:08:48 -06:00
Felix Fontein
09e147f2fb Fix typos.
Signed-off-by: Felix Fontein <felix@fontein.de>
2023-11-03 12:32:52 +01:00
Hidde Beydals
d021b6bf44 pgp: further improve import error format
Looking more at this, it would actually be great if we would detect
multi-line errors from GnuPG in `Import()`, `Decrypt()` and `Encrypt()`
so that we can slightly improve the formatting of the errors with a
newline seperator before the `gpg: ...\ngpg: ...` output. As this would
likely increase readability.

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-10-10 00:46:27 +02:00
Max Jonas Werner
d148ddf274 pgp: better error reporting for missing GPG binary
The error returned by `gpgExec` has just been swallowed. Now it is
stringified and returned together with any output to stderr.

Signed-off-by: Max Jonas Werner <mail@makk.es>
2023-10-10 00:46:22 +02:00
Felix Fontein
dd59dc1096 Check err for nil in tests.
Signed-off-by: Felix Fontein <felix@fontein.de>
2023-10-03 09:41:49 +02:00
Martin Holst Swende
2bba794a96 pgp: do not require abs path for SopsGpgExecEnv
Signed-off-by: Martin Holst Swende <martin@swende.se>
2023-09-29 16:01:04 +02:00
Felix Fontein
74c4b124ab Make error the last return value
Signed-off-by: Felix Fontein <felix@fontein.de>
2023-09-29 13:19:49 +02:00
Hidde Beydals
09793bfa9d pgp: remove --no-default-keyring argument
This argument was confusing and/or misleading, as we do specify a home
directory as the next argument.

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-09-20 01:04:17 +02:00
Hidde Beydals
f21d5256f0 pgp: improve handling of GnuPG home dir
There have been reports about the new logic breaking certain GnuPG
shims (#1294).

As this behavior is only really required when SDK users are making
use of the GnuPG using SOPS as an SDK. Prefer any runtime configuration
when no custom GnuPG home is configured on the key source, instead of
providing an absolute `--homedir` to `gpg`.

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-09-20 01:04:16 +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
0fb45f185a pgp: remove DisableAgent option
This option actually gives a false impression, as disabling the agent is
no longer possible since GnuPG 2.x.

```
--use-agent --no-use-agent This is dummy option. gpg always requires the agent.
```

xref: https://www.gnupg.org/documentation/manuals/gnupg24/gpg.1.html

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-09-13 00:04:30 +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
Brian Kemper
fd3e5ad5f4 Clean up more Mozilla references
Signed-off-by: Brian Kemper <bkemper@gmail.com>
2023-08-16 14:29:40 -06: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
flx5
0e7174c7f9 Replace deprecated gopass package with term 2022-08-20 16:55:19 +02:00
Hidde Beydals
8a98401488 pgp: extend test coverage OpenPGP
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-05-30 16:05:13 +02:00
Hidde Beydals
3c8d637ecf pgp: allow disabling OpenPGP capabilities
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-05-26 11:02:42 +02:00
Hidde Beydals
c4458d7511 pgp: add Cleanup util func to GnuPGHome
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-05-26 11:02:42 +02:00
Hidde Beydals
c6236ada56 pgp: modernize and improve, and add tests
This replaces the current PGP keysource implementation with a modernized
version the Flux project has been using[1].

It includes utilites to configure the MasterKey via other means than
environment variables, to allow SDK users to have extensive control
over what things are decrypted with. This can for example be combined
with an own keyserver implementation.

To be able to contribute it back upstream while keeping it backwards
compatible with SOPS, a couple of changes have been made compared to
Flux:
- Instead of removing the enabling of the agent while making use of
  GnuPG, it can now be disabled.
- Support for OpenPGP has been added back. Note however my comments
  on this in-code, as I am not quite sure to what extend it is used
  at the moment, as it will not work on most setups (GnuPG <2.1 was
  released in 2017.)
- The absolute paths to the pub and sec keyrings can now be configured
  by SDK users. This would add more reason to keep OpenPGP around, if
  they are able to produce the keyring files themselves via other means
  than GnuPG.
- When a sec keyring is not detected, a lookup for the pub keyring is
  made and loaded instead if found. This to account for GnuPG >=2.1
  merging the sec keyring into pub keyring.
- Support for fetching keys from servers has been removed. This can be
  added back if we need to keep it around for a little longer.

This has extensive test coverage for GnuPG, but would need coverage for
the re-added OpenPGP implementation before it can be deemed ready.

[1]: ffdda3f3da/internal/sops/pgp

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-05-26 11:02:42 +02:00
Hidde Beydals
25817ed0f5 Replace x/crypto/openpgp with ProtonMail/go-crypto
As `golang.org/x/crypto/openpgp` has been deprecated (see
golang/go#44226 for details).

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-04-20 21:10:58 +02:00
ikedam
6130ffe35c Use the key of release@mozilla.com for the unit test (#882) (#906)
* `golang.org/x/crypto/openpgp` requires keys contain identity information.
* A email address can have only a single key with identity information on keys.openpgp.org.
2021-07-24 12:12:18 +02:00
Mikhail Katychev
0f2ebcf7ff added wrap verb to outputs (#817) 2021-02-17 22:21:20 +01:00
cloudstarz
886c1ee781 Returning stderr when gpg encrypt fails (#762)
Co-authored-by: AJ Bahnken <1144310+ajvb@users.noreply.github.com>
2020-10-30 00:00:20 +01:00
AJ Bahnken
8acbe730b2 typo fix for deprecation warning in getKeyFromKeyServer 2020-09-24 12:26:16 -07:00
AJ Bahnken
8a09f056de Switch gpg.mozilla.org out for keys.openpgp.org 2020-09-02 11:45:01 -07:00
Dr. Uwe Daub
4f06780ab2 Fix endless loop in x/crypto/openpgp func ReadMessage (#690)
* Fix tests

* Fix endless loop in x/crypto/openpgp func ReadMessage

This fixes https://github.com/mozilla/sops/issues/665
See also https://github.com/golang/go/issues/28786

In some strange situations it can happen, that openpgp.ReadMessage()
runs into a endless loop. This seems to be triggered by a slightly
inconsistency in key settings.
It happened to me, but I wasn't able to reproduce it with a fresh key.
A proposed solution from the x/crypto community was, to break this loop
in the callback passphrasePrompt.

* Revert "Fix tests"

This reverts commit 285f4dc8a1.

* Improve error description

https://github.com/mozilla/sops/pull/690#discussion_r451630193
2020-07-14 21:25:06 +02:00
AJ Bahnken
8e21de8dbc Upgrade sops to go 1.13 (#566) 2019-11-18 10:06:58 -08:00
AJ Bahnken
e9b9f7aeef Replace old functional test gpg keys (#512)
Two of the three old keys have expired, so create a new set with no
expiration.
2019-08-30 09:07:00 -07:00
Benoît Knecht
1de402b5ad pgp/keysource: Check size of key fingerprint
Make sure the key fingerprint is longer than 16 characters before
slicing it.

Closes #463
2019-05-23 16:17:23 +02:00
rabadin
410a687a35 Add support for custom GPG key servers
Add support for the SOPS_GPG_KEYSERVER environment variable to
override the default GPG key server (gpg.mozilla.org).
2019-03-12 12:17:33 +01:00
Jan-Otto Kröpke
b72e3bf3f1 Use $HOME instead ~ to find the gnupg directory. 2018-11-25 16:27:36 +01:00
Dov Reshef
e57c8f2c85 Fixed wrong Errorf format in message 2018-04-08 10:48:11 +03:00
Adrian Utrilla
9d6a8d0e21 Default to Warn log level unless verbose flag is passed 2018-03-07 17:18:45 +01:00
azhi
4efe53ff42 add IsBinary: true to FileHints when encoding with crypto/openpgp
since we encode binary data this is generally a good idea

this commit fixes #278 - now both crypto/openpgp and gpg work in a binary
mode, and we can safely use both interchangeably
(e.g. encrypt with crypto/openpgp, and then decrypt with gpg)
2017-11-28 01:17:44 +03:00
Adrian Utrilla
1847c6cdd6 Support retrieving PGP keys from keyservers 2017-10-05 13:26:10 -07:00
Adrian Utrilla
20046c1b48 Merge branch 'master' into logging 2017-09-16 17:59:00 -07:00
Adrian Utrilla
08a4c7e657 Add documentation to all main packages 2017-09-12 20:01:12 -07:00
Adrian Utrilla
93570b20d7 Fix golint errors 2017-09-12 09:59:23 -07:00
Adrian Utrilla
d1637e0da7 Use custom error type for pgp instead of Errorf 2017-09-12 09:22:33 -07:00
Adrian Utrilla
cdbac51221 s/GPG/PGP 2017-09-12 09:00:12 -07:00
Adrian Utrilla
55c7174713 Use logrus features for better logging 2017-09-07 10:49:27 -07:00
Adrian Utrilla
17d5d6b65c Move all loggers to logrus 2017-09-06 17:36:39 -07:00
Adrian Utrilla
252e0dba17 Fix style problems 2017-08-29 17:57:29 -07:00
Adrian Utrilla
be4a35e7f5 Fix shamir tests 2017-08-25 13:12:34 -07:00
Adrian Utrilla
dae5c6ce6f Add logging to KMS key operations 2017-08-25 09:59:58 -07:00
Adrian Utrilla
e3705100c2 Add support for GPG binary 2017-08-23 14:29:53 -07:00
Adrian Utrilla
48ee4bff63 First step towards keygroups 2017-08-23 11:06:47 -07:00
Adrian Utrilla
10dd9b5441 Use KeyService for all encrypt and decrypt operations 2017-08-17 11:32:04 -07:00