-
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): PC Policy Team Yaml Policies Check-in (#3785)
* PC team policy file for EC2, GCR, Cloud Function * adding checkov id's * added suggested changes * updated PR as per review comments Co-authored-by: ssiddardha <[email protected]>
- Loading branch information
1 parent
79ba526
commit 4245295
Showing
10 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
checkov/terraform/checks/graph_checks/aws/EC2InstanceHasIAMRoleAttached.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 @@ | ||
metadata: | ||
id: "CKV2_AWS_41" | ||
name: "Ensure an IAM role is attached to EC2 instance" | ||
category: "IAM" | ||
definition: | ||
cond_type: "attribute" | ||
resource_types: | ||
- "aws_instance" | ||
attribute: "iam_instance_profile" | ||
operator: "exists" |
11 changes: 11 additions & 0 deletions
11
checkov/terraform/checks/graph_checks/gcp/CloudFunctionSecureHTTPTrigger.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,11 @@ | ||
metadata: | ||
id: "CKV2_GCP_10" | ||
name: "Ensure GCP Cloud Function HTTP trigger is secured" | ||
category: "NETWORKING" | ||
definition: | ||
cond_type: "attribute" | ||
resource_types: | ||
- "google_cloudfunctions_function" | ||
attribute: "https_trigger_security_level" | ||
operator: "equals" | ||
value: "SECURE_ALWAYS" |
11 changes: 11 additions & 0 deletions
11
checkov/terraform/checks/graph_checks/gcp/GCRContainerVulnerabilityScanningEnabled.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,11 @@ | ||
metadata: | ||
id: "CKV2_GCP_11" | ||
name: "Ensure GCP GCR Container Vulnerability Scanning is enabled" | ||
category: "GENERAL_SECURITY" | ||
definition: | ||
cond_type: "attribute" | ||
resource_types: | ||
- "google_project_services" | ||
attribute: "services" | ||
operator: "contains" | ||
value: "containerscanning.googleapis.com" |
5 changes: 5 additions & 0 deletions
5
tests/terraform/graph/checks/resources/CloudFunctionSecureHTTPTrigger/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: | ||
- "google_cloudfunctions_function.pass" | ||
fail: | ||
- "google_cloudfunctions_function.fail_1" | ||
- "google_cloudfunctions_function.fail_2" |
49 changes: 49 additions & 0 deletions
49
tests/terraform/graph/checks/resources/CloudFunctionSecureHTTPTrigger/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,49 @@ | ||
resource "google_cloudfunctions_function" "pass" { | ||
name = "function-test" | ||
description = "My function" | ||
runtime = "nodejs16" | ||
|
||
available_memory_mb = 128 | ||
source_archive_bucket = google_storage_bucket.bucket.name | ||
source_archive_object = google_storage_bucket_object.archive.name | ||
trigger_http = true | ||
https_trigger_security_level = "SECURE_ALWAYS" | ||
timeout = 60 | ||
entry_point = "helloGET" | ||
labels = { | ||
my-label = "my-label-value" | ||
} | ||
} | ||
|
||
resource "google_cloudfunctions_function" "fail_1" { | ||
name = "function-test" | ||
description = "My function" | ||
runtime = "nodejs16" | ||
|
||
available_memory_mb = 128 | ||
source_archive_bucket = google_storage_bucket.bucket.name | ||
source_archive_object = google_storage_bucket_object.archive.name | ||
trigger_http = true | ||
https_trigger_security_level = "SECURE_OPTIONAL" | ||
timeout = 60 | ||
entry_point = "helloGET" | ||
labels = { | ||
my-label = "my-label-value" | ||
} | ||
} | ||
|
||
resource "google_cloudfunctions_function" "fail_2" { | ||
name = "function-test" | ||
description = "My function" | ||
runtime = "nodejs16" | ||
|
||
available_memory_mb = 128 | ||
source_archive_bucket = google_storage_bucket.bucket.name | ||
source_archive_object = google_storage_bucket_object.archive.name | ||
trigger_http = true | ||
timeout = 60 | ||
entry_point = "helloGET" | ||
labels = { | ||
my-label = "my-label-value" | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
tests/terraform/graph/checks/resources/EC2InstanceHasIAMRoleAttached/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 @@ | ||
pass: | ||
- "aws_instance.pass" | ||
fail: | ||
- "aws_instance.fail" |
28 changes: 28 additions & 0 deletions
28
tests/terraform/graph/checks/resources/EC2InstanceHasIAMRoleAttached/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,28 @@ | ||
resource "aws_instance" "pass" { | ||
ami = "ami-005e54dee72cc1d00" # us-west-2 | ||
instance_type = "t2.micro" | ||
iam_instance_profile = "test" | ||
|
||
network_interface { | ||
network_interface_id = aws_network_interface.foo.id | ||
device_index = 0 | ||
} | ||
|
||
credit_specification { | ||
cpu_credits = "unlimited" | ||
} | ||
} | ||
|
||
resource "aws_instance" "fail" { | ||
ami = "ami-005e54dee72cc1d00" | ||
instance_type = "t2.micro" | ||
|
||
network_interface { | ||
network_interface_id = aws_network_interface.foo.id | ||
device_index = 0 | ||
} | ||
|
||
credit_specification { | ||
cpu_credits = "unlimited" | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
...s/terraform/graph/checks/resources/GCRContainerVulnerabilityScanningEnabled/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 @@ | ||
pass: | ||
- "google_project_services.pass_1" | ||
fail: | ||
- "google_project_services.fail_1" |
9 changes: 9 additions & 0 deletions
9
tests/terraform/graph/checks/resources/GCRContainerVulnerabilityScanningEnabled/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,9 @@ | ||
resource "google_project_services" "pass_1" { | ||
project = "your-project-id" | ||
services = ["iam.googleapis.com", "cloudresourcemanager.googleapis.com", "containerscanning.googleapis.com"] | ||
} | ||
|
||
resource "google_project_services" "fail_1" { | ||
project = "your-project-id" | ||
services = ["iam.googleapis.com", "cloudresourcemanager.googleapis.com"] | ||
} |
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