-
Notifications
You must be signed in to change notification settings - Fork 34
🐛 aws-secret-manager-edgecases-enhancement #6534
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
Open
LittleSalkin1806
wants to merge
8
commits into
mondoohq:main
Choose a base branch
from
LittleSalkin1806:edgecase-enhancement-aws-secrets-manager
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+187
−5
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
87863cd
handle edge case for where returned arn is a UUID for KMSKeyID
LittleSalkin1806 7a94a90
change back to key not found instead of partial return
LittleSalkin1806 0e709bb
🐛 Address review comments on KMS key normalization
vjeffrey 8353031
🐛 Return ARN for cross-account KMS keys instead of null
vjeffrey 46419b6
🐛 Skip API calls for cross-account KMS keys
vjeffrey 866aaab
🐛 Address review comments on cross-account KMS key handling
vjeffrey 5151f51
🐛 Add cross-account guards to new KMS key methods
vjeffrey 8a70241
🐛 Address review: use uuid.Parse and share getKeyMetadata cache
vjeffrey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| // Copyright (c) Mondoo, Inc. | ||
| // SPDX-License-Identifier: BUSL-1.1 | ||
|
|
||
| package resources | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestNormalizeKmsKeyRef(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| input string | ||
| region string | ||
| accountId string | ||
| wantARN string | ||
| wantErr string | ||
| }{ | ||
| { | ||
| name: "full ARN is returned as-is", | ||
| input: "arn:aws:kms:us-east-1:123456789012:key/7a4eb143-c07b-4e24-b0b7-f3abfdbbb2c2", | ||
| region: "us-west-2", | ||
| accountId: "999999999999", | ||
| wantARN: "arn:aws:kms:us-east-1:123456789012:key/7a4eb143-c07b-4e24-b0b7-f3abfdbbb2c2", | ||
| }, | ||
| { | ||
| name: "bare UUID is normalized to ARN", | ||
| input: "7a4eb143-c07b-4e24-b0b7-f3abfdbbb2c2", | ||
| region: "us-east-1", | ||
| accountId: "123456789012", | ||
| wantARN: "arn:aws:kms:us-east-1:123456789012:key/7a4eb143-c07b-4e24-b0b7-f3abfdbbb2c2", | ||
| }, | ||
| { | ||
| name: "bare UUID with empty region returns error", | ||
| input: "7a4eb143-c07b-4e24-b0b7-f3abfdbbb2c2", | ||
| region: "", | ||
| accountId: "123456789012", | ||
| wantErr: "cannot normalize KMS key UUID", | ||
| }, | ||
| { | ||
| name: "invalid input returns error", | ||
| input: "not-a-valid-key-ref", | ||
| region: "us-east-1", | ||
| accountId: "123456789012", | ||
| wantErr: "invalid KMS key reference", | ||
| }, | ||
| { | ||
| name: "alias ARN is returned as-is", | ||
| input: "arn:aws:kms:us-east-1:123456789012:alias/my-key", | ||
| region: "us-east-1", | ||
| accountId: "123456789012", | ||
| wantARN: "arn:aws:kms:us-east-1:123456789012:alias/my-key", | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| got, err := NormalizeKmsKeyRef(tt.input, tt.region, tt.accountId) | ||
| if tt.wantErr != "" { | ||
| require.Error(t, err) | ||
| assert.Contains(t, err.Error(), tt.wantErr) | ||
| return | ||
| } | ||
| require.NoError(t, err) | ||
| assert.Equal(t, tt.wantARN, got.String()) | ||
| }) | ||
| } | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.