# Buggy code
def _parse_bucket(self, raw_bucket):
    bucket_dict = {}
    bucket_dict["id"] = get_non_provider_id(raw_bucket.id)
    bucket_dict["name"] = raw_bucket.name
    bucket_dict["project_id"] = self.project_id
    bucket_dict["project_number"] = raw_bucket.project_number
    bucket_dict["creation_date"] = raw_bucket.time_created
    bucket_dict["location"] = raw_bucket.location
    bucket_dict["storage_class"] = raw_bucket.storage_class.lower()
    bucket_dict["versioning_enabled"] = raw_bucket.versioning_enabled
    bucket_dict["logging_enabled"] = raw_bucket.logging is not None
    iam_configuration = raw_bucket.iam_configuration.get(
        "uniformBucketLevelAccess", False
    ) or raw_bucket.iam_configuration.get("bucketPolicyOnly", False)
    if iam_configuration:
        bucket_dict["uniform_bucket_level_access"] = policy.get("enabled", False)
    else:
        print(
            "raw_bucket.iam_configuration missing both uniformBucketLevelAccess and bucketPolicyOnly"
        )
        raise

    if bucket_dict["uniform_bucket_level_access"]:
        bucket_dict["acls"] = []
        bucket_dict["default_object_acl"] = []
    else:
        bucket_dict["acls"] = list(raw_bucket.acl)
        bucket_dict["default_object_acl"] = list(raw_bucket.default_object_acl)

    bucket_dict["acl_configuration"] = self._get_cloudstorage_bucket_acl(
        raw_bucket
    )  # FIXME this should be "IAM"
    return bucket_dict["id"], bucket_dict


# Traceback (KeyError)
2020-03-16` 17:43:42 renzo-latacora-work asyncio[17820] ERROR Task exception was never retrieved
future: <Task finished coro=<Instances.fetch_all() done, defined at /home/user/Documents/scoutsuite/LatacoraScoutSuite/ScoutSuite/ScoutSuite/providers/gcp/resources/gce/instances.py:17> exception=KeyError('source')>
Traceback (most recent call last):
File "/home/user/Documents/scoutsuite/LatacoraScoutSuite/ScoutSuite/ScoutSuite/providers/gcp/resources/gce/instances.py", line 22, in fetch_all
self[instance_id]['disks'].fetch_all()
File "/home/user/Documents/scoutsuite/LatacoraScoutSuite/ScoutSuite/ScoutSuite/providers/gcp/resources/gce/instance_disks.py", line 12, in fetch_all
disk_id, disk = self._parse_disk(raw_disk)
File "/home/user/Documents/scoutsuite/LatacoraScoutSuite/ScoutSuite/ScoutSuite/providers/gcp/resources/gce/disks.py", line 11, in _parse_disk
disk_dict['source_url'] = raw_disk['source']
KeyError: 'source'

# Fixed code
def _parse_bucket(self, raw_bucket):
    bucket_dict = {}
    bucket_dict["id"] = get_non_provider_id(raw_bucket.id)
    bucket_dict["name"] = raw_bucket.name
    bucket_dict["project_id"] = self.project_id
    bucket_dict["project_number"] = raw_bucket.project_number
    bucket_dict["creation_date"] = raw_bucket.time_created
    bucket_dict["location"] = raw_bucket.location
    bucket_dict["storage_class"] = raw_bucket.storage_class.lower()
    bucket_dict["versioning_enabled"] = raw_bucket.versioning_enabled
    bucket_dict["logging_enabled"] = raw_bucket.logging is not None
    iam_configuration = raw_bucket.iam_configuration.get(
        "uniformBucketLevelAccess", False
    ) or raw_bucket.iam_configuration.get("bucketPolicyOnly", False)
    if iam_configuration:
        bucket_dict["uniform_bucket_level_access"] = iam_configuration.get(
            "enabled", False
        )
    else:
        print(
            "raw_bucket.iam_configuration missing both uniformBucketLevelAccess and bucketPolicyOnly"
        )
        raise

    if bucket_dict["uniform_bucket_level_access"]:
        bucket_dict["acls"] = []
        bucket_dict["default_object_acl"] = []
    else:
        bucket_dict["acls"] = list(raw_bucket.acl)
        bucket_dict["default_object_acl"] = list(raw_bucket.default_object_acl)

    bucket_dict["acl_configuration"] = self._get_cloudstorage_bucket_acl(
        raw_bucket
    )  # FIXME this should be "IAM"
    return bucket_dict["id"], bucket_dict