-
Notifications
You must be signed in to change notification settings - Fork 1k
feat(azkv): Skipping key-version will get latest key #1919
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(azkv): Skipping key-version will get latest key #1919
Conversation
|
Not sure whether I understand this correctly, but isn't always using the latest version not a bad idea? If you encrypt a file with a specific key, and then later try to decrypt after the key has been rotated, with your change SOPS would try to use the latest key to decrypt, wouldn't that not work, because it needs the previous one? So I guess it would be OK if |
Thanks for having a look @felixfontein! Sorry — I should have been clearer. Most of the lines of code added here are actually to correctly identify the version of the key and store that in the metadata in the yaml of the file. It is entirely possible that my limited understanding of sops means I've broken other use-cases though. |
|
Ah, that's good to hear! I think that makes sense. One thing I'm worrying about is that retrieving the version might be done too often, i.e. not only when it's actually needed. Did you try adding debug statements which log retrieval and check what happens during various kind of operations (encrypt, decrypt, edit, update keys, ...)? Also did you test whether |
felixfontein
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, you need to sign-off your commits (to accept the DCO), otherwise we cannot merge this. (On the command line, you can do git commit --sign-off --amend to modify the commit, and then force-push.)
I did not, no! That is a very fair question. "When it's actually needed" here being when we are encrypting/decrypting and the version cannot be sourced from anywhere else? I.e it's not in the url, it's not in the metadata somewhere?
That is also something I did not test, no — a big oversight on my part. I'll do that I did this PR as a side-effect of a rush to get something done at work; I will aim to do this testing this week. After that I will be changing jobs and won't have the pleasure of dealing with Azure any more, thus losing access to my testing environment. I'll redo the commits with sign-off then. Thank you! |
It should only query the version when encrypting a new file (not when editing), or when running updatekey (and then it should replace older versions by the latest version). If it queries the latest version more than once in these cases, that would be OK I guess (at least for now), but if it also queries the version in other situations (like when decrypting) this would be bad. (The encrypted file should always contain AZKV URLs with specific versions, namely the version which can be used to decrypt the key.)
Thanks! As I wrote above, the expected behavior would be that it replaces the old version with the latest version of the AZKV URL. (I think this should 'just work' with your PR, but without testing it... who knows :) )
That would be great!
Hehe, sounds good :) I'm lucky that I don't have to use Azure except for AZP in another open source project (and honestly I find the UI/UX there so bad that I'm really wondering why anyone pays money to use that).
Thank you for your contribution! |
e169faf to
5051bdf
Compare
This is a supported behaviour for Azure Key Vault, and is very helpful when it comes to doing rotation of those keys, as updated versions will automatically get fetched by sops for new files with no changes to the config in the repo. This brings AZKV in line with sops' AWS/GCP integrations, which do not require you to specify a key version. Thank you to @felixfontein for some RST syntax help. Co-authored-by: Felix Fontein <[email protected]> Signed-off-by: Drum Ogilvie <[email protected]>
5051bdf to
eb23541
Compare
|
Ok, I've manually tested the behaviours @felixfontein asked for, and it all looks good. |
|
@felixfontein if you need someone to keep testing stuff on Azure with regards to this PR - just @ me. I work[ed] with @daogilvie and I still have the misfortune of having access to Azure |
felixfontein
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the config being loaded multiple times: I'm trying to fix that in #1939.
Besides the comment, I think this looks good!
Co-authored-by: Felix Fontein <[email protected]> Signed-off-by: Drum Ogilvie <[email protected]>
|
@daogilvie thanks for your contribution! |
|
@felixfontein when is the next release planned to include this feature? |
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [getsops/sops](https://github.com/getsops/sops) | minor | `v3.10.2` -> `v3.11.0` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>getsops/sops (getsops/sops)</summary> ### [`v3.11.0`](https://github.com/getsops/sops/releases/tag/v3.11.0) [Compare Source](getsops/sops@v3.10.2...v3.11.0) #### Installation To install `sops`, download one of the pre-built binaries provided for your platform from the artifacts attached to this release. For instance, if you are using Linux on an AMD64 architecture: ```shell ### Download the binary curl -LO https://github.com/getsops/sops/releases/download/v3.11.0/sops-v3.11.0.linux.amd64 ### Move the binary in to your PATH mv sops-v3.11.0.linux.amd64 /usr/local/bin/sops ### Make the binary executable chmod +x /usr/local/bin/sops ``` ##### Verify checksums file signature The checksums file provided within the artifacts attached to this release is signed using [Cosign](https://docs.sigstore.dev/cosign/overview/) with GitHub OIDC. To validate the signature of this file, run the following commands: ```shell ### Download the checksums file, certificate and signature curl -LO https://github.com/getsops/sops/releases/download/v3.11.0/sops-v3.11.0.checksums.txt curl -LO https://github.com/getsops/sops/releases/download/v3.11.0/sops-v3.11.0.checksums.pem curl -LO https://github.com/getsops/sops/releases/download/v3.11.0/sops-v3.11.0.checksums.sig ### Verify the checksums file cosign verify-blob sops-v3.11.0.checksums.txt \ --certificate sops-v3.11.0.checksums.pem \ --signature sops-v3.11.0.checksums.sig \ --certificate-identity-regexp=https://github.com/getsops \ --certificate-oidc-issuer=https://token.actions.githubusercontent.com ``` ##### Verify binary integrity To verify the integrity of the downloaded binary, you can utilize the checksums file after having validated its signature: ```shell ### Verify the binary using the checksums file sha256sum -c sops-v3.11.0.checksums.txt --ignore-missing ``` ##### Verify artifact provenance The [SLSA provenance](https://slsa.dev/provenance/v0.2) of the binaries, packages, and SBOMs can be found within the artifacts associated with this release. It is presented through an [in-toto](https://in-toto.io/) link metadata file named `sops-v3.11.0.intoto.jsonl`. To verify the provenance of an artifact, you can utilize the [`slsa-verifier`](https://github.com/slsa-framework/slsa-verifier#artifacts) tool: ```shell ### Download the metadata file curl -LO https://github.com/getsops/sops/releases/download/v3.11.0/sops-v3.11.0.intoto.jsonl ### Verify the provenance of the artifact slsa-verifier verify-artifact <artifact> \ --provenance-path sops-v3.11.0.intoto.jsonl \ --source-uri github.com/getsops/sops \ --source-tag v3.11.0 ``` #### Container Images The `sops` binaries are also available as container images, based on Debian (slim) and Alpine Linux. The Debian-based container images include any dependencies which may be required to make use of certain key services, such as GnuPG, AWS KMS, Azure Key Vault, and Google Cloud KMS. The Alpine-based container images are smaller in size, but do not include these dependencies. These container images are available for the following architectures: `linux/amd64` and `linux/arm64`. ##### GitHub Container Registry - `ghcr.io/getsops/sops:v3.11.0` - `ghcr.io/getsops/sops:v3.11.0-alpine` ##### Quay.io - `quay.io/getsops/sops:v3.11.0` - `quay.io/getsops/sops:v3.11.0-alpine` ##### Verify container image signature The container images are signed using [Cosign](https://docs.sigstore.dev/cosign/overview/) with GitHub OIDC. To validate the signature of an image, run the following command: ```shell cosign verify ghcr.io/getsops/sops:v3.11.0 \ --certificate-identity-regexp=https://github.com/getsops \ --certificate-oidc-issuer=https://token.actions.githubusercontent.com \ -o text ``` ##### Verify container image provenance The container images include [SLSA provenance](https://slsa.dev/provenance/v0.2) attestations. For more information around the verification of this, please refer to the [`slsa-verifier` documentation](https://github.com/slsa-framework/slsa-verifier#containers). #### Software Bill of Materials The Software Bill of Materials (SBOM) for each binary is accessible within the artifacts enclosed with this release. It is presented as an [SPDX](https://spdx.dev/) JSON file, formatted as `<binary>.spdx.sbom.json`. #### What's Changed - build(deps): Bump the go group with 4 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1845](getsops/sops#1845) - build(deps): Bump the go group with 5 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1850](getsops/sops#1850) - build(deps): Bump the ci group with 4 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1849](getsops/sops#1849) - build(deps): Bump the go group with 8 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1854](getsops/sops#1854) - build(deps): Bump tempfile from 3.19.1 to 3.20.0 in /functional-tests in the rust group by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1853](getsops/sops#1853) - build(deps): Bump actions/setup-go from 5.4.0 to 5.5.0 in the ci group by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1852](getsops/sops#1852) - use bullet points for structure by [@​md42](https://github.com/md42) in [#​1844](getsops/sops#1844) - Introduce EncryptContext and DecryptContext for AWS, Azure, GCP, PGP and HashiCorp Vault by [@​matheuscscp](https://github.com/matheuscscp) in [#​1848](getsops/sops#1848) - build(deps): Bump the go group with 5 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1856](getsops/sops#1856) - build(deps): Bump the ci group with 2 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1857](getsops/sops#1857) - Allow injecting custom HTTP client for AWS, Azure, GCP and HashiCorp Vault by [@​matheuscscp](https://github.com/matheuscscp) in [#​1838](getsops/sops#1838) - Update authors in main.go by [@​jvehent](https://github.com/jvehent) in [#​1860](getsops/sops#1860) - build(deps): Bump the go group with 7 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1861](getsops/sops#1861) - Remove unmatched '\`' from README.rst by [@​wasv](https://github.com/wasv) in [#​1863](getsops/sops#1863) - build(deps): Bump the go group with 4 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1867](getsops/sops#1867) - build(deps): Bump alpine from 3.21 to 3.22 in /.release in the docker group by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1866](getsops/sops#1866) - build(deps): Bump the go group with 12 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1870](getsops/sops#1870) - build(deps): Bump github/codeql-action from 3.28.18 to 3.28.19 in the ci group by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1869](getsops/sops#1869) - build(deps): Bump github.com/cloudflare/circl from 1.6.0 to 1.6.1 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1871](getsops/sops#1871) - build(deps): Bump the go group with 12 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1872](getsops/sops#1872) - build(deps): Bump the ci group across 1 directory with 3 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1874](getsops/sops#1874) - build(deps): Bump the go group with 8 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1878](getsops/sops#1878) - build(deps): Bump the ci group with 2 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1879](getsops/sops#1879) - build(deps): Bump github.com/go-viper/mapstructure/v2 from 2.2.1 to 2.3.0 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1882](getsops/sops#1882) - Fix Typo in README.rst by [@​inverted-tree](https://github.com/inverted-tree) in [#​1881](getsops/sops#1881) - build(deps): Bump the go group with 4 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1884](getsops/sops#1884) - build(deps): Bump the ci group with 2 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1883](getsops/sops#1883) - Correct Windows path to store keys.txt by [@​EshemMimi](https://github.com/EshemMimi) in [#​1885](getsops/sops#1885) - build(deps): Bump the go group with 3 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1888](getsops/sops#1888) - build(deps): Bump the ci group with 2 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1889](getsops/sops#1889) - build(deps): Bump the go group with 6 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1893](getsops/sops#1893) - Add "--value-file" option to "sops set \[...]" by [@​bjornfor](https://github.com/bjornfor) in [#​1876](getsops/sops#1876) - Document XDG\_CONFIG\_HOME support on mac by [@​fredericrous](https://github.com/fredericrous) in [#​1897](getsops/sops#1897) - Fix Shamir threshold encoding for INI and ENV files by [@​felixfontein](https://github.com/felixfontein) in [#​1899](getsops/sops#1899) - build(deps): Bump the go group with 12 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1908](getsops/sops#1908) - build(deps): Bump serde\_json from 1.0.140 to 1.0.142 in /functional-tests in the rust group by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1907](getsops/sops#1907) - build(deps): Bump the ci group with 3 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1905](getsops/sops#1905) - Fix docs: mention all stores instead of just YAML, JSON, and BINARY by [@​felixfontein](https://github.com/felixfontein) in [#​1895](getsops/sops#1895) - Ensure temporary file for editing is only read-writable by owner by [@​felixfontein](https://github.com/felixfontein) in [#​1903](getsops/sops#1903) - Add `--value-stdin` option to `sops set` by [@​felixfontein](https://github.com/felixfontein) in [#​1894](getsops/sops#1894) - Collect age identity loading errors and only report if decryption failed by [@​felixfontein](https://github.com/felixfontein) in [#​1898](getsops/sops#1898) - add completion script. Resolves [#​1868](getsops/sops#1868) by [@​longxiucai](https://github.com/longxiucai) in [#​1892](getsops/sops#1892) - Resolves [#​1864](getsops/sops#1864). Adds Native List as an option for configuring keys. by [@​lucqui](https://github.com/lucqui) in [#​1880](getsops/sops#1880) - Fix example.yaml file by [@​felixfontein](https://github.com/felixfontein) in [#​1909](getsops/sops#1909) - build(deps): Bump the go group with 15 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1912](getsops/sops#1912) - build(deps): Bump the ci group with 4 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1911](getsops/sops#1911) - build(deps): Bump the go group with 9 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1917](getsops/sops#1917) - build(deps): Bump the ci group with 4 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1916](getsops/sops#1916) - build(deps): Bump github.com/go-viper/mapstructure/v2 from 2.3.0 to 2.4.0 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1920](getsops/sops#1920) - build(deps): Bump the go group with 14 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1923](getsops/sops#1923) - build(deps): Bump the rust group in /functional-tests with 2 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1921](getsops/sops#1921) - build(deps): Bump github/codeql-action from 3.29.9 to 3.29.11 in the ci group by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1922](getsops/sops#1922) - Docs: remove paragraph on GPG/PGP keyservers by [@​felixfontein](https://github.com/felixfontein) in [#​1928](getsops/sops#1928) - Allow to configure --enable-local-keyservice and --keyservice through env variables by [@​felixfontein](https://github.com/felixfontein) in [#​1930](getsops/sops#1930) - build(deps): Bump the ci group with 2 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1937](getsops/sops#1937) - fix: correct destination validation logic to detect all conflicts by [@​bruce-szalwinski-he](https://github.com/bruce-szalwinski-he) in [#​1936](getsops/sops#1936) - Switch from deprecated gopkg.in/yaml.v3 to go.yaml.in/yaml/v3 by [@​sylr](https://github.com/sylr) in [#​1934](getsops/sops#1934) - INI: fix converting integers to strings; improve float and time.Time formatting by [@​felixfontein](https://github.com/felixfontein) in [#​1929](getsops/sops#1929) - feat(azkv): Skipping key-version will get latest key by [@​daogilvie](https://github.com/daogilvie) in [#​1919](getsops/sops#1919) - Fix keyservice client for unix domain sockets by [@​matheuscscp](https://github.com/matheuscscp) in [#​1910](getsops/sops#1910) - README: fix argument order by [@​felixfontein](https://github.com/felixfontein) in [#​1940](getsops/sops#1940) - Allow non-complex non-string values in dotenv and exec-env by [@​billy4479](https://github.com/billy4479) in [#​1933](getsops/sops#1933) - Fix mention of macOS XDG\_CONFIG\_HOME fallback by [@​felixfontein](https://github.com/felixfontein) in [#​1944](getsops/sops#1944) - Improve age identity loading by [@​felixfontein](https://github.com/felixfontein) in [#​1931](getsops/sops#1931) - build(deps): Bump the rust group in /functional-tests with 4 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1948](getsops/sops#1948) - build(deps): Bump the ci group with 2 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1949](getsops/sops#1949) - build(deps): Bump the rust group in /functional-tests with 2 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1954](getsops/sops#1954) - build(deps): Bump anchore/sbom-action from 0.20.5 to 0.20.6 in the ci group by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1955](getsops/sops#1955) - Start documenting the configuration file format by [@​felixfontein](https://github.com/felixfontein) in [#​1946](getsops/sops#1946) - CI: Build with Go 1.24 and 1.25, release with 1.25 by [@​felixfontein](https://github.com/felixfontein) in [#​1945](getsops/sops#1945) - build(deps): Bump the go group across 1 directory with 21 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1956](getsops/sops#1956) - When encrypting, load the config only once by [@​felixfontein](https://github.com/felixfontein) in [#​1939](getsops/sops#1939) - build(deps): Bump the go group across 1 directory with 10 updates by [@​dependabot](https://github.com/dependabot)\[bot] in [#​1958](getsops/sops#1958) - Ignore encryption selection options for binary store (and warn when they are used) by [@​felixfontein](https://github.com/felixfontein) in [#​1927](getsops/sops#1927) - AZKV: Also allow to omit version for AZKV keys specified in key groups by [@​felixfontein](https://github.com/felixfontein) in [#​1947](getsops/sops#1947) - Complex values in dotenv, and exec-env: do not print sensitive value in error message by [@​felixfontein](https://github.com/felixfontein) in [#​1959](getsops/sops#1959) - Release 3.11.0 by [@​felixfontein](https://github.com/felixfontein) in [#​1960](getsops/sops#1960) #### New Contributors - [@​md42](https://github.com/md42) made their first contribution in [#​1844](getsops/sops#1844) - [@​wasv](https://github.com/wasv) made their first contribution in [#​1863](getsops/sops#1863) - [@​inverted-tree](https://github.com/inverted-tree) made their first contribution in [#​1881](getsops/sops#1881) - [@​EshemMimi](https://github.com/EshemMimi) made their first contribution in [#​1885](getsops/sops#1885) - [@​bjornfor](https://github.com/bjornfor) made their first contribution in [#​1876](getsops/sops#1876) - [@​fredericrous](https://github.com/fredericrous) made their first contribution in [#​1897](getsops/sops#1897) - [@​longxiucai](https://github.com/longxiucai) made their first contribution in [#​1892](getsops/sops#1892) - [@​lucqui](https://github.com/lucqui) made their first contribution in [#​1880](getsops/sops#1880) - [@​bruce-szalwinski-he](https://github.com/bruce-szalwinski-he) made their first contribution in [#​1936](getsops/sops#1936) - [@​sylr](https://github.com/sylr) made their first contribution in [#​1934](getsops/sops#1934) - [@​daogilvie](https://github.com/daogilvie) made their first contribution in [#​1919](getsops/sops#1919) - [@​billy4479](https://github.com/billy4479) made their first contribution in [#​1933](getsops/sops#1933) **Full Changelog**: <getsops/sops@v3.10.2...v3.11.0> </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xMzEuMiIsInVwZGF0ZWRJblZlciI6IjQxLjEzMS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
Firstly: thanks for maintaining such a great tool! It's made my life a lot easier.
Hopefully this PR is helpful in some way; I checked open/closed issues and PRs for something similar being rejected, and couldn't see it.
Anyway, what's the change? I've edited the AZKV implementation to support not including a version in the URL. I.e this makes
https://${VAULT_URL}/keys/${KEY_NAME}/a valid AZKV URL.This is a supported behaviour for Azure Key Vault, and is very helpful when it comes to doing rotation of those keys. Updated versions will automatically get fetched by sops for new files with no changes to the config in the repo. This brings AZKV in line with sops' AWS/GCP integrations, which do not require you to specify a key version.
EDIT adding clarification after @felixfontein's comment:
If you don't specify a version in the URL, then sops will use the azkey client (already bundled, of course), to retrieve the specific version of the key, and puts that into the struct instead. I.e even with no version supplied, the NewMasterKeyFromURL function always returns a version, so any files edited/encrypted will still have the specific version stored in the metadata.
Note
I am not sure how to test this in the automated test suites, as I can't see any comparable test in azkv/keysource_test.go that would mock or otherwise inject the az client.
I am more than happy to be told this is not something sops should even support, or that I need to redo some or all of the work.
I don't really use golang much day-to-day, so I may be completely missing out on some sensible approach or pattern.
Fixes #1924
Manual Tests
When no version set in URL, SOPS...
updatekeys✅When a version is provided in the URL, SOPS...