Repository navigation
Conversation
Signed-off-by: Ethan Aldrich <ethan@ethanaldrich.net>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #439
--aws-profilewas only used when building master keys from--kms(and forgroups add). Anything that works from an existing file (decrypt, edit, rotate, set, unset, exec-env, exec-file, publish, updatekeys, groups add/delete) loaded the keys from the file's metadata and used the storedaws_profile, so the flag had no effect there.Now, when
--aws-profileis given, it replaces the AWS profile of every AWS KMS key in the file for that invocation, including keys that have different per-key profiles stored. The override is in memory only and is never written to a file:kms.MasterKeygets a non-serializedAwsProfileOverridefield that takes precedence overAwsProfilewhen creating the AWS config and when sending the key to a key service.ToMap,ToStringand the stores are untouched, so the storedaws_profilevalues,rotate --rm-kmsmatching and theupdatekeysdiff are unchanged. Profile names that only make sense in one environment (for example a CI profile) therefore do not end up in the file. With a remote key service, the profile name is resolved on the key service host.The only place the flag is persisted is when new keys are created from it, as before:
--kmstogether with--aws-profile, and now also keys taken from a.sops.yamlcreation rule when encrypting a new file. There the flag overrides the rule'saws_profile.Changes:
common.SetAWSProfilesets the override on all KMS keys of a set of key groups, and does nothing for an empty profile. It is called everywhere keys are loaded from a file:LoadEncryptedFileWithBugFixes(decrypt, edit, rotate, set, unset, exec-env, exec-file, also after the encryption context fix reloads the tree), theedit --show-master-keyseditor loop (which re-parses the keys from the edited text), publish, updatekeys and groups add/delete. In updatekeys it is also applied to the creation-rule groups, so that newly added rule keys are encrypted with the flag's profile; the file still gets the rule'saws_profile, not the flag's.common.PersistAWSProfileis used for creation rules when encrypting.--aws-profileis added to rotate, decrypt, set, unset, exec-env, exec-file, publish, updatekeys and groups delete, and the help text everywhere now says it overrides anyaws_profilestored in the file or.sops.yaml.SetAWSProfile(empty profile, non-KMS keys), and the override being preferred byEffectiveAwsProfileand the key service conversion.This builds on #1659. Thanks to @martelli for the original work and to @felixfontein for the review. The review points are handled as follows:
AWS_PROFILEis not read. Only the explicit flag overrides the stored value, so users who haveAWS_PROFILEset in their environment see no change.cmd/sops/main.goand passed down through the opts structs.decryptOptscreations.Behavior change:
--aws-profilenow also applies when decrypting and when otherwise using the keys stored in a file. Previously it was ignored there.