-
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.
CKV2_GCP_3 a1b2c3d4-e5f6-7890-abcd-ef1234567890
- Loading branch information
1 parent
836dcfd
commit b4b9447
Showing
7 changed files
with
49 additions
and
2 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
12 changes: 12 additions & 0 deletions
12
assets/queries/terraform/gcp/service_has_non_gcp_managed_service_account_keys/metadata.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,12 @@ | ||
{ | ||
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", | ||
"descriptionID": "a1b2c3d4", | ||
"queryName": "There are non GCP-managed service account keys for a service account", | ||
"severity": "HIGH", | ||
"category": "ENCRYPTION", | ||
"descriptionText": "Ensures that only GCP-managed service account keys are used, preventing manually created keys that pose security risks.", | ||
"descriptionUrl": "https://cloud.google.com/iam/docs/best-practices-for-managing-service-account-keys", | ||
"platform": "Terraform", | ||
"cloudProvider": "GCP", | ||
"cwe": "CWE-522" | ||
} |
21 changes: 21 additions & 0 deletions
21
assets/queries/terraform/gcp/service_has_non_gcp_managed_service_account_keys/query.rego
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,21 @@ | ||
package Cx | ||
|
||
import data.generic.common as common_lib | ||
import data.generic.terraform as tf_lib | ||
|
||
CxPolicy[result] { | ||
resource := input.document[i].resource.google_service_account_key[name] | ||
common_lib.valid_key(resource, "public_key_data") | ||
result := { | ||
"documentId": input.document[i].id, | ||
"resourceType": "google_service_account_key", | ||
"resourceName": tf_lib.get_resource_name(resource, name), | ||
"searchKey": sprintf("google_service_account_key[%s].public_key_data", [name]), | ||
"issueType": "IncorrectValue", | ||
"keyExpectedValue": "google_service_account_key should not have a public_key_data attribute", | ||
"keyActualValue": "google_service_account_key has a public_key_data attribute", | ||
"searchLine": common_lib.build_search_line(["resource", "google_service_account_key", name],["public_key_data"]), | ||
"remediation": "Remove the google_service_account_key resource to rely only on GCP-managed keys.", | ||
"remediationType": "removal", | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...s/queries/terraform/gcp/service_has_non_gcp_managed_service_account_keys/test/negative.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,3 @@ | ||
resource "google_service_account_key" "bad_key" { | ||
service_account_id = "projects/my-project/serviceAccounts/my-service-account" | ||
} |
4 changes: 4 additions & 0 deletions
4
...s/queries/terraform/gcp/service_has_non_gcp_managed_service_account_keys/test/positive.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,4 @@ | ||
resource "google_service_account_key" "bad_key" { | ||
service_account_id = "projects/my-project/serviceAccounts/my-service-account" | ||
public_key_data = "dummy-key" | ||
} |
7 changes: 7 additions & 0 deletions
7
...m/gcp/service_has_non_gcp_managed_service_account_keys/test/positive_expected_result.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,7 @@ | ||
[ | ||
{ | ||
"queryName": "Ensure that there are only GCP-managed service account keys for each service account", | ||
"severity": "HIGH", | ||
"line": 3 | ||
} | ||
] |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"exclude-severities":[low], | ||
"exclude-severities":[low, info], | ||
} |