diff --git a/src/control-catalog/terraform_modules/storage/object/ccc.os.c2/gcp/main.tf b/src/control-catalog/terraform_modules/storage/object/ccc.os.c2/gcp/main.tf index d56d9ea2..d2631921 100644 --- a/src/control-catalog/terraform_modules/storage/object/ccc.os.c2/gcp/main.tf +++ b/src/control-catalog/terraform_modules/storage/object/ccc.os.c2/gcp/main.tf @@ -15,32 +15,6 @@ resource "google_storage_bucket" "malicious_storage_bucket" { depends_on = [ google_kms_crypto_key_iam_binding.trusted_kms_key_binding ] } -data "archive_file" "my_function_src" { - type = "zip" - source_dir = "${path.module}/src" - output_file_mode = "0666" - output_path = "${path.module}/example_src.zip" -} -resource "google_storage_bucket_object" "src" { - name = "example_src_${data.archive_file.my_function_src.output_md5}.zip" - bucket = google_storage_bucket.malicious_storage_bucket.name - source = data.archive_file.my_function_src.output_path -} -resource "google_cloudfunctions_function" "untrusted_enc_obj_deleter" { - name = "${var.bucket_name}-ccc-os-c2-autorem-control" - runtime = "python39" - entry_point = "delete_object" - source_archive_bucket = google_storage_bucket_object.src.bucket - source_archive_object = google_storage_bucket_object.src.name - - event_trigger { - event_type = "google.storage.object.finalize" - resource = google_storage_bucket.malicious_storage_bucket.name - } - - https_trigger_security_level = "SECURE_ALWAYS" -} - resource "random_string" "random" { length = 5 special = false diff --git a/src/control-catalog/terraform_modules/storage/object/ccc.os.c2/gcp/src/main.py b/src/control-catalog/terraform_modules/storage/object/ccc.os.c2/gcp/src/main.py deleted file mode 100644 index f1f250d2..00000000 --- a/src/control-catalog/terraform_modules/storage/object/ccc.os.c2/gcp/src/main.py +++ /dev/null @@ -1,33 +0,0 @@ -import logging -import functions_framework -from google.cloud import storage - -logging.basicConfig(level=logging.INFO) - -@functions_framework.cloud_event -def delete_object(event): - logging.info("Function triggered: %s", event.data) - - bucket_name = event.data['bucket'] - object_name = event.data['name'] - kms_key_name = event.data['kmsKeyName'] - - # Initialize the client - client = storage.Client() - - # Get the bucket - bucket = client.get_bucket(bucket_name) - - # Get the object - blob = bucket.blob(object_name) - - # Check if the object is not encrypted with the default CMEK - # or if the object is not encrypted with a CMEK - if bucket.default_kms_key_name not in kms_key_name: - blob.delete() - logging.info("Object %s deleted successfully.", object_name) - return f"Object {object_name} deleted successfully.", 200 - else: - logging.info("Object %s is already encrypted with the default CMEK.", object_name) - return f"Object {object_name} is already encrypted with the default CMEK.", 200 - \ No newline at end of file diff --git a/src/control-catalog/terraform_modules/storage/object/ccc.os.c2/gcp/src/requirements.txt b/src/control-catalog/terraform_modules/storage/object/ccc.os.c2/gcp/src/requirements.txt deleted file mode 100644 index a64bf15b..00000000 --- a/src/control-catalog/terraform_modules/storage/object/ccc.os.c2/gcp/src/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -google-cloud-storage \ No newline at end of file