Skip to content

Commit

Permalink
Merge pull request #490 from harkirat22/harkirat22/382
Browse files Browse the repository at this point in the history
Fixes issue #382, and improves GCP policy to relate disk with the instance
  • Loading branch information
cesar-rodriguez committed Jan 18, 2021
2 parents 4ef6ce1 + fdf8dae commit 4a05a56
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,11 @@ package accurics
vmEncryptedwithCsek[api.id]
{
api := input.google_compute_disk[_]
not api.config.disk_encryption_key == null
not api.config.disk_encryption_key
}

vmEncryptedwithCsek[api.id]
{
api := input.google_compute_disk[_]
api.config.disk_encryption_key == null
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"file": "encryptedwithCsek.rego",
"template_args": null,
"severity": "MEDIUM",
"description": "Ensure VM disks for critical VMs are encrypted with Customer Supplied Encryption Keys (CSEK) .",
"description": "VM disks attached to a compute instance should be encrypted with Customer Supplied Encryption Keys (CSEK) .",
"reference_id": "accurics.gcp.EKM.132",
"category": "Encryption \u0026 Key Management",
"version": 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,33 @@
package accurics

encryptedwithCsek[api.id]
encryptedwithCsek[retVal]
{
api := input.google_compute_disk[_]
not api.config.disk_encryption_key == null
api := input.google_compute_disk[_]
not api.config.disk_encryption_key

association := input.google_compute_attached_disk[_]
diskName := split(association.config.disk, ".")[1]

api.name == diskName
instanceName := split(association.config.instance, ".")[1]

instance := input.google_compute_instance[_]
instanceName == instance.name
retVal := instance.id
}

encryptedwithCsek[retVal]
{
api := input.google_compute_disk[_]
api.config.disk_encryption_key == null

association := input.google_compute_attached_disk[_]
diskName := split(association.config.disk, ".")[1]

api.name == diskName
instanceName := split(association.config.instance, ".")[1]

instance := input.google_compute_instance[_]
instanceName == instance.name
retVal := instance.id
}

0 comments on commit 4a05a56

Please sign in to comment.