Skip to content

Commit cf90d4d

Browse files
authored
DEV-3006 (#17)
* Adding a use case for EBS * Adding VPC SG tests * Adding an s3 unencrypted example
1 parent 82b9763 commit cf90d4d

File tree

23 files changed

+1107
-6
lines changed

23 files changed

+1107
-6
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# EC2 EBS Volume Encryption
2+
3+
This shows various states of EBS. All should be encrypted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
AWSTemplateFormatVersion: 2010-09-09
3+
4+
Transform: AWS::Serverless-2016-10-31
5+
6+
Resources:
7+
Linux:
8+
Type: AWS::EC2::Instance
9+
Properties:
10+
BlockDeviceMappings:
11+
- DeviceName: /dev/xvda
12+
Ebs:
13+
VolumeSize: 20
14+
Encrypted: true
15+
- DeviceName: /dev/xvdb
16+
Ebs:
17+
Encrypted: true
18+
VolumeSize: 20
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
AWSTemplateFormatVersion: 2010-09-09
3+
4+
Transform: AWS::Serverless-2016-10-31
5+
6+
Resources:
7+
Linux:
8+
Type: AWS::EC2::Instance
9+
Properties:
10+
BlockDeviceMappings:
11+
- DeviceName: /dev/xvda
12+
Ebs:
13+
VolumeSize: 20
14+
Encrypted: false
15+
- DeviceName: /dev/xvdb
16+
Ebs:
17+
VolumeSize: 20

aws/cloudformation/abstract/enable-vpc-flow-logs/README.md

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# S3 Unencrypted
2+
3+
This shows the three states of S3 buckets. One is unencrypted. One is encrypted using Customer Managed Keys (CMK). And one is encrypted using Provider Managed Keys (PMK).
4+
5+
As long as encryption is provided one is not better then the other, so there are two expectations. If the CMK is known then the unencrypted bucket should be encrypted using it (example `expected-cmk`). Otherwise it should be encrypted using PMK (example `expected-pmk`). In either case the currently encrypted buckets shouldn't be touched.
6+
7+
You should only test against one of the two expectations.
8+
9+
## Unguessable info
10+
11+
The expectation assumes the following:
12+
13+
1. CMK: `arn:aws:kms:us-east-1:111122223333:alias/my-s3-bucket-key`
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
AWSTemplateFormatVersion: 2010-09-09
3+
4+
Transform: AWS::Serverless-2016-10-31
5+
6+
Resources:
7+
S3BucketUnencrypted:
8+
Type: AWS::S3::Bucket
9+
Properties:
10+
PublicAccessBlockConfiguration:
11+
# flip these to true
12+
BlockPublicAcls: false
13+
BlockPublicPolicy: false
14+
IgnorePublicAcls: false
15+
RestrictPublicBuckets: false
16+
BucketEncryption:
17+
ServerSideEncryptionConfiguration:
18+
- ServerSideEncryptionByDefault:
19+
SSEAlgorithm: "aws:kms"
20+
KMSMasterKeyID: "arn:aws:kms:us-east-1:111122223333:alias/my-s3-bucket-key"
21+
22+
S3BucketEncryptedWithPMK:
23+
Type: AWS::S3::Bucket
24+
Properties:
25+
PublicAccessBlockConfiguration:
26+
# flip these to true
27+
BlockPublicAcls: false
28+
BlockPublicPolicy: false
29+
IgnorePublicAcls: false
30+
RestrictPublicBuckets: false
31+
BucketEncryption:
32+
ServerSideEncryptionConfiguration:
33+
- ServerSideEncryptionByDefault:
34+
SSEAlgorithm: AES256
35+
36+
S3BucketEncryptedWithCMK:
37+
Type: AWS::S3::Bucket
38+
Properties:
39+
PublicAccessBlockConfiguration:
40+
# flip these to true
41+
BlockPublicAcls: false
42+
BlockPublicPolicy: false
43+
IgnorePublicAcls: false
44+
RestrictPublicBuckets: false
45+
BucketEncryption:
46+
ServerSideEncryptionConfiguration:
47+
- ServerSideEncryptionByDefault:
48+
SSEAlgorithm: "aws:kms"
49+
KMSMasterKeyID: "arn:aws:kms:us-east-1:111122223333:alias/my-s3-bucket-key"
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
AWSTemplateFormatVersion: 2010-09-09
3+
4+
Transform: AWS::Serverless-2016-10-31
5+
6+
Resources:
7+
S3BucketUnencrypted:
8+
Type: AWS::S3::Bucket
9+
Properties:
10+
PublicAccessBlockConfiguration:
11+
# flip these to true
12+
BlockPublicAcls: false
13+
BlockPublicPolicy: false
14+
IgnorePublicAcls: false
15+
RestrictPublicBuckets: false
16+
BucketEncryption:
17+
ServerSideEncryptionConfiguration:
18+
- ServerSideEncryptionByDefault:
19+
SSEAlgorithm: AES256
20+
21+
S3BucketEncryptedWithPMK:
22+
Type: AWS::S3::Bucket
23+
Properties:
24+
PublicAccessBlockConfiguration:
25+
# flip these to true
26+
BlockPublicAcls: false
27+
BlockPublicPolicy: false
28+
IgnorePublicAcls: false
29+
RestrictPublicBuckets: false
30+
BucketEncryption:
31+
ServerSideEncryptionConfiguration:
32+
- ServerSideEncryptionByDefault:
33+
SSEAlgorithm: AES256
34+
35+
S3BucketEncryptedWithCMK:
36+
Type: AWS::S3::Bucket
37+
Properties:
38+
PublicAccessBlockConfiguration:
39+
# flip these to true
40+
BlockPublicAcls: false
41+
BlockPublicPolicy: false
42+
IgnorePublicAcls: false
43+
RestrictPublicBuckets: false
44+
BucketEncryption:
45+
ServerSideEncryptionConfiguration:
46+
- ServerSideEncryptionByDefault:
47+
SSEAlgorithm: "aws:kms"
48+
KMSMasterKeyID: "arn:aws:kms:us-east-1:111122223333:alias/my-s3-bucket-key"
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
AWSTemplateFormatVersion: 2010-09-09
3+
4+
Transform: AWS::Serverless-2016-10-31
5+
6+
Resources:
7+
S3BucketUnencrypted:
8+
Type: AWS::S3::Bucket
9+
Properties:
10+
PublicAccessBlockConfiguration:
11+
# flip these to true
12+
BlockPublicAcls: false
13+
BlockPublicPolicy: false
14+
IgnorePublicAcls: false
15+
RestrictPublicBuckets: false
16+
17+
S3BucketEncryptedWithPMK:
18+
Type: AWS::S3::Bucket
19+
Properties:
20+
PublicAccessBlockConfiguration:
21+
# flip these to true
22+
BlockPublicAcls: false
23+
BlockPublicPolicy: false
24+
IgnorePublicAcls: false
25+
RestrictPublicBuckets: false
26+
BucketEncryption:
27+
ServerSideEncryptionConfiguration:
28+
- ServerSideEncryptionByDefault:
29+
SSEAlgorithm: AES256
30+
31+
S3BucketEncryptedWithCMK:
32+
Type: AWS::S3::Bucket
33+
Properties:
34+
PublicAccessBlockConfiguration:
35+
# flip these to true
36+
BlockPublicAcls: false
37+
BlockPublicPolicy: false
38+
IgnorePublicAcls: false
39+
RestrictPublicBuckets: false
40+
BucketEncryption:
41+
ServerSideEncryptionConfiguration:
42+
- ServerSideEncryptionByDefault:
43+
SSEAlgorithm: "aws:kms"
44+
KMSMasterKeyID: "arn:aws:kms:us-east-1:111122223333:alias/my-s3-bucket-key"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# VPC Flow Logs Misconfiguration
2+
3+
Here a flow log set to the wrong bucket. It should be fixed.
4+
5+
## Unguessable info
6+
7+
The expectation assumes the following:
8+
9+
1. The VPC Flow Log LogDestination: `!Sub "arn:aws:s3:::gomboc-security-flowlogs-480437182633/${VPC}/"`
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
AWSTemplateFormatVersion: 2010-09-09
2+
3+
Transform: AWS::Serverless-2016-10-31
4+
5+
Parameters:
6+
EnvironmentName:
7+
Description: An environment name that is prefixed to resource names
8+
Type: String
9+
Default: iac-scanning-poc-cf
10+
11+
Resources:
12+
VPC:
13+
Type: AWS::EC2::VPC
14+
Properties:
15+
CidrBlock: 10.0.0.0/16
16+
EnableDnsSupport: true
17+
EnableDnsHostnames: true
18+
Tags:
19+
- Key: Name
20+
Value: !Ref EnvironmentName
21+
22+
FlowLog_for_VPC:
23+
Type: AWS::EC2::FlowLog
24+
Properties:
25+
LogDestination: !Sub "arn:aws:s3:::gomboc-security-flowlogs-480437182633/${VPC}/"
26+
LogDestinationType: s3
27+
ResourceId: !Ref VPC
28+
ResourceType: VPC
29+
TrafficType: ALL
30+
31+
DefaultSG:
32+
Type: AWS::EC2::SecurityGroupIngress
33+
Properties:
34+
GroupId: !GetAtt VPC.DefaultSecurityGroup
35+
IpProtocol: tcp
36+
FromPort: 65535
37+
ToPort: 65535
38+
CidrIp: 1.1.1.1/32

0 commit comments

Comments
 (0)