-
Notifications
You must be signed in to change notification settings - Fork 899
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
Fix ToString for AWS KMS to include role, context, and profile #1733
Conversation
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.
Hey Felix,
first of all, thank you for creating this fix. Sorry that I broke stuff for others with my change.
The PR looks good to me.
I still am no AWS guy, so my comments on it can not cover the behavior of the code after your changes. I cannot judge if it is working correctly afterwards, but I understood the #1580 (comment) to match what you implemented now.
🚀
@@ -538,9 +553,10 @@ func TestKeyGroupsForFileWithGroups(t *testing.T) { | |||
conf, err := parseCreationRuleForFile(parseConfigFile(sampleConfigWithGroups, t), "/conf/path", "whatever", nil) | |||
assert.Nil(t, err) | |||
assert.Equal(t, "bar", conf.KeyGroups[0][0].ToString()) | |||
assert.Equal(t, "foo", conf.KeyGroups[0][1].ToString()) | |||
assert.Equal(t, "foo||bar", conf.KeyGroups[0][1].ToString()) | |||
assert.Equal(t, "foo|baz:bam", conf.KeyGroups[0][2].ToString()) |
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.
I think there should be a test-case where both context and profile are set?
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.
I've added some more tests.
kms/keysource.go
Outdated
if key.AwsProfile != "" { | ||
return fmt.Sprintf("%s|%s|%s", arnRole, context, key.AwsProfile) | ||
} | ||
if len(key.EncryptionContext) > 0 { |
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.
if len(key.EncryptionContext) > 0 { | |
if context != "" { |
Just a thought, that the kmsContextToString
could return something even if the length of the EncryptionContext
is zero. It doesn’t right now, but maybe in the future?
Checking if the string is empty is also more consistent with the other if statements.
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.
I don't think kmsContextToString()
should ever return anything than the empty string for an empty EncryptionContext
.
Signed-off-by: Felix Fontein <[email protected]>
Signed-off-by: Felix Fontein <[email protected]>
7c15dcc
to
89fd098
Compare
This fixes my use case, thanks! /cc @iblackman |
@jonasbadstuebner @hiddeco thanks a lot for reviewing this! |
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [getsops/sops](https://github.com/getsops/sops) | patch | `v3.9.3` -> `v3.9.4` | 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.9.4`](https://github.com/getsops/sops/releases/tag/v3.9.4) [Compare Source](getsops/sops@v3.9.3...v3.9.4) #### 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.9.4/sops-v3.9.4.linux.amd64 ### Move the binary in to your PATH mv sops-v3.9.4.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.9.4/sops-v3.9.4.checksums.txt curl -LO https://github.com/getsops/sops/releases/download/v3.9.4/sops-v3.9.4.checksums.pem curl -LO https://github.com/getsops/sops/releases/download/v3.9.4/sops-v3.9.4.checksums.sig ### Verify the checksums file cosign verify-blob sops-v3.9.4.checksums.txt \ --certificate sops-v3.9.4.checksums.pem \ --signature sops-v3.9.4.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.9.4.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.9.4.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.9.4/sops-v3.9.4.intoto.jsonl ### Verify the provenance of the artifact slsa-verifier verify-artifact <artifact> \ --provenance-path sops-v3.9.4.intoto.jsonl \ --source-uri github.com/getsops/sops \ --source-tag v3.9.4 ``` #### 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.9.4` - `ghcr.io/getsops/sops:v3.9.4-alpine` ##### Quay.io - `quay.io/getsops/sops:v3.9.4` - `quay.io/getsops/sops:v3.9.4-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.9.4 \ --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 5 updates by [@​dependabot](https://github.com/dependabot) in getsops/sops#1727 - build(deps): Bump tempfile from 3.14.0 to 3.15.0 in /functional-tests in the rust group by [@​dependabot](https://github.com/dependabot) in getsops/sops#1728 - build(deps): Bump the go group with 16 updates by [@​dependabot](https://github.com/dependabot) in getsops/sops#1732 - build(deps): Bump the ci group with 3 updates by [@​dependabot](https://github.com/dependabot) in getsops/sops#1730 - build(deps): Bump serde_json from 1.0.134 to 1.0.135 in /functional-tests in the rust group by [@​dependabot](https://github.com/dependabot) in getsops/sops#1731 - build(deps): Bump the go group with 12 updates by [@​dependabot](https://github.com/dependabot) in getsops/sops#1734 - build(deps): Bump serde_json from 1.0.135 to 1.0.137 in /functional-tests in the rust group by [@​dependabot](https://github.com/dependabot) in getsops/sops#1735 - Fix ToString for AWS KMS to include role, context, and profile by [@​felixfontein](https://github.com/felixfontein) in getsops/sops#1733 - build(deps): Bump the ci group with 3 updates by [@​dependabot](https://github.com/dependabot) in getsops/sops#1738 - build(deps): Bump the go group with 6 updates by [@​dependabot](https://github.com/dependabot) in getsops/sops#1739 - Release 3.9.4 by [@​felixfontein](https://github.com/felixfontein) in getsops/sops#1740 **Full Changelog**: getsops/sops@v3.9.3...v3.9.4 </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:eyJjcmVhdGVkSW5WZXIiOiIzOS4xMjYuMSIsInVwZGF0ZWRJblZlciI6IjM5LjEyNi4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
Follow-up for #1493, in particular #1493 (comment). Turns out the other fields were important as well.
This not only applies to #1493, but also other operations where
kms.ToString
is used, for example therotate
subcommand, theupdatekeys
subcommand, and thepublish
subcommand (the two latter useDiffKeyGroups
, which relies onToString
to identify a full key).Fixes #1580.