forked from Checkmarx/kics
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(query): update ebs not optimized queries (Checkmarx#5020)
* fix(query): update ebs not optimized queries - Add a list of optimized queries by default on `common.json`; - Add a function on `common.rego` to check if instance type is listed on optimized by default instance's list; - Add this check to ebs optimizes rules on terraform, ansible and cloud formation; - Add new test files to validate cases where instance type is optimized by default; - Fix some minor errors; For this fix is important to note there is an explanation which documentation was used to decide what is default value for instance type. Signed-off-by: Felipe Avelar <[email protected]> * fix test samples Signed-off-by: Felipe Avelar <[email protected]> * removed default value for terraform Signed-off-by: Felipe Avelar <[email protected]> * add key check to default ebs optimized instances when ebs_optimized is false Signed-off-by: Felipe Avelar <[email protected]>
- Loading branch information
1 parent
10f8906
commit d6dee9e
Showing
22 changed files
with
782 additions
and
54 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
3 changes: 1 addition & 2 deletions
3
.../ec2_not_ebs_optimized/test/negative.yaml → ...ec2_not_ebs_optimized/test/negative1.yaml
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
9 changes: 9 additions & 0 deletions
9
assets/queries/ansible/aws/ec2_not_ebs_optimized/test/negative2.yaml
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,9 @@ | ||
- name: example5 | ||
amazon.aws.ec2: | ||
key_name: mykey | ||
instance_type: t3.nano | ||
image: ami-123456 | ||
wait: yes | ||
group: my_sg | ||
count: 3 | ||
vpc_subnet_id: subnet-29e63245 |
10 changes: 10 additions & 0 deletions
10
assets/queries/ansible/aws/ec2_not_ebs_optimized/test/negative3.yaml
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,10 @@ | ||
- name: example5 | ||
amazon.aws.ec2: | ||
key_name: mykey | ||
instance_type: t3.nano | ||
image: ami-123456 | ||
wait: yes | ||
group: my_sg | ||
count: 3 | ||
vpc_subnet_id: subnet-29e63245 | ||
ebs_optimized: false |
8 changes: 8 additions & 0 deletions
8
assets/queries/ansible/aws/ec2_not_ebs_optimized/test/positive3.yaml
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,8 @@ | ||
- name: example3 | ||
amazon.aws.ec2: | ||
key_name: mykey | ||
image: ami-123456 | ||
wait: yes | ||
group: default | ||
count: 3 | ||
vpc_subnet_id: subnet-29e63245 |
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
16 changes: 16 additions & 0 deletions
16
assets/queries/cloudFormation/aws/ec2_not_ebs_optimized/test/negative3.yaml
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,16 @@ | ||
Resources: | ||
MyEC2Instance: | ||
Type: AWS::EC2::Instance | ||
Properties: | ||
InstanceType: t3.nano | ||
ImageId: "ami-79fd7eee" | ||
KeyName: "testkey" | ||
BlockDeviceMappings: | ||
- DeviceName: "/dev/sdm" | ||
Ebs: | ||
VolumeType: "io1" | ||
Iops: "200" | ||
DeleteOnTermination: "false" | ||
VolumeSize: "20" | ||
- DeviceName: "/dev/sdk" | ||
NoDevice: {} |
27 changes: 27 additions & 0 deletions
27
assets/queries/cloudFormation/aws/ec2_not_ebs_optimized/test/negative4.json
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,27 @@ | ||
{ | ||
"Resources": { | ||
"MyEC2Instance": { | ||
"Type": "AWS::EC2::Instance", | ||
"Properties": { | ||
"InstanceType": "t3.nano", | ||
"ImageId": "ami-79fd7eee", | ||
"KeyName": "testkey", | ||
"BlockDeviceMappings": [ | ||
{ | ||
"DeviceName": "/dev/sdm", | ||
"Ebs": { | ||
"VolumeType": "io1", | ||
"Iops": "200", | ||
"DeleteOnTermination": "false", | ||
"VolumeSize": "20" | ||
} | ||
}, | ||
{ | ||
"DeviceName": "/dev/sdk", | ||
"NoDevice": {} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
assets/queries/cloudFormation/aws/ec2_not_ebs_optimized/test/positive5.yaml
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,16 @@ | ||
Resources: | ||
MyEC2Instance: | ||
Type: AWS::EC2::Instance | ||
Properties: | ||
InstanceType: t2.small | ||
ImageId: "ami-79fd7eee" | ||
KeyName: "testkey" | ||
BlockDeviceMappings: | ||
- DeviceName: "/dev/sdm" | ||
Ebs: | ||
VolumeType: "io1" | ||
Iops: "200" | ||
DeleteOnTermination: "false" | ||
VolumeSize: "20" | ||
- DeviceName: "/dev/sdk" | ||
NoDevice: {} |
27 changes: 27 additions & 0 deletions
27
assets/queries/cloudFormation/aws/ec2_not_ebs_optimized/test/positive6.json
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,27 @@ | ||
{ | ||
"Resources": { | ||
"MyEC2Instance": { | ||
"Type": "AWS::EC2::Instance", | ||
"Properties": { | ||
"InstanceType": "t2.small", | ||
"ImageId": "ami-79fd7eee", | ||
"KeyName": "testkey", | ||
"BlockDeviceMappings": [ | ||
{ | ||
"DeviceName": "/dev/sdm", | ||
"Ebs": { | ||
"VolumeType": "io1", | ||
"Iops": "200", | ||
"DeleteOnTermination": "false", | ||
"VolumeSize": "20" | ||
} | ||
}, | ||
{ | ||
"DeviceName": "/dev/sdk", | ||
"NoDevice": {} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.