-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(terraform): Adding 2 new AWS policies (#5599)
* adding 2 YAML policies - S3 & Neptune security config * adding 2 YAML policies * adding 2 YAML policies * adding 2 YAML policies * added 2 YAML policies * updated the pass and fail cases * Updated terraform pass and fail cases * Deleted - AWS S3 global ACL view check * added policy "Ensure Elastic Search has dedicated master node enabled" CKV2_AWS_59: Ensure Elastic Search has dedicated master node enabled * added policy "CKV2_AWS_60: Ensure RDS instance with copy tags to snapshots is enabled" Ensure RDS instance with copy tags to snapshots is enabled * [New Policy]: CKV2_AZURE_23: Ensure Azure spring cloud is configured with Virtual network (Vnet) CKV2_AZURE_23: Ensure Azure spring cloud is configured with Virtual network (Vnet) * [2 new Policies]: CKV2_AZURE_24, CKV2_AZURE_25 CKV2_AZURE_24: Ensure Azure automation account is NOT overly permissive CKV2_AZURE_25: Ensure Azure SQL database Transparent Data Encryption (TDE) is enabled * Update checkov/terraform/checks/graph_checks/aws/ElasticSearchDedicatedMasterEnabled.yaml Added opensearch check capability Co-authored-by: Anton Grübel <[email protected]> * Modified CKV2_AWS_59: Ensure ElasticSearch/OpenSearch has dedicated master node enabled * Renamed/Modified CKV2_AZURE_24: Ensure Azure automation account does NOT have overly permissive network access * Renamed/Modified CKV2_AZURE_24: Ensure Azure automation account does NOT have overly permissive network access * Modified CKV2_AZURE_23: Ensure Azure spring cloud is configured with Virtual network (Vnet) * CKV2_AZURE_25: Ensure Azure SQL database Transparent Data Encryption (TDE) is enabled * Modified CKV2_AWS_60: Ensure RDS instance with copy tags to snapshots is enabled * Added 5 YAML policies * Modified CKV2_AWS_60: Ensure RDS instance with copy tags to snapshots is enabled * Added 2 policies related to customer ask (GIC) * Optimised the policy name for CKV2_AWS_66 * Added the 2 policies records to test_yaml_policies.py * Modified policies as per suggestions * fix resource references --------- Co-authored-by: Anton Grübel <[email protected]>
- Loading branch information
1 parent
59cd4d3
commit 3a2d217
Showing
7 changed files
with
177 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
checkov/terraform/checks/graph_checks/aws/AWS_private_MWAA_environment.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,19 @@ | ||
metadata: | ||
id: "CKV2_AWS_66" | ||
name: "Ensure MWAA environment is not publicly accessible" | ||
category: "NETWORKING" | ||
|
||
definition: | ||
|
||
or: | ||
|
||
- cond_type: "attribute" | ||
resource_types: "aws_mwaa_environment" | ||
attribute: "webserver_access_mode" | ||
operator: "not_exists" | ||
|
||
- cond_type: "attribute" | ||
resource_types: "aws_mwaa_environment" | ||
attribute: "webserver_access_mode" | ||
operator: "equals" | ||
value: "PRIVATE_ONLY" |
12 changes: 12 additions & 0 deletions
12
checkov/terraform/checks/graph_checks/aws/AWSdisableS3ACL.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,12 @@ | ||
metadata: | ||
id: "CKV2_AWS_65" | ||
name: "Ensure access control lists for S3 buckets are disabled" | ||
category: "GENERAL_SECURITY" | ||
|
||
definition: | ||
|
||
cond_type: "attribute" | ||
resource_types: "aws_s3_bucket_ownership_controls" | ||
attribute: "rule.object_ownership" | ||
operator: "equals" | ||
value: "BucketOwnerEnforced" |
5 changes: 5 additions & 0 deletions
5
tests/terraform/graph/checks/resources/AWS_private_MWAA_environment/expected.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,5 @@ | ||
pass: | ||
- "aws_mwaa_environment.pud_mwaa_env_pass" | ||
- "aws_mwaa_environment.pud_mwaa_env_pass_1" | ||
fail: | ||
- "aws_mwaa_environment.pud_mwaa_env_fail" |
104 changes: 104 additions & 0 deletions
104
tests/terraform/graph/checks/resources/AWS_private_MWAA_environment/main.tf
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,104 @@ | ||
# PASS 1: webserver_access_mode = PRIVATE_ONLY | ||
|
||
resource "aws_iam_role" "pud_pass_role" { | ||
name = "pud_pass_role" | ||
assume_role_policy = jsonencode({ | ||
Version = "2023-09-27" | ||
Statement = [ | ||
{ | ||
Action = "sts:AssumeRole" | ||
Effect = "Allow" | ||
Sid = "" | ||
Principal = { | ||
Service = "ec2.amazonaws.com" | ||
} | ||
}, | ||
] | ||
}) | ||
|
||
tags = { | ||
tag-key = "pud_checkov_pass" | ||
} | ||
} | ||
|
||
resource "aws_s3_bucket" "pud_pass_bucket" { | ||
bucket = "pud_pass_bucket" | ||
} | ||
|
||
resource "aws_mwaa_environment" "pud_mwaa_env_pass" { | ||
dag_s3_path = "dags/" | ||
execution_role_arn = aws_iam_role.pud_pass_role.arn | ||
name = "pud_mwaa_env_pass" | ||
webserver_access_mode = "PRIVATE_ONLY" | ||
source_bucket_arn = aws_s3_bucket.pud_pass_bucket.arn | ||
} | ||
|
||
# PASS 2: webserver_access_mode Not mentioned. DEFAULT = PRIVATE_ONLY | ||
|
||
resource "aws_iam_role" "pud_pass_role_1" { | ||
name = "pud_pass_role_1" | ||
assume_role_policy = jsonencode({ | ||
Version = "2023-09-27" | ||
Statement = [ | ||
{ | ||
Action = "sts:AssumeRole" | ||
Effect = "Allow" | ||
Sid = "" | ||
Principal = { | ||
Service = "ec2.amazonaws.com" | ||
} | ||
}, | ||
] | ||
}) | ||
|
||
tags = { | ||
tag-key = "pud_checkov_pass_1" | ||
} | ||
} | ||
|
||
resource "aws_s3_bucket" "pud_pass_bucket_1" { | ||
bucket = "pud_pass_bucket_1" | ||
} | ||
|
||
resource "aws_mwaa_environment" "pud_mwaa_env_pass_1" { | ||
dag_s3_path = "dags/" | ||
execution_role_arn = aws_iam_role.pud_pass_role.arn | ||
name = "pud_mwaa_env_pass_1" | ||
source_bucket_arn = aws_s3_bucket.pud_pass_bucket.arn | ||
} | ||
|
||
# FAIL: webserver_access_mode = PUBLIC_ONLY | ||
|
||
resource "aws_iam_role" "pud_fail_role" { | ||
name = "pud_fail_role" | ||
assume_role_policy = jsonencode({ | ||
Version = "2023-09-27" | ||
Statement = [ | ||
{ | ||
Action = "sts:AssumeRole" | ||
Effect = "Allow" | ||
Sid = "" | ||
Principal = { | ||
Service = "ec2.amazonaws.com" | ||
} | ||
}, | ||
] | ||
}) | ||
|
||
tags = { | ||
tag-key = "pud_checkov_fail" | ||
} | ||
} | ||
|
||
resource "aws_s3_bucket" "pud_fail_bucket" { | ||
bucket = "pud_fail_bucket" | ||
} | ||
|
||
resource "aws_mwaa_environment" "pud_mwaa_env_fail" { | ||
dag_s3_path = "dags/" | ||
execution_role_arn = aws_iam_role.pud_fail_role.arn | ||
name = "pud_mwaa_env_fail" | ||
webserver_access_mode = "PUBLIC_ONLY" | ||
source_bucket_arn = aws_s3_bucket.pud_fail_bucket.arn | ||
} | ||
|
4 changes: 4 additions & 0 deletions
4
tests/terraform/graph/checks/resources/AWSdisableS3ACL/expected.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,4 @@ | ||
fail: | ||
- "aws_s3_bucket_ownership_controls.pud_bucket_fail" | ||
pass: | ||
- "aws_s3_bucket_ownership_controls.pud_bucket_pass" |
27 changes: 27 additions & 0 deletions
27
tests/terraform/graph/checks/resources/AWSdisableS3ACL/main.tf
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 @@ | ||
# FAIL | ||
|
||
resource "aws_s3_bucket" "pud_bucket_fail" { | ||
bucket = "pud_bucket_fail" | ||
} | ||
|
||
resource "aws_s3_bucket_ownership_controls" "pud_bucket_fail" { | ||
bucket = aws_s3_bucket.pud_bucket_fail.id | ||
|
||
rule { | ||
object_ownership = "BucketOwnerPreferred" | ||
} | ||
} | ||
|
||
# PASS | ||
|
||
resource "aws_s3_bucket" "pud_bucket_pass" { | ||
bucket = "pud_bucket_pass" | ||
} | ||
|
||
resource "aws_s3_bucket_ownership_controls" "pud_bucket_pass" { | ||
bucket = aws_s3_bucket.pud_bucket_pass.id | ||
|
||
rule { | ||
object_ownership = "BucketOwnerEnforced" | ||
} | ||
} |
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