-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exfiltration of EBS snapshots and AMIs: Handle error when EBS encrypt…
…ion by default is enabled (closes #109)
- Loading branch information
1 parent
44c83db
commit 2855978
Showing
4 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,20 @@ | ||
package utils | ||
|
||
import ( | ||
"errors" | ||
"github.com/aws/aws-sdk-go-v2/service/cloudtrail/types" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestIsErrorRelatedToEbsEncryptionByDefault(t *testing.T) { | ||
assert.False(t, IsErrorDueToEBSEncryptionByDefault(nil)) | ||
assert.False(t, IsErrorDueToEBSEncryptionByDefault(errors.New("foo"))) | ||
assert.False(t, IsErrorDueToEBSEncryptionByDefault(&types.OperationNotPermittedException{})) | ||
assert.True(t, IsErrorDueToEBSEncryptionByDefault( | ||
errors.New("operation error EC2: ModifySnapshotAttribute, https response error StatusCode: 400, RequestID: 12f44aeb-7b3b-4488-ac46-a432d20cc7a9, api error OperationNotPermitted: Encrypted snapshots with EBS default key cannot be shared"), | ||
)) | ||
assert.True(t, IsErrorDueToEBSEncryptionByDefault( | ||
errors.New("operation error EC2: ModifyImageAttribute, https response error StatusCode: 400, RequestID: 85f85eff-4114-4861-a659-f9aeea48d78b, api error InvalidParameter: Snapshots encrypted with the AWS Managed CMK can't be shared. Specify another snapshot"), | ||
)) | ||
} |