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

265 Commits

Author SHA1 Message Date
Felix Fontein
0a9b441181 Make sure to wrap raw errors with toExitError().
Signed-off-by: Felix Fontein <felix@fontein.de>
2023-10-09 08:55:16 +02:00
Felix Fontein
71b5795967 Report key rotation errors.
Signed-off-by: Felix Fontein <felix@fontein.de>
2023-10-08 15:31:00 +02:00
Felix Fontein
f668c71545 Defer only after checking err.
Signed-off-by: Felix Fontein <felix@fontein.de>
2023-10-03 09:41:49 +02:00
Felix Fontein
38ec3f7a52 Handle unhandled errors.
Signed-off-by: Felix Fontein <felix@fontein.de>
2023-10-03 09:41:49 +02:00
Mitar
5f1ca1dd48 Fix descriptions of unencrypted-regex and encrypted-regex flags.
Signed-off-by: Mitar <mitar.git@tnode.com>
2023-09-22 11:48:36 +02:00
Felix Fontein
e422158e13 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>
2023-09-21 08:41:34 +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
Hidde Beydals
7b74dea9fc cmd/edit: switch from MD5 to SHA-256 for checksum
More 2023 alike :-)

This change is fully backwards compatible, as the checksum is only used
to make a comparison before and after the file has been opened by the
editor.

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-08-24 08:59:49 +02:00
Hidde Beydals
cef31343f3 cmd/edit: close temp file before invoking editor
This changes the logic of the edit target to close the temporary file
before it is opened by the user their editor. This works around an
issue on Windows where editors are unable to open the file because the
Go standard library opens file handles with only shared read and write
access (excluding deletion access, which is required by some).

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-08-24 08:59:43 +02:00
Hidde Beydals
faa0e29136 *: deal with various gRPC deprecations
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-08-23 13:42:49 +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
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
AJ Bahnken
9124783930 Merge pull request #1116 from felixfontein/update-keys-input-type
Support --input-type for updatekeys
2022-09-01 11:16:16 -07:00
Felix Fontein
566d51a25b Add --input-type option to updatekeys. 2022-08-27 15:52:29 +02:00
Felix Fontein
8f186bcb37 input-type and output-type description do not mention ini format. 2022-08-27 15:52:02 +02:00
Felix Fontein
148d46108b Do not check whether current version is latest when --disable-version-check is passed. 2022-08-27 15:33:41 +02:00
daurnimator
290ec3dca6 Update to urfave/cli to 1.22.7 2022-05-24 15:47:10 +10: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
8a2fbc0aa4 Initial patch for advisory 2021-04-05 11:35:38 -07:00
Christian Groschupp
49c2514d5c add filename to exec-file (#761)
* add filename to exec-file

* update README.rst

Co-authored-by: Christian Groschupp <christian.groschupp.ext@hermesworld.com>
2021-02-09 13:11:32 +01:00
Jimmy Cuadra
e8d00046e1 Add support for age. 2020-09-21 12:47:13 -07:00
AJ Bahnken
1927e18b52 Merge pull request #732 from mozilla/ajvb/gpg-key-fetching
Switch gpg.mozilla.org out for keys.openpgp.org
2020-09-02 13:06:11 -07:00
AJ Bahnken
8a09f056de Switch gpg.mozilla.org out for keys.openpgp.org 2020-09-02 11:45:01 -07:00
Rene Hernandez
8aca3cb790 Add support for --unencrypted-regex (#715)
* Add support for --unencrypted-regex

* Fix grammar mistake

* Add gofmt'd files
2020-09-02 19:15:50 +02:00
lbonanomi
f78682c6c0 Support --input-type for exec-file (#699)
* Update main.go

* Update main.go

* Update cmd/sops/main.go

Co-authored-by: Adrian Utrilla <adrianutrilla@gmail.com>

Co-authored-by: Adrian Utrilla <adrianutrilla@gmail.com>
2020-07-28 19:02:02 +02:00
Adrian Utrilla
5d32d9a3ee Revert "Add standard newline/quoting behavior to dotenv store (#622)" (#706)
This reverts commit 4507019a33.
2020-07-27 22:20:37 +02:00
lbonanomi
09d511f69f Close tmpfile after writing (#685)
* Close tmpfile after writing

Windows will not allow for deletion of a file with an open handle, 
close tmpfile after writing to prevent unencrypted tmpfiles out-living
the execution

* Update cmd/sops/edit.go

Co-authored-by: Adrian Utrilla <adrianutrilla@gmail.com>

* defer edited file close

Co-authored-by: Adrian Utrilla <adrianutrilla@gmail.com>
2020-07-14 21:25:59 +02:00
Magnus Hyllander
63b22a2f2a updatekeys: Make file path absolute
"sops updatekeys" is not working the same as when encrypting a file. The
reason is that for "sops --encrypt", the file path is made absolute before
it is compared with the path_regex in the config file. This is not done for
"sops updatekeys", therefore it does not match the correct entry in the
config file when updating keys.
2020-06-17 13:49:28 +02:00
TuhinNair
a7b6c5577f Fix #671: updatekeys checks for config file flag (#672)
* update 'updatekeys' subcommand to use config (if exists) from commandline

* Fix #671: `updatekeys` checks for config file flag

The 'updatekeys' subcommand did not check for the config flag
in the command line. Add that check and if found use it to set configPath.

* Fix #671: `updatekeys` checks for config file flag

The 'updatekeys' subcommand did not check for the config global string flag.
 Add that check and if found use it to set configPath.

* Fix #671: `updatekeys` checks for config file flag

The 'updatekeys' subcommand did not check for the config global string flag.
Add that check and if found use it to set configPath.

 Edit: Remove mistake file addition

* Update cmd/sops/main.go

Co-authored-by: Adrian Utrilla <adrianutrilla@gmail.com>
2020-05-08 21:25:23 +02:00
Martin Litvaj
99adfaed0b Rename LoadForFile to LoadCreationRuleForFile (#663) 2020-05-04 22:58:45 +02:00
Vaibhav Kaushik
e4abd871c7 Add HashiCorp Vault support (#655)
* feat: initial adding of vualt transit backend to sops
initial work on integration
feat(vault): added cli coomands working for vualt"

fix(vault): fixed config with correct tests

fix(vault): added vault to keygroup and to keyservice server

fixed metadata load

* feat(docs): added docs in README.md and in command help

fix(doc): fix rst formatting"

fix(doc): fix rst formatting

* fix(vault): addressed typos and fixes from autrilla

feat(cli): moved vault to hc-vault naming

* fix(test): typo while rebasing

* fix typos and imporve error messages for vault kms

* rename package from vault to hcvault

* refactor vault keysource url validation

* add negative test cases  for vault keysource

* add hc vault transit config option via objects
additional to URIs

* remove vault_example.yml

* streamline key name to snake case

* rename `BackendPath` to `EnginePath` for hc vault

* correction in hc-vault-transit commands

Signed-off-by: vnzongzna <github@vaibhavk.in>

* resolving conflict

Signed-off-by: vnzongzna <github@vaibhavk.in>

* Apply suggestions from code review

Co-Authored-By: Adrian Utrilla <adrianutrilla@gmail.com>

* allowing only hc_vault_transit_uri as input

Co-Authored-By: gitirabassi
Co-Authored-By: ldue
Signed-off-by: vnzongzna <github@vaibhavk.in>

Co-authored-by: gitirabassi <giacomo@tirabassi.eu>
Co-authored-by: ldue <larsduennwald@gmail.com>
Co-authored-by: Vaibhav Kaushik <vaibhavkaushik@vaibhavka-ltm1.internal.salesforce.com>
Co-authored-by: Adrian Utrilla <adrianutrilla@gmail.com>
2020-05-04 21:27:51 +02:00
Julien Vehent
273e4bff9d Update authors 2020-03-30 10:31:31 -04:00
Spencer Judd
4507019a33 Add standard newline/quoting behavior to dotenv store (#622)
Rationale
=========

The dotenv store as it exists right now performs splitting on newlines
to determine where a new key-value pair or comment begins. This works
remarkably well, up until you need to handle values that contain
newlines.

While I couldn't find an offical dotenv file format spec, I sampled a
number of open-source dotenv parsers and it seems that they typically
apply the following rules:

Comments:

* Comments may be written by starting a line with the `#` character.

Newline handling:

* If a value is unquoted or single-quoted and contains the character
  sequence `\n` (`0x5c6e`), it IS NOT decoded to a line feed (`0x0a`).

* If a value is double-quoted and contains the character sequence `\n`
  (`0x5c6e`), it IS decoded to a line feed (`0x0a`).

Whitespace trimming:

* For comments, the whitespace immediately after the `#` character and any
  trailing whitespace is trimmed.

* If a value is unquoted and contains any leading or trailing whitespace, it
  is trimmed.

* If a value is either single- or double-quoted and contains any leading or
  trailing whitespace, it is left untrimmed.

Quotation handling:

* If a value is surrounded by single- or double-quotes, the quotation marks
  are interpreted and not included in the value.

* Any number of single-quote characters may appear in a double-quoted
  value, or within a single-quoted value if they are escaped (i.e.,
  `'foo\'bar'`).

* Any number of double-quote characters may appear in a single-quoted
  value, or within a double-quoted value if they are escaped (i.e.,
  `"foo\"bar"`).

Because single- and double-quoted values may contain actual newlines,
we cannot split our input data on newlines as this may be in the middle
of a quoted value. This, along with the other rules around handling
quoted values, prompted me to try and implement a more robust parsing
solution. This commit is my first stab at that.

Special Considerations
======================

This is _not_ a backwards-compatible change:

* The `dotenv` files produced by this version of SOPS _cannot_ be read
  by an earlier version.

* The `dotenv` files produced by an earlier version of SOPS _can_ be
  read by this version, with the understanding that the semantics around
  quotations and newlines have changed.

Examples
========

The below examples show how double-quoted values are passed to the
running environment:

```console
$ echo 'FOO="foo\\nbar\\nbaz"' > plaintext.env
$ sops -e --output ciphertext.env plaintext.env
$ sops exec-env ciphertext.env 'env | grep FOO | xxd'
00000000: 464f 4f3d 666f 6f5c 6e62 6172 5c6e 6261  FOO=foo\nbar\nba
00000010: 7a0a                                     z.
```

```console
$ echo 'FOO="foo\nbar\nbaz"' > plaintext.env
$ sops -e --output ciphertext.env plaintext.env
$ sops exec-env ciphertext.env 'env | grep -A2 FOO | xxd'
00000000: 464f 4f3d 666f 6f0a 6261 720a 6261 7a0a  FOO=foo.bar.baz.
```
2020-03-20 22:47:14 +01:00
Alex Ostapenko
69ecd186ae fixes #626
now returning exit code with exec-env and exec-file
2020-02-10 22:04:27 +01:00
Mikhail Morev
0c26330546 Merge pull request #4 from mmorev/fix-relativepaths
Recursive publish - use relative paths
2020-01-14 15:38:17 +03:00
MOREV Mikhail
0c6558b7f2 Recursive publish - use relative paths 2020-01-14 15:36:26 +03:00
Mikhail Morev
3db9c71596 Update cmd/sops/main.go
Co-Authored-By: AJ Bahnken <1144310+ajvb@users.noreply.github.com>
2020-01-14 00:45:55 +03:00
MOREV Mikhail
3ccc7e4067 Fix destination path on single file publish 2020-01-13 15:00:33 +06:00
MOREV Mikhail
3ab2d41c2f fix filepath.Walk abuse; rename recursive flag; minor fixes 2020-01-10 09:57:36 +06:00
MOREV Mikhail
ef68940d2f Add -omit-extensions option for publish subcommand 2020-01-09 11:07:28 +06:00
MOREV Mikhail
8a216e9260 Add -recurse option for publish subcommand 2020-01-09 11:07:21 +06:00
AJ Bahnken
c19d2580c9 Merged master into develop 2019-11-21 12:34:36 -08:00
AJ Bahnken
6a1fe99d06 Run go fmt on project (#577) 2019-11-21 12:10:55 -08:00
AJ Bahnken
8e21de8dbc Upgrade sops to go 1.13 (#566) 2019-11-18 10:06:58 -08:00
Damien Nozay
4376ac973c add formats 2019-10-22 12:49:09 -07:00
Damien Nozay
559b27c01f mv formats around 2019-10-22 11:52:35 -07:00
Damien Nozay
a03712f086 use enum 2019-10-22 08:14:20 -07:00
Damien Nozay
a40c6a208f use map 2019-10-17 09:25:09 -07:00
Damien Nozay
dad8100da8 fix for #548 2019-10-16 11:48:43 -07:00
Omar
5663d276a5 exec-file and exec-env subcommands, take two (#532)
* first pass: add --exec flag

* fix spacing

* subcommand for exec as well as other bits n bobs

--placeholder to pass files to child procs (similar to `find(1)`'s -exec flag)
--background to background processes if you don't need them to be interactive

* break the 2 execs into 2 subcommands

* add a non-fifo option for people who like files instead

* added a setuid flag just in case

* oups, used the wrong functions

* Update README.rst

* typo

* first attempt at separating out windows/unix functionality

* add the caveat about windows

* windows: make sure --no-fifo is being used and warn when it's not

* stray fixes

* switch to logrus, break out the command builder, and remove /tmp/ default
2019-09-24 12:48:31 -07:00