From dc58f94ce97ac22b5362bdd00ff10fd31e599485 Mon Sep 17 00:00:00 2001 From: Martin Guibert Date: Tue, 28 Jun 2022 09:23:29 +0200 Subject: [PATCH 01/12] chore: extract enumeration to it's own submodule --- {pkg => enumeration}/alerter/alert.go | 0 {pkg => enumeration}/alerter/alerter.go | 2 +- {pkg => enumeration}/alerter/alerter_test.go | 2 +- enumeration/filter.go | 9 + enumeration/mock_Filter.go | 55 ++ .../parallel/parallel_runner.go | 0 .../parallel/parallel_runner_test.go | 0 enumeration/progress.go | 5 + {pkg => enumeration}/remote/alerts/alerts.go | 7 +- .../aws/api_gateway_account_enumerator.go | 8 +- .../aws/api_gateway_api_key_enumerator.go | 8 +- .../aws/api_gateway_authorizer_enumerator.go | 8 +- ...pi_gateway_base_path_mapping_enumerator.go | 8 +- .../aws/api_gateway_domain_name_enumerator.go | 8 +- ...api_gateway_gateway_response_enumerator.go | 8 +- .../aws/api_gateway_integration_enumerator.go | 8 +- ...gateway_integration_response_enumerator.go | 8 +- .../aws/api_gateway_method_enumerator.go | 8 +- .../api_gateway_method_response_enumerator.go | 8 +- .../api_gateway_method_settings_enumerator.go | 8 +- .../aws/api_gateway_model_enumerator.go | 8 +- ...pi_gateway_request_validator_enumerator.go | 8 +- .../aws/api_gateway_resource_enumerator.go | 8 +- .../aws/api_gateway_rest_api_enumerator.go | 8 +- .../api_gateway_rest_api_policy_enumerator.go | 8 +- .../aws/api_gateway_stage_enumerator.go | 8 +- .../aws/api_gateway_vpc_link_enumerator.go | 8 +- .../remote/aws/apigatewayv2_api_enumerator.go | 8 +- .../aws/apigatewayv2_authorizer_enumerator.go | 8 +- .../aws/apigatewayv2_deployment_enumerator.go | 8 +- .../apigatewayv2_domain_name_enumerator.go | 8 +- .../apigatewayv2_integration_enumerator.go | 8 +- ...tewayv2_integration_response_enumerator.go | 8 +- .../aws/apigatewayv2_mapping_enumerator.go | 14 +- .../aws/apigatewayv2_model_enumerator.go | 8 +- .../aws/apigatewayv2_route_enumerator.go | 8 +- .../apigatewayv2_route_response_enumerator.go | 8 +- .../aws/apigatewayv2_stage_enumerator.go | 8 +- .../aws/apigatewayv2_vpc_link_enumerator.go | 8 +- .../aws/appautoscaling_policy_enumerator.go | 8 +- ...autoscaling_scheduled_action_enumerator.go | 8 +- .../aws/appautoscaling_target_enumerator.go | 8 +- .../aws/classic_loadbalancer_enumerator.go | 8 +- .../client/mock_AwsClientFactoryInterface.go | 0 .../remote/aws/client/s3_client_factory.go | 0 .../aws/cloudformation_stack_enumerator.go | 8 +- .../aws/cloudfront_distribution_enumerator.go | 8 +- .../remote/aws/default_vpc_enumerator.go | 9 +- .../remote/aws/dynamodb_table_enumerator.go | 8 +- .../ebs_encryption_by_default_enumerator.go | 8 +- .../remote/aws/ec2_ami_enumerator.go | 8 +- .../aws/ec2_default_network_acl_enumerator.go | 8 +- .../aws/ec2_default_route_table_enumerator.go | 8 +- .../aws/ec2_default_subnet_enumerator.go | 8 +- .../remote/aws/ec2_ebs_snapshot_enumerator.go | 8 +- .../remote/aws/ec2_ebs_volume_enumerator.go | 8 +- .../aws/ec2_eip_association_enumerator.go | 8 +- .../remote/aws/ec2_eip_enumerator.go | 8 +- .../remote/aws/ec2_instance_enumerator.go | 8 +- .../aws/ec2_internet_gateway_enumerator.go | 8 +- .../remote/aws/ec2_key_pair_enumerator.go | 8 +- .../remote/aws/ec2_nat_gateway_enumerator.go | 8 +- .../remote/aws/ec2_network_acl_enumerator.go | 8 +- .../aws/ec2_network_acl_rule_enumerator.go | 15 +- .../remote/aws/ec2_route_enumerator.go | 8 +- .../ec2_route_table_association_enumerator.go | 8 +- .../remote/aws/ec2_route_table_enumerator.go | 8 +- .../remote/aws/ec2_subnet_enumerator.go | 8 +- .../remote/aws/ecr_repository_enumerator.go | 8 +- .../aws/ecr_repository_policy_enumerator.go | 8 +- .../aws/elasticache_cluster_enumerator.go | 8 +- .../remote/aws/iam_access_key_enumerator.go | 8 +- .../remote/aws/iam_group_enumerator.go | 8 +- .../iam_group_policy_attachment_enumerator.go | 8 +- .../remote/aws/iam_group_policy_enumerator.go | 8 +- .../remote/aws/iam_policy_enumerator.go | 8 +- .../remote/aws/iam_role_enumerator.go | 8 +- .../iam_role_policy_attachment_enumerator.go | 8 +- .../remote/aws/iam_role_policy_enumerator.go | 9 +- .../remote/aws/iam_user_enumerator.go | 8 +- .../iam_user_policy_attachment_enumerator.go | 8 +- .../remote/aws/iam_user_policy_enumerator.go | 8 +- {pkg => enumeration}/remote/aws/init.go | 178 ++--- .../remote/aws/kms_alias_enumerator.go | 8 +- .../remote/aws/kms_key_enumerator.go | 8 +- .../lambda_event_source_mapping_enumerator.go | 8 +- .../remote/aws/lambda_function_enumerator.go | 8 +- .../aws/launch_configuration_enumerator.go | 8 +- .../remote/aws/launch_template_enumerator.go | 8 +- .../remote/aws/load_balancer_enumerator.go | 8 +- .../aws/load_balancer_listener_enumerator.go | 8 +- {pkg => enumeration}/remote/aws/provider.go | 8 +- .../remote/aws/rds_cluster_enumerator.go | 8 +- .../remote/aws/rds_db_instance_enumerator.go | 8 +- .../aws/rds_db_subnet_group_enumerator.go | 8 +- .../aws/repository/api_gateway_repository.go | 2 +- .../repository/api_gateway_repository_test.go | 2 +- .../aws/repository/apigatewayv2_repository.go | 2 +- .../apigatewayv2_repository_test.go | 2 +- .../repository/appautoscaling_repository.go | 2 +- .../appautoscaling_repository_test.go | 2 +- .../aws/repository/autoscaling_repository.go | 2 +- .../repository/autoscaling_repository_test.go | 2 +- .../repository/cloudformation_repository.go | 2 +- .../cloudformation_repository_test.go | 2 +- .../aws/repository/cloudfront_repository.go | 2 +- .../repository/cloudfront_repository_test.go | 2 +- .../aws/repository/dynamodb_repository.go | 2 +- .../repository/dynamodb_repository_test.go | 2 +- .../remote/aws/repository/ec2_repository.go | 2 +- .../aws/repository/ec2_repository_test.go | 42 +- .../remote/aws/repository/ecr_repository.go | 2 +- .../aws/repository/ecr_repository_test.go | 2 +- .../aws/repository/elasticache_repository.go | 2 +- .../repository/elasticache_repository_test.go | 2 +- .../remote/aws/repository/elb_repository.go | 2 +- .../aws/repository/elb_repository_test.go | 2 +- .../remote/aws/repository/elbv2_repository.go | 2 +- .../aws/repository/elbv2_repository_test.go | 2 +- .../remote/aws/repository/iam_repository.go | 2 +- .../aws/repository/iam_repository_test.go | 2 +- .../remote/aws/repository/kms_repository.go | 2 +- .../aws/repository/kms_repository_test.go | 2 +- .../aws/repository/lambda_repository.go | 2 +- .../aws/repository/lambda_repository_test.go | 2 +- .../repository/mock_ApiGatewayRepository.go | 0 .../repository/mock_ApiGatewayV2Repository.go | 0 .../mock_AppAutoScalingRepository.go | 0 .../repository/mock_AutoScalingRepository.go | 0 .../mock_CloudformationRepository.go | 0 .../repository/mock_CloudfrontRepository.go | 0 .../aws/repository/mock_DynamoDBRepository.go | 0 .../aws/repository/mock_EC2Repository.go | 0 .../aws/repository/mock_ECRRepository.go | 0 .../aws/repository/mock_ELBRepository.go | 0 .../aws/repository/mock_ELBV2Repository.go | 0 .../repository/mock_ElastiCacheRepository.go | 0 .../aws/repository/mock_IAMRepository.go | 0 .../aws/repository/mock_KMSRepository.go | 0 .../aws/repository/mock_LambdaRepository.go | 0 .../aws/repository/mock_RDSRepository.go | 0 .../aws/repository/mock_Route53Repository.go | 0 .../aws/repository/mock_S3Repository.go | 0 .../aws/repository/mock_SNSRepository.go | 0 .../aws/repository/mock_SQSRepository.go | 0 .../remote/aws/repository/rds_repository.go | 2 +- .../aws/repository/rds_repository_test.go | 14 +- .../aws/repository/route53_repository.go | 2 +- .../aws/repository/route53_repository_test.go | 2 +- .../remote/aws/repository/s3_repository.go | 4 +- .../aws/repository/s3_repository_test.go | 4 +- .../remote/aws/repository/sns_repository.go | 2 +- .../aws/repository/sns_repository_test.go | 2 +- .../remote/aws/repository/sqs_repository.go | 2 +- .../aws/repository/sqs_repository_test.go | 2 +- .../aws/route53_health_check_enumerator.go | 8 +- .../remote/aws/route53_record_enumerator.go | 10 +- .../remote/aws/route53_zone_enumerator.go | 10 +- .../aws/s3_bucket_analytic_enumerator.go | 16 +- .../remote/aws/s3_bucket_enumerator.go | 16 +- .../aws/s3_bucket_inventory_enumerator.go | 16 +- .../aws/s3_bucket_metrics_enumerator.go | 16 +- .../aws/s3_bucket_notification_enumerator.go | 16 +- .../remote/aws/s3_bucket_policy_enumerator.go | 16 +- ...3_bucket_public_access_block_enumerator.go | 16 +- .../remote/aws/sns_topic_enumerator.go | 8 +- .../remote/aws/sns_topic_policy_enumerator.go | 8 +- .../aws/sns_topic_subscription_enumerator.go | 11 +- .../remote/aws/sqs_queue_details_fetcher.go | 8 +- .../remote/aws/sqs_queue_enumerator.go | 8 +- .../remote/aws/sqs_queue_policy_enumerator.go | 8 +- ...t-bucket-martin-test-drift.res.golden.json | 0 ...est-drift_Analytics_Bucket.res.golden.json | 0 ...est-drift_Inventory_Bucket.res.golden.json | 0 ...n-bucket-martin-test-drift.res.golden.json | 0 ...y-bucket-martin-test-drift.res.golden.json | 0 .../results.golden.json | 0 .../schema.golden.json | 0 ...-drift2_Inventory2_Bucket2.res.golden.json | 0 ...t-drift2_Inventory_Bucket2.res.golden.json | 0 .../test/s3_bucket_list/results.golden.json | 0 .../test/s3_bucket_list/schema.golden.json | 0 .../vpc_default_security_group_enumerator.go | 9 +- .../remote/aws/vpc_enumerator.go | 9 +- .../aws/vpc_security_group_enumerator.go | 9 +- .../aws/vpc_security_group_rule_enumerator.go | 9 +- .../remote/aws_api_gateway_scanner_test.go | 427 +++++------ .../remote/aws_apigatewayv2_scanner_test.go | 300 ++++---- ...aws_applicationautoscaling_scanner_test.go | 86 ++- .../remote/aws_autoscaling_scanner_test.go | 38 +- .../remote/aws_cloudformation_scanner_test.go | 48 +- .../remote/aws_cloudfront_scanner_test.go | 48 +- .../remote/aws_dynamodb_scanner_test.go | 48 +- .../remote/aws_ec2_scanner_test.go | 718 +++++++++--------- .../remote/aws_ecr_scanner_test.go | 66 +- .../remote/aws_elasticache_scanner_test.go | 40 +- .../remote/aws_elb_scanner_test.go | 40 +- .../remote/aws_elbv2_scanner_test.go | 68 +- .../remote/aws_iam_scanner_test.go | 316 ++++---- .../remote/aws_kms_scanner_test.go | 78 +- .../remote/aws_lambda_scanner_test.go | 82 +- .../remote/aws_rds_scanner_test.go | 108 +-- .../remote/aws_route53_scanner_test.go | 113 +-- .../remote/aws_s3_scanner_test.go | 224 +++--- .../remote/aws_sns_scanner_test.go | 112 +-- .../remote/aws_sqs_scanner_test.go | 80 +- .../azurerm_container_registry_enumerator.go | 8 +- .../azurerm/azurerm_firewalls_enumerator.go | 8 +- .../azurerm/azurerm_image_enumerator.go | 8 +- .../remote/azurerm/azurerm_lb_enumerator.go | 8 +- .../azurerm/azurerm_lb_rule_enumerator.go | 8 +- ...urerm_network_security_group_enumerator.go | 8 +- .../azurerm_postgresql_database_enumerator.go | 8 +- .../azurerm_postgresql_server_enumerator.go | 8 +- ...erm_private_dns_cname_record_enumerator.go | 8 +- .../azurerm_privatedns_a_record_enumerator.go | 8 +- ...urerm_privatedns_aaaa_record_enumerator.go | 8 +- ...azurerm_privatedns_mx_record_enumerator.go | 8 +- ...zurerm_privatedns_ptr_record_enumerator.go | 8 +- ...zurerm_privatedns_srv_record_enumerator.go | 8 +- ...zurerm_privatedns_txt_record_enumerator.go | 8 +- .../azurerm_privatedns_zone_enumerator.go | 8 +- .../azurerm/azurerm_public_ip_enumerator.go | 8 +- .../azurerm_resource_group_enumerator.go | 8 +- .../azurerm/azurerm_route_enumerator.go | 8 +- .../azurerm/azurerm_route_table_enumerator.go | 8 +- .../azurerm_ssh_public_key_enumerator.go | 8 +- .../azurerm_storage_account_enumerator.go | 8 +- .../azurerm_storage_container_enumerator.go | 8 +- .../azurerm/azurerm_subnets_enumerator.go | 8 +- .../azurerm_virtual_network_enumerator.go | 8 +- .../remote/azurerm/common/config.go | 0 {pkg => enumeration}/remote/azurerm/init.go | 56 +- .../remote/azurerm/provider.go | 14 +- .../remote/azurerm/repository/compute.go | 4 +- .../remote/azurerm/repository/compute_test.go | 2 +- .../azurerm/repository/containerregistry.go | 4 +- .../repository/containerregistry_test.go | 2 +- .../repository/mock_ComputeRepository.go | 0 .../mock_ContainerRegistryRepository.go | 0 .../repository/mock_NetworkRepository.go | 0 .../repository/mock_PostgresqlRespository.go | 0 .../repository/mock_PrivateDNSRepository.go | 0 .../repository/mock_ResourcesRepository.go | 0 .../repository/mock_StorageRespository.go | 0 .../repository/mock_blobContainerClient.go | 0 .../repository/mock_blobContainerListPager.go | 0 .../repository/mock_firewallsClient.go | 0 .../repository/mock_firewallsListAllPager.go | 0 .../azurerm/repository/mock_imagesClient.go | 0 .../repository/mock_imagesListPager.go | 0 .../mock_loadBalancerRulesClient.go | 0 .../mock_loadBalancerRulesListAllPager.go | 0 .../repository/mock_loadBalancersClient.go | 0 .../mock_loadBalancersListAllPager.go | 0 .../mock_networkSecurityGroupsClient.go | 0 .../mock_networkSecurityGroupsListAllPager.go | 0 .../mock_postgresqlDatabaseClient.go | 0 .../mock_postgresqlServersClient.go | 0 .../mock_privateDNSRecordSetListPager.go | 0 .../mock_privateDNSZoneListPager.go | 0 .../repository/mock_privateRecordSetClient.go | 0 .../repository/mock_privateZonesClient.go | 0 .../mock_publicIPAddressesClient.go | 0 .../mock_publicIPAddressesListAllPager.go | 0 .../azurerm/repository/mock_registryClient.go | 0 .../repository/mock_registryListAllPager.go | 0 .../repository/mock_resourcesClient.go | 0 .../repository/mock_resourcesListPager.go | 0 .../repository/mock_routeTablesClient.go | 0 .../mock_routeTablesListAllPager.go | 0 .../repository/mock_sshPublicKeyClient.go | 0 .../repository/mock_sshPublicKeyListPager.go | 0 .../repository/mock_storageAccountClient.go | 0 .../mock_storageAccountListPager.go | 0 .../azurerm/repository/mock_subnetsClient.go | 0 .../repository/mock_subnetsListPager.go | 0 .../repository/mock_virtualNetworkClient.go | 0 .../mock_virtualNetworksListAllPager.go | 0 .../remote/azurerm/repository/network.go | 4 +- .../remote/azurerm/repository/network_test.go | 74 +- .../remote/azurerm/repository/pager.go | 0 .../remote/azurerm/repository/postgresql.go | 4 +- .../azurerm/repository/postgresql_test.go | 2 +- .../remote/azurerm/repository/privatedns.go | 4 +- .../azurerm/repository/privatedns_test.go | 50 +- .../remote/azurerm/repository/resources.go | 4 +- .../azurerm/repository/resources_test.go | 2 +- .../remote/azurerm/repository/storage.go | 4 +- .../remote/azurerm/repository/storage_test.go | 16 +- .../remote/azurerm_compute_scanner_test.go | 64 +- .../azurerm_containerregistry_scanner_test.go | 32 +- .../remote/azurerm_network_scanner_test.go | 216 +++--- .../remote/azurerm_postgresql_scanner_test.go | 52 +- .../remote/azurerm_privatedns_scanner_test.go | 242 +++--- .../remote/azurerm_resources_scanner_test.go | 32 +- .../remote/azurerm_storage_scanner_test.go | 54 +- {pkg => enumeration}/remote/cache/cache.go | 0 .../remote/cache/cache_test.go | 2 +- .../remote/cache/mock_Cache.go | 0 .../remote/common/details_fetcher.go | 6 +- {pkg => enumeration}/remote/common/library.go | 2 +- .../remote/common/mock_Enumerator.go | 2 +- .../remote/common/providers.go | 4 +- {pkg => enumeration}/remote/error/errors.go | 0 .../github_branch_protection_enumerator.go | 6 +- .../github/github_membership_enumerator.go | 6 +- .../github/github_repository_enumerator.go | 6 +- .../remote/github/github_team_enumerator.go | 6 +- .../github_team_membership_enumerator.go | 6 +- {pkg => enumeration}/remote/github/init.go | 28 +- .../remote/github/mock_GithubRepository.go | 0 .../remote/github/provider.go | 10 +- .../remote/github/repository.go | 2 +- .../remote/github/repository_test.go | 2 +- .../github_branch_protection_scanner_test.go | 60 +- .../remote/github_membership_scanner_test.go | 48 +- .../remote/github_repository_scanner_test.go | 48 +- .../github_team_membership_scanner_test.go | 48 +- .../remote/github_team_scanner_test.go | 52 +- .../remote/google/config/config.go | 0 .../google_bigquery_dataset_enumerator.go | 8 +- .../google_bigquery_table_enumerator.go | 8 +- .../google_bigtable_instance_enumerator.go | 8 +- .../google_bigtable_table_enumerator.go | 8 +- ...ogle_cloudfunctions_function_enumerator.go | 8 +- .../google_cloudrun_service_enumerator.go | 8 +- .../google_compute_address_enumerator.go | 8 +- .../google/google_compute_disk_enumerator.go | 8 +- .../google_compute_firewall_enumerator.go | 8 +- ...ogle_compute_forwarding_rule_enumerator.go | 8 +- ...oogle_compute_global_address_enumerator.go | 8 +- ...mpute_global_forwarding_rule_enumerator.go | 8 +- .../google_compute_health_check_enumerator.go | 8 +- .../google/google_compute_image_enumerator.go | 8 +- .../google_compute_instance_enumerator.go | 8 +- ...oogle_compute_instance_group_enumerator.go | 8 +- ...mpute_instance_group_manager_enumerator.go | 8 +- .../google_compute_network_enumerator.go | 8 +- .../google_compute_node_group_enumerator.go | 8 +- .../google_compute_router_enumerator.go | 8 +- .../google_compute_subnetwork_enumerator.go | 8 +- .../google_dns_managed_zone_enumerator.go | 8 +- .../google_project_iam_member_enumerator.go | 8 +- ...google_sql_database_instance_enumerator.go | 8 +- .../google_storage_bucket_enumerator.go | 8 +- ...le_storage_bucket_iam_member_enumerator.go | 14 +- {pkg => enumeration}/remote/google/init.go | 42 +- .../remote/google/provider.go | 15 +- .../remote/google/repository/asset.go | 4 +- .../remote/google/repository/asset_test.go | 4 +- .../google/repository/cloudresourcemanager.go | 4 +- .../google/repository/mock_AssetRepository.go | 0 .../mock_CloudResourceManagerRepository.go | 0 .../repository/mock_StorageRepository.go | 0 .../remote/google/repository/storage.go | 2 +- {pkg => enumeration}/remote/google/util.go | 0 .../remote/google_bigquery_scanner_test.go | 46 +- .../remote/google_bigtable_scanner_test.go | 46 +- .../google_cloudfunctions_scanner_test.go | 32 +- .../remote/google_cloudrun_scanner_test.go | 32 +- .../remote/google_compute_scanner_test.go | 220 +++--- .../remote/google_network_scanner_test.go | 32 +- .../remote/google_project_scanner_test.go | 30 +- .../remote/google_sql_scanner_test.go | 32 +- .../remote/google_storage_scanner_test.go | 78 +- {pkg => enumeration}/remote/remote.go | 38 +- .../resource_enumeration_error_handler.go | 9 +- ...resource_enumeration_error_handler_test.go | 78 +- {pkg => enumeration}/remote/scanner.go | 15 +- {pkg => enumeration}/remote/scanner_test.go | 16 +- .../remote/terraform/provider.go | 22 +- ...ReadCapacityUnits-dynamodb.res.golden.json | 0 .../results.golden.json | 0 ...ReadCapacityUnits-dynamodb.res.golden.json | 0 .../results.golden.json | 0 ...f21-11ec-bd2a-0a2d95c2b2ab.res.golden.json | 0 ...f21-11ec-ba25-129d8c0b3757.res.golden.json | 0 .../aws_cloudformation_stack_multiple/iam.yml | 0 .../results.golden.json | 4 +- .../terraform.tf | 0 ...istribution-E1M9CNS0XSHI19.res.golden.json | 0 .../results.golden.json | 0 .../terraform.tf | 0 ...s_default_vpc-vpc-a8c5d4c1.res.golden.json | 0 .../test/aws_default_vpc/results.golden.json | 0 .../remote/test/aws_default_vpc/terraform.tf | 0 ...able-GameScores-GameScores.res.golden.json | 0 ...modb_table-example-example.res.golden.json | 0 .../results.golden.json | 0 ...ult-ebs_encryption_default.res.golden.json | 0 .../results.golden.json | 0 ..._ami-ami-025962fd8b456731f.res.golden.json | 0 ..._ami-ami-03a578b46f4c3081b.res.golden.json | 0 .../aws_ec2_ami_multiple/results.golden.json | 0 ...t_network_acl-acl-e88ee595.res.golden.json | 0 .../results.golden.json | 9 +- ...0976-vpc-0b4a6b3536da20ecd.res.golden.json | 0 .../results.golden.json | 0 .../terraform.tf | 0 ...ult_subnet-subnet-44fe0c65.res.golden.json | 0 ...ult_subnet-subnet-65e16628.res.golden.json | 0 ...ult_subnet-subnet-afa656f0.res.golden.json | 0 .../results.golden.json | 0 .../terraform.tf | 0 ...hot-snap-00672558cecd93a61.res.golden.json | 0 ...hot-snap-0c509a2a880d95a39.res.golden.json | 0 .../results.golden.json | 0 ...lume-vol-01ddc91d3d9d1318b.res.golden.json | 0 ...lume-vol-081c7272a57a09db1.res.golden.json | 0 .../results.golden.json | 0 ...eipassoc-0e9a7356e30f0c3d1.res.golden.json | 0 .../results.golden.json | 0 ...eipalloc-017d5267e4dda73f1.res.golden.json | 0 ...eipalloc-0cf714dc097c992cc.res.golden.json | 0 .../aws_ec2_eip_multiple/results.golden.json | 0 ...stance-i-010376047a71419f1.res.golden.json | 0 ...stance-i-0d3650a23f4e45dc0.res.golden.json | 0 .../results.golden.json | 0 ...stance-i-0a3a7ed51ae2b4fa0.res.golden.json | 0 ...stance-i-0e1543baf4f2cd990.res.golden.json | 0 .../results.golden.json | 0 ...eway-igw-0184eb41aadc62d1c.res.golden.json | 0 ...eway-igw-047b487f5c60fca99.res.golden.json | 0 .../results.golden.json | 0 .../terraform.tf | 0 .../aws_key_pair-bar.res.golden.json | 0 .../aws_key_pair-test.res.golden.json | 0 .../results.golden.json | 0 ...eway-nat-0a5408508b19ef490.res.golden.json | 0 .../results.golden.json | 0 .../aws_ec2_nat_gateway_single/terraform.tf | 0 ..._acl-acl-043880b4682d2366b.res.golden.json | 0 ..._acl-acl-07a565dbe518c0713.res.golden.json | 0 .../aws_ec2_network_acl/results.golden.json | 0 .../test/aws_ec2_network_acl/terraform.tf | 0 ...-acl-0ad6d657494d17ee2-200.res.golden.json | 0 ...-acl-0ad6d657494d17ee2-100.res.golden.json | 0 ...-acl-0de54ef59074b622e-100.res.golden.json | 0 ...-acl-0ad6d657494d17ee2-100.res.golden.json | 0 ...-acl-0de54ef59074b622e-100.res.golden.json | 0 .../results.golden.json | 20 +- .../aws_ec2_network_acl_rule/terraform.tf | 0 ...e-r-179966490-10.0.0.0_16-.res.golden.json | 0 ....0_0-rtb-0169b0937fd963ddc.res.golden.json | 0 ...0_16-rtb-0169b0937fd963ddc.res.golden.json | 0 ...___0-rtb-0169b0937fd963ddc.res.golden.json | 0 ...0_24-rtb-02780c485f0be93c5.res.golden.json | 0 ...0_16-rtb-02780c485f0be93c5.res.golden.json | 0 ...0_24-rtb-02780c485f0be93c5.res.golden.json | 0 ...0_16-rtb-096bdfb69309c54c3.res.golden.json | 0 ...1_32-rtb-096bdfb69309c54c3.res.golden.json | 0 ...___0-rtb-096bdfb69309c54c3.res.golden.json | 0 .../results.golden.json | 0 .../test/aws_ec2_route_multiple/terraform.tf | 0 ...6ea4-rtb-05aa6c5673311a17b.res.golden.json | 0 ...c03b-rtb-05aa6c5673311a17b.res.golden.json | 0 ...944b-rtb-09df7cc9d16de9f8f.res.golden.json | 0 ...e213-rtb-05aa6c5673311a17b.res.golden.json | 0 .../results.golden.json | 0 ...able-rtb-0002ac731f6fdea55.res.golden.json | 0 ...able-rtb-08b7b71af15e183ce.res.golden.json | 0 ...able-rtb-0c55d55593f33fbac.res.golden.json | 0 .../results.golden.json | 0 .../aws_ec2_route_table_multiple/terraform.tf | 0 ...t-subnet-05810d3f933925f6d.res.golden.json | 0 ...t-subnet-0b13f1e0eacf67424.res.golden.json | 0 ...t-subnet-0c9b78001fe186e22.res.golden.json | 0 .../results.golden.json | 0 .../test/aws_ec2_subnet_multiple/terraform.tf | 0 .../aws_ecr_repository-bar.res.golden.json | 0 ...ws_ecr_repository-test_ecr.res.golden.json | 0 .../results.golden.json | 0 .../aws_ecr_repository_multiple/terraform.tf | 0 ...VVD223VWU32A-test-driftctl.res.golden.json | 0 ...VD26EJME25D-test-driftctl2.res.golden.json | 0 ...VVD2QYI36UZP-test-driftctl.res.golden.json | 0 ...VD2SWDFVVMG-test-driftctl2.res.golden.json | 0 .../results.golden.json | 0 .../aws_iam_access_key_multiple/terraform.tf | 0 ...9327065333_policy_policy-0.res.golden.json | 0 ...9327065333_policy_policy-1.res.golden.json | 0 ...9327065333_policy_policy-2.res.golden.json | 0 .../results.golden.json | 0 .../aws_iam_role-test_role_0.res.golden.json | 0 .../aws_iam_role-test_role_1.res.golden.json | 0 .../aws_iam_role-test_role_2.res.golden.json | 0 .../aws_iam_role_multiple/results.golden.json | 0 .../test/aws_iam_role_multiple/terraform.tf | 0 ...licy_test-policy-test-role.res.golden.json | 0 ...icy_test-policy-test-role2.res.golden.json | 0 ...icy_test-policy2-test-role.res.golden.json | 0 ...cy_test-policy2-test-role2.res.golden.json | 0 ...icy_test-policy3-test-role.res.golden.json | 0 ...cy_test-policy3-test-role2.res.golden.json | 0 .../main.tf | 0 .../results.golden.json | 0 .../schema.golden.json | 0 ...test_role_0_policy-role0-0.res.golden.json | 0 ...test_role_0_policy-role0-1.res.golden.json | 0 ...test_role_0_policy-role0-2.res.golden.json | 0 ...test_role_1_policy-role1-0.res.golden.json | 0 ...test_role_1_policy-role1-1.res.golden.json | 0 ...test_role_1_policy-role1-2.res.golden.json | 0 .../results.golden.json | 0 .../schema.golden.json | 0 .../aws_iam_role_policy_multiple/terraform.tf | 0 ...s_iam_user-test-driftctl-0.res.golden.json | 0 ...s_iam_user-test-driftctl-1.res.golden.json | 0 ...s_iam_user-test-driftctl-2.res.golden.json | 0 .../aws_iam_user_multiple/results.golden.json | 0 .../test/aws_iam_user_multiple/terraform.tf | 0 ...9_policy_test-loadbalancer.res.golden.json | 0 ..._policy_test-loadbalancer2.res.golden.json | 0 ..._policy_test-loadbalancer3.res.golden.json | 0 ..._policy_test2-loadbalancer.res.golden.json | 0 ...policy_test2-loadbalancer2.res.golden.json | 0 ...policy_test2-loadbalancer3.res.golden.json | 0 ..._policy_test3-loadbalancer.res.golden.json | 0 ...policy_test3-loadbalancer2.res.golden.json | 0 ...policy_test3-loadbalancer3.res.golden.json | 0 ..._policy_test4-loadbalancer.res.golden.json | 0 ...policy_test4-loadbalancer2.res.golden.json | 0 ...policy_test4-loadbalancer3.res.golden.json | 0 .../main.tf | 0 .../results.golden.json | 0 ..._policy-loadbalancer2_test.res.golden.json | 0 ...policy-loadbalancer2_test2.res.golden.json | 0 ...olicy-loadbalancer2_test22.res.golden.json | 0 ...olicy-loadbalancer2_test23.res.golden.json | 0 ...olicy-loadbalancer2_test24.res.golden.json | 0 ...policy-loadbalancer2_test3.res.golden.json | 0 ...policy-loadbalancer2_test4.res.golden.json | 0 ..._policy-loadbalancer3_test.res.golden.json | 0 ...policy-loadbalancer3_test2.res.golden.json | 0 ...olicy-loadbalancer3_test22.res.golden.json | 0 ...olicy-loadbalancer3_test23.res.golden.json | 0 ...olicy-loadbalancer3_test24.res.golden.json | 0 ...policy-loadbalancer3_test3.res.golden.json | 0 ...olicy-loadbalancer3_test32.res.golden.json | 0 ...olicy-loadbalancer3_test33.res.golden.json | 0 ...olicy-loadbalancer3_test34.res.golden.json | 0 ...policy-loadbalancer3_test4.res.golden.json | 0 ...r_policy-loadbalancer_test.res.golden.json | 0 ..._policy-loadbalancer_test2.res.golden.json | 0 ..._policy-loadbalancer_test3.res.golden.json | 0 ..._policy-loadbalancer_test4.res.golden.json | 0 .../test/aws_iam_user_policy_multiple/main.tf | 0 .../results.golden.json | 0 .../aws_kms_alias-alias_bar.res.golden.json | 0 ...20210225124429210500000001.res.golden.json | 0 .../aws_kms_alias-alias_foo.res.golden.json | 0 .../results.golden.json | 0 .../test/aws_kms_alias_multiple/terraform.tf | 0 ...fdc-4610-b6ab-f82db5d0601b.res.golden.json | 0 ...a53-40a5-b20a-d84905c622d7.res.golden.json | 0 ...000-428c-8032-235aac55da36.res.golden.json | 0 .../aws_kms_key_multiple/results.golden.json | 0 .../test/aws_kms_key_multiple/terraform.tf | 0 ...ws_lambda_function-bar-bar.res.golden.json | 0 ...ws_lambda_function-foo-foo.res.golden.json | 0 .../results.golden.json | 0 ...ws_lambda_function-foo-foo.res.golden.json | 0 .../aws_lambda_function_signed/lambda.zip | Bin .../test/aws_lambda_function_signed/main.tf | 0 .../results.golden.json | 0 ...60b-41c1-a9ae-dc304ebcdb00.res.golden.json | 0 .../results.golden.json | 0 ...7eb-4ad6-a0a8-594fea72df4f.res.golden.json | 0 ...9e9-4713-9d9d-5af2c01d9058.res.golden.json | 0 .../results.golden.json | 0 ...plate-lt-00b2d18c6cee7fe23.res.golden.json | 0 ...plate-lt-0ed993d09ce6afc67.res.golden.json | 0 .../results.golden.json | 0 ...o-2-aurora-cluster-demo-2-.res.golden.json | 0 ...o-aurora-cluster-demo-mydb.res.golden.json | 0 .../results.golden.json | 8 +- ...aws_db_instance-database-1.res.golden.json | 0 ...20201015115018309600000001.res.golden.json | 0 .../results.golden.json | 0 ...20201015115018309600000001.res.golden.json | 0 .../results.golden.json | 0 .../aws_db_subnet_group-bar.res.golden.json | 0 .../aws_db_subnet_group-foo.res.golden.json | 0 .../results.golden.json | 0 .../schema.golden.json | 0 ...ed4-4802-9909-668eb80b972b.res.golden.json | 0 ...e0d-41d6-b638-280e2f0f4e26.res.golden.json | 0 .../results.golden.json | 0 .../terraform.tf | 0 ...SBZTWFM__test2.foo-2.com_A.res.golden.json | 0 ...ZTWFM__test2.foo-2.com_TXT.res.golden.json | 0 ...486383UC8WYSBZTWFM_test0_A.res.golden.json | 0 ...6383UC8WYSBZTWFM_test0_TXT.res.golden.json | 0 ...YSBZTWFM_test1.foo-2.com_A.res.golden.json | 0 ...BZTWFM_test1.foo-2.com_TXT.res.golden.json | 0 .../main.tf | 0 .../results.golden.json | 0 .../schema.golden.json | 0 ...347383HV75H96J919W_test2_A.res.golden.json | 0 ...5360GLIB82T1EH2G__.test4_A.res.golden.json | 0 ...0GLIB82T1EH2G_foo-0.com_NS.res.golden.json | 0 ...035360GLIB82T1EH2G_test0_A.res.golden.json | 0 ...035360GLIB82T1EH2G_test1_A.res.golden.json | 0 ...035360GLIB82T1EH2G_test2_A.res.golden.json | 0 .../results.golden.json | 0 .../schema.golden.json | 0 .../aws_route53_zone_empty/schema.golden.json | 0 ...zone-Z01804312AV8PHE3C43AD.res.golden.json | 0 ...zone-Z01809283VH9BBALZHO7B.res.golden.json | 0 ...zone-Z01874941AR1TCGV5K65C.res.golden.json | 0 .../results.golden.json | 0 .../schema.golden.json | 0 .../aws_route53_zone_multiples/terraform.tf | 0 ...zone-Z08068311RGDXPHF8KE62.res.golden.json | 0 ..._zone-Z093553112BLINKY4N57.res.golden.json | 0 .../results.golden.json | 0 .../schema.golden.json | 0 .../test/aws_route53_zone_single/terraform.tf | 0 .../schema.golden.json | 0 ...alytics2_Bucket2-eu-west-3.res.golden.json | 0 ...nalytics_Bucket2-eu-west-3.res.golden.json | 0 .../results.golden.json | 0 ...ventory2_Bucket2-eu-west-3.res.golden.json | 0 ...nventory_Bucket2-eu-west-3.res.golden.json | 0 .../results.golden.json | 0 ..._Metric2_Bucket2-eu-west-3.res.golden.json | 0 ...2_Metric_Bucket2-eu-west-3.res.golden.json | 0 ...Metrics2_Bucket2-eu-west-3.res.golden.json | 0 ..._Metrics_Bucket2-eu-west-3.res.golden.json | 0 .../results.golden.json | 0 ...rtin-test-drift2-eu-west-3.res.golden.json | 0 .../test/aws_s3_bucket_multiple/main.tf | 0 .../results.golden.json | 0 ...rtin-test-drift2-eu-west-3.res.golden.json | 0 .../results.golden.json | 0 ...tctl-test-no-notifications.res.golden.json | 0 .../terraform.tf | 0 ...rtin-test-drift2-eu-west-3.res.golden.json | 0 .../results.golden.json | 0 .../terraform.tf | 0 ...4929923_user-updates-topic.res.golden.json | 0 ...929923_user-updates-topic2.res.golden.json | 0 ...929923_user-updates-topic3.res.golden.json | 0 .../test/aws_sns_topic_multiple/main.tf | 0 .../results.golden.json | 0 ...29923_my-topic-with-policy.res.golden.json | 0 ...9923_my-topic-with-policy2.res.golden.json | 0 .../results.golden.json | 0 ...009-4db4-9147-4c55959787fa.res.golden.json | 0 ...b31-4486-8d4b-2a2272264c8e.res.golden.json | 0 .../main.tf | 0 .../results.golden.json | 0 ....com_047081014315_bar.fifo.res.golden.json | 0 ...onaws.com_047081014315_foo.res.golden.json | 0 .../results.golden.json | 0 .../test/aws_sqs_queue_multiple/terraform.tf | 0 ....com_047081014315_bar.fifo.res.golden.json | 0 ...onaws.com_047081014315_baz.res.golden.json | 0 ...onaws.com_047081014315_foo.res.golden.json | 0 .../aws_sqs_queue_policy_multiple/policy.json | 0 .../results.golden.json | 0 .../terraform.tf | 0 ..._vpc-vpc-020b072316a95b97f.res.golden.json | 0 ..._vpc-vpc-02c50896b59598761.res.golden.json | 0 ..._vpc-vpc-0768e1fd0029e3fc3.res.golden.json | 0 .../aws_vpc-vpc-a8c5d4c1.res.golden.json | 0 .../remote/test/aws_vpc/results.golden.json | 0 .../remote/test/aws_vpc/terraform.tf | 0 ...security_group-sg-9e0204ff.res.golden.json | 0 .../results.golden.json | 0 .../terraform.tf | 0 ...-a74815c8-false--0-ingress.res.golden.json | 0 ...g-a74815c8-false--0-egress.res.golden.json | 0 .../results.golden.json | 0 ...group-sg-0254c038e32f25530.res.golden.json | 0 .../results.golden.json | 0 .../terraform.tf | 0 ...3c2851705a-false--0-egress.res.golden.json | 0 ...8e32f25530-false--0-egress.res.golden.json | 0 ...e32f25530-false--0-ingress.res.golden.json | 0 ...e32f25530-false--0-ingress.res.golden.json | 0 ...8e32f25530-false--0-egress.res.golden.json | 0 ...3c2851705a-false--0-egress.res.golden.json | 0 ...-sg-9e0204ff-65535-ingress.res.golden.json | 0 ...f25530-true--65535-ingress.res.golden.json | 0 ...851705a-false--443-ingress.res.golden.json | 0 ...e32f25530-false--0-ingress.res.golden.json | 0 ...3c2851705a-false--0-egress.res.golden.json | 0 .../results.golden.json | 0 ...6670ccbd8dd1d506289fd818c0.res.golden.json | 0 ...229fcfa091837deaa387bee9d8.res.golden.json | 0 .../results.golden.json | 4 +- ...ceptanceTestSecurityGroup1.res.golden.json | 0 ...ceptanceTestSecurityGroup2.res.golden.json | 0 .../results.golden.json | 4 +- ...estusingtf.com_A_othertest.res.golden.json | 0 ...sisatestusingtf.com_A_test.res.golden.json | 0 .../results.golden.json | 4 +- ...usingtf.com_AAAA_othertest.res.golden.json | 0 ...atestusingtf.com_AAAA_test.res.golden.json | 0 .../results.golden.json | 4 +- ...singtf.com_CNAME_othertest.res.golden.json | 0 ...testusingtf.com_CNAME_test.res.golden.json | 0 .../results.golden.json | 4 +- ...usingtf.com_MX_othertestmx.res.golden.json | 0 ...atestusingtf.com_MX_testmx.res.golden.json | 0 .../results.golden.json | 4 +- ...ateDnsZones_testmartin.com.res.golden.json | 0 ...nes_thisisatestusingtf.com.res.golden.json | 0 ...es_thisisatestusingtf2.com.res.golden.json | 0 .../results.golden.json | 12 +- ...ingtf.com_PTR_othertestptr.res.golden.json | 0 ...estusingtf.com_PTR_testptr.res.golden.json | 0 .../results.golden.json | 4 +- ...ingtf.com_SRV_othertestptr.res.golden.json | 0 ...estusingtf.com_SRV_testptr.res.golden.json | 0 .../results.golden.json | 4 +- ...ingtf.com_TXT_othertesttxt.res.golden.json | 0 ...estusingtf.com_TXT_testtxt.res.golden.json | 0 .../results.golden.json | 4 +- ..._sshPublicKeys_example-key.res.golden.json | 0 ...sshPublicKeys_example-key2.res.golden.json | 0 .../results.golden.json | 4 +- ...RlY3Rpb25SdWxlMTk1NDg0NzE=.res.golden.json | 0 ...RlY3Rpb25SdWxlMTk1NDg0NzI=.res.golden.json | 0 ...RlY3Rpb25SdWxlMTk1NDg0NzQ=.res.golden.json | 0 ...RlY3Rpb25SdWxlMTk1NDg0Nzc=.res.golden.json | 0 ...RlY3Rpb25SdWxlMTk1NDg0Nzg=.res.golden.json | 0 ...RlY3Rpb25SdWxlMTk1NDg0ODA=.res.golden.json | 0 .../results.golden.json | 0 .../terraform.tf | 0 ...driftctl-acceptance-tester.res.golden.json | 0 ...p-driftctl-test_eliecharra.res.golden.json | 0 .../results.golden.json | 0 ..._repository-driftctl-demos.res.golden.json | 0 ...github_repository-driftctl.res.golden.json | 0 .../results.golden.json | 0 ...driftctl-acceptance-tester.res.golden.json | 0 ..._membership-4570529_wbeuil.res.golden.json | 0 .../results.golden.json | 0 .../terraform.tf | 0 .../github_team-4556811.res.golden.json | 0 .../github_team-4556812.res.golden.json | 0 .../github_team-4556814.res.golden.json | 0 .../github_teams_multiple/results.golden.json | 0 ...wall-0-cloudskiff-dev-elie.res.golden.json | 0 ...wall-1-cloudskiff-dev-elie.res.golden.json | 0 ...wall-2-cloudskiff-dev-elie.res.golden.json | 0 .../results.golden.json | 6 +- .../test/google_compute_firewall/terraform.tf | 0 ...-dev-raphael-us-central1-a.res.golden.json | 0 ...-dev-raphael-us-central1-a.res.golden.json | 0 .../results.golden.json | 4 +- .../terraform.tf | 0 ...test-1-driftctl-unittest-1.res.golden.json | 0 ...test-2-driftctl-unittest-2.res.golden.json | 0 ...test-3-driftctl-unittest-3.res.golden.json | 0 .../results.golden.json | 18 +- ...est-1-driftctl-unittest-1-.res.golden.json | 0 ...est-2-driftctl-unittest-2-.res.golden.json | 0 ...est-3-driftctl-unittest-3-.res.golden.json | 0 .../results.golden.json | 12 +- .../results.golden.json | 0 ...test-1-driftctl-unittest-1.res.golden.json | 0 ...test-2-driftctl-unittest-2.res.golden.json | 0 ...test-3-driftctl-unittest-3.res.golden.json | 0 .../google_storage_bucket/results.golden.json | 0 .../results.golden.json | 0 {pkg => enumeration}/resource/aws/aws_alb.go | 0 .../resource/aws/aws_alb_listener.go | 0 enumeration/resource/aws/aws_ami.go | 11 + .../resource/aws/aws_api_gateway_account.go | 0 .../resource/aws/aws_api_gateway_api_key.go | 0 .../aws/aws_api_gateway_authorizer.go | 0 .../aws/aws_api_gateway_base_path_mapping.go | 0 .../aws/aws_api_gateway_deployment.go | 0 .../aws/aws_api_gateway_domain_name.go | 0 .../aws/aws_api_gateway_gateway_response.go | 0 .../aws/aws_api_gateway_integration.go | 0 .../aws_api_gateway_integration_response.go | 0 .../resource/aws/aws_api_gateway_method.go | 0 .../aws/aws_api_gateway_method_response.go | 0 .../aws/aws_api_gateway_method_settings.go | 0 .../resource/aws/aws_api_gateway_model.go | 0 .../aws/aws_api_gateway_request_validator.go | 0 .../resource/aws/aws_api_gateway_resource.go | 0 .../resource/aws/aws_api_gateway_rest_api.go | 0 .../aws/aws_api_gateway_rest_api_policy.go | 0 .../resource/aws/aws_api_gateway_stage.go | 0 .../resource/aws/aws_api_gateway_vpc_link.go | 0 .../resource/aws/aws_apigatewayv2_api.go | 0 .../aws/aws_apigatewayv2_authorizer.go | 0 .../aws/aws_apigatewayv2_deployment.go | 0 .../aws/aws_apigatewayv2_domain_name.go | 0 .../aws/aws_apigatewayv2_integration.go | 0 .../aws_apigatewayv2_integration_response.go | 0 .../resource/aws/aws_apigatewayv2_mapping.go | 2 +- .../resource/aws/aws_apigatewayv2_model.go | 2 +- .../resource/aws/aws_apigatewayv2_route.go | 0 .../aws/aws_apigatewayv2_route_response.go | 0 .../resource/aws/aws_apigatewayv2_stage.go | 0 .../resource/aws/aws_apigatewayv2_vpc_link.go | 0 .../resource/aws/aws_appautoscaling_policy.go | 2 +- .../aws_appautoscaling_scheduled_action.go | 0 .../resource/aws/aws_appautoscaling_target.go | 22 + .../resource/aws/aws_cloudformation_stack.go | 22 + .../aws/aws_cloudfront_distribution.go | 11 + enumeration/resource/aws/aws_db_instance.go | 11 + .../resource/aws/aws_db_subnet_group.go | 11 + .../resource/aws/aws_default_network_acl.go | 11 + .../resource/aws/aws_default_route_table.go | 2 +- .../aws/aws_default_security_group.go | 11 + .../resource/aws/aws_default_subnet.go | 11 + .../resource/aws/aws_default_vpc.go | 2 +- .../resource/aws/aws_dynamodb_table.go | 17 + .../aws/aws_ebs_encryption_by_default.go | 2 +- enumeration/resource/aws/aws_ebs_snapshot.go | 11 + enumeration/resource/aws/aws_ebs_volume.go | 11 + .../resource/aws/aws_ecr_repository.go | 10 + .../resource/aws/aws_ecr_repository_policy.go | 0 enumeration/resource/aws/aws_eip.go | 11 + .../resource/aws/aws_eip_association.go | 2 +- .../resource/aws/aws_elasticache_cluster.go | 0 {pkg => enumeration}/resource/aws/aws_elb.go | 0 .../resource/aws/aws_iam_access_key.go | 26 + .../resource/aws/aws_iam_group.go | 0 .../resource/aws/aws_iam_group_policy.go | 0 .../aws/aws_iam_group_policy_attachment.go | 0 enumeration/resource/aws/aws_iam_policy.go | 16 + .../resource/aws/aws_iam_policy_attachment.go | 11 + enumeration/resource/aws/aws_iam_role.go | 16 + .../resource/aws/aws_iam_role_policy.go | 2 +- .../aws/aws_iam_role_policy_attachment.go | 2 +- enumeration/resource/aws/aws_iam_user.go | 11 + .../resource/aws/aws_iam_user_policy.go | 2 +- .../aws/aws_iam_user_policy_attachment.go | 2 +- enumeration/resource/aws/aws_instance.go | 21 + .../resource/aws/aws_internet_gateway.go | 2 +- enumeration/resource/aws/aws_key_pair.go | 11 + enumeration/resource/aws/aws_kms_alias.go | 11 + enumeration/resource/aws/aws_kms_key.go | 16 + .../aws/aws_lambda_event_source_mapping.go | 22 + .../resource/aws/aws_lambda_function.go | 17 + .../resource/aws/aws_launch_configuration.go | 0 .../resource/aws/aws_launch_template.go | 2 +- {pkg => enumeration}/resource/aws/aws_lb.go | 2 +- .../resource/aws/aws_lb_listener.go | 0 .../resource/aws/aws_nat_gateway.go | 2 +- .../resource/aws/aws_network_acl.go | 2 +- .../resource/aws/aws_network_acl_rule.go | 69 ++ enumeration/resource/aws/aws_rds_cluster.go | 17 + .../resource/aws/aws_rds_cluster_instance.go | 0 enumeration/resource/aws/aws_route.go | 62 ++ .../resource/aws/aws_route53_health_check.go | 2 +- .../resource/aws/aws_route53_record.go | 25 + enumeration/resource/aws/aws_route53_zone.go | 19 + .../resource/aws/aws_route_table.go | 2 +- .../aws/aws_route_table_association.go | 2 +- enumeration/resource/aws/aws_s3_bucket.go | 21 + .../aws_s3_bucket_analytics_configuration.go | 2 +- .../resource/aws/aws_s3_bucket_inventory.go | 2 +- .../resource/aws/aws_s3_bucket_metric.go | 2 +- .../aws/aws_s3_bucket_notification.go | 2 +- .../resource/aws/aws_s3_bucket_policy.go | 21 + .../aws/aws_s3_bucket_public_access_block.go | 0 .../resource/aws/aws_security_group.go | 9 + .../resource/aws/aws_security_group_rule.go | 174 +++++ enumeration/resource/aws/aws_sns_topic.go | 33 + .../resource/aws/aws_sns_topic_policy.go | 22 + .../aws/aws_sns_topic_subscription.go | 26 + .../resource/aws/aws_sqs_queue.go | 2 +- .../resource/aws/aws_sqs_queue_policy.go | 16 + enumeration/resource/aws/aws_subnet.go | 11 + {pkg => enumeration}/resource/aws/aws_vpc.go | 2 +- .../resource/aws/metadata_test.go | 5 +- enumeration/resource/aws/metadatas.go | 70 ++ .../azurerm/azurerm_container_registry.go | 2 +- .../resource/azurerm/azurerm_firewall.go | 2 +- .../resource/azurerm/azurerm_image.go | 2 +- .../resource/azurerm/azurerm_lb.go | 2 +- .../resource/azurerm/azurerm_lb_rule.go | 21 + .../azurerm/azurerm_network_security_group.go | 17 + .../azurerm/azurerm_postgresql_database.go | 2 +- .../azurerm/azurerm_postgresql_server.go | 2 +- .../azurerm/azurerm_private_dns_a_record.go | 22 + .../azurerm_private_dns_aaaa_record.go | 22 + .../azurerm_private_dns_cname_record.go | 21 + .../azurerm/azurerm_private_dns_mx_record.go | 25 + .../azurerm/azurerm_private_dns_ptr_record.go | 22 + .../azurerm/azurerm_private_dns_srv_record.go | 22 + .../azurerm/azurerm_private_dns_txt_record.go | 22 + .../azurerm/azurerm_private_dns_zone.go | 11 + .../resource/azurerm/azurerm_public_ip.go | 2 +- .../azurerm/azurerm_resource_group.go | 2 +- .../resource/azurerm/azurerm_route.go | 2 +- .../resource/azurerm/azurerm_route_table.go | 2 +- .../azurerm/azurerm_ssh_public_key.go | 20 + .../azurerm/azurerm_storage_account.go | 0 .../azurerm/azurerm_storage_container.go | 0 .../resource/azurerm/azurerm_subnet.go | 0 .../azurerm/azurerm_virtual_network.go | 2 +- enumeration/resource/azurerm/metadata.go | 28 + .../resource/azurerm/metadata_test.go | 5 +- enumeration/resource/deserializer.go | 48 ++ .../github/github_branch_protection.go | 39 + .../resource/github/github_membership.go | 10 + .../resource/github/github_repository.go | 9 + enumeration/resource/github/github_team.go | 19 + .../resource/github/github_team_membership.go | 10 + .../resource/github/metadata_test.go | 5 +- enumeration/resource/github/metadatas.go | 11 + .../google/google_bigquery_dataset.go | 2 +- .../resource/google/google_bigquery_table.go | 2 +- .../google/google_bigtable_instance.go | 0 .../resource/google/google_bigtable_table.go | 0 .../google/google_cloudfunctions_function.go | 0 .../google/google_cloudrun_service.go | 0 .../resource/google/google_compute_address.go | 2 +- .../resource/google/google_compute_disk.go | 2 +- .../google/google_compute_firewall.go | 15 + .../google/google_compute_forwarding_rule.go | 0 .../google/google_compute_global_address.go | 2 +- .../google_compute_global_forwarding_rule.go | 0 .../google/google_compute_health_check.go | 2 +- .../resource/google/google_compute_image.go | 2 +- .../google/google_compute_instance.go | 0 .../google/google_compute_instance_group.go | 23 + .../google_compute_instance_group_manager.go | 2 +- .../resource/google/google_compute_network.go | 14 + .../google/google_compute_node_group.go | 0 .../resource/google/google_compute_router.go | 2 +- .../google/google_compute_subnetwork.go | 23 + .../google/google_dns_managed_zone.go | 0 .../google/google_project_iam_binding.go | 0 .../google/google_project_iam_member.go | 17 + .../google/google_project_iam_policy.go | 0 .../google/google_sql_database_instance.go | 0 .../resource/google/google_storage_bucket.go | 14 + .../google_storage_bucket_iam_binding.go | 0 .../google_storage_bucket_iam_member.go | 25 + .../google_storage_bucket_iam_policy.go | 0 .../resource/google/metadata_test.go | 5 +- enumeration/resource/google/metadatas.go | 22 + enumeration/resource/mock_Supplier.go | 33 + {pkg => enumeration}/resource/resource.go | 0 .../resource/resource_test.go | 0 .../resource/resource_types.go | 0 {pkg => enumeration}/resource/schemas.go | 0 enumeration/resource/supplier.go | 11 + .../error/provider_download_error.go | 0 .../terraform/lock/lockfile.go | 0 .../terraform/lock/lockfile_test.go | 0 .../lock/testdata/lockfile_empty.hcl | 0 .../lock/testdata/lockfile_invalid.hcl | 0 .../lock/testdata/lockfile_invalid_type-1.hcl | 0 .../lock/testdata/lockfile_invalid_type-3.hcl | 0 .../lock/testdata/lockfile_valid.hcl | 0 .../terraform/mock_ResourceFactory.go | 2 +- .../terraform/parallel_resource_reader.go | 3 +- .../parallel_resource_reader_test.go | 4 +- .../terraform/plugin_client.go | 0 .../terraform/provider_config.go | 0 .../terraform/provider_config_test.go | 0 .../terraform/provider_downloader.go | 6 +- .../terraform/provider_downloader_test.go | 3 +- .../terraform/provider_factory.go | 0 .../terraform/provider_installer.go | 6 +- .../terraform/provider_installer_test.go | 2 +- {pkg => enumeration}/terraform/providers.go | 0 .../terraform/resource_factory.go | 2 +- .../terraform/resource_reader.go | 2 +- .../terraform/schema_supplier.go | 0 .../terraform/terraform_provider.go | 0 .../terraform/testdata/invalid.zip | 0 ...rraform-provider-aws_3.5.0_linux_amd64.zip | Bin mocks/AlerterInterface.go | 2 +- pkg/analyser/analysis.go | 5 +- pkg/analyser/analyzer.go | 6 +- pkg/analyser/analyzer_test.go | 49 +- pkg/cmd/scan.go | 17 +- pkg/cmd/scan/output/console.go | 4 +- pkg/cmd/scan/output/console_test.go | 4 +- pkg/cmd/scan/output/html.go | 4 +- pkg/cmd/scan/output/html_test.go | 2 +- pkg/cmd/scan/output/output_test.go | 13 +- pkg/cmd/scan/output/plan.go | 2 +- pkg/driftctl.go | 10 +- pkg/driftctl_test.go | 54 +- pkg/filter/driftignore.go | 2 +- pkg/filter/driftignore_test.go | 2 +- pkg/filter/filter.go | 2 +- pkg/filter/filter_engine.go | 2 +- pkg/filter/filter_engine_test.go | 2 +- pkg/filter/mock_Filter.go | 2 +- pkg/helpers/interface.go | 34 - pkg/iac/supplier/IacChainSupplier.go | 10 +- pkg/iac/supplier/IacChainSupplier_test.go | 23 +- pkg/iac/supplier/supplier.go | 15 +- pkg/iac/supplier/supplier_test.go | 9 +- .../terraform/state/terraform_state_reader.go | 7 +- .../state/terraform_state_reader_test.go | 32 +- .../route53/.terraform.lock.hcl | 4 +- .../s3/.terraform.lock.hcl | 4 +- pkg/memstore/store_test.go | 2 +- .../aws_alb_listener_transformer.go | 4 +- .../aws_alb_listener_transformer_test.go | 6 +- pkg/middlewares/aws_alb_transformer.go | 4 +- pkg/middlewares/aws_alb_transformer_test.go | 6 +- .../aws_api_gateway_api_expander.go | 4 +- .../aws_api_gateway_api_expander_test.go | 6 +- ...pi_gateway_base_path_mapping_reconciler.go | 4 +- ...teway_base_path_mapping_reconciler_test.go | 4 +- .../aws_api_gateway_deployment_expander.go | 4 +- ...ws_api_gateway_deployment_expander_test.go | 7 +- ...aws_api_gateway_domain_names_reconciler.go | 4 +- ...pi_gateway_domain_names_reconciler_test.go | 4 +- .../aws_api_gateway_resource_expander.go | 4 +- .../aws_api_gateway_resource_expander_test.go | 7 +- ...ws_api_gateway_rest_api_policy_expander.go | 4 +- ...i_gateway_rest_api_policy_expander_test.go | 7 +- pkg/middlewares/aws_bucket_policy_expander.go | 4 +- .../aws_bucket_policy_expander_test.go | 7 +- ...ws_console_api_gateway_gateway_response.go | 4 +- ...nsole_api_gateway_gateway_response_test.go | 4 +- .../aws_default_api_gateway_account.go | 4 +- .../aws_default_api_gateway_account_test.go | 4 +- pkg/middlewares/aws_default_igw_route.go | 4 +- pkg/middlewares/aws_default_igw_route_test.go | 4 +- .../aws_default_internet_gateway.go | 4 +- .../aws_default_internet_gateway_test.go | 4 +- pkg/middlewares/aws_default_network_acl.go | 4 +- .../aws_default_network_acl_rule.go | 4 +- .../aws_default_network_acl_rule_test.go | 4 +- .../aws_default_network_acl_test.go | 4 +- pkg/middlewares/aws_default_route.go | 4 +- pkg/middlewares/aws_default_route_table.go | 4 +- .../aws_default_route_table_test.go | 4 +- pkg/middlewares/aws_default_route_test.go | 4 +- .../aws_default_security_group_rule.go | 4 +- .../aws_default_security_group_rule_test.go | 4 +- .../aws_default_sqs_queue_policy.go | 4 +- .../aws_default_sqs_queue_policy_test.go | 4 +- pkg/middlewares/aws_default_subnet.go | 4 +- pkg/middlewares/aws_default_vpc.go | 4 +- pkg/middlewares/aws_defaults.go | 4 +- pkg/middlewares/aws_defaults_test.go | 4 +- ...ws_ebs_encryption_by_default_reconciler.go | 4 +- ...s_encryption_by_default_reconciler_test.go | 7 +- .../aws_eip_association_expander.go | 4 +- .../aws_iam_policy_attachement_transformer.go | 4 +- ...iam_policy_attachement_transformer_test.go | 6 +- pkg/middlewares/aws_instance_block_device.go | 4 +- .../aws_instance_block_device_test.go | 4 +- pkg/middlewares/aws_instance_eip.go | 4 +- pkg/middlewares/aws_instance_eip_test.go | 4 +- pkg/middlewares/aws_nat_gateway_eip_assoc.go | 4 +- .../aws_nat_gateway_eip_assoc_test.go | 4 +- pkg/middlewares/aws_network_acl_expander.go | 4 +- .../aws_network_acl_expander_test.go | 6 +- .../aws_rds_cluster_instance_expander.go | 4 +- .../aws_rds_cluster_instance_expander_test.go | 6 +- .../aws_role_managed_policy_expander.go | 4 +- pkg/middlewares/aws_route_table_expander.go | 6 +- .../aws_route_table_expander_test.go | 6 +- ..._bucket_public_access_block_reconcilier.go | 4 +- ...et_public_access_block_reconcilier_test.go | 4 +- .../aws_sns_topic_policy_expander.go | 4 +- .../aws_sns_topic_policy_expander_test.go | 6 +- .../aws_sqs_queue_policy_expander.go | 4 +- .../aws_sqs_queue_policy_expander_test.go | 6 +- pkg/middlewares/azurerm_route_expander.go | 4 +- .../azurerm_route_expander_test.go | 6 +- pkg/middlewares/azurerm_subnet_expander.go | 4 +- .../azurerm_subnet_expander_test.go | 6 +- pkg/middlewares/chain_middleware.go | 2 +- pkg/middlewares/chain_middleware_test.go | 2 +- pkg/middlewares/default_vpc_test.go | 4 +- ...mpute_instance_group_manager_reconciler.go | 4 +- ..._instance_group_manager_reconciler_test.go | 4 +- pkg/middlewares/google_default_iam_member.go | 4 +- .../google_default_iam_member_test.go | 4 +- .../google_iam_binding_tranformer_test.go | 6 +- .../google_iam_binding_transformer.go | 4 +- .../google_iam_policy_tranformer_test.go | 6 +- .../google_iam_policy_transformer.go | 4 +- .../google_legacy_bucket_iam_member.go | 4 +- .../google_legacy_bucket_iam_member_test.go | 4 +- .../iam_policy_attachment_expander.go | 4 +- .../iam_policy_attachment_expander_test.go | 7 +- pkg/middlewares/middlewares.go | 2 +- pkg/middlewares/route53_records.go | 4 +- .../route53_records_id_reconcilier.go | 4 +- .../route53_records_id_reconcilier_test.go | 4 +- pkg/middlewares/route53_records_test.go | 4 +- pkg/middlewares/s3_bucket_acl.go | 4 +- pkg/middlewares/s3_bucket_acl_test.go | 4 +- pkg/middlewares/tags_all_manager.go | 2 +- pkg/middlewares/tags_all_manager_test.go | 2 +- pkg/middlewares/vpc_security_group_default.go | 4 +- .../vpc_security_group_default_test.go | 4 +- pkg/middlewares/vpc_security_group_rules.go | 4 +- .../vpc_security_group_rules_test.go | 6 +- pkg/resource/aws/aws_ami.go | 9 +- pkg/resource/aws/aws_appautoscaling_target.go | 23 +- pkg/resource/aws/aws_cloudformation_stack.go | 19 +- .../aws/aws_cloudfront_distribution.go | 8 +- .../aws/aws_cloudfront_distribution_test.go | 2 +- pkg/resource/aws/aws_db_instance.go | 8 +- pkg/resource/aws/aws_db_subnet_group.go | 8 +- pkg/resource/aws/aws_default_network_acl.go | 8 +- .../aws/aws_default_security_group.go | 8 +- pkg/resource/aws/aws_default_subnet.go | 8 +- pkg/resource/aws/aws_dynamodb_table.go | 14 +- pkg/resource/aws/aws_ebs_snapshot.go | 8 +- pkg/resource/aws/aws_ebs_volume.go | 8 +- pkg/resource/aws/aws_ecr_repository.go | 10 +- pkg/resource/aws/aws_ecr_repository_test.go | 2 +- pkg/resource/aws/aws_eip.go | 8 +- pkg/resource/aws/aws_iam_access_key.go | 22 +- pkg/resource/aws/aws_iam_policy.go | 13 +- pkg/resource/aws/aws_iam_policy_attachment.go | 8 +- pkg/resource/aws/aws_iam_role.go | 13 +- pkg/resource/aws/aws_iam_user.go | 8 +- pkg/resource/aws/aws_instance.go | 18 +- pkg/resource/aws/aws_instance_test.go | 2 +- pkg/resource/aws/aws_key_pair.go | 8 +- pkg/resource/aws/aws_kms_alias.go | 8 +- pkg/resource/aws/aws_kms_key.go | 13 +- .../aws/aws_lambda_event_source_mapping.go | 19 +- pkg/resource/aws/aws_lambda_function.go | 15 +- pkg/resource/aws/aws_network_acl_rule.go | 66 +- pkg/resource/aws/aws_rds_cluster.go | 14 +- pkg/resource/aws/aws_route.go | 59 +- .../aws/aws_route53_health_check_test.go | 2 +- pkg/resource/aws/aws_route53_record.go | 22 +- pkg/resource/aws/aws_route53_zone.go | 16 +- pkg/resource/aws/aws_s3_bucket.go | 18 +- pkg/resource/aws/aws_s3_bucket_policy.go | 18 +- pkg/resource/aws/aws_security_group.go | 12 +- pkg/resource/aws/aws_security_group_rule.go | 142 +--- pkg/resource/aws/aws_sns_topic.go | 34 +- pkg/resource/aws/aws_sns_topic_policy.go | 20 +- pkg/resource/aws/aws_sns_topic_policy_test.go | 4 +- .../aws/aws_sns_topic_subscription.go | 23 +- .../aws/aws_sns_topic_subscription_test.go | 4 +- pkg/resource/aws/aws_sns_topic_test.go | 7 +- pkg/resource/aws/aws_sqs_queue_policy.go | 13 +- pkg/resource/aws/aws_sqs_queue_test.go | 2 +- pkg/resource/aws/aws_subnet.go | 8 +- pkg/resource/aws/metadatas.go | 27 +- .../testdata/acc/aws_alb/.terraform.lock.hcl | 1 + .../acc/aws_alb_listener/.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 2 + .../.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 1 + .../aws_dynamodb_table/.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 1 + .../testdata/acc/aws_eip/.terraform.lock.hcl | 3 +- .../aws_eip_association/.terraform.lock.hcl | 3 +- .../testdata/acc/aws_elb/.terraform.lock.hcl | 1 + .../aws_iam_access_key/.terraform.lock.hcl | 3 +- .../acc/aws_iam_group/.terraform.lock.hcl | 1 + .../aws_iam_group_policy/.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 1 + .../acc/aws_iam_role/.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 1 + .../acc/aws_instance/.terraform.lock.hcl | 4 +- .../aws_instance_default/.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 1 + .../aws_launch_template/.terraform.lock.hcl | 1 + .../testdata/acc/aws_lb/.terraform.lock.hcl | 1 + .../acc/aws_lb_listener/.terraform.lock.hcl | 1 + .../acc/aws_nat_gateway/.terraform.lock.hcl | 1 + .../acc/aws_network_acl/.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 1 + .../acc/aws_route/.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 1 + .../aws_route53_record/.terraform.lock.hcl | 3 +- .../acc/aws_route_table/.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 1 + .../acc/aws_s3_bucket/.terraform.lock.hcl | 4 +- .../.terraform.lock.hcl | 2 + .../acc/aws_sns_topic/.terraform.lock.hcl | 1 + .../aws_sns_topic_policy/.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 1 + .../acc/aws_subnet/.terraform.lock.hcl | 1 + .../testdata/acc/aws_vpc/.terraform.lock.hcl | 1 + pkg/resource/azurerm/azurerm_lb_rule.go | 22 +- .../azurerm/azurerm_network_security_group.go | 18 +- .../azurerm/azurerm_private_dns_a_record.go | 19 +- .../azurerm_private_dns_aaaa_record.go | 19 +- .../azurerm_private_dns_cname_record.go | 22 +- .../azurerm/azurerm_private_dns_mx_record.go | 19 +- .../azurerm/azurerm_private_dns_ptr_record.go | 19 +- .../azurerm/azurerm_private_dns_srv_record.go | 19 +- .../azurerm/azurerm_private_dns_txt_record.go | 19 +- .../azurerm/azurerm_private_dns_zone.go | 8 +- .../azurerm/azurerm_ssh_public_key.go | 17 +- pkg/resource/azurerm/metadata.go | 13 +- .../acc/azurerm_image/.terraform.lock.hcl | 1 + .../acc/azurerm_lb_rule/.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 1 + pkg/resource/deserializer.go | 13 +- .../github/github_branch_protection.go | 35 +- pkg/resource/github/github_membership.go | 10 +- pkg/resource/github/github_repository.go | 10 +- pkg/resource/github/github_team.go | 19 +- pkg/resource/github/github_team_membership.go | 10 +- pkg/resource/github/metadatas.go | 2 +- .../.terraform.lock.hcl | 1 + .../acc/github_repository/.terraform.lock.hcl | 1 + .../acc/github_team/.terraform.lock.hcl | 1 + .../google/google_compute_firewall.go | 16 +- .../google/google_compute_instance_group.go | 24 +- pkg/resource/google/google_compute_network.go | 15 +- .../google/google_compute_subnetwork.go | 24 +- .../google/google_project_iam_member.go | 18 +- pkg/resource/google/google_storage_bucket.go | 15 +- .../google_storage_bucket_iam_member.go | 26 +- pkg/resource/google/metadatas.go | 11 +- .../.terraform.lock.hcl | 1 + .../google_bigquery_table/.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 1 + .../google_bigtable_table/.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 2 + .../.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 1 + .../google_compute_disk/.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 1 + .../google_compute_image/.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 2 + .../.terraform.lock.hcl | 2 + .../google_compute_router/.terraform.lock.hcl | 1 + .../.terraform.lock.hcl | 2 + .../.terraform.lock.hcl | 2 + .../.terraform.lock.hcl | 2 + .../google_storage_bucket/.terraform.lock.hcl | 2 + pkg/resource/init_metadatas.go | 29 + pkg/resource/mock_IaCSupplier.go | 13 +- pkg/resource/mock_Supplier.go | 9 +- pkg/resource/supplier.go | 12 +- pkg/telemetry/telemetry_test.go | 2 +- test/cty_test_diff.go | 6 +- test/mocks/MockGoldenTerraformProvider.go | 16 +- test/remote/scanner.go | 2 +- test/resource/resource.go | 2 +- test/terraform/fake_terraform_provider.go | 2 +- test/terraform/provider.go | 10 +- test/terraform/schemas_test.go | 3 +- test/test_diff.go | 5 +- 1266 files changed, 5967 insertions(+), 4923 deletions(-) rename {pkg => enumeration}/alerter/alert.go (100%) rename {pkg => enumeration}/alerter/alerter.go (96%) rename {pkg => enumeration}/alerter/alerter_test.go (98%) create mode 100644 enumeration/filter.go create mode 100644 enumeration/mock_Filter.go rename {pkg => enumeration}/parallel/parallel_runner.go (100%) rename {pkg => enumeration}/parallel/parallel_runner_test.go (100%) create mode 100644 enumeration/progress.go rename {pkg => enumeration}/remote/alerts/alerts.go (94%) rename {pkg => enumeration}/remote/aws/api_gateway_account_enumerator.go (81%) rename {pkg => enumeration}/remote/aws/api_gateway_api_key_enumerator.go (81%) rename {pkg => enumeration}/remote/aws/api_gateway_authorizer_enumerator.go (85%) rename {pkg => enumeration}/remote/aws/api_gateway_base_path_mapping_enumerator.go (87%) rename {pkg => enumeration}/remote/aws/api_gateway_domain_name_enumerator.go (82%) rename {pkg => enumeration}/remote/aws/api_gateway_gateway_response_enumerator.go (86%) rename {pkg => enumeration}/remote/aws/api_gateway_integration_enumerator.go (86%) rename {pkg => enumeration}/remote/aws/api_gateway_integration_response_enumerator.go (88%) rename {pkg => enumeration}/remote/aws/api_gateway_method_enumerator.go (86%) rename {pkg => enumeration}/remote/aws/api_gateway_method_response_enumerator.go (87%) rename {pkg => enumeration}/remote/aws/api_gateway_method_settings_enumerator.go (86%) rename {pkg => enumeration}/remote/aws/api_gateway_model_enumerator.go (84%) rename {pkg => enumeration}/remote/aws/api_gateway_request_validator_enumerator.go (85%) rename {pkg => enumeration}/remote/aws/api_gateway_resource_enumerator.go (85%) rename {pkg => enumeration}/remote/aws/api_gateway_rest_api_enumerator.go (81%) rename {pkg => enumeration}/remote/aws/api_gateway_rest_api_policy_enumerator.go (83%) rename {pkg => enumeration}/remote/aws/api_gateway_stage_enumerator.go (85%) rename {pkg => enumeration}/remote/aws/api_gateway_vpc_link_enumerator.go (81%) rename {pkg => enumeration}/remote/aws/apigatewayv2_api_enumerator.go (81%) rename {pkg => enumeration}/remote/aws/apigatewayv2_authorizer_enumerator.go (85%) rename {pkg => enumeration}/remote/aws/apigatewayv2_deployment_enumerator.go (85%) rename {pkg => enumeration}/remote/aws/apigatewayv2_domain_name_enumerator.go (84%) rename {pkg => enumeration}/remote/aws/apigatewayv2_integration_enumerator.go (87%) rename {pkg => enumeration}/remote/aws/apigatewayv2_integration_response_enumerator.go (88%) rename {pkg => enumeration}/remote/aws/apigatewayv2_mapping_enumerator.go (71%) rename {pkg => enumeration}/remote/aws/apigatewayv2_model_enumerator.go (84%) rename {pkg => enumeration}/remote/aws/apigatewayv2_route_enumerator.go (85%) rename {pkg => enumeration}/remote/aws/apigatewayv2_route_response_enumerator.go (87%) rename {pkg => enumeration}/remote/aws/apigatewayv2_stage_enumerator.go (84%) rename {pkg => enumeration}/remote/aws/apigatewayv2_vpc_link_enumerator.go (81%) rename {pkg => enumeration}/remote/aws/appautoscaling_policy_enumerator.go (85%) rename {pkg => enumeration}/remote/aws/appautoscaling_scheduled_action_enumerator.go (84%) rename {pkg => enumeration}/remote/aws/appautoscaling_target_enumerator.go (85%) rename {pkg => enumeration}/remote/aws/classic_loadbalancer_enumerator.go (81%) rename {pkg => enumeration}/remote/aws/client/mock_AwsClientFactoryInterface.go (100%) rename {pkg => enumeration}/remote/aws/client/s3_client_factory.go (100%) rename {pkg => enumeration}/remote/aws/cloudformation_stack_enumerator.go (86%) rename {pkg => enumeration}/remote/aws/cloudfront_distribution_enumerator.go (82%) rename {pkg => enumeration}/remote/aws/default_vpc_enumerator.go (80%) rename {pkg => enumeration}/remote/aws/dynamodb_table_enumerator.go (80%) rename {pkg => enumeration}/remote/aws/ebs_encryption_by_default_enumerator.go (82%) rename {pkg => enumeration}/remote/aws/ec2_ami_enumerator.go (79%) rename {pkg => enumeration}/remote/aws/ec2_default_network_acl_enumerator.go (83%) rename {pkg => enumeration}/remote/aws/ec2_default_route_table_enumerator.go (82%) rename {pkg => enumeration}/remote/aws/ec2_default_subnet_enumerator.go (81%) rename {pkg => enumeration}/remote/aws/ec2_ebs_snapshot_enumerator.go (81%) rename {pkg => enumeration}/remote/aws/ec2_ebs_volume_enumerator.go (80%) rename {pkg => enumeration}/remote/aws/ec2_eip_association_enumerator.go (82%) rename {pkg => enumeration}/remote/aws/ec2_eip_enumerator.go (82%) rename {pkg => enumeration}/remote/aws/ec2_instance_enumerator.go (80%) rename {pkg => enumeration}/remote/aws/ec2_internet_gateway_enumerator.go (84%) rename {pkg => enumeration}/remote/aws/ec2_key_pair_enumerator.go (80%) rename {pkg => enumeration}/remote/aws/ec2_nat_gateway_enumerator.go (83%) rename {pkg => enumeration}/remote/aws/ec2_network_acl_enumerator.go (82%) rename {pkg => enumeration}/remote/aws/ec2_network_acl_rule_enumerator.go (80%) rename {pkg => enumeration}/remote/aws/ec2_route_enumerator.go (89%) rename {pkg => enumeration}/remote/aws/ec2_route_table_association_enumerator.go (88%) rename {pkg => enumeration}/remote/aws/ec2_route_table_enumerator.go (84%) rename {pkg => enumeration}/remote/aws/ec2_subnet_enumerator.go (80%) rename {pkg => enumeration}/remote/aws/ecr_repository_enumerator.go (80%) rename {pkg => enumeration}/remote/aws/ecr_repository_policy_enumerator.go (85%) rename {pkg => enumeration}/remote/aws/elasticache_cluster_enumerator.go (82%) rename {pkg => enumeration}/remote/aws/iam_access_key_enumerator.go (82%) rename {pkg => enumeration}/remote/aws/iam_group_enumerator.go (80%) rename {pkg => enumeration}/remote/aws/iam_group_policy_attachment_enumerator.go (85%) rename {pkg => enumeration}/remote/aws/iam_group_policy_enumerator.go (83%) rename {pkg => enumeration}/remote/aws/iam_policy_enumerator.go (81%) rename {pkg => enumeration}/remote/aws/iam_role_enumerator.go (85%) rename {pkg => enumeration}/remote/aws/iam_role_policy_attachment_enumerator.go (87%) rename {pkg => enumeration}/remote/aws/iam_role_policy_enumerator.go (83%) rename {pkg => enumeration}/remote/aws/iam_user_enumerator.go (81%) rename {pkg => enumeration}/remote/aws/iam_user_policy_attachment_enumerator.go (85%) rename {pkg => enumeration}/remote/aws/iam_user_policy_enumerator.go (83%) rename {pkg => enumeration}/remote/aws/init.go (62%) rename {pkg => enumeration}/remote/aws/kms_alias_enumerator.go (80%) rename {pkg => enumeration}/remote/aws/kms_key_enumerator.go (79%) rename {pkg => enumeration}/remote/aws/lambda_event_source_mapping_enumerator.go (82%) rename {pkg => enumeration}/remote/aws/lambda_function_enumerator.go (80%) rename {pkg => enumeration}/remote/aws/launch_configuration_enumerator.go (82%) rename {pkg => enumeration}/remote/aws/launch_template_enumerator.go (81%) rename {pkg => enumeration}/remote/aws/load_balancer_enumerator.go (81%) rename {pkg => enumeration}/remote/aws/load_balancer_listener_enumerator.go (85%) rename {pkg => enumeration}/remote/aws/provider.go (92%) rename {pkg => enumeration}/remote/aws/rds_cluster_enumerator.go (83%) rename {pkg => enumeration}/remote/aws/rds_db_instance_enumerator.go (81%) rename {pkg => enumeration}/remote/aws/rds_db_subnet_group_enumerator.go (81%) rename {pkg => enumeration}/remote/aws/repository/api_gateway_repository.go (99%) rename {pkg => enumeration}/remote/aws/repository/api_gateway_repository_test.go (99%) rename {pkg => enumeration}/remote/aws/repository/apigatewayv2_repository.go (99%) rename {pkg => enumeration}/remote/aws/repository/apigatewayv2_repository_test.go (99%) rename {pkg => enumeration}/remote/aws/repository/appautoscaling_repository.go (98%) rename {pkg => enumeration}/remote/aws/repository/appautoscaling_repository_test.go (99%) rename {pkg => enumeration}/remote/aws/repository/autoscaling_repository.go (95%) rename {pkg => enumeration}/remote/aws/repository/autoscaling_repository_test.go (98%) rename {pkg => enumeration}/remote/aws/repository/cloudformation_repository.go (95%) rename {pkg => enumeration}/remote/aws/repository/cloudformation_repository_test.go (97%) rename {pkg => enumeration}/remote/aws/repository/cloudfront_repository.go (95%) rename {pkg => enumeration}/remote/aws/repository/cloudfront_repository_test.go (98%) rename {pkg => enumeration}/remote/aws/repository/dynamodb_repository.go (94%) rename {pkg => enumeration}/remote/aws/repository/dynamodb_repository_test.go (97%) rename {pkg => enumeration}/remote/aws/repository/ec2_repository.go (99%) rename {pkg => enumeration}/remote/aws/repository/ec2_repository_test.go (98%) rename {pkg => enumeration}/remote/aws/repository/ecr_repository.go (97%) rename {pkg => enumeration}/remote/aws/repository/ecr_repository_test.go (98%) rename {pkg => enumeration}/remote/aws/repository/elasticache_repository.go (95%) rename {pkg => enumeration}/remote/aws/repository/elasticache_repository_test.go (98%) rename {pkg => enumeration}/remote/aws/repository/elb_repository.go (95%) rename {pkg => enumeration}/remote/aws/repository/elb_repository_test.go (98%) rename {pkg => enumeration}/remote/aws/repository/elbv2_repository.go (97%) rename {pkg => enumeration}/remote/aws/repository/elbv2_repository_test.go (99%) rename {pkg => enumeration}/remote/aws/repository/iam_repository.go (99%) rename {pkg => enumeration}/remote/aws/repository/iam_repository_test.go (99%) rename {pkg => enumeration}/remote/aws/repository/kms_repository.go (98%) rename {pkg => enumeration}/remote/aws/repository/kms_repository_test.go (99%) rename {pkg => enumeration}/remote/aws/repository/lambda_repository.go (97%) rename {pkg => enumeration}/remote/aws/repository/lambda_repository_test.go (98%) rename {pkg => enumeration}/remote/aws/repository/mock_ApiGatewayRepository.go (100%) rename {pkg => enumeration}/remote/aws/repository/mock_ApiGatewayV2Repository.go (100%) rename {pkg => enumeration}/remote/aws/repository/mock_AppAutoScalingRepository.go (100%) rename {pkg => enumeration}/remote/aws/repository/mock_AutoScalingRepository.go (100%) rename {pkg => enumeration}/remote/aws/repository/mock_CloudformationRepository.go (100%) rename {pkg => enumeration}/remote/aws/repository/mock_CloudfrontRepository.go (100%) rename {pkg => enumeration}/remote/aws/repository/mock_DynamoDBRepository.go (100%) rename {pkg => enumeration}/remote/aws/repository/mock_EC2Repository.go (100%) rename {pkg => enumeration}/remote/aws/repository/mock_ECRRepository.go (100%) rename {pkg => enumeration}/remote/aws/repository/mock_ELBRepository.go (100%) rename {pkg => enumeration}/remote/aws/repository/mock_ELBV2Repository.go (100%) rename {pkg => enumeration}/remote/aws/repository/mock_ElastiCacheRepository.go (100%) rename {pkg => enumeration}/remote/aws/repository/mock_IAMRepository.go (100%) rename {pkg => enumeration}/remote/aws/repository/mock_KMSRepository.go (100%) rename {pkg => enumeration}/remote/aws/repository/mock_LambdaRepository.go (100%) rename {pkg => enumeration}/remote/aws/repository/mock_RDSRepository.go (100%) rename {pkg => enumeration}/remote/aws/repository/mock_Route53Repository.go (100%) rename {pkg => enumeration}/remote/aws/repository/mock_S3Repository.go (100%) rename {pkg => enumeration}/remote/aws/repository/mock_SNSRepository.go (100%) rename {pkg => enumeration}/remote/aws/repository/mock_SQSRepository.go (100%) rename {pkg => enumeration}/remote/aws/repository/rds_repository.go (97%) rename {pkg => enumeration}/remote/aws/repository/rds_repository_test.go (95%) rename {pkg => enumeration}/remote/aws/repository/route53_repository.go (97%) rename {pkg => enumeration}/remote/aws/repository/route53_repository_test.go (99%) rename {pkg => enumeration}/remote/aws/repository/s3_repository.go (98%) rename {pkg => enumeration}/remote/aws/repository/s3_repository_test.go (99%) rename {pkg => enumeration}/remote/aws/repository/sns_repository.go (96%) rename {pkg => enumeration}/remote/aws/repository/sns_repository_test.go (98%) rename {pkg => enumeration}/remote/aws/repository/sqs_repository.go (96%) rename {pkg => enumeration}/remote/aws/repository/sqs_repository_test.go (98%) rename {pkg => enumeration}/remote/aws/route53_health_check_enumerator.go (81%) rename {pkg => enumeration}/remote/aws/route53_record_enumerator.go (90%) rename {pkg => enumeration}/remote/aws/route53_zone_enumerator.go (80%) rename {pkg => enumeration}/remote/aws/s3_bucket_analytic_enumerator.go (82%) rename {pkg => enumeration}/remote/aws/s3_bucket_enumerator.go (78%) rename {pkg => enumeration}/remote/aws/s3_bucket_inventory_enumerator.go (83%) rename {pkg => enumeration}/remote/aws/s3_bucket_metrics_enumerator.go (82%) rename {pkg => enumeration}/remote/aws/s3_bucket_notification_enumerator.go (83%) rename {pkg => enumeration}/remote/aws/s3_bucket_policy_enumerator.go (82%) rename {pkg => enumeration}/remote/aws/s3_bucket_public_access_block_enumerator.go (84%) rename {pkg => enumeration}/remote/aws/sns_topic_enumerator.go (80%) rename {pkg => enumeration}/remote/aws/sns_topic_policy_enumerator.go (81%) rename {pkg => enumeration}/remote/aws/sns_topic_subscription_enumerator.go (88%) rename {pkg => enumeration}/remote/aws/sqs_queue_details_fetcher.go (84%) rename {pkg => enumeration}/remote/aws/sqs_queue_enumerator.go (81%) rename {pkg => enumeration}/remote/aws/sqs_queue_policy_enumerator.go (88%) rename {pkg => enumeration}/remote/aws/test/analytics_inventory_nometrics/aws_s3_bucket-bucket-martin-test-drift.res.golden.json (100%) rename {pkg => enumeration}/remote/aws/test/analytics_inventory_nometrics/aws_s3_bucket_analytics_configuration-bucket-martin-test-drift_Analytics_Bucket.res.golden.json (100%) rename {pkg => enumeration}/remote/aws/test/analytics_inventory_nometrics/aws_s3_bucket_inventory-bucket-martin-test-drift_Inventory_Bucket.res.golden.json (100%) rename {pkg => enumeration}/remote/aws/test/analytics_inventory_nometrics/aws_s3_bucket_notification-bucket-martin-test-drift.res.golden.json (100%) rename {pkg => enumeration}/remote/aws/test/analytics_inventory_nometrics/aws_s3_bucket_policy-bucket-martin-test-drift.res.golden.json (100%) rename {pkg => enumeration}/remote/aws/test/analytics_inventory_nometrics/results.golden.json (100%) rename {pkg => enumeration}/remote/aws/test/analytics_inventory_nometrics/schema.golden.json (100%) rename {pkg => enumeration}/remote/aws/test/s3_bucket_list/aws_s3_bucket_inventory-bucket-martin-test-drift2_Inventory2_Bucket2.res.golden.json (100%) rename {pkg => enumeration}/remote/aws/test/s3_bucket_list/aws_s3_bucket_inventory-bucket-martin-test-drift2_Inventory_Bucket2.res.golden.json (100%) rename {pkg => enumeration}/remote/aws/test/s3_bucket_list/results.golden.json (100%) rename {pkg => enumeration}/remote/aws/test/s3_bucket_list/schema.golden.json (100%) rename {pkg => enumeration}/remote/aws/vpc_default_security_group_enumerator.go (82%) rename {pkg => enumeration}/remote/aws/vpc_enumerator.go (78%) rename {pkg => enumeration}/remote/aws/vpc_security_group_enumerator.go (81%) rename {pkg => enumeration}/remote/aws/vpc_security_group_rule_enumerator.go (95%) rename {pkg => enumeration}/remote/aws_api_gateway_scanner_test.go (71%) rename {pkg => enumeration}/remote/aws_apigatewayv2_scanner_test.go (70%) rename {pkg => enumeration}/remote/aws_applicationautoscaling_scanner_test.go (76%) rename {pkg => enumeration}/remote/aws_autoscaling_scanner_test.go (66%) rename {pkg => enumeration}/remote/aws_cloudformation_scanner_test.go (65%) rename {pkg => enumeration}/remote/aws_cloudfront_scanner_test.go (64%) rename {pkg => enumeration}/remote/aws_dynamodb_scanner_test.go (63%) rename {pkg => enumeration}/remote/aws_ec2_scanner_test.go (73%) rename {pkg => enumeration}/remote/aws_ecr_scanner_test.go (68%) rename {pkg => enumeration}/remote/aws_elasticache_scanner_test.go (65%) rename {pkg => enumeration}/remote/aws_elb_scanner_test.go (66%) rename {pkg => enumeration}/remote/aws_elbv2_scanner_test.go (69%) rename {pkg => enumeration}/remote/aws_iam_scanner_test.go (73%) rename {pkg => enumeration}/remote/aws_kms_scanner_test.go (65%) rename {pkg => enumeration}/remote/aws_lambda_scanner_test.go (66%) rename {pkg => enumeration}/remote/aws_rds_scanner_test.go (66%) rename {pkg => enumeration}/remote/aws_route53_scanner_test.go (70%) rename {pkg => enumeration}/remote/aws_s3_scanner_test.go (72%) rename {pkg => enumeration}/remote/aws_sns_scanner_test.go (67%) rename {pkg => enumeration}/remote/aws_sqs_scanner_test.go (69%) rename {pkg => enumeration}/remote/azurerm/azurerm_container_registry_enumerator.go (82%) rename {pkg => enumeration}/remote/azurerm/azurerm_firewalls_enumerator.go (81%) rename {pkg => enumeration}/remote/azurerm/azurerm_image_enumerator.go (86%) rename {pkg => enumeration}/remote/azurerm/azurerm_lb_enumerator.go (81%) rename {pkg => enumeration}/remote/azurerm/azurerm_lb_rule_enumerator.go (85%) rename {pkg => enumeration}/remote/azurerm/azurerm_network_security_group_enumerator.go (83%) rename {pkg => enumeration}/remote/azurerm/azurerm_postgresql_database_enumerator.go (85%) rename {pkg => enumeration}/remote/azurerm/azurerm_postgresql_server_enumerator.go (81%) rename {pkg => enumeration}/remote/azurerm/azurerm_private_dns_cname_record_enumerator.go (85%) rename {pkg => enumeration}/remote/azurerm/azurerm_privatedns_a_record_enumerator.go (85%) rename {pkg => enumeration}/remote/azurerm/azurerm_privatedns_aaaa_record_enumerator.go (85%) rename {pkg => enumeration}/remote/azurerm/azurerm_privatedns_mx_record_enumerator.go (85%) rename {pkg => enumeration}/remote/azurerm/azurerm_privatedns_ptr_record_enumerator.go (85%) rename {pkg => enumeration}/remote/azurerm/azurerm_privatedns_srv_record_enumerator.go (85%) rename {pkg => enumeration}/remote/azurerm/azurerm_privatedns_txt_record_enumerator.go (85%) rename {pkg => enumeration}/remote/azurerm/azurerm_privatedns_zone_enumerator.go (81%) rename {pkg => enumeration}/remote/azurerm/azurerm_public_ip_enumerator.go (81%) rename {pkg => enumeration}/remote/azurerm/azurerm_resource_group_enumerator.go (81%) rename {pkg => enumeration}/remote/azurerm/azurerm_route_enumerator.go (83%) rename {pkg => enumeration}/remote/azurerm/azurerm_route_table_enumerator.go (81%) rename {pkg => enumeration}/remote/azurerm/azurerm_ssh_public_key_enumerator.go (81%) rename {pkg => enumeration}/remote/azurerm/azurerm_storage_account_enumerator.go (81%) rename {pkg => enumeration}/remote/azurerm/azurerm_storage_container_enumerator.go (84%) rename {pkg => enumeration}/remote/azurerm/azurerm_subnets_enumerator.go (83%) rename {pkg => enumeration}/remote/azurerm/azurerm_virtual_network_enumerator.go (81%) rename {pkg => enumeration}/remote/azurerm/common/config.go (100%) rename {pkg => enumeration}/remote/azurerm/init.go (62%) rename {pkg => enumeration}/remote/azurerm/provider.go (83%) rename {pkg => enumeration}/remote/azurerm/repository/compute.go (96%) rename {pkg => enumeration}/remote/azurerm/repository/compute_test.go (99%) rename {pkg => enumeration}/remote/azurerm/repository/containerregistry.go (94%) rename {pkg => enumeration}/remote/azurerm/repository/containerregistry_test.go (98%) rename {pkg => enumeration}/remote/azurerm/repository/mock_ComputeRepository.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_ContainerRegistryRepository.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_NetworkRepository.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_PostgresqlRespository.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_PrivateDNSRepository.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_ResourcesRepository.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_StorageRespository.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_blobContainerClient.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_blobContainerListPager.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_firewallsClient.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_firewallsListAllPager.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_imagesClient.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_imagesListPager.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_loadBalancerRulesClient.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_loadBalancerRulesListAllPager.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_loadBalancersClient.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_loadBalancersListAllPager.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_networkSecurityGroupsClient.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_networkSecurityGroupsListAllPager.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_postgresqlDatabaseClient.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_postgresqlServersClient.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_privateDNSRecordSetListPager.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_privateDNSZoneListPager.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_privateRecordSetClient.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_privateZonesClient.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_publicIPAddressesClient.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_publicIPAddressesListAllPager.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_registryClient.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_registryListAllPager.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_resourcesClient.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_resourcesListPager.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_routeTablesClient.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_routeTablesListAllPager.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_sshPublicKeyClient.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_sshPublicKeyListPager.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_storageAccountClient.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_storageAccountListPager.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_subnetsClient.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_subnetsListPager.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_virtualNetworkClient.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/mock_virtualNetworksListAllPager.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/network.go (99%) rename {pkg => enumeration}/remote/azurerm/repository/network_test.go (95%) rename {pkg => enumeration}/remote/azurerm/repository/pager.go (100%) rename {pkg => enumeration}/remote/azurerm/repository/postgresql.go (96%) rename {pkg => enumeration}/remote/azurerm/repository/postgresql_test.go (99%) rename {pkg => enumeration}/remote/azurerm/repository/privatedns.go (98%) rename {pkg => enumeration}/remote/azurerm/repository/privatedns_test.go (98%) rename {pkg => enumeration}/remote/azurerm/repository/resources.go (93%) rename {pkg => enumeration}/remote/azurerm/repository/resources_test.go (98%) rename {pkg => enumeration}/remote/azurerm/repository/storage.go (96%) rename {pkg => enumeration}/remote/azurerm/repository/storage_test.go (97%) rename {pkg => enumeration}/remote/azurerm_compute_scanner_test.go (74%) rename {pkg => enumeration}/remote/azurerm_containerregistry_scanner_test.go (72%) rename {pkg => enumeration}/remote/azurerm_network_scanner_test.go (77%) rename {pkg => enumeration}/remote/azurerm_postgresql_scanner_test.go (77%) rename {pkg => enumeration}/remote/azurerm_privatedns_scanner_test.go (80%) rename {pkg => enumeration}/remote/azurerm_resources_scanner_test.go (72%) rename {pkg => enumeration}/remote/azurerm_storage_scanner_test.go (79%) rename {pkg => enumeration}/remote/cache/cache.go (100%) rename {pkg => enumeration}/remote/cache/cache_test.go (98%) rename {pkg => enumeration}/remote/cache/mock_Cache.go (100%) rename {pkg => enumeration}/remote/common/details_fetcher.go (89%) rename {pkg => enumeration}/remote/common/library.go (94%) rename {pkg => enumeration}/remote/common/mock_Enumerator.go (94%) rename {pkg => enumeration}/remote/common/providers.go (85%) rename {pkg => enumeration}/remote/error/errors.go (100%) rename {pkg => enumeration}/remote/github/github_branch_protection_enumerator.go (85%) rename {pkg => enumeration}/remote/github/github_membership_enumerator.go (84%) rename {pkg => enumeration}/remote/github/github_repository_enumerator.go (84%) rename {pkg => enumeration}/remote/github/github_team_enumerator.go (85%) rename {pkg => enumeration}/remote/github/github_team_membership_enumerator.go (85%) rename {pkg => enumeration}/remote/github/init.go (63%) rename {pkg => enumeration}/remote/github/mock_GithubRepository.go (100%) rename {pkg => enumeration}/remote/github/provider.go (78%) rename {pkg => enumeration}/remote/github/repository.go (99%) rename {pkg => enumeration}/remote/github/repository_test.go (99%) rename {pkg => enumeration}/remote/github_branch_protection_scanner_test.go (52%) rename {pkg => enumeration}/remote/github_membership_scanner_test.go (58%) rename {pkg => enumeration}/remote/github_repository_scanner_test.go (58%) rename {pkg => enumeration}/remote/github_team_membership_scanner_test.go (58%) rename {pkg => enumeration}/remote/github_team_scanner_test.go (56%) rename {pkg => enumeration}/remote/google/config/config.go (100%) rename {pkg => enumeration}/remote/google/google_bigquery_dataset_enumerator.go (82%) rename {pkg => enumeration}/remote/google/google_bigquery_table_enumerator.go (82%) rename {pkg => enumeration}/remote/google/google_bigtable_instance_enumerator.go (84%) rename {pkg => enumeration}/remote/google/google_bigtable_table_enumerator.go (84%) rename {pkg => enumeration}/remote/google/google_cloudfunctions_function_enumerator.go (85%) rename {pkg => enumeration}/remote/google/google_cloudrun_service_enumerator.go (86%) rename {pkg => enumeration}/remote/google/google_compute_address_enumerator.go (85%) rename {pkg => enumeration}/remote/google/google_compute_disk_enumerator.go (81%) rename {pkg => enumeration}/remote/google/google_compute_firewall_enumerator.go (85%) rename {pkg => enumeration}/remote/google/google_compute_forwarding_rule_enumerator.go (82%) rename {pkg => enumeration}/remote/google/google_compute_global_address_enumerator.go (86%) rename {pkg => enumeration}/remote/google/google_compute_global_forwarding_rule_enumerator.go (83%) rename {pkg => enumeration}/remote/google/google_compute_health_check_enumerator.go (82%) rename {pkg => enumeration}/remote/google/google_compute_image_enumerator.go (82%) rename {pkg => enumeration}/remote/google/google_compute_instance_enumerator.go (81%) rename {pkg => enumeration}/remote/google/google_compute_instance_group_enumerator.go (86%) rename {pkg => enumeration}/remote/google/google_compute_instance_group_manager_enumerator.go (85%) rename {pkg => enumeration}/remote/google/google_compute_network_enumerator.go (82%) rename {pkg => enumeration}/remote/google/google_compute_node_group_enumerator.go (82%) rename {pkg => enumeration}/remote/google/google_compute_router_enumerator.go (81%) rename {pkg => enumeration}/remote/google/google_compute_subnetwork_enumerator.go (82%) rename {pkg => enumeration}/remote/google/google_dns_managed_zone_enumerator.go (86%) rename {pkg => enumeration}/remote/google/google_project_iam_member_enumerator.go (85%) rename {pkg => enumeration}/remote/google/google_sql_database_instance_enumerator.go (84%) rename {pkg => enumeration}/remote/google/google_storage_bucket_enumerator.go (81%) rename {pkg => enumeration}/remote/google/google_storage_bucket_iam_member_enumerator.go (73%) rename {pkg => enumeration}/remote/google/init.go (71%) rename {pkg => enumeration}/remote/google/provider.go (75%) rename {pkg => enumeration}/remote/google/repository/asset.go (98%) rename {pkg => enumeration}/remote/google/repository/asset_test.go (93%) rename {pkg => enumeration}/remote/google/repository/cloudresourcemanager.go (92%) rename {pkg => enumeration}/remote/google/repository/mock_AssetRepository.go (100%) rename {pkg => enumeration}/remote/google/repository/mock_CloudResourceManagerRepository.go (100%) rename {pkg => enumeration}/remote/google/repository/mock_StorageRepository.go (100%) rename {pkg => enumeration}/remote/google/repository/storage.go (95%) rename {pkg => enumeration}/remote/google/util.go (100%) rename {pkg => enumeration}/remote/google_bigquery_scanner_test.go (82%) rename {pkg => enumeration}/remote/google_bigtable_scanner_test.go (86%) rename {pkg => enumeration}/remote/google_cloudfunctions_scanner_test.go (83%) rename {pkg => enumeration}/remote/google_cloudrun_scanner_test.go (83%) rename {pkg => enumeration}/remote/google_compute_scanner_test.go (89%) rename {pkg => enumeration}/remote/google_network_scanner_test.go (84%) rename {pkg => enumeration}/remote/google_project_scanner_test.go (84%) rename {pkg => enumeration}/remote/google_sql_scanner_test.go (81%) rename {pkg => enumeration}/remote/google_storage_scanner_test.go (77%) rename {pkg => enumeration}/remote/remote.go (57%) rename {pkg => enumeration}/remote/resource_enumeration_error_handler.go (94%) rename {pkg => enumeration}/remote/resource_enumeration_error_handler_test.go (72%) rename {pkg => enumeration}/remote/scanner.go (89%) rename {pkg => enumeration}/remote/scanner_test.go (64%) rename {pkg => enumeration}/remote/terraform/provider.go (89%) rename {pkg => enumeration}/remote/test/aws_appautoscaling_policy_single/aws_appautoscaling_policy-DynamoDBReadCapacityUtilization_table_GameScores-DynamoDBReadCapacityUtilization_table_GameScores-table_GameScores-dynamodb_table_ReadCapacityUnits-dynamodb.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_appautoscaling_policy_single/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_appautoscaling_target_single/aws_appautoscaling_target-table_GameScores-dynamodb_table_ReadCapacityUnits-dynamodb.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_appautoscaling_target_single/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_cloudformation_stack_multiple/aws_cloudformation_stack-arn_aws_cloudformation_us-east-1_047081014315_stack_bar-stack_c7a96e70-0f21-11ec-bd2a-0a2d95c2b2ab.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_cloudformation_stack_multiple/aws_cloudformation_stack-arn_aws_cloudformation_us-east-1_047081014315_stack_foo-stack_c7aa0ab0-0f21-11ec-ba25-129d8c0b3757.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_cloudformation_stack_multiple/iam.yml (100%) rename {pkg => enumeration}/remote/test/aws_cloudformation_stack_multiple/results.golden.json (97%) rename {pkg => enumeration}/remote/test/aws_cloudformation_stack_multiple/terraform.tf (100%) rename {pkg => enumeration}/remote/test/aws_cloudfront_distribution_single/aws_cloudfront_distribution-E1M9CNS0XSHI19.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_cloudfront_distribution_single/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_cloudfront_distribution_single/terraform.tf (100%) rename {pkg => enumeration}/remote/test/aws_default_vpc/aws_default_vpc-vpc-a8c5d4c1.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_default_vpc/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_default_vpc/terraform.tf (100%) rename {pkg => enumeration}/remote/test/aws_dynamodb_table_multiple/aws_dynamodb_table-GameScores-GameScores.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_dynamodb_table_multiple/aws_dynamodb_table-example-example.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_dynamodb_table_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ebs_encryption_by_default_list/aws_ebs_encryption_by_default-ebs_encryption_default.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ebs_encryption_by_default_list/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_ami_multiple/aws_ami-ami-025962fd8b456731f.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_ami_multiple/aws_ami-ami-03a578b46f4c3081b.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_ami_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_default_network_acl/aws_default_network_acl-acl-e88ee595.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_default_network_acl/results.golden.json (80%) rename {pkg => enumeration}/remote/test/aws_ec2_default_route_table_single/aws_default_route_table-rtb-0eabf071c709c0976-vpc-0b4a6b3536da20ecd.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_default_route_table_single/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_default_route_table_single/terraform.tf (100%) rename {pkg => enumeration}/remote/test/aws_ec2_default_subnet_multiple/aws_default_subnet-subnet-44fe0c65.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_default_subnet_multiple/aws_default_subnet-subnet-65e16628.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_default_subnet_multiple/aws_default_subnet-subnet-afa656f0.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_default_subnet_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_default_subnet_multiple/terraform.tf (100%) rename {pkg => enumeration}/remote/test/aws_ec2_ebs_snapshot_multiple/aws_ebs_snapshot-snap-00672558cecd93a61.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_ebs_snapshot_multiple/aws_ebs_snapshot-snap-0c509a2a880d95a39.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_ebs_snapshot_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_ebs_volume_multiple/aws_ebs_volume-vol-01ddc91d3d9d1318b.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_ebs_volume_multiple/aws_ebs_volume-vol-081c7272a57a09db1.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_ebs_volume_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_eip_association_single/aws_eip_association-eipassoc-0e9a7356e30f0c3d1.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_eip_association_single/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_eip_multiple/aws_eip-eipalloc-017d5267e4dda73f1.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_eip_multiple/aws_eip-eipalloc-0cf714dc097c992cc.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_eip_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_instance_multiple/aws_instance-i-010376047a71419f1.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_instance_multiple/aws_instance-i-0d3650a23f4e45dc0.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_instance_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_instance_terminated/aws_instance-i-0a3a7ed51ae2b4fa0.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_instance_terminated/aws_instance-i-0e1543baf4f2cd990.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_instance_terminated/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_internet_gateway_multiple/aws_internet_gateway-igw-0184eb41aadc62d1c.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_internet_gateway_multiple/aws_internet_gateway-igw-047b487f5c60fca99.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_internet_gateway_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_internet_gateway_multiple/terraform.tf (100%) rename {pkg => enumeration}/remote/test/aws_ec2_key_pair_multiple/aws_key_pair-bar.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_key_pair_multiple/aws_key_pair-test.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_key_pair_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_nat_gateway_single/aws_nat_gateway-nat-0a5408508b19ef490.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_nat_gateway_single/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_nat_gateway_single/terraform.tf (100%) rename {pkg => enumeration}/remote/test/aws_ec2_network_acl/aws_network_acl-acl-043880b4682d2366b.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_network_acl/aws_network_acl-acl-07a565dbe518c0713.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_network_acl/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_network_acl/terraform.tf (100%) rename {pkg => enumeration}/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-2289824980-false-acl-0ad6d657494d17ee2-200.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-246660311-true-acl-0ad6d657494d17ee2-100.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-4268384215-true-acl-0de54ef59074b622e-100.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-4293207588-false-acl-0ad6d657494d17ee2-100.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-515082162-false-acl-0de54ef59074b622e-100.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_network_acl_rule/results.golden.json (84%) rename {pkg => enumeration}/remote/test/aws_ec2_network_acl_rule/terraform.tf (100%) rename {pkg => enumeration}/remote/test/aws_ec2_route_multiple/aws_route-r-179966490-10.0.0.0_16-.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-0169b0937fd963ddc1080289494-0.0.0.0_0-rtb-0169b0937fd963ddc.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-0169b0937fd963ddc179966490-10.0.0.0_16-rtb-0169b0937fd963ddc.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-0169b0937fd963ddc2750132062-___0-rtb-0169b0937fd963ddc.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-02780c485f0be93c51325105504-10.1.2.0_24-rtb-02780c485f0be93c5.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-02780c485f0be93c5179966490-10.0.0.0_16-rtb-02780c485f0be93c5.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-02780c485f0be93c53362780110-10.1.1.0_24-rtb-02780c485f0be93c5.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-096bdfb69309c54c3179966490-10.0.0.0_16-rtb-096bdfb69309c54c3.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-096bdfb69309c54c3243279527-1.1.1.1_32-rtb-096bdfb69309c54c3.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-096bdfb69309c54c32750132062-___0-rtb-096bdfb69309c54c3.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_route_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_route_multiple/terraform.tf (100%) rename {pkg => enumeration}/remote/test/aws_ec2_route_table_association_multiple/aws_route_table_association-rtbassoc-01957791b2cfe6ea4-rtb-05aa6c5673311a17b.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_route_table_association_multiple/aws_route_table_association-rtbassoc-0809598f92dbec03b-rtb-05aa6c5673311a17b.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_route_table_association_multiple/aws_route_table_association-rtbassoc-0a79ccacfceb4944b-rtb-09df7cc9d16de9f8f.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_route_table_association_multiple/aws_route_table_association-rtbassoc-0b4f97ea57490e213-rtb-05aa6c5673311a17b.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_route_table_association_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_route_table_multiple/aws_route_table-rtb-0002ac731f6fdea55.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_route_table_multiple/aws_route_table-rtb-08b7b71af15e183ce.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_route_table_multiple/aws_route_table-rtb-0c55d55593f33fbac.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_route_table_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_route_table_multiple/terraform.tf (100%) rename {pkg => enumeration}/remote/test/aws_ec2_subnet_multiple/aws_subnet-subnet-05810d3f933925f6d.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_subnet_multiple/aws_subnet-subnet-0b13f1e0eacf67424.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_subnet_multiple/aws_subnet-subnet-0c9b78001fe186e22.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_subnet_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ec2_subnet_multiple/terraform.tf (100%) rename {pkg => enumeration}/remote/test/aws_ecr_repository_multiple/aws_ecr_repository-bar.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ecr_repository_multiple/aws_ecr_repository-test_ecr.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ecr_repository_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_ecr_repository_multiple/terraform.tf (100%) rename {pkg => enumeration}/remote/test/aws_iam_access_key_multiple/aws_iam_access_key-AKIA5QYBVVD223VWU32A-test-driftctl.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_access_key_multiple/aws_iam_access_key-AKIA5QYBVVD26EJME25D-test-driftctl2.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_access_key_multiple/aws_iam_access_key-AKIA5QYBVVD2QYI36UZP-test-driftctl.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_access_key_multiple/aws_iam_access_key-AKIA5QYBVVD2SWDFVVMG-test-driftctl2.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_access_key_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_access_key_multiple/terraform.tf (100%) rename {pkg => enumeration}/remote/test/aws_iam_policy_multiple/aws_iam_policy-arn_aws_iam__929327065333_policy_policy-0.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_policy_multiple/aws_iam_policy-arn_aws_iam__929327065333_policy_policy-1.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_policy_multiple/aws_iam_policy-arn_aws_iam__929327065333_policy_policy-2.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_policy_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_role_multiple/aws_iam_role-test_role_0.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_role_multiple/aws_iam_role-test_role_1.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_role_multiple/aws_iam_role-test_role_2.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_role_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_role_multiple/terraform.tf (100%) rename {pkg => enumeration}/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy-test-role-arn_aws_iam__929327065333_policy_test-policy-test-role.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy-test-role2-arn_aws_iam__929327065333_policy_test-policy-test-role2.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy2-test-role-arn_aws_iam__929327065333_policy_test-policy2-test-role.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy2-test-role2-arn_aws_iam__929327065333_policy_test-policy2-test-role2.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy3-test-role-arn_aws_iam__929327065333_policy_test-policy3-test-role.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy3-test-role2-arn_aws_iam__929327065333_policy_test-policy3-test-role2.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_role_policy_attachment_multiple/main.tf (100%) rename {pkg => enumeration}/remote/test/aws_iam_role_policy_attachment_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_role_policy_empty/schema.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_0_policy-role0-0.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_0_policy-role0-1.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_0_policy-role0-2.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_1_policy-role1-0.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_1_policy-role1-1.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_1_policy-role1-2.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_role_policy_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_role_policy_multiple/schema.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_role_policy_multiple/terraform.tf (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_multiple/aws_iam_user-test-driftctl-0.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_multiple/aws_iam_user-test-driftctl-1.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_multiple/aws_iam_user-test-driftctl-2.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_multiple/terraform.tf (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test-loadbalancer-arn_aws_iam__726421854799_policy_test-loadbalancer.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test-loadbalancer2-arn_aws_iam__726421854799_policy_test-loadbalancer2.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test-loadbalancer3-arn_aws_iam__726421854799_policy_test-loadbalancer3.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test2-loadbalancer-arn_aws_iam__726421854799_policy_test2-loadbalancer.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test2-loadbalancer2-arn_aws_iam__726421854799_policy_test2-loadbalancer2.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test2-loadbalancer3-arn_aws_iam__726421854799_policy_test2-loadbalancer3.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test3-loadbalancer-arn_aws_iam__726421854799_policy_test3-loadbalancer.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test3-loadbalancer2-arn_aws_iam__726421854799_policy_test3-loadbalancer2.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test3-loadbalancer3-arn_aws_iam__726421854799_policy_test3-loadbalancer3.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test4-loadbalancer-arn_aws_iam__726421854799_policy_test4-loadbalancer.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test4-loadbalancer2-arn_aws_iam__726421854799_policy_test4-loadbalancer2.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test4-loadbalancer3-arn_aws_iam__726421854799_policy_test4-loadbalancer3.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_attachment_multiple/main.tf (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_attachment_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test2.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test22.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test23.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test24.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test3.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test4.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test2.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test22.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test23.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test24.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test3.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test32.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test33.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test34.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test4.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer_test.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer_test2.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer_test3.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer_test4.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_multiple/main.tf (100%) rename {pkg => enumeration}/remote/test/aws_iam_user_policy_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_kms_alias_multiple/aws_kms_alias-alias_bar.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_kms_alias_multiple/aws_kms_alias-alias_baz20210225124429210500000001.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_kms_alias_multiple/aws_kms_alias-alias_foo.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_kms_alias_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_kms_alias_multiple/terraform.tf (100%) rename {pkg => enumeration}/remote/test/aws_kms_key_multiple/aws_kms_key-5d765f32-bfdc-4610-b6ab-f82db5d0601b.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_kms_key_multiple/aws_kms_key-89d2c023-ea53-40a5-b20a-d84905c622d7.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_kms_key_multiple/aws_kms_key-8ee21d91-c000-428c-8032-235aac55da36.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_kms_key_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_kms_key_multiple/terraform.tf (100%) rename {pkg => enumeration}/remote/test/aws_lambda_function_multiple/aws_lambda_function-bar-bar.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_lambda_function_multiple/aws_lambda_function-foo-foo.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_lambda_function_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_lambda_function_signed/aws_lambda_function-foo-foo.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_lambda_function_signed/lambda.zip (100%) rename {pkg => enumeration}/remote/test/aws_lambda_function_signed/main.tf (100%) rename {pkg => enumeration}/remote/test/aws_lambda_function_signed/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_lambda_source_mapping_dynamo_multiple/aws_lambda_event_source_mapping-1aa9c4a0-060b-41c1-a9ae-dc304ebcdb00.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_lambda_source_mapping_dynamo_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_lambda_source_mapping_sqs_multiple/aws_lambda_event_source_mapping-13ff66f8-37eb-4ad6-a0a8-594fea72df4f.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_lambda_source_mapping_sqs_multiple/aws_lambda_event_source_mapping-4ad7e2b3-79e9-4713-9d9d-5af2c01d9058.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_lambda_source_mapping_sqs_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_launch_template_multiple/aws_launch_template-lt-00b2d18c6cee7fe23.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_launch_template_multiple/aws_launch_template-lt-0ed993d09ce6afc67.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_launch_template_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_rds_clusters_results/aws_rds_cluster-aurora-cluster-demo-2-aurora-cluster-demo-2-.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_rds_clusters_results/aws_rds_cluster-aurora-cluster-demo-aurora-cluster-demo-mydb.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_rds_clusters_results/results.golden.json (97%) rename {pkg => enumeration}/remote/test/aws_rds_db_instance_multiple/aws_db_instance-database-1.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_rds_db_instance_multiple/aws_db_instance-terraform-20201015115018309600000001.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_rds_db_instance_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_rds_db_instance_single/aws_db_instance-terraform-20201015115018309600000001.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_rds_db_instance_single/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_rds_db_subnet_group_multiple/aws_db_subnet_group-bar.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_rds_db_subnet_group_multiple/aws_db_subnet_group-foo.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_rds_db_subnet_group_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_health_check_empty/schema.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_health_check_multiple/aws_route53_health_check-7001a9df-ded4-4802-9909-668eb80b972b.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_health_check_multiple/aws_route53_health_check-84fc318a-2e0d-41d6-b638-280e2f0f4e26.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_health_check_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_health_check_multiple/terraform.tf (100%) rename {pkg => enumeration}/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM__test2.foo-2.com_A.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM__test2.foo-2.com_TXT.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test0_A.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test0_TXT.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test1.foo-2.com_A.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test1.foo-2.com_TXT.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_record_explicit_subdomain/main.tf (100%) rename {pkg => enumeration}/remote/test/aws_route53_record_explicit_subdomain/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_record_explicit_subdomain/schema.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_record_multiples/aws_route53_record-Z10347383HV75H96J919W_test2_A.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G__.test4_A.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_foo-0.com_NS.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_test0_A.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_test1_A.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_test2_A.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_record_multiples/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_record_multiples/schema.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_zone_empty/schema.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_zone_multiples/aws_route53_zone-Z01804312AV8PHE3C43AD.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_zone_multiples/aws_route53_zone-Z01809283VH9BBALZHO7B.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_zone_multiples/aws_route53_zone-Z01874941AR1TCGV5K65C.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_zone_multiples/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_zone_multiples/schema.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_zone_multiples/terraform.tf (100%) rename {pkg => enumeration}/remote/test/aws_route53_zone_single/aws_route53_zone-Z08068311RGDXPHF8KE62.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_zone_single/aws_route53_zone-Z093553112BLINKY4N57.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_zone_single/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_zone_single/schema.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_route53_zone_single/terraform.tf (100%) rename {pkg => enumeration}/remote/test/aws_route53_zone_with_no_record/schema.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_s3_bucket_analytics_multiple/aws_s3_bucket_analytics_configuration-bucket-martin-test-drift2_Analytics2_Bucket2-eu-west-3.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_s3_bucket_analytics_multiple/aws_s3_bucket_analytics_configuration-bucket-martin-test-drift2_Analytics_Bucket2-eu-west-3.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_s3_bucket_analytics_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_s3_bucket_inventories_multiple/aws_s3_bucket_inventory-bucket-martin-test-drift2_Inventory2_Bucket2-eu-west-3.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_s3_bucket_inventories_multiple/aws_s3_bucket_inventory-bucket-martin-test-drift2_Inventory_Bucket2-eu-west-3.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_s3_bucket_inventories_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_s3_bucket_metrics_multiple/aws_s3_bucket_metric-bucket-martin-test-drift2_Metric2_Bucket2-eu-west-3.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_s3_bucket_metrics_multiple/aws_s3_bucket_metric-bucket-martin-test-drift2_Metric_Bucket2-eu-west-3.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_s3_bucket_metrics_multiple/aws_s3_bucket_metric-bucket-martin-test-drift2_Metrics2_Bucket2-eu-west-3.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_s3_bucket_metrics_multiple/aws_s3_bucket_metric-bucket-martin-test-drift2_Metrics_Bucket2-eu-west-3.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_s3_bucket_metrics_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_s3_bucket_multiple/aws_s3_bucket-bucket-martin-test-drift2-eu-west-3.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_s3_bucket_multiple/main.tf (100%) rename {pkg => enumeration}/remote/test/aws_s3_bucket_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_s3_bucket_notifications_multiple/aws_s3_bucket_notification-bucket-martin-test-drift2-eu-west-3.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_s3_bucket_notifications_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_s3_bucket_notifications_no_notif/aws_s3_bucket_notification-dritftctl-test-no-notifications.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_s3_bucket_notifications_no_notif/terraform.tf (100%) rename {pkg => enumeration}/remote/test/aws_s3_bucket_policies_multiple/aws_s3_bucket_policy-bucket-martin-test-drift2-eu-west-3.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_s3_bucket_policies_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_s3_bucket_policy_no_policy/terraform.tf (100%) rename {pkg => enumeration}/remote/test/aws_sns_topic_multiple/aws_sns_topic-arn_aws_sns_eu-west-3_526954929923_user-updates-topic-arn_aws_sns_eu-west-3_526954929923_user-updates-topic.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_sns_topic_multiple/aws_sns_topic-arn_aws_sns_eu-west-3_526954929923_user-updates-topic2-arn_aws_sns_eu-west-3_526954929923_user-updates-topic2.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_sns_topic_multiple/aws_sns_topic-arn_aws_sns_eu-west-3_526954929923_user-updates-topic3-arn_aws_sns_eu-west-3_526954929923_user-updates-topic3.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_sns_topic_multiple/main.tf (100%) rename {pkg => enumeration}/remote/test/aws_sns_topic_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_sns_topic_policy_multiple/aws_sns_topic_policy-arn_aws_sns_us-east-1_526954929923_my-topic-with-policy-arn_aws_sns_us-east-1_526954929923_my-topic-with-policy.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_sns_topic_policy_multiple/aws_sns_topic_policy-arn_aws_sns_us-east-1_526954929923_my-topic-with-policy2-arn_aws_sns_us-east-1_526954929923_my-topic-with-policy2.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_sns_topic_policy_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_sns_topic_subscription_multiple/aws_sns_topic_subscription-arn_aws_sns_us-east-1_526954929923_user-updates-topic2_c0f794c5-a009-4db4-9147-4c55959787fa-arn_aws_sns_us-east-1_526954929923_user-updates-topic2_c0f794c5-a009-4db4-9147-4c55959787fa.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_sns_topic_subscription_multiple/aws_sns_topic_subscription-arn_aws_sns_us-east-1_526954929923_user-updates-topic_b6e66147-2b31-4486-8d4b-2a2272264c8e-arn_aws_sns_us-east-1_526954929923_user-updates-topic_b6e66147-2b31-4486-8d4b-2a2272264c8e.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_sns_topic_subscription_multiple/main.tf (100%) rename {pkg => enumeration}/remote/test/aws_sns_topic_subscription_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_sqs_queue_multiple/aws_sqs_queue-https___sqs.eu-west-3.amazonaws.com_047081014315_bar.fifo.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_sqs_queue_multiple/aws_sqs_queue-https___sqs.eu-west-3.amazonaws.com_047081014315_foo.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_sqs_queue_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_sqs_queue_multiple/terraform.tf (100%) rename {pkg => enumeration}/remote/test/aws_sqs_queue_policy_multiple/aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_bar.fifo.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_sqs_queue_policy_multiple/aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_baz.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_sqs_queue_policy_multiple/aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_foo.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_sqs_queue_policy_multiple/policy.json (100%) rename {pkg => enumeration}/remote/test/aws_sqs_queue_policy_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_sqs_queue_policy_multiple/terraform.tf (100%) rename {pkg => enumeration}/remote/test/aws_vpc/aws_vpc-vpc-020b072316a95b97f.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_vpc/aws_vpc-vpc-02c50896b59598761.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_vpc/aws_vpc-vpc-0768e1fd0029e3fc3.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_vpc/aws_vpc-vpc-a8c5d4c1.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_vpc/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_vpc/terraform.tf (100%) rename {pkg => enumeration}/remote/test/aws_vpc_default_security_group_multiple/aws_default_security_group-sg-9e0204ff.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_vpc_default_security_group_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_vpc_default_security_group_multiple/terraform.tf (100%) rename {pkg => enumeration}/remote/test/aws_vpc_security_group_default_rules/aws_security_group_rule-sgrule-3820791514-1-1.2.0.0_16-0-0-0--1-sg-a74815c8-false--0-ingress.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_vpc_security_group_default_rules/aws_security_group_rule-sgrule-529352477-1-1.2.3.4_32-0-0-0--1-sg-a74815c8-false--0-egress.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_vpc_security_group_default_rules/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_vpc_security_group_multiple/aws_security_group-sg-0254c038e32f25530.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_vpc_security_group_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_vpc_security_group_multiple/terraform.tf (100%) rename pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-1175318309-1-0.0.0.0_0-0--1-sg-0cc8b3c3c2851705a-false-0-egress.res.golden.json => enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-1175318309-1-0.0.0.0_0-0--1-sg-0cc8b3c3c2851705a-false--0-egress.res.golden.json (100%) rename pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-1707973622-1-0.0.0.0_0-0--1-sg-0254c038e32f25530-false-0-egress.res.golden.json => enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-1707973622-1-0.0.0.0_0-0--1-sg-0254c038e32f25530-false--0-egress.res.golden.json (100%) rename pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2165103420-1-5.6.7.0_24-0--1-sg-0254c038e32f25530-false-0-ingress.res.golden.json => enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2165103420-1-5.6.7.0_24-0--1-sg-0254c038e32f25530-false--0-ingress.res.golden.json (100%) rename pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2582518759-1-1.2.0.0_16-0--1-sg-0254c038e32f25530-false-0-ingress.res.golden.json => enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2582518759-1-1.2.0.0_16-0--1-sg-0254c038e32f25530-false--0-ingress.res.golden.json (100%) rename pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2821752134-0-1-___0--1-sg-0254c038e32f25530-false-0-egress.res.golden.json => enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2821752134-0-1-___0--1-sg-0254c038e32f25530-false--0-egress.res.golden.json (100%) rename pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-350400929-0-1-___0--1-sg-0cc8b3c3c2851705a-false-0-egress.res.golden.json => enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-350400929-0-1-___0--1-sg-0cc8b3c3c2851705a-false--0-egress.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-3587309474-0-tcp-sg-0254c038e32f25530-false-sg-9e0204ff-65535-ingress.res.golden.json (100%) rename pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-3970541193-0-tcp-sg-0254c038e32f25530-true-65535-ingress.res.golden.json => enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-3970541193-0-tcp-sg-0254c038e32f25530-true--65535-ingress.res.golden.json (100%) rename pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-453320892-1-0.0.0.0_0-443-tcp-sg-0cc8b3c3c2851705a-false-443-ingress.res.golden.json => enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-453320892-1-0.0.0.0_0-443-tcp-sg-0cc8b3c3c2851705a-false--443-ingress.res.golden.json (100%) rename pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-674800228-0-1-___0--1-sg-0254c038e32f25530-false-0-ingress.res.golden.json => enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-674800228-0-1-___0--1-sg-0254c038e32f25530-false--0-ingress.res.golden.json (100%) rename pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-850043874-1-0.0.0.0_0-5-sg-0cc8b3c3c2851705a-false-egress.res.golden.json => enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-850043874-1-0.0.0.0_0-0-5-sg-0cc8b3c3c2851705a-false--0-egress.res.golden.json (100%) rename {pkg => enumeration}/remote/test/aws_vpc_security_group_rule_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/azurerm_lb_rule_multiple/17c4e2b7f4cc466670ccbd8dd1d506289fd818c0.res.golden.json (100%) rename {pkg => enumeration}/remote/test/azurerm_lb_rule_multiple/2f725aa2c71898229fcfa091837deaa387bee9d8.res.golden.json (100%) rename {pkg => enumeration}/remote/test/azurerm_lb_rule_multiple/results.golden.json (98%) rename {pkg => enumeration}/remote/test/azurerm_network_security_group_multiple/azurerm_network_security_group-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_example-resources_providers_Microsoft.Network_networkSecurityGroups_acceptanceTestSecurityGroup1.res.golden.json (100%) rename {pkg => enumeration}/remote/test/azurerm_network_security_group_multiple/azurerm_network_security_group-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_example-resources_providers_Microsoft.Network_networkSecurityGroups_acceptanceTestSecurityGroup2.res.golden.json (100%) rename {pkg => enumeration}/remote/test/azurerm_network_security_group_multiple/results.golden.json (97%) rename {pkg => enumeration}/remote/test/azurerm_private_dns_a_record_multiple/azurerm_private_dns_a_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_A_othertest.res.golden.json (100%) rename {pkg => enumeration}/remote/test/azurerm_private_dns_a_record_multiple/azurerm_private_dns_a_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_A_test.res.golden.json (100%) rename {pkg => enumeration}/remote/test/azurerm_private_dns_a_record_multiple/results.golden.json (95%) rename {pkg => enumeration}/remote/test/azurerm_private_dns_aaaaa_record_multiple/azurerm_private_dns_aaaa_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_AAAA_othertest.res.golden.json (100%) rename {pkg => enumeration}/remote/test/azurerm_private_dns_aaaaa_record_multiple/azurerm_private_dns_aaaa_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_AAAA_test.res.golden.json (100%) rename {pkg => enumeration}/remote/test/azurerm_private_dns_aaaaa_record_multiple/results.golden.json (95%) rename {pkg => enumeration}/remote/test/azurerm_private_dns_cname_record_multiple/azurerm_private_dns_cname_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_CNAME_othertest.res.golden.json (100%) rename {pkg => enumeration}/remote/test/azurerm_private_dns_cname_record_multiple/azurerm_private_dns_cname_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_CNAME_test.res.golden.json (100%) rename {pkg => enumeration}/remote/test/azurerm_private_dns_cname_record_multiple/results.golden.json (94%) rename {pkg => enumeration}/remote/test/azurerm_private_dns_mx_record_multiple/azurerm_private_dns_mx_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_MX_othertestmx.res.golden.json (100%) rename {pkg => enumeration}/remote/test/azurerm_private_dns_mx_record_multiple/azurerm_private_dns_mx_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_MX_testmx.res.golden.json (100%) rename {pkg => enumeration}/remote/test/azurerm_private_dns_mx_record_multiple/results.golden.json (96%) rename {pkg => enumeration}/remote/test/azurerm_private_dns_private_zone_multiple/azurerm_private_dns_zone-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_testmartin.com.res.golden.json (100%) rename {pkg => enumeration}/remote/test/azurerm_private_dns_private_zone_multiple/azurerm_private_dns_zone-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com.res.golden.json (100%) rename {pkg => enumeration}/remote/test/azurerm_private_dns_private_zone_multiple/azurerm_private_dns_zone-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf2.com.res.golden.json (100%) rename {pkg => enumeration}/remote/test/azurerm_private_dns_private_zone_multiple/results.golden.json (93%) rename {pkg => enumeration}/remote/test/azurerm_private_dns_ptr_record_multiple/azurerm_private_dns_ptr_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_PTR_othertestptr.res.golden.json (100%) rename {pkg => enumeration}/remote/test/azurerm_private_dns_ptr_record_multiple/azurerm_private_dns_ptr_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_PTR_testptr.res.golden.json (100%) rename {pkg => enumeration}/remote/test/azurerm_private_dns_ptr_record_multiple/results.golden.json (95%) rename {pkg => enumeration}/remote/test/azurerm_private_dns_srv_record_multiple/azurerm_private_dns_srv_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_SRV_othertestptr.res.golden.json (100%) rename {pkg => enumeration}/remote/test/azurerm_private_dns_srv_record_multiple/azurerm_private_dns_srv_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_SRV_testptr.res.golden.json (100%) rename {pkg => enumeration}/remote/test/azurerm_private_dns_srv_record_multiple/results.golden.json (96%) rename {pkg => enumeration}/remote/test/azurerm_private_dns_txt_record_multiple/azurerm_private_dns_txt_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_TXT_othertesttxt.res.golden.json (100%) rename {pkg => enumeration}/remote/test/azurerm_private_dns_txt_record_multiple/azurerm_private_dns_txt_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_TXT_testtxt.res.golden.json (100%) rename {pkg => enumeration}/remote/test/azurerm_private_dns_txt_record_multiple/results.golden.json (95%) rename {pkg => enumeration}/remote/test/azurerm_ssh_public_key_multiple/azurerm_ssh_public_key-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_TESTRESGROUP_providers_Microsoft.Compute_sshPublicKeys_example-key.res.golden.json (100%) rename {pkg => enumeration}/remote/test/azurerm_ssh_public_key_multiple/azurerm_ssh_public_key-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_TESTRESGROUP_providers_Microsoft.Compute_sshPublicKeys_example-key2.res.golden.json (100%) rename {pkg => enumeration}/remote/test/azurerm_ssh_public_key_multiple/results.golden.json (98%) rename {pkg => enumeration}/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzE=.res.golden.json (100%) rename {pkg => enumeration}/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzI=.res.golden.json (100%) rename {pkg => enumeration}/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzQ=.res.golden.json (100%) rename {pkg => enumeration}/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0Nzc=.res.golden.json (100%) rename {pkg => enumeration}/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0Nzg=.res.golden.json (100%) rename {pkg => enumeration}/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0ODA=.res.golden.json (100%) rename {pkg => enumeration}/remote/test/github_branch_protection_multiples/results.golden.json (100%) rename {pkg => enumeration}/remote/test/github_branch_protection_multiples/terraform.tf (100%) rename {pkg => enumeration}/remote/test/github_membership_multiple/github_membership-driftctl-test_driftctl-acceptance-tester.res.golden.json (100%) rename {pkg => enumeration}/remote/test/github_membership_multiple/github_membership-driftctl-test_eliecharra.res.golden.json (100%) rename {pkg => enumeration}/remote/test/github_membership_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/github_repository_multiple/github_repository-driftctl-demos.res.golden.json (100%) rename {pkg => enumeration}/remote/test/github_repository_multiple/github_repository-driftctl.res.golden.json (100%) rename {pkg => enumeration}/remote/test/github_repository_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/github_team_membership_multiple/github_team_membership-4570529_driftctl-acceptance-tester.res.golden.json (100%) rename {pkg => enumeration}/remote/test/github_team_membership_multiple/github_team_membership-4570529_wbeuil.res.golden.json (100%) rename {pkg => enumeration}/remote/test/github_team_membership_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/github_team_membership_multiple/terraform.tf (100%) rename {pkg => enumeration}/remote/test/github_teams_multiple/github_team-4556811.res.golden.json (100%) rename {pkg => enumeration}/remote/test/github_teams_multiple/github_team-4556812.res.golden.json (100%) rename {pkg => enumeration}/remote/test/github_teams_multiple/github_team-4556814.res.golden.json (100%) rename {pkg => enumeration}/remote/test/github_teams_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/google_compute_firewall/google_compute_firewall-projects_cloudskiff-dev-elie_global_firewalls_test-firewall-0-test-firewall-0-cloudskiff-dev-elie.res.golden.json (100%) rename {pkg => enumeration}/remote/test/google_compute_firewall/google_compute_firewall-projects_cloudskiff-dev-elie_global_firewalls_test-firewall-1-test-firewall-1-cloudskiff-dev-elie.res.golden.json (100%) rename {pkg => enumeration}/remote/test/google_compute_firewall/google_compute_firewall-projects_cloudskiff-dev-elie_global_firewalls_test-firewall-2-test-firewall-2-cloudskiff-dev-elie.res.golden.json (100%) rename {pkg => enumeration}/remote/test/google_compute_firewall/results.golden.json (98%) rename {pkg => enumeration}/remote/test/google_compute_firewall/terraform.tf (100%) rename {pkg => enumeration}/remote/test/google_compute_instance_group/google_compute_instance_group-projects_cloudskiff-dev-raphael_zones_us-central1-a_instanceGroups_driftctl-test-1-driftctl-test-1-cloudskiff-dev-raphael-us-central1-a.res.golden.json (100%) rename {pkg => enumeration}/remote/test/google_compute_instance_group/google_compute_instance_group-projects_cloudskiff-dev-raphael_zones_us-central1-a_instanceGroups_driftctl-test-2-driftctl-test-2-cloudskiff-dev-raphael-us-central1-a.res.golden.json (100%) rename {pkg => enumeration}/remote/test/google_compute_instance_group/results.golden.json (96%) rename {pkg => enumeration}/remote/test/google_compute_instance_group/terraform.tf (100%) rename {pkg => enumeration}/remote/test/google_compute_network/google_compute_network-projects_driftctl-qa-1_global_networks_driftctl-unittest-1-driftctl-unittest-1.res.golden.json (100%) rename {pkg => enumeration}/remote/test/google_compute_network/google_compute_network-projects_driftctl-qa-1_global_networks_driftctl-unittest-2-driftctl-unittest-2.res.golden.json (100%) rename {pkg => enumeration}/remote/test/google_compute_network/google_compute_network-projects_driftctl-qa-1_global_networks_driftctl-unittest-3-driftctl-unittest-3.res.golden.json (100%) rename {pkg => enumeration}/remote/test/google_compute_network/results.golden.json (65%) rename {pkg => enumeration}/remote/test/google_compute_subnetwork_multiple/google_compute_subnetwork-projects_cloudskiff-dev-raphael_regions_us-central1_subnetworks_driftctl-unittest-1-driftctl-unittest-1-.res.golden.json (100%) rename {pkg => enumeration}/remote/test/google_compute_subnetwork_multiple/google_compute_subnetwork-projects_cloudskiff-dev-raphael_regions_us-central1_subnetworks_driftctl-unittest-2-driftctl-unittest-2-.res.golden.json (100%) rename {pkg => enumeration}/remote/test/google_compute_subnetwork_multiple/google_compute_subnetwork-projects_cloudskiff-dev-raphael_regions_us-central1_subnetworks_driftctl-unittest-3-driftctl-unittest-3-.res.golden.json (100%) rename {pkg => enumeration}/remote/test/google_compute_subnetwork_multiple/results.golden.json (82%) rename {pkg => enumeration}/remote/test/google_project_member_listing_multiple/results.golden.json (100%) rename {pkg => enumeration}/remote/test/google_storage_bucket/google_storage_bucket-driftctl-unittest-1-driftctl-unittest-1.res.golden.json (100%) rename {pkg => enumeration}/remote/test/google_storage_bucket/google_storage_bucket-driftctl-unittest-2-driftctl-unittest-2.res.golden.json (100%) rename {pkg => enumeration}/remote/test/google_storage_bucket/google_storage_bucket-driftctl-unittest-3-driftctl-unittest-3.res.golden.json (100%) rename {pkg => enumeration}/remote/test/google_storage_bucket/results.golden.json (100%) rename {pkg => enumeration}/remote/test/google_storage_bucket_member_listing_multiple/results.golden.json (100%) rename {pkg => enumeration}/resource/aws/aws_alb.go (100%) rename {pkg => enumeration}/resource/aws/aws_alb_listener.go (100%) create mode 100644 enumeration/resource/aws/aws_ami.go rename {pkg => enumeration}/resource/aws/aws_api_gateway_account.go (100%) rename {pkg => enumeration}/resource/aws/aws_api_gateway_api_key.go (100%) rename {pkg => enumeration}/resource/aws/aws_api_gateway_authorizer.go (100%) rename {pkg => enumeration}/resource/aws/aws_api_gateway_base_path_mapping.go (100%) rename {pkg => enumeration}/resource/aws/aws_api_gateway_deployment.go (100%) rename {pkg => enumeration}/resource/aws/aws_api_gateway_domain_name.go (100%) rename {pkg => enumeration}/resource/aws/aws_api_gateway_gateway_response.go (100%) rename {pkg => enumeration}/resource/aws/aws_api_gateway_integration.go (100%) rename {pkg => enumeration}/resource/aws/aws_api_gateway_integration_response.go (100%) rename {pkg => enumeration}/resource/aws/aws_api_gateway_method.go (100%) rename {pkg => enumeration}/resource/aws/aws_api_gateway_method_response.go (100%) rename {pkg => enumeration}/resource/aws/aws_api_gateway_method_settings.go (100%) rename {pkg => enumeration}/resource/aws/aws_api_gateway_model.go (100%) rename {pkg => enumeration}/resource/aws/aws_api_gateway_request_validator.go (100%) rename {pkg => enumeration}/resource/aws/aws_api_gateway_resource.go (100%) rename {pkg => enumeration}/resource/aws/aws_api_gateway_rest_api.go (100%) rename {pkg => enumeration}/resource/aws/aws_api_gateway_rest_api_policy.go (100%) rename {pkg => enumeration}/resource/aws/aws_api_gateway_stage.go (100%) rename {pkg => enumeration}/resource/aws/aws_api_gateway_vpc_link.go (100%) rename {pkg => enumeration}/resource/aws/aws_apigatewayv2_api.go (100%) rename {pkg => enumeration}/resource/aws/aws_apigatewayv2_authorizer.go (100%) rename {pkg => enumeration}/resource/aws/aws_apigatewayv2_deployment.go (100%) rename {pkg => enumeration}/resource/aws/aws_apigatewayv2_domain_name.go (100%) rename {pkg => enumeration}/resource/aws/aws_apigatewayv2_integration.go (100%) rename {pkg => enumeration}/resource/aws/aws_apigatewayv2_integration_response.go (100%) rename {pkg => enumeration}/resource/aws/aws_apigatewayv2_mapping.go (91%) rename {pkg => enumeration}/resource/aws/aws_apigatewayv2_model.go (88%) rename {pkg => enumeration}/resource/aws/aws_apigatewayv2_route.go (100%) rename {pkg => enumeration}/resource/aws/aws_apigatewayv2_route_response.go (100%) rename {pkg => enumeration}/resource/aws/aws_apigatewayv2_stage.go (100%) rename {pkg => enumeration}/resource/aws/aws_apigatewayv2_vpc_link.go (100%) rename {pkg => enumeration}/resource/aws/aws_appautoscaling_policy.go (95%) rename {pkg => enumeration}/resource/aws/aws_appautoscaling_scheduled_action.go (100%) create mode 100644 enumeration/resource/aws/aws_appautoscaling_target.go create mode 100644 enumeration/resource/aws/aws_cloudformation_stack.go create mode 100644 enumeration/resource/aws/aws_cloudfront_distribution.go create mode 100644 enumeration/resource/aws/aws_db_instance.go create mode 100644 enumeration/resource/aws/aws_db_subnet_group.go create mode 100644 enumeration/resource/aws/aws_default_network_acl.go rename {pkg => enumeration}/resource/aws/aws_default_route_table.go (92%) create mode 100644 enumeration/resource/aws/aws_default_security_group.go create mode 100644 enumeration/resource/aws/aws_default_subnet.go rename {pkg => enumeration}/resource/aws/aws_default_vpc.go (81%) create mode 100644 enumeration/resource/aws/aws_dynamodb_table.go rename {pkg => enumeration}/resource/aws/aws_ebs_encryption_by_default.go (84%) create mode 100644 enumeration/resource/aws/aws_ebs_snapshot.go create mode 100644 enumeration/resource/aws/aws_ebs_volume.go create mode 100644 enumeration/resource/aws/aws_ecr_repository.go rename {pkg => enumeration}/resource/aws/aws_ecr_repository_policy.go (100%) create mode 100644 enumeration/resource/aws/aws_eip.go rename {pkg => enumeration}/resource/aws/aws_eip_association.go (82%) rename {pkg => enumeration}/resource/aws/aws_elasticache_cluster.go (100%) rename {pkg => enumeration}/resource/aws/aws_elb.go (100%) create mode 100644 enumeration/resource/aws/aws_iam_access_key.go rename {pkg => enumeration}/resource/aws/aws_iam_group.go (100%) rename {pkg => enumeration}/resource/aws/aws_iam_group_policy.go (100%) rename {pkg => enumeration}/resource/aws/aws_iam_group_policy_attachment.go (100%) create mode 100644 enumeration/resource/aws/aws_iam_policy.go create mode 100644 enumeration/resource/aws/aws_iam_policy_attachment.go create mode 100644 enumeration/resource/aws/aws_iam_role.go rename {pkg => enumeration}/resource/aws/aws_iam_role_policy.go (91%) rename {pkg => enumeration}/resource/aws/aws_iam_role_policy_attachment.go (91%) create mode 100644 enumeration/resource/aws/aws_iam_user.go rename {pkg => enumeration}/resource/aws/aws_iam_user_policy.go (91%) rename {pkg => enumeration}/resource/aws/aws_iam_user_policy_attachment.go (91%) create mode 100644 enumeration/resource/aws/aws_instance.go rename {pkg => enumeration}/resource/aws/aws_internet_gateway.go (85%) create mode 100644 enumeration/resource/aws/aws_key_pair.go create mode 100644 enumeration/resource/aws/aws_kms_alias.go create mode 100644 enumeration/resource/aws/aws_kms_key.go create mode 100644 enumeration/resource/aws/aws_lambda_event_source_mapping.go create mode 100644 enumeration/resource/aws/aws_lambda_function.go rename {pkg => enumeration}/resource/aws/aws_launch_configuration.go (100%) rename {pkg => enumeration}/resource/aws/aws_launch_template.go (82%) rename {pkg => enumeration}/resource/aws/aws_lb.go (87%) rename {pkg => enumeration}/resource/aws/aws_lb_listener.go (100%) rename {pkg => enumeration}/resource/aws/aws_nat_gateway.go (81%) rename {pkg => enumeration}/resource/aws/aws_network_acl.go (84%) create mode 100644 enumeration/resource/aws/aws_network_acl_rule.go create mode 100644 enumeration/resource/aws/aws_rds_cluster.go rename {pkg => enumeration}/resource/aws/aws_rds_cluster_instance.go (100%) create mode 100644 enumeration/resource/aws/aws_route.go rename {pkg => enumeration}/resource/aws/aws_route53_health_check.go (96%) create mode 100644 enumeration/resource/aws/aws_route53_record.go create mode 100644 enumeration/resource/aws/aws_route53_zone.go rename {pkg => enumeration}/resource/aws/aws_route_table.go (88%) rename {pkg => enumeration}/resource/aws/aws_route_table_association.go (95%) create mode 100644 enumeration/resource/aws/aws_s3_bucket.go rename {pkg => enumeration}/resource/aws/aws_s3_bucket_analytics_configuration.go (91%) rename {pkg => enumeration}/resource/aws/aws_s3_bucket_inventory.go (90%) rename {pkg => enumeration}/resource/aws/aws_s3_bucket_metric.go (89%) rename {pkg => enumeration}/resource/aws/aws_s3_bucket_notification.go (90%) create mode 100644 enumeration/resource/aws/aws_s3_bucket_policy.go rename {pkg => enumeration}/resource/aws/aws_s3_bucket_public_access_block.go (100%) create mode 100644 enumeration/resource/aws/aws_security_group.go create mode 100644 enumeration/resource/aws/aws_security_group_rule.go create mode 100644 enumeration/resource/aws/aws_sns_topic.go create mode 100644 enumeration/resource/aws/aws_sns_topic_policy.go create mode 100644 enumeration/resource/aws/aws_sns_topic_subscription.go rename {pkg => enumeration}/resource/aws/aws_sqs_queue.go (83%) create mode 100644 enumeration/resource/aws/aws_sqs_queue_policy.go create mode 100644 enumeration/resource/aws/aws_subnet.go rename {pkg => enumeration}/resource/aws/aws_vpc.go (79%) rename {pkg => enumeration}/resource/aws/metadata_test.go (98%) create mode 100644 enumeration/resource/aws/metadatas.go rename {pkg => enumeration}/resource/azurerm/azurerm_container_registry.go (90%) rename {pkg => enumeration}/resource/azurerm/azurerm_firewall.go (89%) rename {pkg => enumeration}/resource/azurerm/azurerm_image.go (90%) rename {pkg => enumeration}/resource/azurerm/azurerm_lb.go (89%) create mode 100644 enumeration/resource/azurerm/azurerm_lb_rule.go create mode 100644 enumeration/resource/azurerm/azurerm_network_security_group.go rename {pkg => enumeration}/resource/azurerm/azurerm_postgresql_database.go (90%) rename {pkg => enumeration}/resource/azurerm/azurerm_postgresql_server.go (90%) create mode 100644 enumeration/resource/azurerm/azurerm_private_dns_a_record.go create mode 100644 enumeration/resource/azurerm/azurerm_private_dns_aaaa_record.go create mode 100644 enumeration/resource/azurerm/azurerm_private_dns_cname_record.go create mode 100644 enumeration/resource/azurerm/azurerm_private_dns_mx_record.go create mode 100644 enumeration/resource/azurerm/azurerm_private_dns_ptr_record.go create mode 100644 enumeration/resource/azurerm/azurerm_private_dns_srv_record.go create mode 100644 enumeration/resource/azurerm/azurerm_private_dns_txt_record.go create mode 100644 enumeration/resource/azurerm/azurerm_private_dns_zone.go rename {pkg => enumeration}/resource/azurerm/azurerm_public_ip.go (89%) rename {pkg => enumeration}/resource/azurerm/azurerm_resource_group.go (89%) rename {pkg => enumeration}/resource/azurerm/azurerm_route.go (91%) rename {pkg => enumeration}/resource/azurerm/azurerm_route_table.go (90%) create mode 100644 enumeration/resource/azurerm/azurerm_ssh_public_key.go rename {pkg => enumeration}/resource/azurerm/azurerm_storage_account.go (100%) rename {pkg => enumeration}/resource/azurerm/azurerm_storage_container.go (100%) rename {pkg => enumeration}/resource/azurerm/azurerm_subnet.go (100%) rename {pkg => enumeration}/resource/azurerm/azurerm_virtual_network.go (90%) create mode 100644 enumeration/resource/azurerm/metadata.go rename {pkg => enumeration}/resource/azurerm/metadata_test.go (95%) create mode 100644 enumeration/resource/deserializer.go create mode 100644 enumeration/resource/github/github_branch_protection.go create mode 100644 enumeration/resource/github/github_membership.go create mode 100644 enumeration/resource/github/github_repository.go create mode 100644 enumeration/resource/github/github_team.go create mode 100644 enumeration/resource/github/github_team_membership.go rename {pkg => enumeration}/resource/github/metadata_test.go (91%) create mode 100644 enumeration/resource/github/metadatas.go rename {pkg => enumeration}/resource/google/google_bigquery_dataset.go (88%) rename {pkg => enumeration}/resource/google/google_bigquery_table.go (88%) rename {pkg => enumeration}/resource/google/google_bigtable_instance.go (100%) rename {pkg => enumeration}/resource/google/google_bigtable_table.go (100%) rename {pkg => enumeration}/resource/google/google_cloudfunctions_function.go (100%) rename {pkg => enumeration}/resource/google/google_cloudrun_service.go (100%) rename {pkg => enumeration}/resource/google/google_compute_address.go (89%) rename {pkg => enumeration}/resource/google/google_compute_disk.go (87%) create mode 100644 enumeration/resource/google/google_compute_firewall.go rename {pkg => enumeration}/resource/google/google_compute_forwarding_rule.go (100%) rename {pkg => enumeration}/resource/google/google_compute_global_address.go (89%) rename {pkg => enumeration}/resource/google/google_compute_global_forwarding_rule.go (100%) rename {pkg => enumeration}/resource/google/google_compute_health_check.go (88%) rename {pkg => enumeration}/resource/google/google_compute_image.go (87%) rename {pkg => enumeration}/resource/google/google_compute_instance.go (100%) create mode 100644 enumeration/resource/google/google_compute_instance_group.go rename {pkg => enumeration}/resource/google/google_compute_instance_group_manager.go (90%) create mode 100644 enumeration/resource/google/google_compute_network.go rename {pkg => enumeration}/resource/google/google_compute_node_group.go (100%) rename {pkg => enumeration}/resource/google/google_compute_router.go (89%) create mode 100644 enumeration/resource/google/google_compute_subnetwork.go rename {pkg => enumeration}/resource/google/google_dns_managed_zone.go (100%) rename {pkg => enumeration}/resource/google/google_project_iam_binding.go (100%) create mode 100644 enumeration/resource/google/google_project_iam_member.go rename {pkg => enumeration}/resource/google/google_project_iam_policy.go (100%) rename {pkg => enumeration}/resource/google/google_sql_database_instance.go (100%) create mode 100644 enumeration/resource/google/google_storage_bucket.go rename {pkg => enumeration}/resource/google/google_storage_bucket_iam_binding.go (100%) create mode 100644 enumeration/resource/google/google_storage_bucket_iam_member.go rename {pkg => enumeration}/resource/google/google_storage_bucket_iam_policy.go (100%) rename {pkg => enumeration}/resource/google/metadata_test.go (95%) create mode 100644 enumeration/resource/google/metadatas.go create mode 100644 enumeration/resource/mock_Supplier.go rename {pkg => enumeration}/resource/resource.go (100%) rename {pkg => enumeration}/resource/resource_test.go (100%) rename {pkg => enumeration}/resource/resource_types.go (100%) rename {pkg => enumeration}/resource/schemas.go (100%) create mode 100644 enumeration/resource/supplier.go rename {pkg => enumeration}/terraform/error/provider_download_error.go (100%) rename {pkg => enumeration}/terraform/lock/lockfile.go (100%) rename {pkg => enumeration}/terraform/lock/lockfile_test.go (100%) rename {pkg => enumeration}/terraform/lock/testdata/lockfile_empty.hcl (100%) rename {pkg => enumeration}/terraform/lock/testdata/lockfile_invalid.hcl (100%) rename {pkg => enumeration}/terraform/lock/testdata/lockfile_invalid_type-1.hcl (100%) rename {pkg => enumeration}/terraform/lock/testdata/lockfile_invalid_type-3.hcl (100%) rename {pkg => enumeration}/terraform/lock/testdata/lockfile_valid.hcl (100%) rename {pkg => enumeration}/terraform/mock_ResourceFactory.go (96%) rename {pkg => enumeration}/terraform/parallel_resource_reader.go (94%) rename {pkg => enumeration}/terraform/parallel_resource_reader_test.go (97%) rename {pkg => enumeration}/terraform/plugin_client.go (100%) rename {pkg => enumeration}/terraform/provider_config.go (100%) rename {pkg => enumeration}/terraform/provider_config_test.go (100%) rename {pkg => enumeration}/terraform/provider_downloader.go (94%) rename {pkg => enumeration}/terraform/provider_downloader_test.go (97%) rename {pkg => enumeration}/terraform/provider_factory.go (100%) rename {pkg => enumeration}/terraform/provider_installer.go (92%) rename {pkg => enumeration}/terraform/provider_installer_test.go (98%) rename {pkg => enumeration}/terraform/providers.go (100%) rename {pkg => enumeration}/terraform/resource_factory.go (94%) rename {pkg => enumeration}/terraform/resource_reader.go (84%) rename {pkg => enumeration}/terraform/schema_supplier.go (100%) rename {pkg => enumeration}/terraform/terraform_provider.go (100%) rename {pkg => enumeration}/terraform/testdata/invalid.zip (100%) rename {pkg => enumeration}/terraform/testdata/terraform-provider-aws_3.5.0_linux_amd64.zip (100%) delete mode 100644 pkg/helpers/interface.go mode change 100755 => 100644 pkg/iac/terraform/state/testdata/acc/multiple_states_local/route53/.terraform.lock.hcl mode change 100755 => 100644 pkg/iac/terraform/state/testdata/acc/multiple_states_local/s3/.terraform.lock.hcl mode change 100755 => 100644 pkg/resource/aws/testdata/acc/aws_instance/.terraform.lock.hcl mode change 100755 => 100644 pkg/resource/aws/testdata/acc/aws_nat_gateway/.terraform.lock.hcl mode change 100755 => 100644 pkg/resource/aws/testdata/acc/aws_route53_record/.terraform.lock.hcl mode change 100755 => 100644 pkg/resource/aws/testdata/acc/aws_route_table_association/.terraform.lock.hcl mode change 100755 => 100644 pkg/resource/aws/testdata/acc/aws_s3_bucket/.terraform.lock.hcl mode change 100755 => 100644 pkg/resource/aws/testdata/acc/aws_sns_topic/.terraform.lock.hcl mode change 100755 => 100644 pkg/resource/aws/testdata/acc/aws_sns_topic_policy/.terraform.lock.hcl mode change 100755 => 100644 pkg/resource/aws/testdata/acc/aws_sns_topic_subscription/.terraform.lock.hcl mode change 100755 => 100644 pkg/resource/aws/testdata/acc/aws_subnet/.terraform.lock.hcl mode change 100755 => 100644 pkg/resource/azurerm/testdata/acc/azurerm_resource_group/.terraform.lock.hcl mode change 100755 => 100644 pkg/resource/github/testdata/acc/github_branch_protection/.terraform.lock.hcl mode change 100755 => 100644 pkg/resource/github/testdata/acc/github_repository/.terraform.lock.hcl mode change 100755 => 100644 pkg/resource/github/testdata/acc/github_team/.terraform.lock.hcl create mode 100644 pkg/resource/init_metadatas.go diff --git a/pkg/alerter/alert.go b/enumeration/alerter/alert.go similarity index 100% rename from pkg/alerter/alert.go rename to enumeration/alerter/alert.go diff --git a/pkg/alerter/alerter.go b/enumeration/alerter/alerter.go similarity index 96% rename from pkg/alerter/alerter.go rename to enumeration/alerter/alerter.go index a6b268800..d134d2b15 100644 --- a/pkg/alerter/alerter.go +++ b/enumeration/alerter/alerter.go @@ -3,7 +3,7 @@ package alerter import ( "fmt" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) type AlerterInterface interface { diff --git a/pkg/alerter/alerter_test.go b/enumeration/alerter/alerter_test.go similarity index 98% rename from pkg/alerter/alerter_test.go rename to enumeration/alerter/alerter_test.go index f195760bc..ff1252d21 100644 --- a/pkg/alerter/alerter_test.go +++ b/enumeration/alerter/alerter_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) func TestAlerter_Alert(t *testing.T) { diff --git a/enumeration/filter.go b/enumeration/filter.go new file mode 100644 index 000000000..7c8ef215b --- /dev/null +++ b/enumeration/filter.go @@ -0,0 +1,9 @@ +package enumeration + +import "github.com/snyk/driftctl/enumeration/resource" + +type Filter interface { + IsTypeIgnored(ty resource.ResourceType) bool + IsResourceIgnored(res *resource.Resource) bool + IsFieldIgnored(res *resource.Resource, path []string) bool +} diff --git a/enumeration/mock_Filter.go b/enumeration/mock_Filter.go new file mode 100644 index 000000000..172b23c81 --- /dev/null +++ b/enumeration/mock_Filter.go @@ -0,0 +1,55 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package enumeration + +import ( + resource "github.com/snyk/driftctl/enumeration/resource" + mock "github.com/stretchr/testify/mock" +) + +// MockFilter is an autogenerated mock type for the Filter type +type MockFilter struct { + mock.Mock +} + +// IsFieldIgnored provides a mock function with given fields: res, path +func (_m *MockFilter) IsFieldIgnored(res *resource.Resource, path []string) bool { + ret := _m.Called(res, path) + + var r0 bool + if rf, ok := ret.Get(0).(func(*resource.Resource, []string) bool); ok { + r0 = rf(res, path) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// IsResourceIgnored provides a mock function with given fields: res +func (_m *MockFilter) IsResourceIgnored(res *resource.Resource) bool { + ret := _m.Called(res) + + var r0 bool + if rf, ok := ret.Get(0).(func(*resource.Resource) bool); ok { + r0 = rf(res) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// IsTypeIgnored provides a mock function with given fields: ty +func (_m *MockFilter) IsTypeIgnored(ty resource.ResourceType) bool { + ret := _m.Called(ty) + + var r0 bool + if rf, ok := ret.Get(0).(func(resource.ResourceType) bool); ok { + r0 = rf(ty) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} diff --git a/pkg/parallel/parallel_runner.go b/enumeration/parallel/parallel_runner.go similarity index 100% rename from pkg/parallel/parallel_runner.go rename to enumeration/parallel/parallel_runner.go diff --git a/pkg/parallel/parallel_runner_test.go b/enumeration/parallel/parallel_runner_test.go similarity index 100% rename from pkg/parallel/parallel_runner_test.go rename to enumeration/parallel/parallel_runner_test.go diff --git a/enumeration/progress.go b/enumeration/progress.go new file mode 100644 index 000000000..b7dda18d4 --- /dev/null +++ b/enumeration/progress.go @@ -0,0 +1,5 @@ +package enumeration + +type ProgressCounter interface { + Inc() +} diff --git a/pkg/remote/alerts/alerts.go b/enumeration/remote/alerts/alerts.go similarity index 94% rename from pkg/remote/alerts/alerts.go rename to enumeration/remote/alerts/alerts.go index 4bcc0b704..180369aaf 100644 --- a/pkg/remote/alerts/alerts.go +++ b/enumeration/remote/alerts/alerts.go @@ -3,10 +3,11 @@ package alerts import ( "fmt" + "github.com/snyk/driftctl/enumeration/alerter" + "github.com/snyk/driftctl/enumeration/remote/common" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/alerter" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" ) type ScanningPhase int diff --git a/pkg/remote/aws/api_gateway_account_enumerator.go b/enumeration/remote/aws/api_gateway_account_enumerator.go similarity index 81% rename from pkg/remote/aws/api_gateway_account_enumerator.go rename to enumeration/remote/aws/api_gateway_account_enumerator.go index dec862604..857dc23b9 100644 --- a/pkg/remote/aws/api_gateway_account_enumerator.go +++ b/enumeration/remote/aws/api_gateway_account_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayAccountEnumerator struct { diff --git a/pkg/remote/aws/api_gateway_api_key_enumerator.go b/enumeration/remote/aws/api_gateway_api_key_enumerator.go similarity index 81% rename from pkg/remote/aws/api_gateway_api_key_enumerator.go rename to enumeration/remote/aws/api_gateway_api_key_enumerator.go index 1f6b1101a..88bca5268 100644 --- a/pkg/remote/aws/api_gateway_api_key_enumerator.go +++ b/enumeration/remote/aws/api_gateway_api_key_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayApiKeyEnumerator struct { diff --git a/pkg/remote/aws/api_gateway_authorizer_enumerator.go b/enumeration/remote/aws/api_gateway_authorizer_enumerator.go similarity index 85% rename from pkg/remote/aws/api_gateway_authorizer_enumerator.go rename to enumeration/remote/aws/api_gateway_authorizer_enumerator.go index a652e6a32..d69372cc6 100644 --- a/pkg/remote/aws/api_gateway_authorizer_enumerator.go +++ b/enumeration/remote/aws/api_gateway_authorizer_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayAuthorizerEnumerator struct { diff --git a/pkg/remote/aws/api_gateway_base_path_mapping_enumerator.go b/enumeration/remote/aws/api_gateway_base_path_mapping_enumerator.go similarity index 87% rename from pkg/remote/aws/api_gateway_base_path_mapping_enumerator.go rename to enumeration/remote/aws/api_gateway_base_path_mapping_enumerator.go index 868996f96..c9a3247a6 100644 --- a/pkg/remote/aws/api_gateway_base_path_mapping_enumerator.go +++ b/enumeration/remote/aws/api_gateway_base_path_mapping_enumerator.go @@ -1,12 +1,12 @@ package aws import ( + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" "strings" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayBasePathMappingEnumerator struct { diff --git a/pkg/remote/aws/api_gateway_domain_name_enumerator.go b/enumeration/remote/aws/api_gateway_domain_name_enumerator.go similarity index 82% rename from pkg/remote/aws/api_gateway_domain_name_enumerator.go rename to enumeration/remote/aws/api_gateway_domain_name_enumerator.go index b5984cdc5..d24fc9da4 100644 --- a/pkg/remote/aws/api_gateway_domain_name_enumerator.go +++ b/enumeration/remote/aws/api_gateway_domain_name_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayDomainNameEnumerator struct { diff --git a/pkg/remote/aws/api_gateway_gateway_response_enumerator.go b/enumeration/remote/aws/api_gateway_gateway_response_enumerator.go similarity index 86% rename from pkg/remote/aws/api_gateway_gateway_response_enumerator.go rename to enumeration/remote/aws/api_gateway_gateway_response_enumerator.go index 2dd406fb4..828ba3c58 100644 --- a/pkg/remote/aws/api_gateway_gateway_response_enumerator.go +++ b/enumeration/remote/aws/api_gateway_gateway_response_enumerator.go @@ -1,12 +1,12 @@ package aws import ( + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" "strings" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayGatewayResponseEnumerator struct { diff --git a/pkg/remote/aws/api_gateway_integration_enumerator.go b/enumeration/remote/aws/api_gateway_integration_enumerator.go similarity index 86% rename from pkg/remote/aws/api_gateway_integration_enumerator.go rename to enumeration/remote/aws/api_gateway_integration_enumerator.go index eef949395..ef2089d3e 100644 --- a/pkg/remote/aws/api_gateway_integration_enumerator.go +++ b/enumeration/remote/aws/api_gateway_integration_enumerator.go @@ -1,12 +1,12 @@ package aws import ( + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" "strings" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayIntegrationEnumerator struct { diff --git a/pkg/remote/aws/api_gateway_integration_response_enumerator.go b/enumeration/remote/aws/api_gateway_integration_response_enumerator.go similarity index 88% rename from pkg/remote/aws/api_gateway_integration_response_enumerator.go rename to enumeration/remote/aws/api_gateway_integration_response_enumerator.go index 2d1382316..3ede03176 100644 --- a/pkg/remote/aws/api_gateway_integration_response_enumerator.go +++ b/enumeration/remote/aws/api_gateway_integration_response_enumerator.go @@ -1,12 +1,12 @@ package aws import ( + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" "strings" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayIntegrationResponseEnumerator struct { diff --git a/pkg/remote/aws/api_gateway_method_enumerator.go b/enumeration/remote/aws/api_gateway_method_enumerator.go similarity index 86% rename from pkg/remote/aws/api_gateway_method_enumerator.go rename to enumeration/remote/aws/api_gateway_method_enumerator.go index f8c3443b9..15034e275 100644 --- a/pkg/remote/aws/api_gateway_method_enumerator.go +++ b/enumeration/remote/aws/api_gateway_method_enumerator.go @@ -1,12 +1,12 @@ package aws import ( + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" "strings" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayMethodEnumerator struct { diff --git a/pkg/remote/aws/api_gateway_method_response_enumerator.go b/enumeration/remote/aws/api_gateway_method_response_enumerator.go similarity index 87% rename from pkg/remote/aws/api_gateway_method_response_enumerator.go rename to enumeration/remote/aws/api_gateway_method_response_enumerator.go index b56e70111..c0cee5952 100644 --- a/pkg/remote/aws/api_gateway_method_response_enumerator.go +++ b/enumeration/remote/aws/api_gateway_method_response_enumerator.go @@ -1,12 +1,12 @@ package aws import ( + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" "strings" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayMethodResponseEnumerator struct { diff --git a/pkg/remote/aws/api_gateway_method_settings_enumerator.go b/enumeration/remote/aws/api_gateway_method_settings_enumerator.go similarity index 86% rename from pkg/remote/aws/api_gateway_method_settings_enumerator.go rename to enumeration/remote/aws/api_gateway_method_settings_enumerator.go index 219a59764..254359f23 100644 --- a/pkg/remote/aws/api_gateway_method_settings_enumerator.go +++ b/enumeration/remote/aws/api_gateway_method_settings_enumerator.go @@ -1,12 +1,12 @@ package aws import ( + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" "strings" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayMethodSettingsEnumerator struct { diff --git a/pkg/remote/aws/api_gateway_model_enumerator.go b/enumeration/remote/aws/api_gateway_model_enumerator.go similarity index 84% rename from pkg/remote/aws/api_gateway_model_enumerator.go rename to enumeration/remote/aws/api_gateway_model_enumerator.go index a959cd874..e2a3b53ec 100644 --- a/pkg/remote/aws/api_gateway_model_enumerator.go +++ b/enumeration/remote/aws/api_gateway_model_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayModelEnumerator struct { diff --git a/pkg/remote/aws/api_gateway_request_validator_enumerator.go b/enumeration/remote/aws/api_gateway_request_validator_enumerator.go similarity index 85% rename from pkg/remote/aws/api_gateway_request_validator_enumerator.go rename to enumeration/remote/aws/api_gateway_request_validator_enumerator.go index 05cdf5061..d886bfc98 100644 --- a/pkg/remote/aws/api_gateway_request_validator_enumerator.go +++ b/enumeration/remote/aws/api_gateway_request_validator_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayRequestValidatorEnumerator struct { diff --git a/pkg/remote/aws/api_gateway_resource_enumerator.go b/enumeration/remote/aws/api_gateway_resource_enumerator.go similarity index 85% rename from pkg/remote/aws/api_gateway_resource_enumerator.go rename to enumeration/remote/aws/api_gateway_resource_enumerator.go index 8f47afb4d..ea1bd8000 100644 --- a/pkg/remote/aws/api_gateway_resource_enumerator.go +++ b/enumeration/remote/aws/api_gateway_resource_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayResourceEnumerator struct { diff --git a/pkg/remote/aws/api_gateway_rest_api_enumerator.go b/enumeration/remote/aws/api_gateway_rest_api_enumerator.go similarity index 81% rename from pkg/remote/aws/api_gateway_rest_api_enumerator.go rename to enumeration/remote/aws/api_gateway_rest_api_enumerator.go index 68b24fda7..44588d252 100644 --- a/pkg/remote/aws/api_gateway_rest_api_enumerator.go +++ b/enumeration/remote/aws/api_gateway_rest_api_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayRestApiEnumerator struct { diff --git a/pkg/remote/aws/api_gateway_rest_api_policy_enumerator.go b/enumeration/remote/aws/api_gateway_rest_api_policy_enumerator.go similarity index 83% rename from pkg/remote/aws/api_gateway_rest_api_policy_enumerator.go rename to enumeration/remote/aws/api_gateway_rest_api_policy_enumerator.go index 4520c153f..9cb109bbb 100644 --- a/pkg/remote/aws/api_gateway_rest_api_policy_enumerator.go +++ b/enumeration/remote/aws/api_gateway_rest_api_policy_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayRestApiPolicyEnumerator struct { diff --git a/pkg/remote/aws/api_gateway_stage_enumerator.go b/enumeration/remote/aws/api_gateway_stage_enumerator.go similarity index 85% rename from pkg/remote/aws/api_gateway_stage_enumerator.go rename to enumeration/remote/aws/api_gateway_stage_enumerator.go index 79dc63638..34860c9c2 100644 --- a/pkg/remote/aws/api_gateway_stage_enumerator.go +++ b/enumeration/remote/aws/api_gateway_stage_enumerator.go @@ -1,12 +1,12 @@ package aws import ( + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" "strings" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayStageEnumerator struct { diff --git a/pkg/remote/aws/api_gateway_vpc_link_enumerator.go b/enumeration/remote/aws/api_gateway_vpc_link_enumerator.go similarity index 81% rename from pkg/remote/aws/api_gateway_vpc_link_enumerator.go rename to enumeration/remote/aws/api_gateway_vpc_link_enumerator.go index ad24665ac..a66ace88b 100644 --- a/pkg/remote/aws/api_gateway_vpc_link_enumerator.go +++ b/enumeration/remote/aws/api_gateway_vpc_link_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayVpcLinkEnumerator struct { diff --git a/pkg/remote/aws/apigatewayv2_api_enumerator.go b/enumeration/remote/aws/apigatewayv2_api_enumerator.go similarity index 81% rename from pkg/remote/aws/apigatewayv2_api_enumerator.go rename to enumeration/remote/aws/apigatewayv2_api_enumerator.go index d4eefee93..34333542c 100644 --- a/pkg/remote/aws/apigatewayv2_api_enumerator.go +++ b/enumeration/remote/aws/apigatewayv2_api_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayV2ApiEnumerator struct { diff --git a/pkg/remote/aws/apigatewayv2_authorizer_enumerator.go b/enumeration/remote/aws/apigatewayv2_authorizer_enumerator.go similarity index 85% rename from pkg/remote/aws/apigatewayv2_authorizer_enumerator.go rename to enumeration/remote/aws/apigatewayv2_authorizer_enumerator.go index cff25da2e..7370abf8f 100644 --- a/pkg/remote/aws/apigatewayv2_authorizer_enumerator.go +++ b/enumeration/remote/aws/apigatewayv2_authorizer_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayV2AuthorizerEnumerator struct { diff --git a/pkg/remote/aws/apigatewayv2_deployment_enumerator.go b/enumeration/remote/aws/apigatewayv2_deployment_enumerator.go similarity index 85% rename from pkg/remote/aws/apigatewayv2_deployment_enumerator.go rename to enumeration/remote/aws/apigatewayv2_deployment_enumerator.go index 4a66f92d1..43eef1fe2 100644 --- a/pkg/remote/aws/apigatewayv2_deployment_enumerator.go +++ b/enumeration/remote/aws/apigatewayv2_deployment_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayV2DeploymentEnumerator struct { diff --git a/pkg/remote/aws/apigatewayv2_domain_name_enumerator.go b/enumeration/remote/aws/apigatewayv2_domain_name_enumerator.go similarity index 84% rename from pkg/remote/aws/apigatewayv2_domain_name_enumerator.go rename to enumeration/remote/aws/apigatewayv2_domain_name_enumerator.go index 64b70bb87..87315f4f0 100644 --- a/pkg/remote/aws/apigatewayv2_domain_name_enumerator.go +++ b/enumeration/remote/aws/apigatewayv2_domain_name_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayV2DomainNameEnumerator struct { diff --git a/pkg/remote/aws/apigatewayv2_integration_enumerator.go b/enumeration/remote/aws/apigatewayv2_integration_enumerator.go similarity index 87% rename from pkg/remote/aws/apigatewayv2_integration_enumerator.go rename to enumeration/remote/aws/apigatewayv2_integration_enumerator.go index 7b7434bac..57552d875 100644 --- a/pkg/remote/aws/apigatewayv2_integration_enumerator.go +++ b/enumeration/remote/aws/apigatewayv2_integration_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayV2IntegrationEnumerator struct { diff --git a/pkg/remote/aws/apigatewayv2_integration_response_enumerator.go b/enumeration/remote/aws/apigatewayv2_integration_response_enumerator.go similarity index 88% rename from pkg/remote/aws/apigatewayv2_integration_response_enumerator.go rename to enumeration/remote/aws/apigatewayv2_integration_response_enumerator.go index 0b2976a7b..62f45850e 100644 --- a/pkg/remote/aws/apigatewayv2_integration_response_enumerator.go +++ b/enumeration/remote/aws/apigatewayv2_integration_response_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayV2IntegrationResponseEnumerator struct { diff --git a/pkg/remote/aws/apigatewayv2_mapping_enumerator.go b/enumeration/remote/aws/apigatewayv2_mapping_enumerator.go similarity index 71% rename from pkg/remote/aws/apigatewayv2_mapping_enumerator.go rename to enumeration/remote/aws/apigatewayv2_mapping_enumerator.go index 0bc1e8768..01e812a0d 100644 --- a/pkg/remote/aws/apigatewayv2_mapping_enumerator.go +++ b/enumeration/remote/aws/apigatewayv2_mapping_enumerator.go @@ -1,19 +1,19 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayV2MappingEnumerator struct { - repository repository.ApiGatewayV2Repository - repositoryV1 repository.ApiGatewayRepository + repository repository2.ApiGatewayV2Repository + repositoryV1 repository2.ApiGatewayRepository factory resource.ResourceFactory } -func NewApiGatewayV2MappingEnumerator(repo repository.ApiGatewayV2Repository, repov1 repository.ApiGatewayRepository, factory resource.ResourceFactory) *ApiGatewayV2MappingEnumerator { +func NewApiGatewayV2MappingEnumerator(repo repository2.ApiGatewayV2Repository, repov1 repository2.ApiGatewayRepository, factory resource.ResourceFactory) *ApiGatewayV2MappingEnumerator { return &ApiGatewayV2MappingEnumerator{ repository: repo, repositoryV1: repov1, diff --git a/pkg/remote/aws/apigatewayv2_model_enumerator.go b/enumeration/remote/aws/apigatewayv2_model_enumerator.go similarity index 84% rename from pkg/remote/aws/apigatewayv2_model_enumerator.go rename to enumeration/remote/aws/apigatewayv2_model_enumerator.go index 64f7f0ebf..0704f2909 100644 --- a/pkg/remote/aws/apigatewayv2_model_enumerator.go +++ b/enumeration/remote/aws/apigatewayv2_model_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayV2ModelEnumerator struct { diff --git a/pkg/remote/aws/apigatewayv2_route_enumerator.go b/enumeration/remote/aws/apigatewayv2_route_enumerator.go similarity index 85% rename from pkg/remote/aws/apigatewayv2_route_enumerator.go rename to enumeration/remote/aws/apigatewayv2_route_enumerator.go index ac41a8a89..b0cfc02f5 100644 --- a/pkg/remote/aws/apigatewayv2_route_enumerator.go +++ b/enumeration/remote/aws/apigatewayv2_route_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayV2RouteEnumerator struct { diff --git a/pkg/remote/aws/apigatewayv2_route_response_enumerator.go b/enumeration/remote/aws/apigatewayv2_route_response_enumerator.go similarity index 87% rename from pkg/remote/aws/apigatewayv2_route_response_enumerator.go rename to enumeration/remote/aws/apigatewayv2_route_response_enumerator.go index 4e23bb097..9c6d5a62c 100644 --- a/pkg/remote/aws/apigatewayv2_route_response_enumerator.go +++ b/enumeration/remote/aws/apigatewayv2_route_response_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayV2RouteResponseEnumerator struct { diff --git a/pkg/remote/aws/apigatewayv2_stage_enumerator.go b/enumeration/remote/aws/apigatewayv2_stage_enumerator.go similarity index 84% rename from pkg/remote/aws/apigatewayv2_stage_enumerator.go rename to enumeration/remote/aws/apigatewayv2_stage_enumerator.go index 8041a0366..bdc14473c 100644 --- a/pkg/remote/aws/apigatewayv2_stage_enumerator.go +++ b/enumeration/remote/aws/apigatewayv2_stage_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayV2StageEnumerator struct { diff --git a/pkg/remote/aws/apigatewayv2_vpc_link_enumerator.go b/enumeration/remote/aws/apigatewayv2_vpc_link_enumerator.go similarity index 81% rename from pkg/remote/aws/apigatewayv2_vpc_link_enumerator.go rename to enumeration/remote/aws/apigatewayv2_vpc_link_enumerator.go index 8f5c4bc0b..5edef1aa4 100644 --- a/pkg/remote/aws/apigatewayv2_vpc_link_enumerator.go +++ b/enumeration/remote/aws/apigatewayv2_vpc_link_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayV2VpcLinkEnumerator struct { diff --git a/pkg/remote/aws/appautoscaling_policy_enumerator.go b/enumeration/remote/aws/appautoscaling_policy_enumerator.go similarity index 85% rename from pkg/remote/aws/appautoscaling_policy_enumerator.go rename to enumeration/remote/aws/appautoscaling_policy_enumerator.go index e773cee40..4662b8b99 100644 --- a/pkg/remote/aws/appautoscaling_policy_enumerator.go +++ b/enumeration/remote/aws/appautoscaling_policy_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type AppAutoscalingPolicyEnumerator struct { diff --git a/pkg/remote/aws/appautoscaling_scheduled_action_enumerator.go b/enumeration/remote/aws/appautoscaling_scheduled_action_enumerator.go similarity index 84% rename from pkg/remote/aws/appautoscaling_scheduled_action_enumerator.go rename to enumeration/remote/aws/appautoscaling_scheduled_action_enumerator.go index d77874d82..3cb182e73 100644 --- a/pkg/remote/aws/appautoscaling_scheduled_action_enumerator.go +++ b/enumeration/remote/aws/appautoscaling_scheduled_action_enumerator.go @@ -1,12 +1,12 @@ package aws import ( + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" "strings" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type AppAutoscalingScheduledActionEnumerator struct { diff --git a/pkg/remote/aws/appautoscaling_target_enumerator.go b/enumeration/remote/aws/appautoscaling_target_enumerator.go similarity index 85% rename from pkg/remote/aws/appautoscaling_target_enumerator.go rename to enumeration/remote/aws/appautoscaling_target_enumerator.go index 177f3f1bc..fbe039aab 100644 --- a/pkg/remote/aws/appautoscaling_target_enumerator.go +++ b/enumeration/remote/aws/appautoscaling_target_enumerator.go @@ -2,10 +2,10 @@ package aws import ( "github.com/aws/aws-sdk-go/service/applicationautoscaling" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type AppAutoscalingTargetEnumerator struct { diff --git a/pkg/remote/aws/classic_loadbalancer_enumerator.go b/enumeration/remote/aws/classic_loadbalancer_enumerator.go similarity index 81% rename from pkg/remote/aws/classic_loadbalancer_enumerator.go rename to enumeration/remote/aws/classic_loadbalancer_enumerator.go index fa14f3fc7..7890f1594 100644 --- a/pkg/remote/aws/classic_loadbalancer_enumerator.go +++ b/enumeration/remote/aws/classic_loadbalancer_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ClassicLoadBalancerEnumerator struct { diff --git a/pkg/remote/aws/client/mock_AwsClientFactoryInterface.go b/enumeration/remote/aws/client/mock_AwsClientFactoryInterface.go similarity index 100% rename from pkg/remote/aws/client/mock_AwsClientFactoryInterface.go rename to enumeration/remote/aws/client/mock_AwsClientFactoryInterface.go diff --git a/pkg/remote/aws/client/s3_client_factory.go b/enumeration/remote/aws/client/s3_client_factory.go similarity index 100% rename from pkg/remote/aws/client/s3_client_factory.go rename to enumeration/remote/aws/client/s3_client_factory.go diff --git a/pkg/remote/aws/cloudformation_stack_enumerator.go b/enumeration/remote/aws/cloudformation_stack_enumerator.go similarity index 86% rename from pkg/remote/aws/cloudformation_stack_enumerator.go rename to enumeration/remote/aws/cloudformation_stack_enumerator.go index 7c3d064b5..5be5e5192 100644 --- a/pkg/remote/aws/cloudformation_stack_enumerator.go +++ b/enumeration/remote/aws/cloudformation_stack_enumerator.go @@ -2,10 +2,10 @@ package aws import ( "github.com/aws/aws-sdk-go/service/cloudformation" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type CloudformationStackEnumerator struct { diff --git a/pkg/remote/aws/cloudfront_distribution_enumerator.go b/enumeration/remote/aws/cloudfront_distribution_enumerator.go similarity index 82% rename from pkg/remote/aws/cloudfront_distribution_enumerator.go rename to enumeration/remote/aws/cloudfront_distribution_enumerator.go index 9114e2ac9..58aa7c1b2 100644 --- a/pkg/remote/aws/cloudfront_distribution_enumerator.go +++ b/enumeration/remote/aws/cloudfront_distribution_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type CloudfrontDistributionEnumerator struct { diff --git a/pkg/remote/aws/default_vpc_enumerator.go b/enumeration/remote/aws/default_vpc_enumerator.go similarity index 80% rename from pkg/remote/aws/default_vpc_enumerator.go rename to enumeration/remote/aws/default_vpc_enumerator.go index 31ba45088..b49b8fb06 100644 --- a/pkg/remote/aws/default_vpc_enumerator.go +++ b/enumeration/remote/aws/default_vpc_enumerator.go @@ -1,12 +1,11 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource/aws" - "github.com/snyk/driftctl/pkg/resource/aws" - - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) type DefaultVPCEnumerator struct { diff --git a/pkg/remote/aws/dynamodb_table_enumerator.go b/enumeration/remote/aws/dynamodb_table_enumerator.go similarity index 80% rename from pkg/remote/aws/dynamodb_table_enumerator.go rename to enumeration/remote/aws/dynamodb_table_enumerator.go index 4085712f5..37cdaffe3 100644 --- a/pkg/remote/aws/dynamodb_table_enumerator.go +++ b/enumeration/remote/aws/dynamodb_table_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type DynamoDBTableEnumerator struct { diff --git a/pkg/remote/aws/ebs_encryption_by_default_enumerator.go b/enumeration/remote/aws/ebs_encryption_by_default_enumerator.go similarity index 82% rename from pkg/remote/aws/ebs_encryption_by_default_enumerator.go rename to enumeration/remote/aws/ebs_encryption_by_default_enumerator.go index 8ccf89378..2363ca087 100644 --- a/pkg/remote/aws/ebs_encryption_by_default_enumerator.go +++ b/enumeration/remote/aws/ebs_encryption_by_default_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type EC2EbsEncryptionByDefaultEnumerator struct { diff --git a/pkg/remote/aws/ec2_ami_enumerator.go b/enumeration/remote/aws/ec2_ami_enumerator.go similarity index 79% rename from pkg/remote/aws/ec2_ami_enumerator.go rename to enumeration/remote/aws/ec2_ami_enumerator.go index fe4b5baa4..ed409fb3e 100644 --- a/pkg/remote/aws/ec2_ami_enumerator.go +++ b/enumeration/remote/aws/ec2_ami_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type EC2AmiEnumerator struct { diff --git a/pkg/remote/aws/ec2_default_network_acl_enumerator.go b/enumeration/remote/aws/ec2_default_network_acl_enumerator.go similarity index 83% rename from pkg/remote/aws/ec2_default_network_acl_enumerator.go rename to enumeration/remote/aws/ec2_default_network_acl_enumerator.go index 3d268a672..1490211ea 100644 --- a/pkg/remote/aws/ec2_default_network_acl_enumerator.go +++ b/enumeration/remote/aws/ec2_default_network_acl_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type EC2DefaultNetworkACLEnumerator struct { diff --git a/pkg/remote/aws/ec2_default_route_table_enumerator.go b/enumeration/remote/aws/ec2_default_route_table_enumerator.go similarity index 82% rename from pkg/remote/aws/ec2_default_route_table_enumerator.go rename to enumeration/remote/aws/ec2_default_route_table_enumerator.go index 6bdf45141..75ec8036f 100644 --- a/pkg/remote/aws/ec2_default_route_table_enumerator.go +++ b/enumeration/remote/aws/ec2_default_route_table_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type EC2DefaultRouteTableEnumerator struct { diff --git a/pkg/remote/aws/ec2_default_subnet_enumerator.go b/enumeration/remote/aws/ec2_default_subnet_enumerator.go similarity index 81% rename from pkg/remote/aws/ec2_default_subnet_enumerator.go rename to enumeration/remote/aws/ec2_default_subnet_enumerator.go index 809795100..dbc5cef99 100644 --- a/pkg/remote/aws/ec2_default_subnet_enumerator.go +++ b/enumeration/remote/aws/ec2_default_subnet_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type EC2DefaultSubnetEnumerator struct { diff --git a/pkg/remote/aws/ec2_ebs_snapshot_enumerator.go b/enumeration/remote/aws/ec2_ebs_snapshot_enumerator.go similarity index 81% rename from pkg/remote/aws/ec2_ebs_snapshot_enumerator.go rename to enumeration/remote/aws/ec2_ebs_snapshot_enumerator.go index 5742e9082..20d69dd09 100644 --- a/pkg/remote/aws/ec2_ebs_snapshot_enumerator.go +++ b/enumeration/remote/aws/ec2_ebs_snapshot_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type EC2EbsSnapshotEnumerator struct { diff --git a/pkg/remote/aws/ec2_ebs_volume_enumerator.go b/enumeration/remote/aws/ec2_ebs_volume_enumerator.go similarity index 80% rename from pkg/remote/aws/ec2_ebs_volume_enumerator.go rename to enumeration/remote/aws/ec2_ebs_volume_enumerator.go index bfbe6033a..7528b1395 100644 --- a/pkg/remote/aws/ec2_ebs_volume_enumerator.go +++ b/enumeration/remote/aws/ec2_ebs_volume_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type EC2EbsVolumeEnumerator struct { diff --git a/pkg/remote/aws/ec2_eip_association_enumerator.go b/enumeration/remote/aws/ec2_eip_association_enumerator.go similarity index 82% rename from pkg/remote/aws/ec2_eip_association_enumerator.go rename to enumeration/remote/aws/ec2_eip_association_enumerator.go index d533450c8..7da15c1c1 100644 --- a/pkg/remote/aws/ec2_eip_association_enumerator.go +++ b/enumeration/remote/aws/ec2_eip_association_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type EC2EipAssociationEnumerator struct { diff --git a/pkg/remote/aws/ec2_eip_enumerator.go b/enumeration/remote/aws/ec2_eip_enumerator.go similarity index 82% rename from pkg/remote/aws/ec2_eip_enumerator.go rename to enumeration/remote/aws/ec2_eip_enumerator.go index 9513c62e1..a4ace5748 100644 --- a/pkg/remote/aws/ec2_eip_enumerator.go +++ b/enumeration/remote/aws/ec2_eip_enumerator.go @@ -2,10 +2,10 @@ package aws import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type EC2EipEnumerator struct { diff --git a/pkg/remote/aws/ec2_instance_enumerator.go b/enumeration/remote/aws/ec2_instance_enumerator.go similarity index 80% rename from pkg/remote/aws/ec2_instance_enumerator.go rename to enumeration/remote/aws/ec2_instance_enumerator.go index 80a39c3c1..0779759f0 100644 --- a/pkg/remote/aws/ec2_instance_enumerator.go +++ b/enumeration/remote/aws/ec2_instance_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type EC2InstanceEnumerator struct { diff --git a/pkg/remote/aws/ec2_internet_gateway_enumerator.go b/enumeration/remote/aws/ec2_internet_gateway_enumerator.go similarity index 84% rename from pkg/remote/aws/ec2_internet_gateway_enumerator.go rename to enumeration/remote/aws/ec2_internet_gateway_enumerator.go index 7d9748518..82dedf7c3 100644 --- a/pkg/remote/aws/ec2_internet_gateway_enumerator.go +++ b/enumeration/remote/aws/ec2_internet_gateway_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type EC2InternetGatewayEnumerator struct { diff --git a/pkg/remote/aws/ec2_key_pair_enumerator.go b/enumeration/remote/aws/ec2_key_pair_enumerator.go similarity index 80% rename from pkg/remote/aws/ec2_key_pair_enumerator.go rename to enumeration/remote/aws/ec2_key_pair_enumerator.go index 52f95aade..9753a8cf4 100644 --- a/pkg/remote/aws/ec2_key_pair_enumerator.go +++ b/enumeration/remote/aws/ec2_key_pair_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type EC2KeyPairEnumerator struct { diff --git a/pkg/remote/aws/ec2_nat_gateway_enumerator.go b/enumeration/remote/aws/ec2_nat_gateway_enumerator.go similarity index 83% rename from pkg/remote/aws/ec2_nat_gateway_enumerator.go rename to enumeration/remote/aws/ec2_nat_gateway_enumerator.go index 46f44294e..1cc1a14f3 100644 --- a/pkg/remote/aws/ec2_nat_gateway_enumerator.go +++ b/enumeration/remote/aws/ec2_nat_gateway_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type EC2NatGatewayEnumerator struct { diff --git a/pkg/remote/aws/ec2_network_acl_enumerator.go b/enumeration/remote/aws/ec2_network_acl_enumerator.go similarity index 82% rename from pkg/remote/aws/ec2_network_acl_enumerator.go rename to enumeration/remote/aws/ec2_network_acl_enumerator.go index 5cae702f0..3facb89c9 100644 --- a/pkg/remote/aws/ec2_network_acl_enumerator.go +++ b/enumeration/remote/aws/ec2_network_acl_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type EC2NetworkACLEnumerator struct { diff --git a/pkg/remote/aws/ec2_network_acl_rule_enumerator.go b/enumeration/remote/aws/ec2_network_acl_rule_enumerator.go similarity index 80% rename from pkg/remote/aws/ec2_network_acl_rule_enumerator.go rename to enumeration/remote/aws/ec2_network_acl_rule_enumerator.go index 5f343f515..25aef07a4 100644 --- a/pkg/remote/aws/ec2_network_acl_rule_enumerator.go +++ b/enumeration/remote/aws/ec2_network_acl_rule_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type EC2NetworkACLRuleEnumerator struct { @@ -54,7 +54,12 @@ func (e *EC2NetworkACLRuleEnumerator) Enumerate() ([]*resource.Resource, error) results, e.factory.CreateAbstractResource( string(e.SupportedType()), - "", // Will be computed during normalization + aws.CreateNetworkACLRuleID( + *res.NetworkAclId, + int(float64(*entry.RuleNumber)), + *entry.Egress, + *entry.Protocol, + ), attrs, ), ) diff --git a/pkg/remote/aws/ec2_route_enumerator.go b/enumeration/remote/aws/ec2_route_enumerator.go similarity index 89% rename from pkg/remote/aws/ec2_route_enumerator.go rename to enumeration/remote/aws/ec2_route_enumerator.go index a6bae4ff2..e41c193ff 100644 --- a/pkg/remote/aws/ec2_route_enumerator.go +++ b/enumeration/remote/aws/ec2_route_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type EC2RouteEnumerator struct { diff --git a/pkg/remote/aws/ec2_route_table_association_enumerator.go b/enumeration/remote/aws/ec2_route_table_association_enumerator.go similarity index 88% rename from pkg/remote/aws/ec2_route_table_association_enumerator.go rename to enumeration/remote/aws/ec2_route_table_association_enumerator.go index 723dd2b18..4ccd63350 100644 --- a/pkg/remote/aws/ec2_route_table_association_enumerator.go +++ b/enumeration/remote/aws/ec2_route_table_association_enumerator.go @@ -2,10 +2,10 @@ package aws import ( "github.com/aws/aws-sdk-go/service/ec2" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type EC2RouteTableAssociationEnumerator struct { diff --git a/pkg/remote/aws/ec2_route_table_enumerator.go b/enumeration/remote/aws/ec2_route_table_enumerator.go similarity index 84% rename from pkg/remote/aws/ec2_route_table_enumerator.go rename to enumeration/remote/aws/ec2_route_table_enumerator.go index 41e0a6779..052d278db 100644 --- a/pkg/remote/aws/ec2_route_table_enumerator.go +++ b/enumeration/remote/aws/ec2_route_table_enumerator.go @@ -2,10 +2,10 @@ package aws import ( "github.com/aws/aws-sdk-go/service/ec2" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type EC2RouteTableEnumerator struct { diff --git a/pkg/remote/aws/ec2_subnet_enumerator.go b/enumeration/remote/aws/ec2_subnet_enumerator.go similarity index 80% rename from pkg/remote/aws/ec2_subnet_enumerator.go rename to enumeration/remote/aws/ec2_subnet_enumerator.go index cf33875d0..77592046f 100644 --- a/pkg/remote/aws/ec2_subnet_enumerator.go +++ b/enumeration/remote/aws/ec2_subnet_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type EC2SubnetEnumerator struct { diff --git a/pkg/remote/aws/ecr_repository_enumerator.go b/enumeration/remote/aws/ecr_repository_enumerator.go similarity index 80% rename from pkg/remote/aws/ecr_repository_enumerator.go rename to enumeration/remote/aws/ecr_repository_enumerator.go index 22c6cab23..7ad474961 100644 --- a/pkg/remote/aws/ecr_repository_enumerator.go +++ b/enumeration/remote/aws/ecr_repository_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ECRRepositoryEnumerator struct { diff --git a/pkg/remote/aws/ecr_repository_policy_enumerator.go b/enumeration/remote/aws/ecr_repository_policy_enumerator.go similarity index 85% rename from pkg/remote/aws/ecr_repository_policy_enumerator.go rename to enumeration/remote/aws/ecr_repository_policy_enumerator.go index c50617bb6..990302ef8 100644 --- a/pkg/remote/aws/ecr_repository_policy_enumerator.go +++ b/enumeration/remote/aws/ecr_repository_policy_enumerator.go @@ -2,10 +2,10 @@ package aws import ( "github.com/aws/aws-sdk-go/service/ecr" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ECRRepositoryPolicyEnumerator struct { diff --git a/pkg/remote/aws/elasticache_cluster_enumerator.go b/enumeration/remote/aws/elasticache_cluster_enumerator.go similarity index 82% rename from pkg/remote/aws/elasticache_cluster_enumerator.go rename to enumeration/remote/aws/elasticache_cluster_enumerator.go index 3d41ecb9a..2ffd0eae2 100644 --- a/pkg/remote/aws/elasticache_cluster_enumerator.go +++ b/enumeration/remote/aws/elasticache_cluster_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type ElastiCacheClusterEnumerator struct { diff --git a/pkg/remote/aws/iam_access_key_enumerator.go b/enumeration/remote/aws/iam_access_key_enumerator.go similarity index 82% rename from pkg/remote/aws/iam_access_key_enumerator.go rename to enumeration/remote/aws/iam_access_key_enumerator.go index 7e2b0fda2..733060460 100644 --- a/pkg/remote/aws/iam_access_key_enumerator.go +++ b/enumeration/remote/aws/iam_access_key_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" ) type IamAccessKeyEnumerator struct { diff --git a/pkg/remote/aws/iam_group_enumerator.go b/enumeration/remote/aws/iam_group_enumerator.go similarity index 80% rename from pkg/remote/aws/iam_group_enumerator.go rename to enumeration/remote/aws/iam_group_enumerator.go index e24f424ac..ba0931b81 100644 --- a/pkg/remote/aws/iam_group_enumerator.go +++ b/enumeration/remote/aws/iam_group_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type IamGroupEnumerator struct { diff --git a/pkg/remote/aws/iam_group_policy_attachment_enumerator.go b/enumeration/remote/aws/iam_group_policy_attachment_enumerator.go similarity index 85% rename from pkg/remote/aws/iam_group_policy_attachment_enumerator.go rename to enumeration/remote/aws/iam_group_policy_attachment_enumerator.go index c16dc7d10..b3e130d7e 100644 --- a/pkg/remote/aws/iam_group_policy_attachment_enumerator.go +++ b/enumeration/remote/aws/iam_group_policy_attachment_enumerator.go @@ -2,11 +2,11 @@ package aws import ( "fmt" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" ) type IamGroupPolicyAttachmentEnumerator struct { diff --git a/pkg/remote/aws/iam_group_policy_enumerator.go b/enumeration/remote/aws/iam_group_policy_enumerator.go similarity index 83% rename from pkg/remote/aws/iam_group_policy_enumerator.go rename to enumeration/remote/aws/iam_group_policy_enumerator.go index e2a9d10c8..daff7f612 100644 --- a/pkg/remote/aws/iam_group_policy_enumerator.go +++ b/enumeration/remote/aws/iam_group_policy_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type IamGroupPolicyEnumerator struct { diff --git a/pkg/remote/aws/iam_policy_enumerator.go b/enumeration/remote/aws/iam_policy_enumerator.go similarity index 81% rename from pkg/remote/aws/iam_policy_enumerator.go rename to enumeration/remote/aws/iam_policy_enumerator.go index e1f8a2f38..0f17dd74d 100644 --- a/pkg/remote/aws/iam_policy_enumerator.go +++ b/enumeration/remote/aws/iam_policy_enumerator.go @@ -2,10 +2,10 @@ package aws import ( awssdk "github.com/aws/aws-sdk-go/aws" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type IamPolicyEnumerator struct { diff --git a/pkg/remote/aws/iam_role_enumerator.go b/enumeration/remote/aws/iam_role_enumerator.go similarity index 85% rename from pkg/remote/aws/iam_role_enumerator.go rename to enumeration/remote/aws/iam_role_enumerator.go index 65b2db8e8..0e142e4cc 100644 --- a/pkg/remote/aws/iam_role_enumerator.go +++ b/enumeration/remote/aws/iam_role_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" ) var iamRoleExclusionList = map[string]struct{}{ diff --git a/pkg/remote/aws/iam_role_policy_attachment_enumerator.go b/enumeration/remote/aws/iam_role_policy_attachment_enumerator.go similarity index 87% rename from pkg/remote/aws/iam_role_policy_attachment_enumerator.go rename to enumeration/remote/aws/iam_role_policy_attachment_enumerator.go index 0685ffdbc..c2e0c2cb9 100644 --- a/pkg/remote/aws/iam_role_policy_attachment_enumerator.go +++ b/enumeration/remote/aws/iam_role_policy_attachment_enumerator.go @@ -2,12 +2,12 @@ package aws import ( "fmt" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" "github.com/aws/aws-sdk-go/service/iam" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" ) type IamRolePolicyAttachmentEnumerator struct { diff --git a/pkg/remote/aws/iam_role_policy_enumerator.go b/enumeration/remote/aws/iam_role_policy_enumerator.go similarity index 83% rename from pkg/remote/aws/iam_role_policy_enumerator.go rename to enumeration/remote/aws/iam_role_policy_enumerator.go index fb1de5087..340455857 100644 --- a/pkg/remote/aws/iam_role_policy_enumerator.go +++ b/enumeration/remote/aws/iam_role_policy_enumerator.go @@ -2,12 +2,11 @@ package aws import ( "fmt" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" ) type IamRolePolicyEnumerator struct { diff --git a/pkg/remote/aws/iam_user_enumerator.go b/enumeration/remote/aws/iam_user_enumerator.go similarity index 81% rename from pkg/remote/aws/iam_user_enumerator.go rename to enumeration/remote/aws/iam_user_enumerator.go index 9b2d1120a..23118fc45 100644 --- a/pkg/remote/aws/iam_user_enumerator.go +++ b/enumeration/remote/aws/iam_user_enumerator.go @@ -2,10 +2,10 @@ package aws import ( awssdk "github.com/aws/aws-sdk-go/aws" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type IamUserEnumerator struct { diff --git a/pkg/remote/aws/iam_user_policy_attachment_enumerator.go b/enumeration/remote/aws/iam_user_policy_attachment_enumerator.go similarity index 85% rename from pkg/remote/aws/iam_user_policy_attachment_enumerator.go rename to enumeration/remote/aws/iam_user_policy_attachment_enumerator.go index 3c0a15861..f910bb84a 100644 --- a/pkg/remote/aws/iam_user_policy_attachment_enumerator.go +++ b/enumeration/remote/aws/iam_user_policy_attachment_enumerator.go @@ -2,11 +2,11 @@ package aws import ( "fmt" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" ) type IamUserPolicyAttachmentEnumerator struct { diff --git a/pkg/remote/aws/iam_user_policy_enumerator.go b/enumeration/remote/aws/iam_user_policy_enumerator.go similarity index 83% rename from pkg/remote/aws/iam_user_policy_enumerator.go rename to enumeration/remote/aws/iam_user_policy_enumerator.go index fdc938c07..14c6a7295 100644 --- a/pkg/remote/aws/iam_user_policy_enumerator.go +++ b/enumeration/remote/aws/iam_user_policy_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type IamUserPolicyEnumerator struct { diff --git a/pkg/remote/aws/init.go b/enumeration/remote/aws/init.go similarity index 62% rename from pkg/remote/aws/init.go rename to enumeration/remote/aws/init.go index d601dbb5b..5d8e3409a 100644 --- a/pkg/remote/aws/init.go +++ b/enumeration/remote/aws/init.go @@ -1,15 +1,15 @@ package aws import ( - "github.com/snyk/driftctl/pkg/alerter" - "github.com/snyk/driftctl/pkg/output" - "github.com/snyk/driftctl/pkg/remote/aws/client" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/alerter" + "github.com/snyk/driftctl/enumeration/remote/aws/client" + repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/enumeration/terraform" ) /** @@ -19,8 +19,8 @@ import ( func Init(version string, alerter *alerter.Alerter, providerLibrary *terraform.ProviderLibrary, - remoteLibrary *common.RemoteLibrary, - progress output.Progress, + remoteLibrary *common2.RemoteLibrary, + progress enumeration.ProgressCounter, resourceSchemaRepository *resource.SchemaRepository, factory resource.ResourceFactory, configDir string) error { @@ -40,164 +40,164 @@ func Init(version string, alerter *alerter.Alerter, repositoryCache := cache.New(100) - s3Repository := repository.NewS3Repository(client.NewAWSClientFactory(provider.session), repositoryCache) - ec2repository := repository.NewEC2Repository(provider.session, repositoryCache) - elbv2Repository := repository.NewELBV2Repository(provider.session, repositoryCache) - route53repository := repository.NewRoute53Repository(provider.session, repositoryCache) - lambdaRepository := repository.NewLambdaRepository(provider.session, repositoryCache) - rdsRepository := repository.NewRDSRepository(provider.session, repositoryCache) - sqsRepository := repository.NewSQSRepository(provider.session, repositoryCache) - snsRepository := repository.NewSNSRepository(provider.session, repositoryCache) - cloudfrontRepository := repository.NewCloudfrontRepository(provider.session, repositoryCache) - dynamoDBRepository := repository.NewDynamoDBRepository(provider.session, repositoryCache) - ecrRepository := repository.NewECRRepository(provider.session, repositoryCache) - kmsRepository := repository.NewKMSRepository(provider.session, repositoryCache) - iamRepository := repository.NewIAMRepository(provider.session, repositoryCache) - cloudformationRepository := repository.NewCloudformationRepository(provider.session, repositoryCache) - apigatewayRepository := repository.NewApiGatewayRepository(provider.session, repositoryCache) - appAutoScalingRepository := repository.NewAppAutoScalingRepository(provider.session, repositoryCache) - apigatewayv2Repository := repository.NewApiGatewayV2Repository(provider.session, repositoryCache) - autoscalingRepository := repository.NewAutoScalingRepository(provider.session, repositoryCache) - elbRepository := repository.NewELBRepository(provider.session, repositoryCache) - elasticacheRepository := repository.NewElastiCacheRepository(provider.session, repositoryCache) + s3Repository := repository2.NewS3Repository(client.NewAWSClientFactory(provider.session), repositoryCache) + ec2repository := repository2.NewEC2Repository(provider.session, repositoryCache) + elbv2Repository := repository2.NewELBV2Repository(provider.session, repositoryCache) + route53repository := repository2.NewRoute53Repository(provider.session, repositoryCache) + lambdaRepository := repository2.NewLambdaRepository(provider.session, repositoryCache) + rdsRepository := repository2.NewRDSRepository(provider.session, repositoryCache) + sqsRepository := repository2.NewSQSRepository(provider.session, repositoryCache) + snsRepository := repository2.NewSNSRepository(provider.session, repositoryCache) + cloudfrontRepository := repository2.NewCloudfrontRepository(provider.session, repositoryCache) + dynamoDBRepository := repository2.NewDynamoDBRepository(provider.session, repositoryCache) + ecrRepository := repository2.NewECRRepository(provider.session, repositoryCache) + kmsRepository := repository2.NewKMSRepository(provider.session, repositoryCache) + iamRepository := repository2.NewIAMRepository(provider.session, repositoryCache) + cloudformationRepository := repository2.NewCloudformationRepository(provider.session, repositoryCache) + apigatewayRepository := repository2.NewApiGatewayRepository(provider.session, repositoryCache) + appAutoScalingRepository := repository2.NewAppAutoScalingRepository(provider.session, repositoryCache) + apigatewayv2Repository := repository2.NewApiGatewayV2Repository(provider.session, repositoryCache) + autoscalingRepository := repository2.NewAutoScalingRepository(provider.session, repositoryCache) + elbRepository := repository2.NewELBRepository(provider.session, repositoryCache) + elasticacheRepository := repository2.NewElastiCacheRepository(provider.session, repositoryCache) deserializer := resource.NewDeserializer(factory) providerLibrary.AddProvider(terraform.AWS, provider) remoteLibrary.AddEnumerator(NewS3BucketEnumerator(s3Repository, factory, provider.Config, alerter)) - remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketResourceType, common.NewGenericDetailsFetcher(aws.AwsS3BucketResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketResourceType, common2.NewGenericDetailsFetcher(aws.AwsS3BucketResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewS3BucketInventoryEnumerator(s3Repository, factory, provider.Config, alerter)) - remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketInventoryResourceType, common.NewGenericDetailsFetcher(aws.AwsS3BucketInventoryResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketInventoryResourceType, common2.NewGenericDetailsFetcher(aws.AwsS3BucketInventoryResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewS3BucketNotificationEnumerator(s3Repository, factory, provider.Config, alerter)) - remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketNotificationResourceType, common.NewGenericDetailsFetcher(aws.AwsS3BucketNotificationResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketNotificationResourceType, common2.NewGenericDetailsFetcher(aws.AwsS3BucketNotificationResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewS3BucketMetricsEnumerator(s3Repository, factory, provider.Config, alerter)) - remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketMetricResourceType, common.NewGenericDetailsFetcher(aws.AwsS3BucketMetricResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketMetricResourceType, common2.NewGenericDetailsFetcher(aws.AwsS3BucketMetricResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewS3BucketPolicyEnumerator(s3Repository, factory, provider.Config, alerter)) - remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketPolicyResourceType, common.NewGenericDetailsFetcher(aws.AwsS3BucketPolicyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketPolicyResourceType, common2.NewGenericDetailsFetcher(aws.AwsS3BucketPolicyResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewS3BucketAnalyticEnumerator(s3Repository, factory, provider.Config, alerter)) - remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketAnalyticsConfigurationResourceType, common.NewGenericDetailsFetcher(aws.AwsS3BucketAnalyticsConfigurationResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketAnalyticsConfigurationResourceType, common2.NewGenericDetailsFetcher(aws.AwsS3BucketAnalyticsConfigurationResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewS3BucketPublicAccessBlockEnumerator(s3Repository, factory, provider.Config, alerter)) remoteLibrary.AddEnumerator(NewEC2EbsVolumeEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsEbsVolumeResourceType, common.NewGenericDetailsFetcher(aws.AwsEbsVolumeResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsEbsVolumeResourceType, common2.NewGenericDetailsFetcher(aws.AwsEbsVolumeResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2EbsSnapshotEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsEbsSnapshotResourceType, common.NewGenericDetailsFetcher(aws.AwsEbsSnapshotResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsEbsSnapshotResourceType, common2.NewGenericDetailsFetcher(aws.AwsEbsSnapshotResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2EipEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsEipResourceType, common.NewGenericDetailsFetcher(aws.AwsEipResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsEipResourceType, common2.NewGenericDetailsFetcher(aws.AwsEipResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2AmiEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsAmiResourceType, common.NewGenericDetailsFetcher(aws.AwsAmiResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsAmiResourceType, common2.NewGenericDetailsFetcher(aws.AwsAmiResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2KeyPairEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsKeyPairResourceType, common.NewGenericDetailsFetcher(aws.AwsKeyPairResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsKeyPairResourceType, common2.NewGenericDetailsFetcher(aws.AwsKeyPairResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2EipAssociationEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsEipAssociationResourceType, common.NewGenericDetailsFetcher(aws.AwsEipAssociationResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsEipAssociationResourceType, common2.NewGenericDetailsFetcher(aws.AwsEipAssociationResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2InstanceEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsInstanceResourceType, common.NewGenericDetailsFetcher(aws.AwsInstanceResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsInstanceResourceType, common2.NewGenericDetailsFetcher(aws.AwsInstanceResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2InternetGatewayEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsInternetGatewayResourceType, common.NewGenericDetailsFetcher(aws.AwsInternetGatewayResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsInternetGatewayResourceType, common2.NewGenericDetailsFetcher(aws.AwsInternetGatewayResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewVPCEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsVpcResourceType, common.NewGenericDetailsFetcher(aws.AwsVpcResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsVpcResourceType, common2.NewGenericDetailsFetcher(aws.AwsVpcResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewDefaultVPCEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsDefaultVpcResourceType, common.NewGenericDetailsFetcher(aws.AwsDefaultVpcResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsDefaultVpcResourceType, common2.NewGenericDetailsFetcher(aws.AwsDefaultVpcResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2RouteTableEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsRouteTableResourceType, common.NewGenericDetailsFetcher(aws.AwsRouteTableResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsRouteTableResourceType, common2.NewGenericDetailsFetcher(aws.AwsRouteTableResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2DefaultRouteTableEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsDefaultRouteTableResourceType, common.NewGenericDetailsFetcher(aws.AwsDefaultRouteTableResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsDefaultRouteTableResourceType, common2.NewGenericDetailsFetcher(aws.AwsDefaultRouteTableResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2RouteTableAssociationEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsRouteTableAssociationResourceType, common.NewGenericDetailsFetcher(aws.AwsRouteTableAssociationResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsRouteTableAssociationResourceType, common2.NewGenericDetailsFetcher(aws.AwsRouteTableAssociationResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2SubnetEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsSubnetResourceType, common.NewGenericDetailsFetcher(aws.AwsSubnetResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsSubnetResourceType, common2.NewGenericDetailsFetcher(aws.AwsSubnetResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2DefaultSubnetEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsDefaultSubnetResourceType, common.NewGenericDetailsFetcher(aws.AwsDefaultSubnetResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsDefaultSubnetResourceType, common2.NewGenericDetailsFetcher(aws.AwsDefaultSubnetResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewVPCSecurityGroupEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsSecurityGroupResourceType, common.NewGenericDetailsFetcher(aws.AwsSecurityGroupResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsSecurityGroupResourceType, common2.NewGenericDetailsFetcher(aws.AwsSecurityGroupResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewVPCDefaultSecurityGroupEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsDefaultSecurityGroupResourceType, common.NewGenericDetailsFetcher(aws.AwsDefaultSecurityGroupResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsDefaultSecurityGroupResourceType, common2.NewGenericDetailsFetcher(aws.AwsDefaultSecurityGroupResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2NatGatewayEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsNatGatewayResourceType, common.NewGenericDetailsFetcher(aws.AwsNatGatewayResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsNatGatewayResourceType, common2.NewGenericDetailsFetcher(aws.AwsNatGatewayResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2NetworkACLEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsNetworkACLResourceType, common.NewGenericDetailsFetcher(aws.AwsNetworkACLResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsNetworkACLResourceType, common2.NewGenericDetailsFetcher(aws.AwsNetworkACLResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2NetworkACLRuleEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsNetworkACLRuleResourceType, common.NewGenericDetailsFetcher(aws.AwsNetworkACLRuleResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsNetworkACLRuleResourceType, common2.NewGenericDetailsFetcher(aws.AwsNetworkACLRuleResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2DefaultNetworkACLEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsDefaultNetworkACLResourceType, common.NewGenericDetailsFetcher(aws.AwsDefaultNetworkACLResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsDefaultNetworkACLResourceType, common2.NewGenericDetailsFetcher(aws.AwsDefaultNetworkACLResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2RouteEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsRouteResourceType, common.NewGenericDetailsFetcher(aws.AwsRouteResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsRouteResourceType, common2.NewGenericDetailsFetcher(aws.AwsRouteResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewVPCSecurityGroupRuleEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsSecurityGroupRuleResourceType, common.NewGenericDetailsFetcher(aws.AwsSecurityGroupRuleResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsSecurityGroupRuleResourceType, common2.NewGenericDetailsFetcher(aws.AwsSecurityGroupRuleResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewLaunchTemplateEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsLaunchTemplateResourceType, common.NewGenericDetailsFetcher(aws.AwsLaunchTemplateResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsLaunchTemplateResourceType, common2.NewGenericDetailsFetcher(aws.AwsLaunchTemplateResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2EbsEncryptionByDefaultEnumerator(ec2repository, factory)) remoteLibrary.AddEnumerator(NewKMSKeyEnumerator(kmsRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsKmsKeyResourceType, common.NewGenericDetailsFetcher(aws.AwsKmsKeyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsKmsKeyResourceType, common2.NewGenericDetailsFetcher(aws.AwsKmsKeyResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewKMSAliasEnumerator(kmsRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsKmsAliasResourceType, common.NewGenericDetailsFetcher(aws.AwsKmsAliasResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsKmsAliasResourceType, common2.NewGenericDetailsFetcher(aws.AwsKmsAliasResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewRoute53HealthCheckEnumerator(route53repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsRoute53HealthCheckResourceType, common.NewGenericDetailsFetcher(aws.AwsRoute53HealthCheckResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsRoute53HealthCheckResourceType, common2.NewGenericDetailsFetcher(aws.AwsRoute53HealthCheckResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewRoute53ZoneEnumerator(route53repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsRoute53ZoneResourceType, common.NewGenericDetailsFetcher(aws.AwsRoute53ZoneResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsRoute53ZoneResourceType, common2.NewGenericDetailsFetcher(aws.AwsRoute53ZoneResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewRoute53RecordEnumerator(route53repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsRoute53RecordResourceType, common.NewGenericDetailsFetcher(aws.AwsRoute53RecordResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsRoute53RecordResourceType, common2.NewGenericDetailsFetcher(aws.AwsRoute53RecordResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewCloudfrontDistributionEnumerator(cloudfrontRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsCloudfrontDistributionResourceType, common.NewGenericDetailsFetcher(aws.AwsCloudfrontDistributionResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsCloudfrontDistributionResourceType, common2.NewGenericDetailsFetcher(aws.AwsCloudfrontDistributionResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewRDSDBInstanceEnumerator(rdsRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsDbInstanceResourceType, common.NewGenericDetailsFetcher(aws.AwsDbInstanceResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsDbInstanceResourceType, common2.NewGenericDetailsFetcher(aws.AwsDbInstanceResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewRDSDBSubnetGroupEnumerator(rdsRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsDbSubnetGroupResourceType, common.NewGenericDetailsFetcher(aws.AwsDbSubnetGroupResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsDbSubnetGroupResourceType, common2.NewGenericDetailsFetcher(aws.AwsDbSubnetGroupResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewSQSQueueEnumerator(sqsRepository, factory)) remoteLibrary.AddDetailsFetcher(aws.AwsSqsQueueResourceType, NewSQSQueueDetailsFetcher(provider, deserializer)) remoteLibrary.AddEnumerator(NewSQSQueuePolicyEnumerator(sqsRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsSqsQueuePolicyResourceType, common.NewGenericDetailsFetcher(aws.AwsSqsQueuePolicyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsSqsQueuePolicyResourceType, common2.NewGenericDetailsFetcher(aws.AwsSqsQueuePolicyResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewSNSTopicEnumerator(snsRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsSnsTopicResourceType, common.NewGenericDetailsFetcher(aws.AwsSnsTopicResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsSnsTopicResourceType, common2.NewGenericDetailsFetcher(aws.AwsSnsTopicResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewSNSTopicPolicyEnumerator(snsRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsSnsTopicPolicyResourceType, common.NewGenericDetailsFetcher(aws.AwsSnsTopicPolicyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsSnsTopicPolicyResourceType, common2.NewGenericDetailsFetcher(aws.AwsSnsTopicPolicyResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewSNSTopicSubscriptionEnumerator(snsRepository, factory, alerter)) - remoteLibrary.AddDetailsFetcher(aws.AwsSnsTopicSubscriptionResourceType, common.NewGenericDetailsFetcher(aws.AwsSnsTopicSubscriptionResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsSnsTopicSubscriptionResourceType, common2.NewGenericDetailsFetcher(aws.AwsSnsTopicSubscriptionResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewDynamoDBTableEnumerator(dynamoDBRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsDynamodbTableResourceType, common.NewGenericDetailsFetcher(aws.AwsDynamodbTableResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsDynamodbTableResourceType, common2.NewGenericDetailsFetcher(aws.AwsDynamodbTableResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewIamPolicyEnumerator(iamRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsIamPolicyResourceType, common.NewGenericDetailsFetcher(aws.AwsIamPolicyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsIamPolicyResourceType, common2.NewGenericDetailsFetcher(aws.AwsIamPolicyResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewLambdaFunctionEnumerator(lambdaRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsLambdaFunctionResourceType, common.NewGenericDetailsFetcher(aws.AwsLambdaFunctionResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsLambdaFunctionResourceType, common2.NewGenericDetailsFetcher(aws.AwsLambdaFunctionResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewLambdaEventSourceMappingEnumerator(lambdaRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsLambdaEventSourceMappingResourceType, common.NewGenericDetailsFetcher(aws.AwsLambdaEventSourceMappingResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsLambdaEventSourceMappingResourceType, common2.NewGenericDetailsFetcher(aws.AwsLambdaEventSourceMappingResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewIamUserEnumerator(iamRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsIamUserResourceType, common.NewGenericDetailsFetcher(aws.AwsIamUserResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsIamUserResourceType, common2.NewGenericDetailsFetcher(aws.AwsIamUserResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewIamUserPolicyEnumerator(iamRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsIamUserPolicyResourceType, common.NewGenericDetailsFetcher(aws.AwsIamUserPolicyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsIamUserPolicyResourceType, common2.NewGenericDetailsFetcher(aws.AwsIamUserPolicyResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewIamRoleEnumerator(iamRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsIamRoleResourceType, common.NewGenericDetailsFetcher(aws.AwsIamRoleResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsIamRoleResourceType, common2.NewGenericDetailsFetcher(aws.AwsIamRoleResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewIamAccessKeyEnumerator(iamRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsIamAccessKeyResourceType, common.NewGenericDetailsFetcher(aws.AwsIamAccessKeyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsIamAccessKeyResourceType, common2.NewGenericDetailsFetcher(aws.AwsIamAccessKeyResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewIamRolePolicyAttachmentEnumerator(iamRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsIamRolePolicyAttachmentResourceType, common.NewGenericDetailsFetcher(aws.AwsIamRolePolicyAttachmentResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsIamRolePolicyAttachmentResourceType, common2.NewGenericDetailsFetcher(aws.AwsIamRolePolicyAttachmentResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewIamRolePolicyEnumerator(iamRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsIamRolePolicyResourceType, common.NewGenericDetailsFetcher(aws.AwsIamRolePolicyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsIamRolePolicyResourceType, common2.NewGenericDetailsFetcher(aws.AwsIamRolePolicyResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewIamUserPolicyAttachmentEnumerator(iamRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsIamUserPolicyAttachmentResourceType, common.NewGenericDetailsFetcher(aws.AwsIamUserPolicyAttachmentResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsIamUserPolicyAttachmentResourceType, common2.NewGenericDetailsFetcher(aws.AwsIamUserPolicyAttachmentResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewIamGroupPolicyEnumerator(iamRepository, factory)) remoteLibrary.AddEnumerator(NewIamGroupEnumerator(iamRepository, factory)) remoteLibrary.AddEnumerator(NewIamGroupPolicyAttachmentEnumerator(iamRepository, factory)) remoteLibrary.AddEnumerator(NewECRRepositoryEnumerator(ecrRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsEcrRepositoryResourceType, common.NewGenericDetailsFetcher(aws.AwsEcrRepositoryResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsEcrRepositoryResourceType, common2.NewGenericDetailsFetcher(aws.AwsEcrRepositoryResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewECRRepositoryPolicyEnumerator(ecrRepository, factory)) remoteLibrary.AddEnumerator(NewRDSClusterEnumerator(rdsRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsRDSClusterResourceType, common.NewGenericDetailsFetcher(aws.AwsRDSClusterResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsRDSClusterResourceType, common2.NewGenericDetailsFetcher(aws.AwsRDSClusterResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewCloudformationStackEnumerator(cloudformationRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsCloudformationStackResourceType, common.NewGenericDetailsFetcher(aws.AwsCloudformationStackResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsCloudformationStackResourceType, common2.NewGenericDetailsFetcher(aws.AwsCloudformationStackResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewApiGatewayRestApiEnumerator(apigatewayRepository, factory)) remoteLibrary.AddEnumerator(NewApiGatewayAccountEnumerator(apigatewayRepository, factory)) @@ -232,10 +232,10 @@ func Init(version string, alerter *alerter.Alerter, remoteLibrary.AddEnumerator(NewApiGatewayV2IntegrationResponseEnumerator(apigatewayv2Repository, factory)) remoteLibrary.AddEnumerator(NewAppAutoscalingTargetEnumerator(appAutoScalingRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsAppAutoscalingTargetResourceType, common.NewGenericDetailsFetcher(aws.AwsAppAutoscalingTargetResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsAppAutoscalingTargetResourceType, common2.NewGenericDetailsFetcher(aws.AwsAppAutoscalingTargetResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewAppAutoscalingPolicyEnumerator(appAutoScalingRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsAppAutoscalingPolicyResourceType, common.NewGenericDetailsFetcher(aws.AwsAppAutoscalingPolicyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsAppAutoscalingPolicyResourceType, common2.NewGenericDetailsFetcher(aws.AwsAppAutoscalingPolicyResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewAppAutoscalingScheduledActionEnumerator(appAutoScalingRepository, factory)) diff --git a/pkg/remote/aws/kms_alias_enumerator.go b/enumeration/remote/aws/kms_alias_enumerator.go similarity index 80% rename from pkg/remote/aws/kms_alias_enumerator.go rename to enumeration/remote/aws/kms_alias_enumerator.go index 43f550a3e..44f841d2d 100644 --- a/pkg/remote/aws/kms_alias_enumerator.go +++ b/enumeration/remote/aws/kms_alias_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type KMSAliasEnumerator struct { diff --git a/pkg/remote/aws/kms_key_enumerator.go b/enumeration/remote/aws/kms_key_enumerator.go similarity index 79% rename from pkg/remote/aws/kms_key_enumerator.go rename to enumeration/remote/aws/kms_key_enumerator.go index 376844f14..f2078c964 100644 --- a/pkg/remote/aws/kms_key_enumerator.go +++ b/enumeration/remote/aws/kms_key_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type KMSKeyEnumerator struct { diff --git a/pkg/remote/aws/lambda_event_source_mapping_enumerator.go b/enumeration/remote/aws/lambda_event_source_mapping_enumerator.go similarity index 82% rename from pkg/remote/aws/lambda_event_source_mapping_enumerator.go rename to enumeration/remote/aws/lambda_event_source_mapping_enumerator.go index f8b0781cc..0fb03c174 100644 --- a/pkg/remote/aws/lambda_event_source_mapping_enumerator.go +++ b/enumeration/remote/aws/lambda_event_source_mapping_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" ) type LambdaEventSourceMappingEnumerator struct { diff --git a/pkg/remote/aws/lambda_function_enumerator.go b/enumeration/remote/aws/lambda_function_enumerator.go similarity index 80% rename from pkg/remote/aws/lambda_function_enumerator.go rename to enumeration/remote/aws/lambda_function_enumerator.go index cf854c657..ec3c23204 100644 --- a/pkg/remote/aws/lambda_function_enumerator.go +++ b/enumeration/remote/aws/lambda_function_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" ) type LambdaFunctionEnumerator struct { diff --git a/pkg/remote/aws/launch_configuration_enumerator.go b/enumeration/remote/aws/launch_configuration_enumerator.go similarity index 82% rename from pkg/remote/aws/launch_configuration_enumerator.go rename to enumeration/remote/aws/launch_configuration_enumerator.go index 940b83563..c52655220 100644 --- a/pkg/remote/aws/launch_configuration_enumerator.go +++ b/enumeration/remote/aws/launch_configuration_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type LaunchConfigurationEnumerator struct { diff --git a/pkg/remote/aws/launch_template_enumerator.go b/enumeration/remote/aws/launch_template_enumerator.go similarity index 81% rename from pkg/remote/aws/launch_template_enumerator.go rename to enumeration/remote/aws/launch_template_enumerator.go index 0c09c6674..b19b98ac6 100644 --- a/pkg/remote/aws/launch_template_enumerator.go +++ b/enumeration/remote/aws/launch_template_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type LaunchTemplateEnumerator struct { diff --git a/pkg/remote/aws/load_balancer_enumerator.go b/enumeration/remote/aws/load_balancer_enumerator.go similarity index 81% rename from pkg/remote/aws/load_balancer_enumerator.go rename to enumeration/remote/aws/load_balancer_enumerator.go index 7d87da409..77746a503 100644 --- a/pkg/remote/aws/load_balancer_enumerator.go +++ b/enumeration/remote/aws/load_balancer_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type LoadBalancerEnumerator struct { diff --git a/pkg/remote/aws/load_balancer_listener_enumerator.go b/enumeration/remote/aws/load_balancer_listener_enumerator.go similarity index 85% rename from pkg/remote/aws/load_balancer_listener_enumerator.go rename to enumeration/remote/aws/load_balancer_listener_enumerator.go index 2cc518aa4..cc0d0ec52 100644 --- a/pkg/remote/aws/load_balancer_listener_enumerator.go +++ b/enumeration/remote/aws/load_balancer_listener_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type LoadBalancerListenerEnumerator struct { diff --git a/pkg/remote/aws/provider.go b/enumeration/remote/aws/provider.go similarity index 92% rename from pkg/remote/aws/provider.go rename to enumeration/remote/aws/provider.go index 6ccb0e958..1bd10f19a 100644 --- a/pkg/remote/aws/provider.go +++ b/enumeration/remote/aws/provider.go @@ -6,9 +6,9 @@ import ( "github.com/aws/aws-sdk-go/service/sts" "github.com/pkg/errors" "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/output" - "github.com/snyk/driftctl/pkg/remote/terraform" - tf "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/terraform" + tf "github.com/snyk/driftctl/enumeration/terraform" ) type awsConfig struct { @@ -47,7 +47,7 @@ type AWSTerraformProvider struct { version string } -func NewAWSTerraformProvider(version string, progress output.Progress, configDir string) (*AWSTerraformProvider, error) { +func NewAWSTerraformProvider(version string, progress enumeration.ProgressCounter, configDir string) (*AWSTerraformProvider, error) { if version == "" { version = "3.19.0" } diff --git a/pkg/remote/aws/rds_cluster_enumerator.go b/enumeration/remote/aws/rds_cluster_enumerator.go similarity index 83% rename from pkg/remote/aws/rds_cluster_enumerator.go rename to enumeration/remote/aws/rds_cluster_enumerator.go index eb51ba65f..990b2e8cc 100644 --- a/pkg/remote/aws/rds_cluster_enumerator.go +++ b/enumeration/remote/aws/rds_cluster_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type RDSClusterEnumerator struct { diff --git a/pkg/remote/aws/rds_db_instance_enumerator.go b/enumeration/remote/aws/rds_db_instance_enumerator.go similarity index 81% rename from pkg/remote/aws/rds_db_instance_enumerator.go rename to enumeration/remote/aws/rds_db_instance_enumerator.go index 5e35f1cf0..11df11203 100644 --- a/pkg/remote/aws/rds_db_instance_enumerator.go +++ b/enumeration/remote/aws/rds_db_instance_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type RDSDBInstanceEnumerator struct { diff --git a/pkg/remote/aws/rds_db_subnet_group_enumerator.go b/enumeration/remote/aws/rds_db_subnet_group_enumerator.go similarity index 81% rename from pkg/remote/aws/rds_db_subnet_group_enumerator.go rename to enumeration/remote/aws/rds_db_subnet_group_enumerator.go index 4992f09b2..51973fd63 100644 --- a/pkg/remote/aws/rds_db_subnet_group_enumerator.go +++ b/enumeration/remote/aws/rds_db_subnet_group_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type RDSDBSubnetGroupEnumerator struct { diff --git a/pkg/remote/aws/repository/api_gateway_repository.go b/enumeration/remote/aws/repository/api_gateway_repository.go similarity index 99% rename from pkg/remote/aws/repository/api_gateway_repository.go rename to enumeration/remote/aws/repository/api_gateway_repository.go index 4cf88ff5e..bb69d7dd6 100644 --- a/pkg/remote/aws/repository/api_gateway_repository.go +++ b/enumeration/remote/aws/repository/api_gateway_repository.go @@ -2,12 +2,12 @@ package repository import ( "fmt" + "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/apigateway" "github.com/aws/aws-sdk-go/service/apigateway/apigatewayiface" - "github.com/snyk/driftctl/pkg/remote/cache" ) type ApiGatewayRepository interface { diff --git a/pkg/remote/aws/repository/api_gateway_repository_test.go b/enumeration/remote/aws/repository/api_gateway_repository_test.go similarity index 99% rename from pkg/remote/aws/repository/api_gateway_repository_test.go rename to enumeration/remote/aws/repository/api_gateway_repository_test.go index 83898b4b8..8f452d074 100644 --- a/pkg/remote/aws/repository/api_gateway_repository_test.go +++ b/enumeration/remote/aws/repository/api_gateway_repository_test.go @@ -1,13 +1,13 @@ package repository import ( + "github.com/snyk/driftctl/enumeration/remote/cache" "strings" "testing" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/apigateway" "github.com/pkg/errors" - "github.com/snyk/driftctl/pkg/remote/cache" awstest "github.com/snyk/driftctl/test/aws" "github.com/stretchr/testify/mock" diff --git a/pkg/remote/aws/repository/apigatewayv2_repository.go b/enumeration/remote/aws/repository/apigatewayv2_repository.go similarity index 99% rename from pkg/remote/aws/repository/apigatewayv2_repository.go rename to enumeration/remote/aws/repository/apigatewayv2_repository.go index ad5286828..cb28704db 100644 --- a/pkg/remote/aws/repository/apigatewayv2_repository.go +++ b/enumeration/remote/aws/repository/apigatewayv2_repository.go @@ -2,11 +2,11 @@ package repository import ( "fmt" + "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/apigatewayv2" "github.com/aws/aws-sdk-go/service/apigatewayv2/apigatewayv2iface" - "github.com/snyk/driftctl/pkg/remote/cache" ) type ApiGatewayV2Repository interface { diff --git a/pkg/remote/aws/repository/apigatewayv2_repository_test.go b/enumeration/remote/aws/repository/apigatewayv2_repository_test.go similarity index 99% rename from pkg/remote/aws/repository/apigatewayv2_repository_test.go rename to enumeration/remote/aws/repository/apigatewayv2_repository_test.go index f459ed036..ea76f53e3 100644 --- a/pkg/remote/aws/repository/apigatewayv2_repository_test.go +++ b/enumeration/remote/aws/repository/apigatewayv2_repository_test.go @@ -1,13 +1,13 @@ package repository import ( + "github.com/snyk/driftctl/enumeration/remote/cache" "strings" "testing" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/apigatewayv2" "github.com/pkg/errors" - "github.com/snyk/driftctl/pkg/remote/cache" awstest "github.com/snyk/driftctl/test/aws" "github.com/r3labs/diff/v2" diff --git a/pkg/remote/aws/repository/appautoscaling_repository.go b/enumeration/remote/aws/repository/appautoscaling_repository.go similarity index 98% rename from pkg/remote/aws/repository/appautoscaling_repository.go rename to enumeration/remote/aws/repository/appautoscaling_repository.go index 47fdaea8a..601559997 100644 --- a/pkg/remote/aws/repository/appautoscaling_repository.go +++ b/enumeration/remote/aws/repository/appautoscaling_repository.go @@ -2,11 +2,11 @@ package repository import ( "fmt" + "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/applicationautoscaling" "github.com/aws/aws-sdk-go/service/applicationautoscaling/applicationautoscalingiface" - "github.com/snyk/driftctl/pkg/remote/cache" ) type AppAutoScalingRepository interface { diff --git a/pkg/remote/aws/repository/appautoscaling_repository_test.go b/enumeration/remote/aws/repository/appautoscaling_repository_test.go similarity index 99% rename from pkg/remote/aws/repository/appautoscaling_repository_test.go rename to enumeration/remote/aws/repository/appautoscaling_repository_test.go index 88d871389..bc41cb048 100644 --- a/pkg/remote/aws/repository/appautoscaling_repository_test.go +++ b/enumeration/remote/aws/repository/appautoscaling_repository_test.go @@ -1,13 +1,13 @@ package repository import ( + "github.com/snyk/driftctl/enumeration/remote/cache" "strings" "testing" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/applicationautoscaling" "github.com/pkg/errors" - "github.com/snyk/driftctl/pkg/remote/cache" awstest "github.com/snyk/driftctl/test/aws" "github.com/r3labs/diff/v2" diff --git a/pkg/remote/aws/repository/autoscaling_repository.go b/enumeration/remote/aws/repository/autoscaling_repository.go similarity index 95% rename from pkg/remote/aws/repository/autoscaling_repository.go rename to enumeration/remote/aws/repository/autoscaling_repository.go index b28aa740d..b00da44c3 100644 --- a/pkg/remote/aws/repository/autoscaling_repository.go +++ b/enumeration/remote/aws/repository/autoscaling_repository.go @@ -4,7 +4,7 @@ import ( "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/autoscaling" "github.com/aws/aws-sdk-go/service/autoscaling/autoscalingiface" - "github.com/snyk/driftctl/pkg/remote/cache" + "github.com/snyk/driftctl/enumeration/remote/cache" ) type AutoScalingRepository interface { diff --git a/pkg/remote/aws/repository/autoscaling_repository_test.go b/enumeration/remote/aws/repository/autoscaling_repository_test.go similarity index 98% rename from pkg/remote/aws/repository/autoscaling_repository_test.go rename to enumeration/remote/aws/repository/autoscaling_repository_test.go index 723f59541..fad155b7f 100644 --- a/pkg/remote/aws/repository/autoscaling_repository_test.go +++ b/enumeration/remote/aws/repository/autoscaling_repository_test.go @@ -2,11 +2,11 @@ package repository import ( "errors" + "github.com/snyk/driftctl/enumeration/remote/cache" "strings" "testing" "github.com/aws/aws-sdk-go/service/autoscaling" - "github.com/snyk/driftctl/pkg/remote/cache" awstest "github.com/snyk/driftctl/test/aws" "github.com/stretchr/testify/mock" diff --git a/pkg/remote/aws/repository/cloudformation_repository.go b/enumeration/remote/aws/repository/cloudformation_repository.go similarity index 95% rename from pkg/remote/aws/repository/cloudformation_repository.go rename to enumeration/remote/aws/repository/cloudformation_repository.go index 52be2b639..e0aa1dd09 100644 --- a/pkg/remote/aws/repository/cloudformation_repository.go +++ b/enumeration/remote/aws/repository/cloudformation_repository.go @@ -4,7 +4,7 @@ import ( "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/cloudformation" "github.com/aws/aws-sdk-go/service/cloudformation/cloudformationiface" - "github.com/snyk/driftctl/pkg/remote/cache" + "github.com/snyk/driftctl/enumeration/remote/cache" ) type CloudformationRepository interface { diff --git a/pkg/remote/aws/repository/cloudformation_repository_test.go b/enumeration/remote/aws/repository/cloudformation_repository_test.go similarity index 97% rename from pkg/remote/aws/repository/cloudformation_repository_test.go rename to enumeration/remote/aws/repository/cloudformation_repository_test.go index 1dffdc281..3f2dd7473 100644 --- a/pkg/remote/aws/repository/cloudformation_repository_test.go +++ b/enumeration/remote/aws/repository/cloudformation_repository_test.go @@ -1,12 +1,12 @@ package repository import ( + "github.com/snyk/driftctl/enumeration/remote/cache" "strings" "testing" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/cloudformation" - "github.com/snyk/driftctl/pkg/remote/cache" awstest "github.com/snyk/driftctl/test/aws" "github.com/stretchr/testify/mock" diff --git a/pkg/remote/aws/repository/cloudfront_repository.go b/enumeration/remote/aws/repository/cloudfront_repository.go similarity index 95% rename from pkg/remote/aws/repository/cloudfront_repository.go rename to enumeration/remote/aws/repository/cloudfront_repository.go index 847b69a89..bb7d0ec72 100644 --- a/pkg/remote/aws/repository/cloudfront_repository.go +++ b/enumeration/remote/aws/repository/cloudfront_repository.go @@ -4,7 +4,7 @@ import ( "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/cloudfront" "github.com/aws/aws-sdk-go/service/cloudfront/cloudfrontiface" - "github.com/snyk/driftctl/pkg/remote/cache" + "github.com/snyk/driftctl/enumeration/remote/cache" ) type CloudfrontRepository interface { diff --git a/pkg/remote/aws/repository/cloudfront_repository_test.go b/enumeration/remote/aws/repository/cloudfront_repository_test.go similarity index 98% rename from pkg/remote/aws/repository/cloudfront_repository_test.go rename to enumeration/remote/aws/repository/cloudfront_repository_test.go index baa869be1..4c39d4377 100644 --- a/pkg/remote/aws/repository/cloudfront_repository_test.go +++ b/enumeration/remote/aws/repository/cloudfront_repository_test.go @@ -1,12 +1,12 @@ package repository import ( + "github.com/snyk/driftctl/enumeration/remote/cache" "strings" "testing" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/cloudfront" - "github.com/snyk/driftctl/pkg/remote/cache" awstest "github.com/snyk/driftctl/test/aws" "github.com/stretchr/testify/mock" diff --git a/pkg/remote/aws/repository/dynamodb_repository.go b/enumeration/remote/aws/repository/dynamodb_repository.go similarity index 94% rename from pkg/remote/aws/repository/dynamodb_repository.go rename to enumeration/remote/aws/repository/dynamodb_repository.go index e902f7092..42efe29a5 100644 --- a/pkg/remote/aws/repository/dynamodb_repository.go +++ b/enumeration/remote/aws/repository/dynamodb_repository.go @@ -4,7 +4,7 @@ import ( "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/dynamodb" "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbiface" - "github.com/snyk/driftctl/pkg/remote/cache" + "github.com/snyk/driftctl/enumeration/remote/cache" ) type DynamoDBRepository interface { diff --git a/pkg/remote/aws/repository/dynamodb_repository_test.go b/enumeration/remote/aws/repository/dynamodb_repository_test.go similarity index 97% rename from pkg/remote/aws/repository/dynamodb_repository_test.go rename to enumeration/remote/aws/repository/dynamodb_repository_test.go index 00a03ab73..3b89046da 100644 --- a/pkg/remote/aws/repository/dynamodb_repository_test.go +++ b/enumeration/remote/aws/repository/dynamodb_repository_test.go @@ -1,12 +1,12 @@ package repository import ( + "github.com/snyk/driftctl/enumeration/remote/cache" "strings" "testing" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/dynamodb" - "github.com/snyk/driftctl/pkg/remote/cache" awstest "github.com/snyk/driftctl/test/aws" "github.com/stretchr/testify/mock" diff --git a/pkg/remote/aws/repository/ec2_repository.go b/enumeration/remote/aws/repository/ec2_repository.go similarity index 99% rename from pkg/remote/aws/repository/ec2_repository.go rename to enumeration/remote/aws/repository/ec2_repository.go index 776fd8237..725c11e7f 100644 --- a/pkg/remote/aws/repository/ec2_repository.go +++ b/enumeration/remote/aws/repository/ec2_repository.go @@ -5,7 +5,7 @@ import ( "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2/ec2iface" - "github.com/snyk/driftctl/pkg/remote/cache" + "github.com/snyk/driftctl/enumeration/remote/cache" ) type EC2Repository interface { diff --git a/pkg/remote/aws/repository/ec2_repository_test.go b/enumeration/remote/aws/repository/ec2_repository_test.go similarity index 98% rename from pkg/remote/aws/repository/ec2_repository_test.go rename to enumeration/remote/aws/repository/ec2_repository_test.go index 2d0b4aebb..273a811b8 100644 --- a/pkg/remote/aws/repository/ec2_repository_test.go +++ b/enumeration/remote/aws/repository/ec2_repository_test.go @@ -1,11 +1,11 @@ package repository import ( + cache2 "github.com/snyk/driftctl/enumeration/remote/cache" "strings" "testing" "github.com/pkg/errors" - "github.com/snyk/driftctl/pkg/remote/cache" awstest "github.com/snyk/driftctl/test/aws" "github.com/stretchr/testify/mock" @@ -52,7 +52,7 @@ func Test_ec2Repository_ListAllImages(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache.New(1) + store := cache2.New(1) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -131,7 +131,7 @@ func Test_ec2Repository_ListAllSnapshots(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache.New(1) + store := cache2.New(1) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -206,7 +206,7 @@ func Test_ec2Repository_ListAllVolumes(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache.New(1) + store := cache2.New(1) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -266,7 +266,7 @@ func Test_ec2Repository_ListAllAddresses(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache.New(1) + store := cache2.New(1) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -326,7 +326,7 @@ func Test_ec2Repository_ListAllAddressesAssociation(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache.New(1) + store := cache2.New(1) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -438,7 +438,7 @@ func Test_ec2Repository_ListAllInstances(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache.New(1) + store := cache2.New(1) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -497,7 +497,7 @@ func Test_ec2Repository_ListAllKeyPairs(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache.New(1) + store := cache2.New(1) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -581,7 +581,7 @@ func Test_ec2Repository_ListAllInternetGateways(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache.New(1) + store := cache2.New(1) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -692,7 +692,7 @@ func Test_ec2Repository_ListAllSubnets(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache.New(2) + store := cache2.New(2) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -786,7 +786,7 @@ func Test_ec2Repository_ListAllNatGateways(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache.New(1) + store := cache2.New(1) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -978,7 +978,7 @@ func Test_ec2Repository_ListAllRouteTables(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache.New(1) + store := cache2.New(1) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -1071,7 +1071,7 @@ func Test_ec2Repository_ListAllVPCs(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache.New(2) + store := cache2.New(2) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -1156,7 +1156,7 @@ func Test_ec2Repository_ListAllSecurityGroups(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache.New(2) + store := cache2.New(2) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -1247,7 +1247,7 @@ func Test_ec2Repository_ListAllNetworkACLs(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache.New(2) + store := cache2.New(2) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -1325,7 +1325,7 @@ func Test_ec2Repository_DescribeLaunchTemplates(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache.New(1) + store := cache2.New(1) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -1362,13 +1362,13 @@ func Test_ec2Repository_IsEbsEncryptionEnabledByDefault(t *testing.T) { tests := []struct { name string - mocks func(client *awstest.MockFakeEC2, store *cache.MockCache) + mocks func(client *awstest.MockFakeEC2, store *cache2.MockCache) want bool wantErr error }{ { name: "test that encryption enabled by default", - mocks: func(client *awstest.MockFakeEC2, store *cache.MockCache) { + mocks: func(client *awstest.MockFakeEC2, store *cache2.MockCache) { store.On("Get", "ec2IsEbsEncryptionEnabledByDefault"). Return(nil). Once() @@ -1387,7 +1387,7 @@ func Test_ec2Repository_IsEbsEncryptionEnabledByDefault(t *testing.T) { }, { name: "test that encryption enabled by default (cached)", - mocks: func(client *awstest.MockFakeEC2, store *cache.MockCache) { + mocks: func(client *awstest.MockFakeEC2, store *cache2.MockCache) { store.On("Get", "ec2IsEbsEncryptionEnabledByDefault"). Return(false). Once() @@ -1396,7 +1396,7 @@ func Test_ec2Repository_IsEbsEncryptionEnabledByDefault(t *testing.T) { }, { name: "error while getting default encryption value", - mocks: func(client *awstest.MockFakeEC2, store *cache.MockCache) { + mocks: func(client *awstest.MockFakeEC2, store *cache2.MockCache) { store.On("Get", "ec2IsEbsEncryptionEnabledByDefault"). Return(nil). Once() @@ -1410,7 +1410,7 @@ func Test_ec2Repository_IsEbsEncryptionEnabledByDefault(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := &cache.MockCache{} + store := &cache2.MockCache{} client := &awstest.MockFakeEC2{} tt.mocks(client, store) r := &ec2Repository{ diff --git a/pkg/remote/aws/repository/ecr_repository.go b/enumeration/remote/aws/repository/ecr_repository.go similarity index 97% rename from pkg/remote/aws/repository/ecr_repository.go rename to enumeration/remote/aws/repository/ecr_repository.go index 9ca2f50f5..d7b42563f 100644 --- a/pkg/remote/aws/repository/ecr_repository.go +++ b/enumeration/remote/aws/repository/ecr_repository.go @@ -2,11 +2,11 @@ package repository import ( "fmt" + "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ecr" "github.com/aws/aws-sdk-go/service/ecr/ecriface" - "github.com/snyk/driftctl/pkg/remote/cache" ) type ECRRepository interface { diff --git a/pkg/remote/aws/repository/ecr_repository_test.go b/enumeration/remote/aws/repository/ecr_repository_test.go similarity index 98% rename from pkg/remote/aws/repository/ecr_repository_test.go rename to enumeration/remote/aws/repository/ecr_repository_test.go index 2c8f81900..e36894e86 100644 --- a/pkg/remote/aws/repository/ecr_repository_test.go +++ b/enumeration/remote/aws/repository/ecr_repository_test.go @@ -2,12 +2,12 @@ package repository import ( "fmt" + "github.com/snyk/driftctl/enumeration/remote/cache" "strings" "testing" "github.com/aws/aws-sdk-go/service/ecr" "github.com/pkg/errors" - "github.com/snyk/driftctl/pkg/remote/cache" awstest "github.com/snyk/driftctl/test/aws" "github.com/aws/aws-sdk-go/aws" diff --git a/pkg/remote/aws/repository/elasticache_repository.go b/enumeration/remote/aws/repository/elasticache_repository.go similarity index 95% rename from pkg/remote/aws/repository/elasticache_repository.go rename to enumeration/remote/aws/repository/elasticache_repository.go index 8d05cf0ae..9fc991aec 100644 --- a/pkg/remote/aws/repository/elasticache_repository.go +++ b/enumeration/remote/aws/repository/elasticache_repository.go @@ -4,7 +4,7 @@ import ( "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/elasticache" "github.com/aws/aws-sdk-go/service/elasticache/elasticacheiface" - "github.com/snyk/driftctl/pkg/remote/cache" + "github.com/snyk/driftctl/enumeration/remote/cache" ) type ElastiCacheRepository interface { diff --git a/pkg/remote/aws/repository/elasticache_repository_test.go b/enumeration/remote/aws/repository/elasticache_repository_test.go similarity index 98% rename from pkg/remote/aws/repository/elasticache_repository_test.go rename to enumeration/remote/aws/repository/elasticache_repository_test.go index fa01590ba..110bff123 100644 --- a/pkg/remote/aws/repository/elasticache_repository_test.go +++ b/enumeration/remote/aws/repository/elasticache_repository_test.go @@ -1,6 +1,7 @@ package repository import ( + "github.com/snyk/driftctl/enumeration/remote/cache" "strings" "testing" @@ -8,7 +9,6 @@ import ( "github.com/aws/aws-sdk-go/service/elasticache" "github.com/pkg/errors" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/remote/cache" awstest "github.com/snyk/driftctl/test/aws" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" diff --git a/pkg/remote/aws/repository/elb_repository.go b/enumeration/remote/aws/repository/elb_repository.go similarity index 95% rename from pkg/remote/aws/repository/elb_repository.go rename to enumeration/remote/aws/repository/elb_repository.go index 3fe181471..46c05cbaf 100644 --- a/pkg/remote/aws/repository/elb_repository.go +++ b/enumeration/remote/aws/repository/elb_repository.go @@ -4,7 +4,7 @@ import ( "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/elb" "github.com/aws/aws-sdk-go/service/elb/elbiface" - "github.com/snyk/driftctl/pkg/remote/cache" + "github.com/snyk/driftctl/enumeration/remote/cache" ) type ELBRepository interface { diff --git a/pkg/remote/aws/repository/elb_repository_test.go b/enumeration/remote/aws/repository/elb_repository_test.go similarity index 98% rename from pkg/remote/aws/repository/elb_repository_test.go rename to enumeration/remote/aws/repository/elb_repository_test.go index 48be952ff..b21b06e0d 100644 --- a/pkg/remote/aws/repository/elb_repository_test.go +++ b/enumeration/remote/aws/repository/elb_repository_test.go @@ -2,12 +2,12 @@ package repository import ( "errors" + "github.com/snyk/driftctl/enumeration/remote/cache" "strings" "testing" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/elb" - "github.com/snyk/driftctl/pkg/remote/cache" awstest "github.com/snyk/driftctl/test/aws" "github.com/stretchr/testify/mock" diff --git a/pkg/remote/aws/repository/elbv2_repository.go b/enumeration/remote/aws/repository/elbv2_repository.go similarity index 97% rename from pkg/remote/aws/repository/elbv2_repository.go rename to enumeration/remote/aws/repository/elbv2_repository.go index aab456863..28639b15f 100644 --- a/pkg/remote/aws/repository/elbv2_repository.go +++ b/enumeration/remote/aws/repository/elbv2_repository.go @@ -4,7 +4,7 @@ import ( "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/elbv2" "github.com/aws/aws-sdk-go/service/elbv2/elbv2iface" - "github.com/snyk/driftctl/pkg/remote/cache" + "github.com/snyk/driftctl/enumeration/remote/cache" ) type ELBV2Repository interface { diff --git a/pkg/remote/aws/repository/elbv2_repository_test.go b/enumeration/remote/aws/repository/elbv2_repository_test.go similarity index 99% rename from pkg/remote/aws/repository/elbv2_repository_test.go rename to enumeration/remote/aws/repository/elbv2_repository_test.go index a96b96907..2ca320d6e 100644 --- a/pkg/remote/aws/repository/elbv2_repository_test.go +++ b/enumeration/remote/aws/repository/elbv2_repository_test.go @@ -1,13 +1,13 @@ package repository import ( + "github.com/snyk/driftctl/enumeration/remote/cache" "strings" "testing" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/elbv2" "github.com/pkg/errors" - "github.com/snyk/driftctl/pkg/remote/cache" awstest "github.com/snyk/driftctl/test/aws" "github.com/stretchr/testify/mock" diff --git a/pkg/remote/aws/repository/iam_repository.go b/enumeration/remote/aws/repository/iam_repository.go similarity index 99% rename from pkg/remote/aws/repository/iam_repository.go rename to enumeration/remote/aws/repository/iam_repository.go index c828c1db3..e7882fe92 100644 --- a/pkg/remote/aws/repository/iam_repository.go +++ b/enumeration/remote/aws/repository/iam_repository.go @@ -2,12 +2,12 @@ package repository import ( "fmt" + "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/iam" "github.com/aws/aws-sdk-go/service/iam/iamiface" - "github.com/snyk/driftctl/pkg/remote/cache" ) type IAMRepository interface { diff --git a/pkg/remote/aws/repository/iam_repository_test.go b/enumeration/remote/aws/repository/iam_repository_test.go similarity index 99% rename from pkg/remote/aws/repository/iam_repository_test.go rename to enumeration/remote/aws/repository/iam_repository_test.go index 2aff283e6..8d2ad6e21 100644 --- a/pkg/remote/aws/repository/iam_repository_test.go +++ b/enumeration/remote/aws/repository/iam_repository_test.go @@ -2,12 +2,12 @@ package repository import ( "fmt" + "github.com/snyk/driftctl/enumeration/remote/cache" "strings" "testing" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/iam" - "github.com/snyk/driftctl/pkg/remote/cache" awstest "github.com/snyk/driftctl/test/aws" "github.com/stretchr/testify/mock" diff --git a/pkg/remote/aws/repository/kms_repository.go b/enumeration/remote/aws/repository/kms_repository.go similarity index 98% rename from pkg/remote/aws/repository/kms_repository.go rename to enumeration/remote/aws/repository/kms_repository.go index 2b21baff6..347ad5ca8 100644 --- a/pkg/remote/aws/repository/kms_repository.go +++ b/enumeration/remote/aws/repository/kms_repository.go @@ -2,6 +2,7 @@ package repository import ( "fmt" + "github.com/snyk/driftctl/enumeration/remote/cache" "strings" "sync" @@ -10,7 +11,6 @@ import ( "github.com/aws/aws-sdk-go/service/kms" "github.com/aws/aws-sdk-go/service/kms/kmsiface" "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/remote/cache" ) type KMSRepository interface { diff --git a/pkg/remote/aws/repository/kms_repository_test.go b/enumeration/remote/aws/repository/kms_repository_test.go similarity index 99% rename from pkg/remote/aws/repository/kms_repository_test.go rename to enumeration/remote/aws/repository/kms_repository_test.go index 51ee23f31..30ea14ec2 100644 --- a/pkg/remote/aws/repository/kms_repository_test.go +++ b/enumeration/remote/aws/repository/kms_repository_test.go @@ -1,13 +1,13 @@ package repository import ( + "github.com/snyk/driftctl/enumeration/remote/cache" "strings" "sync" "testing" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/kms" - "github.com/snyk/driftctl/pkg/remote/cache" awstest "github.com/snyk/driftctl/test/aws" "github.com/stretchr/testify/mock" diff --git a/pkg/remote/aws/repository/lambda_repository.go b/enumeration/remote/aws/repository/lambda_repository.go similarity index 97% rename from pkg/remote/aws/repository/lambda_repository.go rename to enumeration/remote/aws/repository/lambda_repository.go index 6b9b6fdf1..d9377d269 100644 --- a/pkg/remote/aws/repository/lambda_repository.go +++ b/enumeration/remote/aws/repository/lambda_repository.go @@ -4,7 +4,7 @@ import ( "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/lambda" "github.com/aws/aws-sdk-go/service/lambda/lambdaiface" - "github.com/snyk/driftctl/pkg/remote/cache" + "github.com/snyk/driftctl/enumeration/remote/cache" ) type LambdaRepository interface { diff --git a/pkg/remote/aws/repository/lambda_repository_test.go b/enumeration/remote/aws/repository/lambda_repository_test.go similarity index 98% rename from pkg/remote/aws/repository/lambda_repository_test.go rename to enumeration/remote/aws/repository/lambda_repository_test.go index 627629834..4981884ea 100644 --- a/pkg/remote/aws/repository/lambda_repository_test.go +++ b/enumeration/remote/aws/repository/lambda_repository_test.go @@ -1,11 +1,11 @@ package repository import ( + "github.com/snyk/driftctl/enumeration/remote/cache" "strings" "testing" "github.com/aws/aws-sdk-go/aws" - "github.com/snyk/driftctl/pkg/remote/cache" awstest "github.com/snyk/driftctl/test/aws" "github.com/stretchr/testify/mock" diff --git a/pkg/remote/aws/repository/mock_ApiGatewayRepository.go b/enumeration/remote/aws/repository/mock_ApiGatewayRepository.go similarity index 100% rename from pkg/remote/aws/repository/mock_ApiGatewayRepository.go rename to enumeration/remote/aws/repository/mock_ApiGatewayRepository.go diff --git a/pkg/remote/aws/repository/mock_ApiGatewayV2Repository.go b/enumeration/remote/aws/repository/mock_ApiGatewayV2Repository.go similarity index 100% rename from pkg/remote/aws/repository/mock_ApiGatewayV2Repository.go rename to enumeration/remote/aws/repository/mock_ApiGatewayV2Repository.go diff --git a/pkg/remote/aws/repository/mock_AppAutoScalingRepository.go b/enumeration/remote/aws/repository/mock_AppAutoScalingRepository.go similarity index 100% rename from pkg/remote/aws/repository/mock_AppAutoScalingRepository.go rename to enumeration/remote/aws/repository/mock_AppAutoScalingRepository.go diff --git a/pkg/remote/aws/repository/mock_AutoScalingRepository.go b/enumeration/remote/aws/repository/mock_AutoScalingRepository.go similarity index 100% rename from pkg/remote/aws/repository/mock_AutoScalingRepository.go rename to enumeration/remote/aws/repository/mock_AutoScalingRepository.go diff --git a/pkg/remote/aws/repository/mock_CloudformationRepository.go b/enumeration/remote/aws/repository/mock_CloudformationRepository.go similarity index 100% rename from pkg/remote/aws/repository/mock_CloudformationRepository.go rename to enumeration/remote/aws/repository/mock_CloudformationRepository.go diff --git a/pkg/remote/aws/repository/mock_CloudfrontRepository.go b/enumeration/remote/aws/repository/mock_CloudfrontRepository.go similarity index 100% rename from pkg/remote/aws/repository/mock_CloudfrontRepository.go rename to enumeration/remote/aws/repository/mock_CloudfrontRepository.go diff --git a/pkg/remote/aws/repository/mock_DynamoDBRepository.go b/enumeration/remote/aws/repository/mock_DynamoDBRepository.go similarity index 100% rename from pkg/remote/aws/repository/mock_DynamoDBRepository.go rename to enumeration/remote/aws/repository/mock_DynamoDBRepository.go diff --git a/pkg/remote/aws/repository/mock_EC2Repository.go b/enumeration/remote/aws/repository/mock_EC2Repository.go similarity index 100% rename from pkg/remote/aws/repository/mock_EC2Repository.go rename to enumeration/remote/aws/repository/mock_EC2Repository.go diff --git a/pkg/remote/aws/repository/mock_ECRRepository.go b/enumeration/remote/aws/repository/mock_ECRRepository.go similarity index 100% rename from pkg/remote/aws/repository/mock_ECRRepository.go rename to enumeration/remote/aws/repository/mock_ECRRepository.go diff --git a/pkg/remote/aws/repository/mock_ELBRepository.go b/enumeration/remote/aws/repository/mock_ELBRepository.go similarity index 100% rename from pkg/remote/aws/repository/mock_ELBRepository.go rename to enumeration/remote/aws/repository/mock_ELBRepository.go diff --git a/pkg/remote/aws/repository/mock_ELBV2Repository.go b/enumeration/remote/aws/repository/mock_ELBV2Repository.go similarity index 100% rename from pkg/remote/aws/repository/mock_ELBV2Repository.go rename to enumeration/remote/aws/repository/mock_ELBV2Repository.go diff --git a/pkg/remote/aws/repository/mock_ElastiCacheRepository.go b/enumeration/remote/aws/repository/mock_ElastiCacheRepository.go similarity index 100% rename from pkg/remote/aws/repository/mock_ElastiCacheRepository.go rename to enumeration/remote/aws/repository/mock_ElastiCacheRepository.go diff --git a/pkg/remote/aws/repository/mock_IAMRepository.go b/enumeration/remote/aws/repository/mock_IAMRepository.go similarity index 100% rename from pkg/remote/aws/repository/mock_IAMRepository.go rename to enumeration/remote/aws/repository/mock_IAMRepository.go diff --git a/pkg/remote/aws/repository/mock_KMSRepository.go b/enumeration/remote/aws/repository/mock_KMSRepository.go similarity index 100% rename from pkg/remote/aws/repository/mock_KMSRepository.go rename to enumeration/remote/aws/repository/mock_KMSRepository.go diff --git a/pkg/remote/aws/repository/mock_LambdaRepository.go b/enumeration/remote/aws/repository/mock_LambdaRepository.go similarity index 100% rename from pkg/remote/aws/repository/mock_LambdaRepository.go rename to enumeration/remote/aws/repository/mock_LambdaRepository.go diff --git a/pkg/remote/aws/repository/mock_RDSRepository.go b/enumeration/remote/aws/repository/mock_RDSRepository.go similarity index 100% rename from pkg/remote/aws/repository/mock_RDSRepository.go rename to enumeration/remote/aws/repository/mock_RDSRepository.go diff --git a/pkg/remote/aws/repository/mock_Route53Repository.go b/enumeration/remote/aws/repository/mock_Route53Repository.go similarity index 100% rename from pkg/remote/aws/repository/mock_Route53Repository.go rename to enumeration/remote/aws/repository/mock_Route53Repository.go diff --git a/pkg/remote/aws/repository/mock_S3Repository.go b/enumeration/remote/aws/repository/mock_S3Repository.go similarity index 100% rename from pkg/remote/aws/repository/mock_S3Repository.go rename to enumeration/remote/aws/repository/mock_S3Repository.go diff --git a/pkg/remote/aws/repository/mock_SNSRepository.go b/enumeration/remote/aws/repository/mock_SNSRepository.go similarity index 100% rename from pkg/remote/aws/repository/mock_SNSRepository.go rename to enumeration/remote/aws/repository/mock_SNSRepository.go diff --git a/pkg/remote/aws/repository/mock_SQSRepository.go b/enumeration/remote/aws/repository/mock_SQSRepository.go similarity index 100% rename from pkg/remote/aws/repository/mock_SQSRepository.go rename to enumeration/remote/aws/repository/mock_SQSRepository.go diff --git a/pkg/remote/aws/repository/rds_repository.go b/enumeration/remote/aws/repository/rds_repository.go similarity index 97% rename from pkg/remote/aws/repository/rds_repository.go rename to enumeration/remote/aws/repository/rds_repository.go index 28d78a5d9..95d2ebfbe 100644 --- a/pkg/remote/aws/repository/rds_repository.go +++ b/enumeration/remote/aws/repository/rds_repository.go @@ -4,7 +4,7 @@ import ( "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/rds" "github.com/aws/aws-sdk-go/service/rds/rdsiface" - "github.com/snyk/driftctl/pkg/remote/cache" + "github.com/snyk/driftctl/enumeration/remote/cache" ) type RDSRepository interface { diff --git a/pkg/remote/aws/repository/rds_repository_test.go b/enumeration/remote/aws/repository/rds_repository_test.go similarity index 95% rename from pkg/remote/aws/repository/rds_repository_test.go rename to enumeration/remote/aws/repository/rds_repository_test.go index 5a4d38988..639ffb8c1 100644 --- a/pkg/remote/aws/repository/rds_repository_test.go +++ b/enumeration/remote/aws/repository/rds_repository_test.go @@ -1,13 +1,13 @@ package repository import ( + cache2 "github.com/snyk/driftctl/enumeration/remote/cache" "strings" "testing" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/rds" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/remote/cache" awstest "github.com/snyk/driftctl/test/aws" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -55,7 +55,7 @@ func Test_rdsRepository_ListAllDBInstances(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache.New(1) + store := cache2.New(1) client := &awstest.MockFakeRDS{} tt.mocks(client) r := &rdsRepository{ @@ -127,7 +127,7 @@ func Test_rdsRepository_ListAllDBSubnetGroups(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache.New(1) + store := cache2.New(1) client := &awstest.MockFakeRDS{} tt.mocks(client) r := &rdsRepository{ @@ -160,13 +160,13 @@ func Test_rdsRepository_ListAllDBSubnetGroups(t *testing.T) { func Test_rdsRepository_ListAllDBClusters(t *testing.T) { tests := []struct { name string - mocks func(*awstest.MockFakeRDS, *cache.MockCache) + mocks func(*awstest.MockFakeRDS, *cache2.MockCache) want []*rds.DBCluster wantErr error }{ { name: "should list with 2 pages", - mocks: func(client *awstest.MockFakeRDS, store *cache.MockCache) { + mocks: func(client *awstest.MockFakeRDS, store *cache2.MockCache) { clusters := []*rds.DBCluster{ {DBClusterIdentifier: aws.String("1")}, {DBClusterIdentifier: aws.String("2")}, @@ -198,7 +198,7 @@ func Test_rdsRepository_ListAllDBClusters(t *testing.T) { }, { name: "should hit cache", - mocks: func(client *awstest.MockFakeRDS, store *cache.MockCache) { + mocks: func(client *awstest.MockFakeRDS, store *cache2.MockCache) { clusters := []*rds.DBCluster{ {DBClusterIdentifier: aws.String("1")}, {DBClusterIdentifier: aws.String("2")}, @@ -222,7 +222,7 @@ func Test_rdsRepository_ListAllDBClusters(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := &cache.MockCache{} + store := &cache2.MockCache{} client := &awstest.MockFakeRDS{} tt.mocks(client, store) r := &rdsRepository{ diff --git a/pkg/remote/aws/repository/route53_repository.go b/enumeration/remote/aws/repository/route53_repository.go similarity index 97% rename from pkg/remote/aws/repository/route53_repository.go rename to enumeration/remote/aws/repository/route53_repository.go index 2e7dc962e..d1e7a51cc 100644 --- a/pkg/remote/aws/repository/route53_repository.go +++ b/enumeration/remote/aws/repository/route53_repository.go @@ -2,12 +2,12 @@ package repository import ( "fmt" + "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/route53" "github.com/aws/aws-sdk-go/service/route53/route53iface" - "github.com/snyk/driftctl/pkg/remote/cache" ) type Route53Repository interface { diff --git a/pkg/remote/aws/repository/route53_repository_test.go b/enumeration/remote/aws/repository/route53_repository_test.go similarity index 99% rename from pkg/remote/aws/repository/route53_repository_test.go rename to enumeration/remote/aws/repository/route53_repository_test.go index 7a6523361..77a23c237 100644 --- a/pkg/remote/aws/repository/route53_repository_test.go +++ b/enumeration/remote/aws/repository/route53_repository_test.go @@ -2,12 +2,12 @@ package repository import ( "fmt" + "github.com/snyk/driftctl/enumeration/remote/cache" "strings" "testing" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/route53" - "github.com/snyk/driftctl/pkg/remote/cache" awstest "github.com/snyk/driftctl/test/aws" "github.com/stretchr/testify/mock" diff --git a/pkg/remote/aws/repository/s3_repository.go b/enumeration/remote/aws/repository/s3_repository.go similarity index 98% rename from pkg/remote/aws/repository/s3_repository.go rename to enumeration/remote/aws/repository/s3_repository.go index cabd14bff..2b5f5557b 100644 --- a/pkg/remote/aws/repository/s3_repository.go +++ b/enumeration/remote/aws/repository/s3_repository.go @@ -2,14 +2,14 @@ package repository import ( "fmt" + "github.com/snyk/driftctl/enumeration/remote/aws/client" + "github.com/snyk/driftctl/enumeration/remote/cache" awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/s3" "github.com/pkg/errors" "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/remote/aws/client" - "github.com/snyk/driftctl/pkg/remote/cache" ) type S3Repository interface { diff --git a/pkg/remote/aws/repository/s3_repository_test.go b/enumeration/remote/aws/repository/s3_repository_test.go similarity index 99% rename from pkg/remote/aws/repository/s3_repository_test.go rename to enumeration/remote/aws/repository/s3_repository_test.go index 4e49b6bf2..a73c80c80 100644 --- a/pkg/remote/aws/repository/s3_repository_test.go +++ b/enumeration/remote/aws/repository/s3_repository_test.go @@ -2,6 +2,8 @@ package repository import ( "fmt" + "github.com/snyk/driftctl/enumeration/remote/aws/client" + "github.com/snyk/driftctl/enumeration/remote/cache" "strings" "testing" @@ -11,8 +13,6 @@ import ( "github.com/aws/aws-sdk-go/service/s3" "github.com/pkg/errors" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/remote/aws/client" - "github.com/snyk/driftctl/pkg/remote/cache" awstest "github.com/snyk/driftctl/test/aws" "github.com/stretchr/testify/assert" ) diff --git a/pkg/remote/aws/repository/sns_repository.go b/enumeration/remote/aws/repository/sns_repository.go similarity index 96% rename from pkg/remote/aws/repository/sns_repository.go rename to enumeration/remote/aws/repository/sns_repository.go index 1e9f3a20e..b4c17f5b7 100644 --- a/pkg/remote/aws/repository/sns_repository.go +++ b/enumeration/remote/aws/repository/sns_repository.go @@ -4,7 +4,7 @@ import ( "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/sns" "github.com/aws/aws-sdk-go/service/sns/snsiface" - "github.com/snyk/driftctl/pkg/remote/cache" + "github.com/snyk/driftctl/enumeration/remote/cache" ) type SNSRepository interface { diff --git a/pkg/remote/aws/repository/sns_repository_test.go b/enumeration/remote/aws/repository/sns_repository_test.go similarity index 98% rename from pkg/remote/aws/repository/sns_repository_test.go rename to enumeration/remote/aws/repository/sns_repository_test.go index 3554d6600..d5b6778d8 100644 --- a/pkg/remote/aws/repository/sns_repository_test.go +++ b/enumeration/remote/aws/repository/sns_repository_test.go @@ -1,11 +1,11 @@ package repository import ( + "github.com/snyk/driftctl/enumeration/remote/cache" "strings" "testing" "github.com/aws/aws-sdk-go/aws" - "github.com/snyk/driftctl/pkg/remote/cache" awstest "github.com/snyk/driftctl/test/aws" "github.com/stretchr/testify/mock" diff --git a/pkg/remote/aws/repository/sqs_repository.go b/enumeration/remote/aws/repository/sqs_repository.go similarity index 96% rename from pkg/remote/aws/repository/sqs_repository.go rename to enumeration/remote/aws/repository/sqs_repository.go index 97900ed69..dbf46bc21 100644 --- a/pkg/remote/aws/repository/sqs_repository.go +++ b/enumeration/remote/aws/repository/sqs_repository.go @@ -2,12 +2,12 @@ package repository import ( "fmt" + "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/sqs" "github.com/aws/aws-sdk-go/service/sqs/sqsiface" - "github.com/snyk/driftctl/pkg/remote/cache" ) type SQSRepository interface { diff --git a/pkg/remote/aws/repository/sqs_repository_test.go b/enumeration/remote/aws/repository/sqs_repository_test.go similarity index 98% rename from pkg/remote/aws/repository/sqs_repository_test.go rename to enumeration/remote/aws/repository/sqs_repository_test.go index f7c11c8d2..51889afba 100644 --- a/pkg/remote/aws/repository/sqs_repository_test.go +++ b/enumeration/remote/aws/repository/sqs_repository_test.go @@ -1,11 +1,11 @@ package repository import ( + "github.com/snyk/driftctl/enumeration/remote/cache" "strings" "testing" awssdk "github.com/aws/aws-sdk-go/aws" - "github.com/snyk/driftctl/pkg/remote/cache" awstest "github.com/snyk/driftctl/test/aws" "github.com/aws/aws-sdk-go/service/sqs" diff --git a/pkg/remote/aws/route53_health_check_enumerator.go b/enumeration/remote/aws/route53_health_check_enumerator.go similarity index 81% rename from pkg/remote/aws/route53_health_check_enumerator.go rename to enumeration/remote/aws/route53_health_check_enumerator.go index 16ec37f1d..15d7019ae 100644 --- a/pkg/remote/aws/route53_health_check_enumerator.go +++ b/enumeration/remote/aws/route53_health_check_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type Route53HealthCheckEnumerator struct { diff --git a/pkg/remote/aws/route53_record_enumerator.go b/enumeration/remote/aws/route53_record_enumerator.go similarity index 90% rename from pkg/remote/aws/route53_record_enumerator.go rename to enumeration/remote/aws/route53_record_enumerator.go index 24d2ff1dd..4cefb5c58 100644 --- a/pkg/remote/aws/route53_record_enumerator.go +++ b/enumeration/remote/aws/route53_record_enumerator.go @@ -1,15 +1,13 @@ package aws import ( + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" "strconv" "strings" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" ) type Route53RecordEnumerator struct { diff --git a/pkg/remote/aws/route53_zone_enumerator.go b/enumeration/remote/aws/route53_zone_enumerator.go similarity index 80% rename from pkg/remote/aws/route53_zone_enumerator.go rename to enumeration/remote/aws/route53_zone_enumerator.go index 2ecfde235..7e51bf16f 100644 --- a/pkg/remote/aws/route53_zone_enumerator.go +++ b/enumeration/remote/aws/route53_zone_enumerator.go @@ -1,14 +1,12 @@ package aws import ( + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" "strings" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" ) type Route53ZoneSupplier struct { diff --git a/pkg/remote/aws/s3_bucket_analytic_enumerator.go b/enumeration/remote/aws/s3_bucket_analytic_enumerator.go similarity index 82% rename from pkg/remote/aws/s3_bucket_analytic_enumerator.go rename to enumeration/remote/aws/s3_bucket_analytic_enumerator.go index 5e5370850..b2c931eea 100644 --- a/pkg/remote/aws/s3_bucket_analytic_enumerator.go +++ b/enumeration/remote/aws/s3_bucket_analytic_enumerator.go @@ -2,16 +2,16 @@ package aws import ( "fmt" + "github.com/snyk/driftctl/enumeration/alerter" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/common" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + tf "github.com/snyk/driftctl/enumeration/remote/terraform" "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/alerter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - tf "github.com/snyk/driftctl/pkg/remote/terraform" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type S3BucketAnalyticEnumerator struct { diff --git a/pkg/remote/aws/s3_bucket_enumerator.go b/enumeration/remote/aws/s3_bucket_enumerator.go similarity index 78% rename from pkg/remote/aws/s3_bucket_enumerator.go rename to enumeration/remote/aws/s3_bucket_enumerator.go index e245bf13a..e96b69d57 100644 --- a/pkg/remote/aws/s3_bucket_enumerator.go +++ b/enumeration/remote/aws/s3_bucket_enumerator.go @@ -2,14 +2,14 @@ package aws import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/alerter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - tf "github.com/snyk/driftctl/pkg/remote/terraform" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/alerter" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/common" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + tf "github.com/snyk/driftctl/enumeration/remote/terraform" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type S3BucketEnumerator struct { diff --git a/pkg/remote/aws/s3_bucket_inventory_enumerator.go b/enumeration/remote/aws/s3_bucket_inventory_enumerator.go similarity index 83% rename from pkg/remote/aws/s3_bucket_inventory_enumerator.go rename to enumeration/remote/aws/s3_bucket_inventory_enumerator.go index 35f6f83b7..975185501 100644 --- a/pkg/remote/aws/s3_bucket_inventory_enumerator.go +++ b/enumeration/remote/aws/s3_bucket_inventory_enumerator.go @@ -2,16 +2,16 @@ package aws import ( "fmt" + "github.com/snyk/driftctl/enumeration/alerter" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/common" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + tf "github.com/snyk/driftctl/enumeration/remote/terraform" "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/alerter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - tf "github.com/snyk/driftctl/pkg/remote/terraform" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type S3BucketInventoryEnumerator struct { diff --git a/pkg/remote/aws/s3_bucket_metrics_enumerator.go b/enumeration/remote/aws/s3_bucket_metrics_enumerator.go similarity index 82% rename from pkg/remote/aws/s3_bucket_metrics_enumerator.go rename to enumeration/remote/aws/s3_bucket_metrics_enumerator.go index 6a23d1d26..b70675ff6 100644 --- a/pkg/remote/aws/s3_bucket_metrics_enumerator.go +++ b/enumeration/remote/aws/s3_bucket_metrics_enumerator.go @@ -2,16 +2,16 @@ package aws import ( "fmt" + "github.com/snyk/driftctl/enumeration/alerter" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/common" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + tf "github.com/snyk/driftctl/enumeration/remote/terraform" "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/alerter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - tf "github.com/snyk/driftctl/pkg/remote/terraform" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type S3BucketMetricsEnumerator struct { diff --git a/pkg/remote/aws/s3_bucket_notification_enumerator.go b/enumeration/remote/aws/s3_bucket_notification_enumerator.go similarity index 83% rename from pkg/remote/aws/s3_bucket_notification_enumerator.go rename to enumeration/remote/aws/s3_bucket_notification_enumerator.go index 7e84daec8..8f9ec599d 100644 --- a/pkg/remote/aws/s3_bucket_notification_enumerator.go +++ b/enumeration/remote/aws/s3_bucket_notification_enumerator.go @@ -2,14 +2,14 @@ package aws import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/alerter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - tf "github.com/snyk/driftctl/pkg/remote/terraform" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/alerter" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/common" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + tf "github.com/snyk/driftctl/enumeration/remote/terraform" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type S3BucketNotificationEnumerator struct { diff --git a/pkg/remote/aws/s3_bucket_policy_enumerator.go b/enumeration/remote/aws/s3_bucket_policy_enumerator.go similarity index 82% rename from pkg/remote/aws/s3_bucket_policy_enumerator.go rename to enumeration/remote/aws/s3_bucket_policy_enumerator.go index c5548057a..c2f860f56 100644 --- a/pkg/remote/aws/s3_bucket_policy_enumerator.go +++ b/enumeration/remote/aws/s3_bucket_policy_enumerator.go @@ -2,14 +2,14 @@ package aws import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/alerter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - tf "github.com/snyk/driftctl/pkg/remote/terraform" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/alerter" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/common" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + tf "github.com/snyk/driftctl/enumeration/remote/terraform" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type S3BucketPolicyEnumerator struct { diff --git a/pkg/remote/aws/s3_bucket_public_access_block_enumerator.go b/enumeration/remote/aws/s3_bucket_public_access_block_enumerator.go similarity index 84% rename from pkg/remote/aws/s3_bucket_public_access_block_enumerator.go rename to enumeration/remote/aws/s3_bucket_public_access_block_enumerator.go index f61cfc036..be658c3e7 100644 --- a/pkg/remote/aws/s3_bucket_public_access_block_enumerator.go +++ b/enumeration/remote/aws/s3_bucket_public_access_block_enumerator.go @@ -3,14 +3,14 @@ package aws import ( awssdk "github.com/aws/aws-sdk-go/aws" "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/alerter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - tf "github.com/snyk/driftctl/pkg/remote/terraform" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/alerter" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/common" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + tf "github.com/snyk/driftctl/enumeration/remote/terraform" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type S3BucketPublicAccessBlockEnumerator struct { diff --git a/pkg/remote/aws/sns_topic_enumerator.go b/enumeration/remote/aws/sns_topic_enumerator.go similarity index 80% rename from pkg/remote/aws/sns_topic_enumerator.go rename to enumeration/remote/aws/sns_topic_enumerator.go index 89e5ecfb6..608496174 100644 --- a/pkg/remote/aws/sns_topic_enumerator.go +++ b/enumeration/remote/aws/sns_topic_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type SNSTopicEnumerator struct { diff --git a/pkg/remote/aws/sns_topic_policy_enumerator.go b/enumeration/remote/aws/sns_topic_policy_enumerator.go similarity index 81% rename from pkg/remote/aws/sns_topic_policy_enumerator.go rename to enumeration/remote/aws/sns_topic_policy_enumerator.go index c5e7b2ad6..0c6433836 100644 --- a/pkg/remote/aws/sns_topic_policy_enumerator.go +++ b/enumeration/remote/aws/sns_topic_policy_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type SNSTopicPolicyEnumerator struct { diff --git a/pkg/remote/aws/sns_topic_subscription_enumerator.go b/enumeration/remote/aws/sns_topic_subscription_enumerator.go similarity index 88% rename from pkg/remote/aws/sns_topic_subscription_enumerator.go rename to enumeration/remote/aws/sns_topic_subscription_enumerator.go index ce7fe0786..eaa89c55f 100644 --- a/pkg/remote/aws/sns_topic_subscription_enumerator.go +++ b/enumeration/remote/aws/sns_topic_subscription_enumerator.go @@ -2,15 +2,14 @@ package aws import ( "fmt" + "github.com/snyk/driftctl/enumeration/alerter" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/arn" - "github.com/snyk/driftctl/pkg/alerter" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type wrongArnTopicAlert struct { diff --git a/pkg/remote/aws/sqs_queue_details_fetcher.go b/enumeration/remote/aws/sqs_queue_details_fetcher.go similarity index 84% rename from pkg/remote/aws/sqs_queue_details_fetcher.go rename to enumeration/remote/aws/sqs_queue_details_fetcher.go index ed267409a..7aba9327e 100644 --- a/pkg/remote/aws/sqs_queue_details_fetcher.go +++ b/enumeration/remote/aws/sqs_queue_details_fetcher.go @@ -1,13 +1,13 @@ package aws import ( + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/terraform" "strings" "github.com/sirupsen/logrus" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type SQSQueueDetailsFetcher struct { diff --git a/pkg/remote/aws/sqs_queue_enumerator.go b/enumeration/remote/aws/sqs_queue_enumerator.go similarity index 81% rename from pkg/remote/aws/sqs_queue_enumerator.go rename to enumeration/remote/aws/sqs_queue_enumerator.go index de2a70ae0..88af3ad59 100644 --- a/pkg/remote/aws/sqs_queue_enumerator.go +++ b/enumeration/remote/aws/sqs_queue_enumerator.go @@ -1,10 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" awssdk "github.com/aws/aws-sdk-go/aws" ) diff --git a/pkg/remote/aws/sqs_queue_policy_enumerator.go b/enumeration/remote/aws/sqs_queue_policy_enumerator.go similarity index 88% rename from pkg/remote/aws/sqs_queue_policy_enumerator.go rename to enumeration/remote/aws/sqs_queue_policy_enumerator.go index b60828c7e..3640cc8ee 100644 --- a/pkg/remote/aws/sqs_queue_policy_enumerator.go +++ b/enumeration/remote/aws/sqs_queue_policy_enumerator.go @@ -1,14 +1,14 @@ package aws import ( + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" "strings" "github.com/aws/aws-sdk-go/service/sqs" "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" awssdk "github.com/aws/aws-sdk-go/aws" ) diff --git a/pkg/remote/aws/test/analytics_inventory_nometrics/aws_s3_bucket-bucket-martin-test-drift.res.golden.json b/enumeration/remote/aws/test/analytics_inventory_nometrics/aws_s3_bucket-bucket-martin-test-drift.res.golden.json similarity index 100% rename from pkg/remote/aws/test/analytics_inventory_nometrics/aws_s3_bucket-bucket-martin-test-drift.res.golden.json rename to enumeration/remote/aws/test/analytics_inventory_nometrics/aws_s3_bucket-bucket-martin-test-drift.res.golden.json diff --git a/pkg/remote/aws/test/analytics_inventory_nometrics/aws_s3_bucket_analytics_configuration-bucket-martin-test-drift_Analytics_Bucket.res.golden.json b/enumeration/remote/aws/test/analytics_inventory_nometrics/aws_s3_bucket_analytics_configuration-bucket-martin-test-drift_Analytics_Bucket.res.golden.json similarity index 100% rename from pkg/remote/aws/test/analytics_inventory_nometrics/aws_s3_bucket_analytics_configuration-bucket-martin-test-drift_Analytics_Bucket.res.golden.json rename to enumeration/remote/aws/test/analytics_inventory_nometrics/aws_s3_bucket_analytics_configuration-bucket-martin-test-drift_Analytics_Bucket.res.golden.json diff --git a/pkg/remote/aws/test/analytics_inventory_nometrics/aws_s3_bucket_inventory-bucket-martin-test-drift_Inventory_Bucket.res.golden.json b/enumeration/remote/aws/test/analytics_inventory_nometrics/aws_s3_bucket_inventory-bucket-martin-test-drift_Inventory_Bucket.res.golden.json similarity index 100% rename from pkg/remote/aws/test/analytics_inventory_nometrics/aws_s3_bucket_inventory-bucket-martin-test-drift_Inventory_Bucket.res.golden.json rename to enumeration/remote/aws/test/analytics_inventory_nometrics/aws_s3_bucket_inventory-bucket-martin-test-drift_Inventory_Bucket.res.golden.json diff --git a/pkg/remote/aws/test/analytics_inventory_nometrics/aws_s3_bucket_notification-bucket-martin-test-drift.res.golden.json b/enumeration/remote/aws/test/analytics_inventory_nometrics/aws_s3_bucket_notification-bucket-martin-test-drift.res.golden.json similarity index 100% rename from pkg/remote/aws/test/analytics_inventory_nometrics/aws_s3_bucket_notification-bucket-martin-test-drift.res.golden.json rename to enumeration/remote/aws/test/analytics_inventory_nometrics/aws_s3_bucket_notification-bucket-martin-test-drift.res.golden.json diff --git a/pkg/remote/aws/test/analytics_inventory_nometrics/aws_s3_bucket_policy-bucket-martin-test-drift.res.golden.json b/enumeration/remote/aws/test/analytics_inventory_nometrics/aws_s3_bucket_policy-bucket-martin-test-drift.res.golden.json similarity index 100% rename from pkg/remote/aws/test/analytics_inventory_nometrics/aws_s3_bucket_policy-bucket-martin-test-drift.res.golden.json rename to enumeration/remote/aws/test/analytics_inventory_nometrics/aws_s3_bucket_policy-bucket-martin-test-drift.res.golden.json diff --git a/pkg/remote/aws/test/analytics_inventory_nometrics/results.golden.json b/enumeration/remote/aws/test/analytics_inventory_nometrics/results.golden.json similarity index 100% rename from pkg/remote/aws/test/analytics_inventory_nometrics/results.golden.json rename to enumeration/remote/aws/test/analytics_inventory_nometrics/results.golden.json diff --git a/pkg/remote/aws/test/analytics_inventory_nometrics/schema.golden.json b/enumeration/remote/aws/test/analytics_inventory_nometrics/schema.golden.json similarity index 100% rename from pkg/remote/aws/test/analytics_inventory_nometrics/schema.golden.json rename to enumeration/remote/aws/test/analytics_inventory_nometrics/schema.golden.json diff --git a/pkg/remote/aws/test/s3_bucket_list/aws_s3_bucket_inventory-bucket-martin-test-drift2_Inventory2_Bucket2.res.golden.json b/enumeration/remote/aws/test/s3_bucket_list/aws_s3_bucket_inventory-bucket-martin-test-drift2_Inventory2_Bucket2.res.golden.json similarity index 100% rename from pkg/remote/aws/test/s3_bucket_list/aws_s3_bucket_inventory-bucket-martin-test-drift2_Inventory2_Bucket2.res.golden.json rename to enumeration/remote/aws/test/s3_bucket_list/aws_s3_bucket_inventory-bucket-martin-test-drift2_Inventory2_Bucket2.res.golden.json diff --git a/pkg/remote/aws/test/s3_bucket_list/aws_s3_bucket_inventory-bucket-martin-test-drift2_Inventory_Bucket2.res.golden.json b/enumeration/remote/aws/test/s3_bucket_list/aws_s3_bucket_inventory-bucket-martin-test-drift2_Inventory_Bucket2.res.golden.json similarity index 100% rename from pkg/remote/aws/test/s3_bucket_list/aws_s3_bucket_inventory-bucket-martin-test-drift2_Inventory_Bucket2.res.golden.json rename to enumeration/remote/aws/test/s3_bucket_list/aws_s3_bucket_inventory-bucket-martin-test-drift2_Inventory_Bucket2.res.golden.json diff --git a/pkg/remote/aws/test/s3_bucket_list/results.golden.json b/enumeration/remote/aws/test/s3_bucket_list/results.golden.json similarity index 100% rename from pkg/remote/aws/test/s3_bucket_list/results.golden.json rename to enumeration/remote/aws/test/s3_bucket_list/results.golden.json diff --git a/pkg/remote/aws/test/s3_bucket_list/schema.golden.json b/enumeration/remote/aws/test/s3_bucket_list/schema.golden.json similarity index 100% rename from pkg/remote/aws/test/s3_bucket_list/schema.golden.json rename to enumeration/remote/aws/test/s3_bucket_list/schema.golden.json diff --git a/pkg/remote/aws/vpc_default_security_group_enumerator.go b/enumeration/remote/aws/vpc_default_security_group_enumerator.go similarity index 82% rename from pkg/remote/aws/vpc_default_security_group_enumerator.go rename to enumeration/remote/aws/vpc_default_security_group_enumerator.go index 5e36f9f65..1f18fb95e 100644 --- a/pkg/remote/aws/vpc_default_security_group_enumerator.go +++ b/enumeration/remote/aws/vpc_default_security_group_enumerator.go @@ -1,11 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/aws/aws-sdk-go/aws" ) diff --git a/pkg/remote/aws/vpc_enumerator.go b/enumeration/remote/aws/vpc_enumerator.go similarity index 78% rename from pkg/remote/aws/vpc_enumerator.go rename to enumeration/remote/aws/vpc_enumerator.go index 590518085..bcac83478 100644 --- a/pkg/remote/aws/vpc_enumerator.go +++ b/enumeration/remote/aws/vpc_enumerator.go @@ -1,12 +1,11 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource/aws" - "github.com/snyk/driftctl/pkg/resource/aws" - - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) type VPCEnumerator struct { diff --git a/pkg/remote/aws/vpc_security_group_enumerator.go b/enumeration/remote/aws/vpc_security_group_enumerator.go similarity index 81% rename from pkg/remote/aws/vpc_security_group_enumerator.go rename to enumeration/remote/aws/vpc_security_group_enumerator.go index be93e3699..47d066999 100644 --- a/pkg/remote/aws/vpc_security_group_enumerator.go +++ b/enumeration/remote/aws/vpc_security_group_enumerator.go @@ -1,11 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/aws/aws-sdk-go/aws" ) diff --git a/pkg/remote/aws/vpc_security_group_rule_enumerator.go b/enumeration/remote/aws/vpc_security_group_rule_enumerator.go similarity index 95% rename from pkg/remote/aws/vpc_security_group_rule_enumerator.go rename to enumeration/remote/aws/vpc_security_group_rule_enumerator.go index ebd80567f..aacc2f74e 100644 --- a/pkg/remote/aws/vpc_security_group_rule_enumerator.go +++ b/enumeration/remote/aws/vpc_security_group_rule_enumerator.go @@ -1,11 +1,10 @@ package aws import ( - "github.com/snyk/driftctl/pkg/remote/aws/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" diff --git a/pkg/remote/aws_api_gateway_scanner_test.go b/enumeration/remote/aws_api_gateway_scanner_test.go similarity index 71% rename from pkg/remote/aws_api_gateway_scanner_test.go rename to enumeration/remote/aws_api_gateway_scanner_test.go index 9efef0a05..8be6291ba 100644 --- a/pkg/remote/aws_api_gateway_scanner_test.go +++ b/enumeration/remote/aws_api_gateway_scanner_test.go @@ -6,16 +6,17 @@ import ( awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/apigateway" "github.com/pkg/errors" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + aws2 "github.com/snyk/driftctl/enumeration/remote/aws" + repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/enumeration/terraform" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/aws" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/test/remote" testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" @@ -27,13 +28,13 @@ func TestApiGatewayRestApi(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway rest apis", - mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllRestApis").Return([]*apigateway.RestApi{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -42,7 +43,7 @@ func TestApiGatewayRestApi(t *testing.T) { }, { test: "multiple api gateway rest apis", - mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllRestApis").Return([]*apigateway.RestApi{ {Id: awssdk.String("3of73v5ob4")}, {Id: awssdk.String("1jitcobwol")}, @@ -60,9 +61,9 @@ func TestApiGatewayRestApi(t *testing.T) { }, { test: "cannot list api gateway rest apis", - mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllRestApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayRestApiResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayRestApiResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayRestApiResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayRestApiResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayRestApiResourceType), }, @@ -76,18 +77,18 @@ func TestApiGatewayRestApi(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayRepository{} + fakeRepo := &repository2.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayRepository = fakeRepo + var repo repository2.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayRestApiEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayRestApiEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -110,13 +111,13 @@ func TestApiGatewayAccount(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway account", - mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("GetAccount").Return(nil, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -125,7 +126,7 @@ func TestApiGatewayAccount(t *testing.T) { }, { test: "empty api gateway account", - mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("GetAccount").Return(&apigateway.Account{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -137,9 +138,9 @@ func TestApiGatewayAccount(t *testing.T) { }, { test: "cannot get api gateway account", - mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("GetAccount").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayAccountResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayAccountResourceType, resourceaws.AwsApiGatewayAccountResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayAccountResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayAccountResourceType, resourceaws.AwsApiGatewayAccountResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayAccountResourceType), }, @@ -153,18 +154,18 @@ func TestApiGatewayAccount(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayRepository{} + fakeRepo := &repository2.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayRepository = fakeRepo + var repo repository2.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayAccountEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayAccountEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -187,13 +188,13 @@ func TestApiGatewayApiKey(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway api keys", - mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllApiKeys").Return([]*apigateway.ApiKey{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -202,7 +203,7 @@ func TestApiGatewayApiKey(t *testing.T) { }, { test: "multiple api gateway api keys", - mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllApiKeys").Return([]*apigateway.ApiKey{ {Id: awssdk.String("fuwnl8lrva")}, {Id: awssdk.String("9ge737dd45")}, @@ -220,9 +221,9 @@ func TestApiGatewayApiKey(t *testing.T) { }, { test: "cannot list api gateway api keys", - mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllApiKeys").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayApiKeyResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayApiKeyResourceType, resourceaws.AwsApiGatewayApiKeyResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayApiKeyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayApiKeyResourceType, resourceaws.AwsApiGatewayApiKeyResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayApiKeyResourceType), }, @@ -236,18 +237,18 @@ func TestApiGatewayApiKey(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayRepository{} + fakeRepo := &repository2.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayRepository = fakeRepo + var repo repository2.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayApiKeyEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayApiKeyEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -274,13 +275,13 @@ func TestApiGatewayAuthorizer(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway authorizers", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiAuthorizers", *apis[0].Id).Return([]*apigateway.Authorizer{}, nil).Once() repo.On("ListAllRestApiAuthorizers", *apis[1].Id).Return([]*apigateway.Authorizer{}, nil).Once() @@ -291,7 +292,7 @@ func TestApiGatewayAuthorizer(t *testing.T) { }, { test: "multiple api gateway authorizers", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiAuthorizers", *apis[0].Id).Return([]*apigateway.Authorizer{ {Id: awssdk.String("ypcpde")}, @@ -312,18 +313,18 @@ func TestApiGatewayAuthorizer(t *testing.T) { }, { test: "cannot list rest apis", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayAuthorizerResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayAuthorizerResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayAuthorizerResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayAuthorizerResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayAuthorizerResourceType, resourceaws.AwsApiGatewayRestApiResourceType), }, { test: "cannot list api gateway resources", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiAuthorizers", *apis[0].Id).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayAuthorizerResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayAuthorizerResourceType, resourceaws.AwsApiGatewayAuthorizerResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayAuthorizerResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayAuthorizerResourceType, resourceaws.AwsApiGatewayAuthorizerResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayAuthorizerResourceType), }, @@ -337,18 +338,18 @@ func TestApiGatewayAuthorizer(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayRepository{} + fakeRepo := &repository2.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayRepository = fakeRepo + var repo repository2.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayAuthorizerEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayAuthorizerEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -374,13 +375,13 @@ func TestApiGatewayStage(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway stages", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiStages", *apis[0].Id).Return([]*apigateway.Stage{}, nil) }, @@ -390,7 +391,7 @@ func TestApiGatewayStage(t *testing.T) { }, { test: "multiple api gateway stages", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiStages", *apis[0].Id).Return([]*apigateway.Stage{ {StageName: awssdk.String("foo")}, @@ -409,18 +410,18 @@ func TestApiGatewayStage(t *testing.T) { }, { test: "cannot list rest apis", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayStageResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayStageResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayStageResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayStageResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayStageResourceType, resourceaws.AwsApiGatewayRestApiResourceType), }, { test: "cannot list api gateway stages", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiStages", *apis[0].Id).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayStageResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayStageResourceType, resourceaws.AwsApiGatewayStageResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayStageResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayStageResourceType, resourceaws.AwsApiGatewayStageResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayStageResourceType), }, @@ -434,18 +435,18 @@ func TestApiGatewayStage(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayRepository{} + fakeRepo := &repository2.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayRepository = fakeRepo + var repo repository2.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayStageEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayStageEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -471,13 +472,13 @@ func TestApiGatewayResource(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway resources", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{}, nil) }, @@ -487,7 +488,7 @@ func TestApiGatewayResource(t *testing.T) { }, { test: "multiple api gateway resources", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{ {Id: awssdk.String("21zk4y"), Path: awssdk.String("/")}, @@ -506,18 +507,18 @@ func TestApiGatewayResource(t *testing.T) { }, { test: "cannot list rest apis", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayResourceResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayResourceResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayResourceResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayResourceResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayResourceResourceType, resourceaws.AwsApiGatewayRestApiResourceType), }, { test: "cannot list api gateway resources", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayResourceResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayResourceResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayResourceResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayResourceResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayResourceResourceType), }, @@ -531,18 +532,18 @@ func TestApiGatewayResource(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayRepository{} + fakeRepo := &repository2.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayRepository = fakeRepo + var repo repository2.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayResourceEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayResourceEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -565,13 +566,13 @@ func TestApiGatewayDomainName(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway domain names", - mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDomainNames").Return([]*apigateway.DomainName{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -580,7 +581,7 @@ func TestApiGatewayDomainName(t *testing.T) { }, { test: "single api gateway domain name", - mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDomainNames").Return([]*apigateway.DomainName{ {DomainName: awssdk.String("example-driftctl.com")}, }, nil) @@ -594,9 +595,9 @@ func TestApiGatewayDomainName(t *testing.T) { }, { test: "cannot list api gateway domain names", - mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDomainNames").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayDomainNameResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayDomainNameResourceType, resourceaws.AwsApiGatewayDomainNameResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayDomainNameResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayDomainNameResourceType, resourceaws.AwsApiGatewayDomainNameResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayDomainNameResourceType), }, @@ -610,18 +611,18 @@ func TestApiGatewayDomainName(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayRepository{} + fakeRepo := &repository2.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayRepository = fakeRepo + var repo repository2.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayDomainNameEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayDomainNameEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -644,13 +645,13 @@ func TestApiGatewayVpcLink(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway vpc links", - mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllVpcLinks").Return([]*apigateway.UpdateVpcLinkOutput{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -659,7 +660,7 @@ func TestApiGatewayVpcLink(t *testing.T) { }, { test: "single api gateway vpc link", - mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllVpcLinks").Return([]*apigateway.UpdateVpcLinkOutput{ {Id: awssdk.String("ipu24n")}, }, nil) @@ -673,9 +674,9 @@ func TestApiGatewayVpcLink(t *testing.T) { }, { test: "cannot list api gateway vpc links", - mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllVpcLinks").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayVpcLinkResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayVpcLinkResourceType, resourceaws.AwsApiGatewayVpcLinkResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayVpcLinkResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayVpcLinkResourceType, resourceaws.AwsApiGatewayVpcLinkResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayVpcLinkResourceType), }, @@ -689,18 +690,18 @@ func TestApiGatewayVpcLink(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayRepository{} + fakeRepo := &repository2.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayRepository = fakeRepo + var repo repository2.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayVpcLinkEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayVpcLinkEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -726,13 +727,13 @@ func TestApiGatewayRequestValidator(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway request validators", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiRequestValidators", *apis[0].Id).Return([]*apigateway.UpdateRequestValidatorOutput{}, nil) }, @@ -742,7 +743,7 @@ func TestApiGatewayRequestValidator(t *testing.T) { }, { test: "multiple api gateway request validators", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiRequestValidators", *apis[0].Id).Return([]*apigateway.UpdateRequestValidatorOutput{ {Id: awssdk.String("ywlcuf")}, @@ -761,18 +762,18 @@ func TestApiGatewayRequestValidator(t *testing.T) { }, { test: "cannot list rest apis", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayRequestValidatorResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayRequestValidatorResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayRequestValidatorResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayRequestValidatorResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayRequestValidatorResourceType, resourceaws.AwsApiGatewayRestApiResourceType), }, { test: "cannot list api gateway request validators", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiRequestValidators", *apis[0].Id).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayRequestValidatorResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayRequestValidatorResourceType, resourceaws.AwsApiGatewayRequestValidatorResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayRequestValidatorResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayRequestValidatorResourceType, resourceaws.AwsApiGatewayRequestValidatorResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayRequestValidatorResourceType), }, @@ -786,18 +787,18 @@ func TestApiGatewayRequestValidator(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayRepository{} + fakeRepo := &repository2.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayRepository = fakeRepo + var repo repository2.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayRequestValidatorEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayRequestValidatorEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -820,13 +821,13 @@ func TestApiGatewayRestApiPolicy(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway rest api policies", - mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllRestApis").Return([]*apigateway.RestApi{ {Id: awssdk.String("3of73v5ob4")}, {Id: awssdk.String("9x7kq9pbyh"), Policy: awssdk.String("")}, @@ -838,7 +839,7 @@ func TestApiGatewayRestApiPolicy(t *testing.T) { }, { test: "multiple api gateway rest api policies", - mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllRestApis").Return([]*apigateway.RestApi{ {Id: awssdk.String("c3n3aqga5d"), Policy: awssdk.String("{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":\"execute-api:Invoke\",\"Resource\":\"arn:aws:execute-api:us-east-1:111111111111:c3n3aqga5d/*\",\"Condition\":{\"IpAddress\":{\"aws:SourceIp\":\"123.123.123.123/32\"}}}]}")}, {Id: awssdk.String("9y1eus3hr7"), Policy: awssdk.String("{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":\"execute-api:Invoke\",\"Resource\":\"arn:aws:execute-api:us-east-1:111111111111:9y1eus3hr7/*\",\"Condition\":{\"IpAddress\":{\"aws:SourceIp\":\"123.123.123.123/32\"}}}]}")}, @@ -856,9 +857,9 @@ func TestApiGatewayRestApiPolicy(t *testing.T) { }, { test: "cannot list rest apis", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayRestApiPolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayRestApiPolicyResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayRestApiPolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayRestApiPolicyResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayRestApiPolicyResourceType, resourceaws.AwsApiGatewayRestApiResourceType), }, @@ -872,18 +873,18 @@ func TestApiGatewayRestApiPolicy(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayRepository{} + fakeRepo := &repository2.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayRepository = fakeRepo + var repo repository2.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayRestApiPolicyEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayRestApiPolicyEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -909,13 +910,13 @@ func TestApiGatewayBasePathMapping(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no domain name base path mappings", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllDomainNames").Return(domainNames, nil) repo.On("ListAllDomainNameBasePathMappings", *domainNames[0].DomainName).Return([]*apigateway.BasePathMapping{}, nil) }, @@ -925,7 +926,7 @@ func TestApiGatewayBasePathMapping(t *testing.T) { }, { test: "multiple domain name base path mappings", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllDomainNames").Return(domainNames, nil) repo.On("ListAllDomainNameBasePathMappings", *domainNames[0].DomainName).Return([]*apigateway.BasePathMapping{ {BasePath: awssdk.String("foo")}, @@ -944,18 +945,18 @@ func TestApiGatewayBasePathMapping(t *testing.T) { }, { test: "cannot list domain names", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllDomainNames").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayBasePathMappingResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayBasePathMappingResourceType, resourceaws.AwsApiGatewayDomainNameResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayBasePathMappingResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayBasePathMappingResourceType, resourceaws.AwsApiGatewayDomainNameResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayBasePathMappingResourceType, resourceaws.AwsApiGatewayDomainNameResourceType), }, { test: "cannot list domain name base path mappings", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllDomainNames").Return(domainNames, nil) repo.On("ListAllDomainNameBasePathMappings", *domainNames[0].DomainName).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayBasePathMappingResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayBasePathMappingResourceType, resourceaws.AwsApiGatewayBasePathMappingResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayBasePathMappingResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayBasePathMappingResourceType, resourceaws.AwsApiGatewayBasePathMappingResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayBasePathMappingResourceType), }, @@ -969,18 +970,18 @@ func TestApiGatewayBasePathMapping(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayRepository{} + fakeRepo := &repository2.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayRepository = fakeRepo + var repo repository2.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayBasePathMappingEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayBasePathMappingEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -1006,13 +1007,13 @@ func TestApiGatewayMethod(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway methods", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{ {Id: awssdk.String("hl7ksq"), Path: awssdk.String("/foo")}, @@ -1024,7 +1025,7 @@ func TestApiGatewayMethod(t *testing.T) { }, { test: "multiple api gateway methods", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{ {Id: awssdk.String("hl7ksq"), Path: awssdk.String("/foo"), ResourceMethods: map[string]*apigateway.Method{ @@ -1049,18 +1050,18 @@ func TestApiGatewayMethod(t *testing.T) { }, { test: "cannot list rest apis", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResourceType, resourceaws.AwsApiGatewayRestApiResourceType), }, { test: "cannot list api gateway resources", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResourceType, resourceaws.AwsApiGatewayResourceResourceType), }, @@ -1074,18 +1075,18 @@ func TestApiGatewayMethod(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayRepository{} + fakeRepo := &repository2.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayRepository = fakeRepo + var repo repository2.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayMethodEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayMethodEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := remote.NewSortableScanner(NewScanner(remoteLibrary, alerter, scanOptions, testFilter)) @@ -1111,13 +1112,13 @@ func TestApiGatewayModel(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway models", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiModels", *apis[0].Id).Return([]*apigateway.Model{}, nil) }, @@ -1127,7 +1128,7 @@ func TestApiGatewayModel(t *testing.T) { }, { test: "multiple api gateway models", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiModels", *apis[0].Id).Return([]*apigateway.Model{ {Id: awssdk.String("g68a4s")}, @@ -1146,18 +1147,18 @@ func TestApiGatewayModel(t *testing.T) { }, { test: "cannot list rest apis", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayModelResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayModelResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayModelResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayModelResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayModelResourceType, resourceaws.AwsApiGatewayRestApiResourceType), }, { test: "cannot list api gateway models", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiModels", *apis[0].Id).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayModelResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayModelResourceType, resourceaws.AwsApiGatewayModelResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayModelResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayModelResourceType, resourceaws.AwsApiGatewayModelResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayModelResourceType), }, @@ -1171,18 +1172,18 @@ func TestApiGatewayModel(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayRepository{} + fakeRepo := &repository2.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayRepository = fakeRepo + var repo repository2.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayModelEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayModelEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -1208,13 +1209,13 @@ func TestApiGatewayMethodResponse(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway method responses", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{ {Id: awssdk.String("hl7ksq"), Path: awssdk.String("/foo"), ResourceMethods: map[string]*apigateway.Method{ @@ -1228,7 +1229,7 @@ func TestApiGatewayMethodResponse(t *testing.T) { }, { test: "multiple api gateway method responses", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{ {Id: awssdk.String("hl7ksq"), Path: awssdk.String("/foo"), ResourceMethods: map[string]*apigateway.Method{ @@ -1255,18 +1256,18 @@ func TestApiGatewayMethodResponse(t *testing.T) { }, { test: "cannot list rest apis", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResponseResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResponseResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResponseResourceType, resourceaws.AwsApiGatewayRestApiResourceType), }, { test: "cannot list api gateway resources", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResponseResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResponseResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResponseResourceType, resourceaws.AwsApiGatewayResourceResourceType), }, @@ -1280,18 +1281,18 @@ func TestApiGatewayMethodResponse(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayRepository{} + fakeRepo := &repository2.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayRepository = fakeRepo + var repo repository2.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayMethodResponseEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayMethodResponseEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := remote.NewSortableScanner(NewScanner(remoteLibrary, alerter, scanOptions, testFilter)) @@ -1317,13 +1318,13 @@ func TestApiGatewayGatewayResponse(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway gateway responses", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiGatewayResponses", *apis[0].Id).Return([]*apigateway.UpdateGatewayResponseOutput{}, nil) }, @@ -1333,7 +1334,7 @@ func TestApiGatewayGatewayResponse(t *testing.T) { }, { test: "multiple api gateway gateway responses", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiGatewayResponses", *apis[0].Id).Return([]*apigateway.UpdateGatewayResponseOutput{ {ResponseType: awssdk.String("UNAUTHORIZED")}, @@ -1352,18 +1353,18 @@ func TestApiGatewayGatewayResponse(t *testing.T) { }, { test: "cannot list rest apis", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayGatewayResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayGatewayResponseResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayGatewayResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayGatewayResponseResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayGatewayResponseResourceType, resourceaws.AwsApiGatewayRestApiResourceType), }, { test: "cannot list api gateway gateway responses", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiGatewayResponses", *apis[0].Id).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayGatewayResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayGatewayResponseResourceType, resourceaws.AwsApiGatewayGatewayResponseResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayGatewayResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayGatewayResponseResourceType, resourceaws.AwsApiGatewayGatewayResponseResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayGatewayResponseResourceType), }, @@ -1377,18 +1378,18 @@ func TestApiGatewayGatewayResponse(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayRepository{} + fakeRepo := &repository2.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayRepository = fakeRepo + var repo repository2.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayGatewayResponseEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayGatewayResponseEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -1414,13 +1415,13 @@ func TestApiGatewayMethodSettings(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway method settings", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiStages", *apis[0].Id).Return([]*apigateway.Stage{ {StageName: awssdk.String("foo"), MethodSettings: map[string]*apigateway.MethodSetting{}}, @@ -1432,7 +1433,7 @@ func TestApiGatewayMethodSettings(t *testing.T) { }, { test: "multiple api gateway method settings", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiStages", *apis[0].Id).Return([]*apigateway.Stage{ {StageName: awssdk.String("foo"), MethodSettings: map[string]*apigateway.MethodSetting{ @@ -1457,18 +1458,18 @@ func TestApiGatewayMethodSettings(t *testing.T) { }, { test: "cannot list rest apis", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodSettingsResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodSettingsResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodSettingsResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodSettingsResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodSettingsResourceType, resourceaws.AwsApiGatewayRestApiResourceType), }, { test: "cannot list api gateway settings", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiStages", *apis[0].Id).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodSettingsResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodSettingsResourceType, resourceaws.AwsApiGatewayStageResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodSettingsResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodSettingsResourceType, resourceaws.AwsApiGatewayStageResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodSettingsResourceType, resourceaws.AwsApiGatewayStageResourceType), }, @@ -1482,18 +1483,18 @@ func TestApiGatewayMethodSettings(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayRepository{} + fakeRepo := &repository2.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayRepository = fakeRepo + var repo repository2.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayMethodSettingsEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayMethodSettingsEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := remote.NewSortableScanner(NewScanner(remoteLibrary, alerter, scanOptions, testFilter)) @@ -1519,13 +1520,13 @@ func TestApiGatewayIntegration(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway integrations", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{ {Id: awssdk.String("z9ag20"), Path: awssdk.String("/foo")}, @@ -1537,7 +1538,7 @@ func TestApiGatewayIntegration(t *testing.T) { }, { test: "multiple api gateway integrations", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{ {Id: awssdk.String("z9ag20"), Path: awssdk.String("/foo"), ResourceMethods: map[string]*apigateway.Method{ @@ -1562,18 +1563,18 @@ func TestApiGatewayIntegration(t *testing.T) { }, { test: "cannot list rest apis", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayIntegrationResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayIntegrationResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResourceType, resourceaws.AwsApiGatewayRestApiResourceType), }, { test: "cannot list api gateway resources", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayIntegrationResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayIntegrationResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResourceType, resourceaws.AwsApiGatewayResourceResourceType), }, @@ -1587,18 +1588,18 @@ func TestApiGatewayIntegration(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayRepository{} + fakeRepo := &repository2.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayRepository = fakeRepo + var repo repository2.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayIntegrationEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayIntegrationEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := remote.NewSortableScanner(NewScanner(remoteLibrary, alerter, scanOptions, testFilter)) @@ -1624,13 +1625,13 @@ func TestApiGatewayIntegrationResponse(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway integration responses", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{ {Id: awssdk.String("z9ag20"), Path: awssdk.String("/foo"), ResourceMethods: map[string]*apigateway.Method{ @@ -1644,7 +1645,7 @@ func TestApiGatewayIntegrationResponse(t *testing.T) { }, { test: "multiple api gateway integration responses", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{ {Id: awssdk.String("z9ag20"), Path: awssdk.String("/foo"), ResourceMethods: map[string]*apigateway.Method{ @@ -1671,18 +1672,18 @@ func TestApiGatewayIntegrationResponse(t *testing.T) { }, { test: "cannot list rest apis", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayIntegrationResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResponseResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayIntegrationResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResponseResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResponseResourceType, resourceaws.AwsApiGatewayRestApiResourceType), }, { test: "cannot list api gateway resources", - mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayIntegrationResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResponseResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayIntegrationResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResponseResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResponseResourceType, resourceaws.AwsApiGatewayResourceResourceType), }, @@ -1696,18 +1697,18 @@ func TestApiGatewayIntegrationResponse(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayRepository{} + fakeRepo := &repository2.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayRepository = fakeRepo + var repo repository2.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayIntegrationResponseEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayIntegrationResponseEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := remote.NewSortableScanner(NewScanner(remoteLibrary, alerter, scanOptions, testFilter)) diff --git a/pkg/remote/aws_apigatewayv2_scanner_test.go b/enumeration/remote/aws_apigatewayv2_scanner_test.go similarity index 70% rename from pkg/remote/aws_apigatewayv2_scanner_test.go rename to enumeration/remote/aws_apigatewayv2_scanner_test.go index 28d3f1103..564b34b56 100644 --- a/pkg/remote/aws_apigatewayv2_scanner_test.go +++ b/enumeration/remote/aws_apigatewayv2_scanner_test.go @@ -3,20 +3,22 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + aws2 "github.com/snyk/driftctl/enumeration/remote/aws" + repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/terraform" + awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/apigateway" "github.com/aws/aws-sdk-go/service/apigatewayv2" "github.com/pkg/errors" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/aws" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" + testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -27,13 +29,13 @@ func TestApiGatewayV2Api(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway v2 api", - mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -42,7 +44,7 @@ func TestApiGatewayV2Api(t *testing.T) { }, { test: "single api gateway v2 api", - mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{ {ApiId: awssdk.String("f5vdrg12tk")}, }, nil) @@ -56,9 +58,9 @@ func TestApiGatewayV2Api(t *testing.T) { }, { test: "cannot list api gateway v2 apis", - mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2ApiResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2ApiResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType), }, @@ -72,18 +74,18 @@ func TestApiGatewayV2Api(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayV2Repository{} + fakeRepo := &repository2.MockApiGatewayV2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayV2Repository = fakeRepo + var repo repository2.ApiGatewayV2Repository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayV2ApiEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2ApiEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -106,13 +108,13 @@ func TestApiGatewayV2Route(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway v2 api", - mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -121,7 +123,7 @@ func TestApiGatewayV2Route(t *testing.T) { }, { test: "single api gateway v2 api with a single route", - mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{ {ApiId: awssdk.String("a-gateway")}, }, nil) @@ -145,9 +147,9 @@ func TestApiGatewayV2Route(t *testing.T) { }, { test: "cannot list api gateway v2 apis", - mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2RouteResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2RouteResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2RouteResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2RouteResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2RouteResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), }, @@ -161,18 +163,18 @@ func TestApiGatewayV2Route(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayV2Repository{} + fakeRepo := &repository2.MockApiGatewayV2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayV2Repository = fakeRepo + var repo repository2.ApiGatewayV2Repository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayV2RouteEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2RouteEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -195,13 +197,13 @@ func TestApiGatewayV2Deployment(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "single api gateway v2 api with a single deployment", - mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{ {ApiId: awssdk.String("a-gateway")}, }, nil) @@ -221,7 +223,7 @@ func TestApiGatewayV2Deployment(t *testing.T) { }, { test: "no API gateways", - mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -230,7 +232,7 @@ func TestApiGatewayV2Deployment(t *testing.T) { }, { test: "single API gateway with no deployments", - mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{ {ApiId: awssdk.String("a-gateway")}, }, nil) @@ -243,20 +245,20 @@ func TestApiGatewayV2Deployment(t *testing.T) { }, { test: "error listing API gateways", - mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2DeploymentResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2RouteResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2DeploymentResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2RouteResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2DeploymentResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), }, { test: "error listing deployments of an API", - mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{ {ApiId: awssdk.String("a-gateway")}, }, nil) repository.On("ListAllApiDeployments", awssdk.String("a-gateway")).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2DeploymentResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2DeploymentResourceType, resourceaws.AwsApiGatewayV2DeploymentResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2DeploymentResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2DeploymentResourceType, resourceaws.AwsApiGatewayV2DeploymentResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2DeploymentResourceType, resourceaws.AwsApiGatewayV2DeploymentResourceType), }, @@ -270,18 +272,18 @@ func TestApiGatewayV2Deployment(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayV2Repository{} + fakeRepo := &repository2.MockApiGatewayV2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayV2Repository = fakeRepo + var repo repository2.ApiGatewayV2Repository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayV2DeploymentEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2DeploymentEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -304,13 +306,13 @@ func TestApiGatewayV2VpcLink(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway v2 vpc links", - mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllVpcLinks").Return([]*apigatewayv2.VpcLink{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -319,7 +321,7 @@ func TestApiGatewayV2VpcLink(t *testing.T) { }, { test: "single api gateway v2 vpc link", - mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllVpcLinks").Return([]*apigatewayv2.VpcLink{ {VpcLinkId: awssdk.String("b8r351")}, }, nil) @@ -333,9 +335,9 @@ func TestApiGatewayV2VpcLink(t *testing.T) { }, { test: "cannot list api gateway v2 vpc links", - mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllVpcLinks").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2VpcLinkResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2VpcLinkResourceType, resourceaws.AwsApiGatewayV2VpcLinkResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2VpcLinkResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2VpcLinkResourceType, resourceaws.AwsApiGatewayV2VpcLinkResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayV2VpcLinkResourceType), }, @@ -349,18 +351,18 @@ func TestApiGatewayV2VpcLink(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayV2Repository{} + fakeRepo := &repository2.MockApiGatewayV2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayV2Repository = fakeRepo + var repo repository2.ApiGatewayV2Repository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayV2VpcLinkEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2VpcLinkEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -388,13 +390,13 @@ func TestApiGatewayV2Authorizer(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway v2 authorizers", - mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(apis, nil) repo.On("ListAllApiAuthorizers", *apis[0].ApiId).Return([]*apigatewayv2.Authorizer{}, nil).Once() repo.On("ListAllApiAuthorizers", *apis[1].ApiId).Return([]*apigatewayv2.Authorizer{}, nil).Once() @@ -405,7 +407,7 @@ func TestApiGatewayV2Authorizer(t *testing.T) { }, { test: "multiple api gateway v2 authorizers", - mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(apis, nil) repo.On("ListAllApiAuthorizers", *apis[0].ApiId).Return([]*apigatewayv2.Authorizer{ {AuthorizerId: awssdk.String("xaappu")}, @@ -426,18 +428,18 @@ func TestApiGatewayV2Authorizer(t *testing.T) { }, { test: "cannot list apis", - mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2AuthorizerResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2AuthorizerResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2AuthorizerResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2AuthorizerResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2AuthorizerResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), }, { test: "cannot list api gateway v2 authorizers", - mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(apis, nil) repo.On("ListAllApiAuthorizers", *apis[0].ApiId).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2AuthorizerResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2AuthorizerResourceType, resourceaws.AwsApiGatewayV2AuthorizerResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2AuthorizerResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2AuthorizerResourceType, resourceaws.AwsApiGatewayV2AuthorizerResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayV2AuthorizerResourceType), }, @@ -451,18 +453,18 @@ func TestApiGatewayV2Authorizer(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayV2Repository{} + fakeRepo := &repository2.MockApiGatewayV2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayV2Repository = fakeRepo + var repo repository2.ApiGatewayV2Repository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayV2AuthorizerEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2AuthorizerEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -490,13 +492,13 @@ func TestApiGatewayV2Integration(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway v2 integrations", - mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(apis, nil) repo.On("ListAllApiIntegrations", *apis[0].ApiId).Return([]*apigatewayv2.Integration{}, nil).Once() repo.On("ListAllApiIntegrations", *apis[1].ApiId).Return([]*apigatewayv2.Integration{}, nil).Once() @@ -507,7 +509,7 @@ func TestApiGatewayV2Integration(t *testing.T) { }, { test: "multiple api gateway v2 integrations", - mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(apis, nil) repo.On("ListAllApiIntegrations", *apis[0].ApiId).Return([]*apigatewayv2.Integration{ { @@ -534,18 +536,18 @@ func TestApiGatewayV2Integration(t *testing.T) { }, { test: "cannot list apis", - mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2IntegrationResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2IntegrationResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2IntegrationResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2IntegrationResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2IntegrationResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), }, { test: "cannot list api gateway v2 integrations", - mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(apis, nil) repo.On("ListAllApiIntegrations", *apis[0].ApiId).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2IntegrationResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2IntegrationResourceType, resourceaws.AwsApiGatewayV2IntegrationResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2IntegrationResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2IntegrationResourceType, resourceaws.AwsApiGatewayV2IntegrationResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayV2IntegrationResourceType), }, @@ -559,18 +561,18 @@ func TestApiGatewayV2Integration(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayV2Repository{} + fakeRepo := &repository2.MockApiGatewayV2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayV2Repository = fakeRepo + var repo repository2.ApiGatewayV2Repository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayV2IntegrationEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2IntegrationEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -598,13 +600,13 @@ func TestApiGatewayV2Model(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway v2 models", - mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(apis, nil) repo.On("ListAllApiModels", *apis[0].ApiId).Return([]*apigatewayv2.Model{}, nil).Once() repo.On("ListAllApiModels", *apis[1].ApiId).Return([]*apigatewayv2.Model{}, nil).Once() @@ -615,7 +617,7 @@ func TestApiGatewayV2Model(t *testing.T) { }, { test: "multiple api gateway v2 models", - mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(apis, nil) repo.On("ListAllApiModels", *apis[0].ApiId).Return([]*apigatewayv2.Model{ { @@ -645,18 +647,18 @@ func TestApiGatewayV2Model(t *testing.T) { }, { test: "cannot list apis", - mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2ModelResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ModelResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2ModelResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ModelResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ModelResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), }, { test: "cannot list api gateway v2 model", - mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(apis, nil) repo.On("ListAllApiModels", *apis[0].ApiId).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2ModelResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ModelResourceType, resourceaws.AwsApiGatewayV2ModelResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2ModelResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ModelResourceType, resourceaws.AwsApiGatewayV2ModelResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayV2ModelResourceType), }, @@ -670,18 +672,18 @@ func TestApiGatewayV2Model(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayV2Repository{} + fakeRepo := &repository2.MockApiGatewayV2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayV2Repository = fakeRepo + var repo repository2.ApiGatewayV2Repository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayV2ModelEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2ModelEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -704,13 +706,13 @@ func TestApiGatewayV2Stage(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway v2 api", - mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -719,7 +721,7 @@ func TestApiGatewayV2Stage(t *testing.T) { }, { test: "single api gateway v2 api with a single stage", - mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{ {ApiId: awssdk.String("a-gateway")}, }, nil) @@ -737,9 +739,9 @@ func TestApiGatewayV2Stage(t *testing.T) { }, { test: "cannot list api gateway v2 apis", - mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2StageResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2StageResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2StageResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2StageResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2StageResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), }, @@ -753,18 +755,18 @@ func TestApiGatewayV2Stage(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayV2Repository{} + fakeRepo := &repository2.MockApiGatewayV2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayV2Repository = fakeRepo + var repo repository2.ApiGatewayV2Repository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayV2StageEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2StageEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -787,13 +789,13 @@ func TestApiGatewayV2RouteResponse(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway v2 route responses", - mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{ {ApiId: awssdk.String("77ooqulkke")}, }, nil) @@ -810,7 +812,7 @@ func TestApiGatewayV2RouteResponse(t *testing.T) { }, { test: "single api gateway v2 route with one route response", - mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{ {ApiId: awssdk.String("77ooqulkke")}, }, nil) @@ -832,26 +834,26 @@ func TestApiGatewayV2RouteResponse(t *testing.T) { }, { test: "cannot list api gateway v2 apis", - mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2RouteResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2RouteResponseResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2RouteResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2RouteResponseResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2RouteResponseResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), }, { test: "cannot list api gateway v2 routes", - mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{ {ApiId: awssdk.String("77ooqulkke")}, }, nil) repository.On("ListAllApiRoutes", awssdk.String("77ooqulkke")).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2RouteResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2RouteResourceType, resourceaws.AwsApiGatewayV2RouteResponseResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2RouteResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2RouteResourceType, resourceaws.AwsApiGatewayV2RouteResponseResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2RouteResponseResourceType, resourceaws.AwsApiGatewayV2RouteResourceType), }, { test: "cannot list api gateway v2 route responses", - mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{ {ApiId: awssdk.String("77ooqulkke")}, }, nil) @@ -860,7 +862,7 @@ func TestApiGatewayV2RouteResponse(t *testing.T) { {RouteId: awssdk.String("liqc5u4")}, }, nil) repository.On("ListAllApiRouteResponses", "77ooqulkke", "liqc5u4").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2RouteResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2RouteResponseResourceType, resourceaws.AwsApiGatewayV2RouteResponseResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2RouteResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2RouteResponseResourceType, resourceaws.AwsApiGatewayV2RouteResponseResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2RouteResponseResourceType, resourceaws.AwsApiGatewayV2RouteResponseResourceType), }, @@ -874,18 +876,18 @@ func TestApiGatewayV2RouteResponse(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayV2Repository{} + fakeRepo := &repository2.MockApiGatewayV2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayV2Repository = fakeRepo + var repo repository2.ApiGatewayV2Repository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayV2RouteResponseEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2RouteResponseEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -908,13 +910,13 @@ func TestApiGatewayV2Mapping(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayRepository, *repository.MockApiGatewayV2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayRepository, *repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway v2 domains", - mocks: func(repositoryV1 *repository.MockApiGatewayRepository, repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repositoryV1 *repository2.MockApiGatewayRepository, repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repositoryV1.On("ListAllDomainNames").Return([]*apigateway.DomainName{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -923,7 +925,7 @@ func TestApiGatewayV2Mapping(t *testing.T) { }, { test: "single api gateway v2 domain with a single mapping", - mocks: func(repositoryV1 *repository.MockApiGatewayRepository, repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repositoryV1 *repository2.MockApiGatewayRepository, repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repositoryV1.On("ListAllDomainNames").Return([]*apigateway.DomainName{ {DomainName: awssdk.String("example.com")}, }, nil) @@ -943,27 +945,27 @@ func TestApiGatewayV2Mapping(t *testing.T) { }, { test: "cannot list api gateway v2 domains", - mocks: func(repositoryV1 *repository.MockApiGatewayRepository, repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repositoryV1 *repository2.MockApiGatewayRepository, repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repositoryV1.On("ListAllDomainNames").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2MappingResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayDomainNameResourceType, resourceaws.AwsApiGatewayV2MappingResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2MappingResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayDomainNameResourceType, resourceaws.AwsApiGatewayV2MappingResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2MappingResourceType, resourceaws.AwsApiGatewayDomainNameResourceType), }, { test: "cannot list api gateway v2 mappings", - mocks: func(repositoryV1 *repository.MockApiGatewayRepository, repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repositoryV1 *repository2.MockApiGatewayRepository, repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repositoryV1.On("ListAllDomainNames").Return([]*apigateway.DomainName{ {DomainName: awssdk.String("example.com")}, }, nil) repository.On("ListAllApiMappings", "example.com"). Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2MappingResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2MappingResourceType, resourceaws.AwsApiGatewayV2MappingResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2MappingResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2MappingResourceType, resourceaws.AwsApiGatewayV2MappingResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayV2MappingResourceType), }, { test: "returning mapping with invalid attributes", - mocks: func(repositoryV1 *repository.MockApiGatewayRepository, repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repositoryV1 *repository2.MockApiGatewayRepository, repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repositoryV1.On("ListAllDomainNames").Return([]*apigateway.DomainName{ {DomainName: awssdk.String("example.com")}, }, nil) @@ -999,17 +1001,17 @@ func TestApiGatewayV2Mapping(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepoV1 := &repository.MockApiGatewayRepository{} - fakeRepo := &repository.MockApiGatewayV2Repository{} + fakeRepoV1 := &repository2.MockApiGatewayRepository{} + fakeRepo := &repository2.MockApiGatewayV2Repository{} c.mocks(fakeRepoV1, fakeRepo, alerter) - remoteLibrary.AddEnumerator(aws.NewApiGatewayV2MappingEnumerator(fakeRepo, fakeRepoV1, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2MappingEnumerator(fakeRepo, fakeRepoV1, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -1033,13 +1035,13 @@ func TestApiGatewayV2DomainName(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway v2 domain names", - mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDomainNames").Return([]*apigateway.DomainName{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -1048,7 +1050,7 @@ func TestApiGatewayV2DomainName(t *testing.T) { }, { test: "single api gateway v2 domain name", - mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDomainNames").Return([]*apigateway.DomainName{ {DomainName: awssdk.String("b8r351.example.com")}, }, nil) @@ -1062,9 +1064,9 @@ func TestApiGatewayV2DomainName(t *testing.T) { }, { test: "cannot list api gateway v2 domain names", - mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDomainNames").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2DomainNameResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2DomainNameResourceType, resourceaws.AwsApiGatewayV2DomainNameResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2DomainNameResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2DomainNameResourceType, resourceaws.AwsApiGatewayV2DomainNameResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayV2DomainNameResourceType), }, @@ -1078,18 +1080,18 @@ func TestApiGatewayV2DomainName(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayRepository{} + fakeRepo := &repository2.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayRepository = fakeRepo + var repo repository2.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayV2DomainNameEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2DomainNameEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -1112,13 +1114,13 @@ func TestApiGatewayV2IntegrationResponse(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway v2 integration responses", - mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{ {ApiId: awssdk.String("yw28nwdf34")}, }, nil) @@ -1135,7 +1137,7 @@ func TestApiGatewayV2IntegrationResponse(t *testing.T) { }, { test: "single api gateway v2 integration with one integration response", - mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{ {ApiId: awssdk.String("yw28nwdf34")}, }, nil) @@ -1157,26 +1159,26 @@ func TestApiGatewayV2IntegrationResponse(t *testing.T) { }, { test: "cannot list api gateway v2 apis", - mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2IntegrationResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2IntegrationResponseResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2IntegrationResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2IntegrationResponseResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2IntegrationResponseResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), }, { test: "cannot list api gateway v2 integrations", - mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{ {ApiId: awssdk.String("yw28nwdf34")}, }, nil) repository.On("ListAllApiIntegrations", "yw28nwdf34").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2IntegrationResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2IntegrationResourceType, resourceaws.AwsApiGatewayV2IntegrationResponseResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2IntegrationResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2IntegrationResourceType, resourceaws.AwsApiGatewayV2IntegrationResponseResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2IntegrationResponseResourceType, resourceaws.AwsApiGatewayV2IntegrationResourceType), }, { test: "cannot list api gateway v2 integration responses", - mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{ {ApiId: awssdk.String("yw28nwdf34")}, }, nil) @@ -1185,7 +1187,7 @@ func TestApiGatewayV2IntegrationResponse(t *testing.T) { {IntegrationId: awssdk.String("fmezvlh")}, }, nil) repository.On("ListAllApiIntegrationResponses", "yw28nwdf34", "fmezvlh").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2IntegrationResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2IntegrationResponseResourceType, resourceaws.AwsApiGatewayV2IntegrationResponseResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2IntegrationResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2IntegrationResponseResourceType, resourceaws.AwsApiGatewayV2IntegrationResponseResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2IntegrationResponseResourceType, resourceaws.AwsApiGatewayV2IntegrationResponseResourceType), }, @@ -1199,18 +1201,18 @@ func TestApiGatewayV2IntegrationResponse(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockApiGatewayV2Repository{} + fakeRepo := &repository2.MockApiGatewayV2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.ApiGatewayV2Repository = fakeRepo + var repo repository2.ApiGatewayV2Repository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewApiGatewayV2IntegrationResponseEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2IntegrationResponseEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/aws_applicationautoscaling_scanner_test.go b/enumeration/remote/aws_applicationautoscaling_scanner_test.go similarity index 76% rename from pkg/remote/aws_applicationautoscaling_scanner_test.go rename to enumeration/remote/aws_applicationautoscaling_scanner_test.go index 9830de456..75ff488ea 100644 --- a/pkg/remote/aws_applicationautoscaling_scanner_test.go +++ b/enumeration/remote/aws_applicationautoscaling_scanner_test.go @@ -3,20 +3,22 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + aws2 "github.com/snyk/driftctl/enumeration/remote/aws" + repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + terraform3 "github.com/snyk/driftctl/enumeration/terraform" + awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/applicationautoscaling" "github.com/pkg/errors" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/aws" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" testresource "github.com/snyk/driftctl/test/resource" @@ -29,13 +31,13 @@ func TestAppAutoScalingTarget(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockAppAutoScalingRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockAppAutoScalingRepository, *mocks.AlerterInterface) wantErr error }{ { test: "should return one target", dirName: "aws_appautoscaling_target_single", - mocks: func(client *repository.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) { client.On("ServiceNamespaceValues").Return(applicationautoscaling.ServiceNamespace_Values()).Once() client.On("DescribeScalableTargets", "dynamodb").Return([]*applicationautoscaling.ScalableTarget{ @@ -56,7 +58,7 @@ func TestAppAutoScalingTarget(t *testing.T) { { test: "should return remote error", dirName: "aws_appautoscaling_target_single", - mocks: func(client *repository.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) { client.On("ServiceNamespaceValues").Return(applicationautoscaling.ServiceNamespace_Values()).Once() client.On("DescribeScalableTargets", mock.AnythingOfType("string")).Return(nil, errors.New("remote error")).Once() @@ -67,7 +69,7 @@ func TestAppAutoScalingTarget(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -79,15 +81,15 @@ func TestAppAutoScalingTarget(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockAppAutoScalingRepository{} + fakeRepo := &repository2.MockAppAutoScalingRepository{} c.mocks(fakeRepo, alerter) - var repo repository.AppAutoScalingRepository = fakeRepo + var repo repository2.AppAutoScalingRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -103,13 +105,13 @@ func TestAppAutoScalingTarget(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewAppAutoScalingRepository(sess, cache.New(0)) + repo = repository2.NewAppAutoScalingRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewAppAutoscalingTargetEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsAppAutoscalingTargetResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsAppAutoscalingTargetResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewAppAutoscalingTargetEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsAppAutoscalingTargetResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsAppAutoscalingTargetResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -134,13 +136,13 @@ func TestAppAutoScalingPolicy(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockAppAutoScalingRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockAppAutoScalingRepository, *mocks.AlerterInterface) wantErr error }{ { test: "should return one policy", dirName: "aws_appautoscaling_policy_single", - mocks: func(client *repository.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) { client.On("ServiceNamespaceValues").Return(applicationautoscaling.ServiceNamespace_Values()).Once() client.On("DescribeScalingPolicies", "dynamodb").Return([]*applicationautoscaling.ScalingPolicy{ @@ -159,7 +161,7 @@ func TestAppAutoScalingPolicy(t *testing.T) { { test: "should return remote error", dirName: "aws_appautoscaling_policy_single", - mocks: func(client *repository.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) { client.On("ServiceNamespaceValues").Return(applicationautoscaling.ServiceNamespace_Values()).Once() client.On("DescribeScalingPolicies", mock.AnythingOfType("string")).Return(nil, errors.New("remote error")).Once() @@ -170,7 +172,7 @@ func TestAppAutoScalingPolicy(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -182,15 +184,15 @@ func TestAppAutoScalingPolicy(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockAppAutoScalingRepository{} + fakeRepo := &repository2.MockAppAutoScalingRepository{} c.mocks(fakeRepo, alerter) - var repo repository.AppAutoScalingRepository = fakeRepo + var repo repository2.AppAutoScalingRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -206,13 +208,13 @@ func TestAppAutoScalingPolicy(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewAppAutoScalingRepository(sess, cache.New(0)) + repo = repository2.NewAppAutoScalingRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewAppAutoscalingPolicyEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsAppAutoscalingPolicyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsAppAutoscalingPolicyResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewAppAutoscalingPolicyEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsAppAutoscalingPolicyResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsAppAutoscalingPolicyResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -238,13 +240,13 @@ func TestAppAutoScalingScheduledAction(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockAppAutoScalingRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockAppAutoScalingRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "should return one scheduled action", - mocks: func(client *repository.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) { matchServiceNamespaceFunc := func(ns string) bool { for _, n := range applicationautoscaling.ServiceNamespace_Values() { if n == ns { @@ -276,7 +278,7 @@ func TestAppAutoScalingScheduledAction(t *testing.T) { }, { test: "should return remote error", - mocks: func(client *repository.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) { client.On("ServiceNamespaceValues").Return(applicationautoscaling.ServiceNamespace_Values()).Once() client.On("DescribeScheduledActions", mock.AnythingOfType("string")).Return(nil, dummyError).Once() @@ -291,23 +293,23 @@ func TestAppAutoScalingScheduledAction(t *testing.T) { providerVersion := "3.19.0" schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockAppAutoScalingRepository{} + fakeRepo := &repository2.MockAppAutoScalingRepository{} c.mocks(fakeRepo, alerter) - var repo repository.AppAutoScalingRepository = fakeRepo + var repo repository2.AppAutoScalingRepository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewAppAutoscalingScheduledActionEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewAppAutoscalingScheduledActionEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/aws_autoscaling_scanner_test.go b/enumeration/remote/aws_autoscaling_scanner_test.go similarity index 66% rename from pkg/remote/aws_autoscaling_scanner_test.go rename to enumeration/remote/aws_autoscaling_scanner_test.go index 1a68df409..acb411551 100644 --- a/pkg/remote/aws_autoscaling_scanner_test.go +++ b/enumeration/remote/aws_autoscaling_scanner_test.go @@ -3,20 +3,22 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/aws" + repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/terraform" + awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/autoscaling" "github.com/pkg/errors" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/aws" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" + testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -25,13 +27,13 @@ import ( func TestAutoscaling_LaunchConfiguration(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockAutoScalingRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockAutoScalingRepository, *mocks.AlerterInterface) assertExpected func(*testing.T, []*resource.Resource) wantErr error }{ { test: "no launch configuration", - mocks: func(repository *repository.MockAutoScalingRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockAutoScalingRepository, alerter *mocks.AlerterInterface) { repository.On("DescribeLaunchConfigurations").Return([]*autoscaling.LaunchConfiguration{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -40,7 +42,7 @@ func TestAutoscaling_LaunchConfiguration(t *testing.T) { }, { test: "multiple launch configurations", - mocks: func(repository *repository.MockAutoScalingRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockAutoScalingRepository, alerter *mocks.AlerterInterface) { repository.On("DescribeLaunchConfigurations").Return([]*autoscaling.LaunchConfiguration{ {LaunchConfigurationName: awssdk.String("web_config_1")}, {LaunchConfigurationName: awssdk.String("web_config_2")}, @@ -58,11 +60,11 @@ func TestAutoscaling_LaunchConfiguration(t *testing.T) { }, { test: "cannot list launch configurations", - mocks: func(repository *repository.MockAutoScalingRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockAutoScalingRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("DescribeLaunchConfigurations").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsLaunchConfigurationResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsLaunchConfigurationResourceType, resourceaws.AwsLaunchConfigurationResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsLaunchConfigurationResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsLaunchConfigurationResourceType, resourceaws.AwsLaunchConfigurationResourceType), alerts.EnumerationPhase)).Return() }, assertExpected: func(t *testing.T, got []*resource.Resource) { assert.Len(t, got, 0) @@ -79,18 +81,18 @@ func TestAutoscaling_LaunchConfiguration(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockAutoScalingRepository{} + fakeRepo := &repository2.MockAutoScalingRepository{} c.mocks(fakeRepo, alerter) - var repo repository.AutoScalingRepository = fakeRepo + var repo repository2.AutoScalingRepository = fakeRepo remoteLibrary.AddEnumerator(aws.NewLaunchConfigurationEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/aws_cloudformation_scanner_test.go b/enumeration/remote/aws_cloudformation_scanner_test.go similarity index 65% rename from pkg/remote/aws_cloudformation_scanner_test.go rename to enumeration/remote/aws_cloudformation_scanner_test.go index e95b98ecd..c4bfba87e 100644 --- a/pkg/remote/aws_cloudformation_scanner_test.go +++ b/enumeration/remote/aws_cloudformation_scanner_test.go @@ -4,21 +4,23 @@ import ( "errors" "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/aws" + repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + terraform3 "github.com/snyk/driftctl/enumeration/terraform" + awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/cloudformation" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/aws" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" testresource "github.com/snyk/driftctl/test/resource" @@ -31,20 +33,20 @@ func TestCloudformationStack(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockCloudformationRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockCloudformationRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no cloudformation stacks", dirName: "aws_cloudformation_stack_empty", - mocks: func(repository *repository.MockCloudformationRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockCloudformationRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllStacks").Return([]*cloudformation.Stack{}, nil) }, }, { test: "multiple cloudformation stacks", dirName: "aws_cloudformation_stack_multiple", - mocks: func(repository *repository.MockCloudformationRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockCloudformationRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllStacks").Return([]*cloudformation.Stack{ {StackId: awssdk.String("arn:aws:cloudformation:us-east-1:047081014315:stack/bar-stack/c7a96e70-0f21-11ec-bd2a-0a2d95c2b2ab")}, {StackId: awssdk.String("arn:aws:cloudformation:us-east-1:047081014315:stack/foo-stack/c7aa0ab0-0f21-11ec-ba25-129d8c0b3757")}, @@ -54,11 +56,11 @@ func TestCloudformationStack(t *testing.T) { { test: "cannot list cloudformation stacks", dirName: "aws_cloudformation_stack_list", - mocks: func(repository *repository.MockCloudformationRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockCloudformationRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 400, "") repository.On("ListAllStacks").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsCloudformationStackResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsCloudformationStackResourceType, resourceaws.AwsCloudformationStackResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsCloudformationStackResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsCloudformationStackResourceType, resourceaws.AwsCloudformationStackResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -66,7 +68,7 @@ func TestCloudformationStack(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -78,15 +80,15 @@ func TestCloudformationStack(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockCloudformationRepository{} + fakeRepo := &repository2.MockCloudformationRepository{} c.mocks(fakeRepo, alerter) - var repo repository.CloudformationRepository = fakeRepo + var repo repository2.CloudformationRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -102,13 +104,13 @@ func TestCloudformationStack(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewCloudformationRepository(sess, cache.New(0)) + repo = repository2.NewCloudformationRepository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws.NewCloudformationStackEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsCloudformationStackResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsCloudformationStackResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsCloudformationStackResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsCloudformationStackResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/aws_cloudfront_scanner_test.go b/enumeration/remote/aws_cloudfront_scanner_test.go similarity index 64% rename from pkg/remote/aws_cloudfront_scanner_test.go rename to enumeration/remote/aws_cloudfront_scanner_test.go index fa6ff6d5a..39d8ac548 100644 --- a/pkg/remote/aws_cloudfront_scanner_test.go +++ b/enumeration/remote/aws_cloudfront_scanner_test.go @@ -3,22 +3,24 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/aws" + repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + terraform3 "github.com/snyk/driftctl/enumeration/terraform" + awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/cloudfront" "github.com/pkg/errors" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/aws" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" testresource "github.com/snyk/driftctl/test/resource" @@ -31,20 +33,20 @@ func TestCloudfrontDistribution(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockCloudfrontRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockCloudfrontRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no cloudfront distributions", dirName: "aws_cloudfront_distribution_empty", - mocks: func(repository *repository.MockCloudfrontRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockCloudfrontRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDistributions").Return([]*cloudfront.DistributionSummary{}, nil) }, }, { test: "single cloudfront distribution", dirName: "aws_cloudfront_distribution_single", - mocks: func(repository *repository.MockCloudfrontRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockCloudfrontRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDistributions").Return([]*cloudfront.DistributionSummary{ {Id: awssdk.String("E1M9CNS0XSHI19")}, }, nil) @@ -53,11 +55,11 @@ func TestCloudfrontDistribution(t *testing.T) { { test: "cannot list cloudfront distributions", dirName: "aws_cloudfront_distribution_list", - mocks: func(repository *repository.MockCloudfrontRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockCloudfrontRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 400, "") repository.On("ListAllDistributions").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsCloudfrontDistributionResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsCloudfrontDistributionResourceType, resourceaws.AwsCloudfrontDistributionResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsCloudfrontDistributionResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsCloudfrontDistributionResourceType, resourceaws.AwsCloudfrontDistributionResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -65,7 +67,7 @@ func TestCloudfrontDistribution(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -77,15 +79,15 @@ func TestCloudfrontDistribution(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockCloudfrontRepository{} + fakeRepo := &repository2.MockCloudfrontRepository{} c.mocks(fakeRepo, alerter) - var repo repository.CloudfrontRepository = fakeRepo + var repo repository2.CloudfrontRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -101,13 +103,13 @@ func TestCloudfrontDistribution(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewCloudfrontRepository(sess, cache.New(0)) + repo = repository2.NewCloudfrontRepository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws.NewCloudfrontDistributionEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsCloudfrontDistributionResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsCloudfrontDistributionResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsCloudfrontDistributionResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsCloudfrontDistributionResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/aws_dynamodb_scanner_test.go b/enumeration/remote/aws_dynamodb_scanner_test.go similarity index 63% rename from pkg/remote/aws_dynamodb_scanner_test.go rename to enumeration/remote/aws_dynamodb_scanner_test.go index b1ad56434..7c21587c1 100644 --- a/pkg/remote/aws_dynamodb_scanner_test.go +++ b/enumeration/remote/aws_dynamodb_scanner_test.go @@ -4,20 +4,22 @@ import ( "errors" "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/aws" + repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + terraform3 "github.com/snyk/driftctl/enumeration/terraform" + awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/session" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/aws" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" testresource "github.com/snyk/driftctl/test/resource" @@ -30,13 +32,13 @@ func TestDynamoDBTable(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockDynamoDBRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockDynamoDBRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no DynamoDB Table", dirName: "aws_dynamodb_table_empty", - mocks: func(client *repository.MockDynamoDBRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockDynamoDBRepository, alerter *mocks.AlerterInterface) { client.On("ListAllTables").Return([]*string{}, nil) }, wantErr: nil, @@ -44,7 +46,7 @@ func TestDynamoDBTable(t *testing.T) { { test: "Multiple DynamoDB Table", dirName: "aws_dynamodb_table_multiple", - mocks: func(client *repository.MockDynamoDBRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockDynamoDBRepository, alerter *mocks.AlerterInterface) { client.On("ListAllTables").Return([]*string{ awssdk.String("GameScores"), awssdk.String("example"), @@ -55,11 +57,11 @@ func TestDynamoDBTable(t *testing.T) { { test: "cannot list DynamoDB Table", dirName: "aws_dynamodb_table_list", - mocks: func(client *repository.MockDynamoDBRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockDynamoDBRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 400, "") client.On("ListAllTables").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsDynamodbTableResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsDynamodbTableResourceType, resourceaws.AwsDynamodbTableResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsDynamodbTableResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsDynamodbTableResourceType, resourceaws.AwsDynamodbTableResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -67,7 +69,7 @@ func TestDynamoDBTable(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -79,15 +81,15 @@ func TestDynamoDBTable(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockDynamoDBRepository{} + fakeRepo := &repository2.MockDynamoDBRepository{} c.mocks(fakeRepo, alerter) - var repo repository.DynamoDBRepository = fakeRepo + var repo repository2.DynamoDBRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -103,13 +105,13 @@ func TestDynamoDBTable(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewDynamoDBRepository(sess, cache.New(0)) + repo = repository2.NewDynamoDBRepository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws.NewDynamoDBTableEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsDynamodbTableResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDynamodbTableResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsDynamodbTableResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsDynamodbTableResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/aws_ec2_scanner_test.go b/enumeration/remote/aws_ec2_scanner_test.go similarity index 73% rename from pkg/remote/aws_ec2_scanner_test.go rename to enumeration/remote/aws_ec2_scanner_test.go index 49ea7c51f..9ba6b9a45 100644 --- a/pkg/remote/aws_ec2_scanner_test.go +++ b/enumeration/remote/aws_ec2_scanner_test.go @@ -3,22 +3,24 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + aws2 "github.com/snyk/driftctl/enumeration/remote/aws" + repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + terraform3 "github.com/snyk/driftctl/enumeration/terraform" + awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ec2" "github.com/pkg/errors" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/aws" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" testresource "github.com/snyk/driftctl/test/resource" @@ -31,20 +33,20 @@ func TestEC2EbsVolume(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no volumes", dirName: "aws_ec2_ebs_volume_empty", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllVolumes").Return([]*ec2.Volume{}, nil) }, }, { test: "multiple volumes", dirName: "aws_ec2_ebs_volume_multiple", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllVolumes").Return([]*ec2.Volume{ {VolumeId: awssdk.String("vol-081c7272a57a09db1")}, {VolumeId: awssdk.String("vol-01ddc91d3d9d1318b")}, @@ -54,11 +56,11 @@ func TestEC2EbsVolume(t *testing.T) { { test: "cannot list volumes", dirName: "aws_ec2_ebs_volume_list", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllVolumes").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsEbsVolumeResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsEbsVolumeResourceType, resourceaws.AwsEbsVolumeResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsEbsVolumeResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsEbsVolumeResourceType, resourceaws.AwsEbsVolumeResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -66,7 +68,7 @@ func TestEC2EbsVolume(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -78,15 +80,15 @@ func TestEC2EbsVolume(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockEC2Repository{} + fakeRepo := &repository2.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.EC2Repository = fakeRepo + var repo repository2.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -102,13 +104,13 @@ func TestEC2EbsVolume(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewEC2Repository(sess, cache.New(0)) + repo = repository2.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewEC2EbsVolumeEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsEbsVolumeResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEbsVolumeResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewEC2EbsVolumeEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsEbsVolumeResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsEbsVolumeResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -128,20 +130,20 @@ func TestEC2EbsSnapshot(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no snapshots", dirName: "aws_ec2_ebs_snapshot_empty", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllSnapshots").Return([]*ec2.Snapshot{}, nil) }, }, { test: "multiple snapshots", dirName: "aws_ec2_ebs_snapshot_multiple", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllSnapshots").Return([]*ec2.Snapshot{ {SnapshotId: awssdk.String("snap-0c509a2a880d95a39")}, {SnapshotId: awssdk.String("snap-00672558cecd93a61")}, @@ -151,11 +153,11 @@ func TestEC2EbsSnapshot(t *testing.T) { { test: "cannot list snapshots", dirName: "aws_ec2_ebs_snapshot_list", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllSnapshots").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsEbsSnapshotResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsEbsSnapshotResourceType, resourceaws.AwsEbsSnapshotResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsEbsSnapshotResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsEbsSnapshotResourceType, resourceaws.AwsEbsSnapshotResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -163,7 +165,7 @@ func TestEC2EbsSnapshot(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -175,15 +177,15 @@ func TestEC2EbsSnapshot(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockEC2Repository{} + fakeRepo := &repository2.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.EC2Repository = fakeRepo + var repo repository2.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -199,13 +201,13 @@ func TestEC2EbsSnapshot(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewEC2Repository(sess, cache.New(0)) + repo = repository2.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewEC2EbsSnapshotEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsEbsSnapshotResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEbsSnapshotResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewEC2EbsSnapshotEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsEbsSnapshotResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsEbsSnapshotResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -225,13 +227,13 @@ func TestEC2Eip(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no eips", dirName: "aws_ec2_eip_empty", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllAddresses").Return([]*ec2.Address{ {}, // Test Eip without AllocationId because it can happen (seen in sentry) }, nil) @@ -240,7 +242,7 @@ func TestEC2Eip(t *testing.T) { { test: "multiple eips", dirName: "aws_ec2_eip_multiple", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllAddresses").Return([]*ec2.Address{ {AllocationId: awssdk.String("eipalloc-017d5267e4dda73f1")}, {AllocationId: awssdk.String("eipalloc-0cf714dc097c992cc")}, @@ -250,11 +252,11 @@ func TestEC2Eip(t *testing.T) { { test: "cannot list eips", dirName: "aws_ec2_eip_list", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllAddresses").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsEipResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsEipResourceType, resourceaws.AwsEipResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsEipResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsEipResourceType, resourceaws.AwsEipResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -262,7 +264,7 @@ func TestEC2Eip(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -274,15 +276,15 @@ func TestEC2Eip(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockEC2Repository{} + fakeRepo := &repository2.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.EC2Repository = fakeRepo + var repo repository2.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -298,13 +300,13 @@ func TestEC2Eip(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewEC2Repository(sess, cache.New(0)) + repo = repository2.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewEC2EipEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsEipResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEipResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewEC2EipEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsEipResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsEipResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -324,20 +326,20 @@ func TestEC2Ami(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no amis", dirName: "aws_ec2_ami_empty", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllImages").Return([]*ec2.Image{}, nil) }, }, { test: "multiple amis", dirName: "aws_ec2_ami_multiple", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllImages").Return([]*ec2.Image{ {ImageId: awssdk.String("ami-03a578b46f4c3081b")}, {ImageId: awssdk.String("ami-025962fd8b456731f")}, @@ -347,11 +349,11 @@ func TestEC2Ami(t *testing.T) { { test: "cannot list ami", dirName: "aws_ec2_ami_list", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllImages").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsAmiResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsAmiResourceType, resourceaws.AwsAmiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsAmiResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsAmiResourceType, resourceaws.AwsAmiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -359,7 +361,7 @@ func TestEC2Ami(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -371,15 +373,15 @@ func TestEC2Ami(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockEC2Repository{} + fakeRepo := &repository2.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.EC2Repository = fakeRepo + var repo repository2.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -395,13 +397,13 @@ func TestEC2Ami(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewEC2Repository(sess, cache.New(0)) + repo = repository2.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewEC2AmiEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsAmiResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsAmiResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewEC2AmiEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsAmiResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsAmiResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -421,20 +423,20 @@ func TestEC2KeyPair(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no key pairs", dirName: "aws_ec2_key_pair_empty", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllKeyPairs").Return([]*ec2.KeyPairInfo{}, nil) }, }, { test: "multiple key pairs", dirName: "aws_ec2_key_pair_multiple", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllKeyPairs").Return([]*ec2.KeyPairInfo{ {KeyName: awssdk.String("test")}, {KeyName: awssdk.String("bar")}, @@ -444,11 +446,11 @@ func TestEC2KeyPair(t *testing.T) { { test: "cannot list key pairs", dirName: "aws_ec2_key_pair_list", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllKeyPairs").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsKeyPairResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsKeyPairResourceType, resourceaws.AwsKeyPairResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsKeyPairResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsKeyPairResourceType, resourceaws.AwsKeyPairResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -456,7 +458,7 @@ func TestEC2KeyPair(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -468,15 +470,15 @@ func TestEC2KeyPair(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockEC2Repository{} + fakeRepo := &repository2.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.EC2Repository = fakeRepo + var repo repository2.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -492,13 +494,13 @@ func TestEC2KeyPair(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewEC2Repository(sess, cache.New(0)) + repo = repository2.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewEC2KeyPairEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsKeyPairResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsKeyPairResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewEC2KeyPairEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsKeyPairResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsKeyPairResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -518,20 +520,20 @@ func TestEC2EipAssociation(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no eip associations", dirName: "aws_ec2_eip_association_empty", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllAddressesAssociation").Return([]*ec2.Address{}, nil) }, }, { test: "single eip association", dirName: "aws_ec2_eip_association_single", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllAddressesAssociation").Return([]*ec2.Address{ { AssociationId: awssdk.String("eipassoc-0e9a7356e30f0c3d1"), @@ -543,11 +545,11 @@ func TestEC2EipAssociation(t *testing.T) { { test: "cannot list eip associations", dirName: "aws_ec2_eip_association_list", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllAddressesAssociation").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsEipAssociationResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsEipAssociationResourceType, resourceaws.AwsEipAssociationResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsEipAssociationResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsEipAssociationResourceType, resourceaws.AwsEipAssociationResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -555,7 +557,7 @@ func TestEC2EipAssociation(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -567,15 +569,15 @@ func TestEC2EipAssociation(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockEC2Repository{} + fakeRepo := &repository2.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.EC2Repository = fakeRepo + var repo repository2.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -591,13 +593,13 @@ func TestEC2EipAssociation(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewEC2Repository(sess, cache.New(0)) + repo = repository2.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewEC2EipAssociationEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsEipAssociationResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEipAssociationResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewEC2EipAssociationEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsEipAssociationResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsEipAssociationResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -617,20 +619,20 @@ func TestEC2Instance(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no instances", dirName: "aws_ec2_instance_empty", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllInstances").Return([]*ec2.Instance{}, nil) }, }, { test: "multiple instances", dirName: "aws_ec2_instance_multiple", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllInstances").Return([]*ec2.Instance{ {InstanceId: awssdk.String("i-0d3650a23f4e45dc0")}, {InstanceId: awssdk.String("i-010376047a71419f1")}, @@ -640,7 +642,7 @@ func TestEC2Instance(t *testing.T) { { test: "terminated instances", dirName: "aws_ec2_instance_terminated", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllInstances").Return([]*ec2.Instance{ {InstanceId: awssdk.String("i-0e1543baf4f2cd990")}, {InstanceId: awssdk.String("i-0a3a7ed51ae2b4fa0")}, // Nil @@ -650,11 +652,11 @@ func TestEC2Instance(t *testing.T) { { test: "cannot list instances", dirName: "aws_ec2_instance_list", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllInstances").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsInstanceResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsInstanceResourceType, resourceaws.AwsInstanceResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsInstanceResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsInstanceResourceType, resourceaws.AwsInstanceResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -662,7 +664,7 @@ func TestEC2Instance(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -674,15 +676,15 @@ func TestEC2Instance(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockEC2Repository{} + fakeRepo := &repository2.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.EC2Repository = fakeRepo + var repo repository2.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -698,13 +700,13 @@ func TestEC2Instance(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewEC2Repository(sess, cache.New(0)) + repo = repository2.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewEC2InstanceEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsInstanceResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsInstanceResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewEC2InstanceEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsInstanceResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsInstanceResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -724,20 +726,20 @@ func TestEC2InternetGateway(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no internet gateways", dirName: "aws_ec2_internet_gateway_empty", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllInternetGateways").Return([]*ec2.InternetGateway{}, nil) }, }, { test: "multiple internet gateways", dirName: "aws_ec2_internet_gateway_multiple", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllInternetGateways").Return([]*ec2.InternetGateway{ {InternetGatewayId: awssdk.String("igw-0184eb41aadc62d1c")}, {InternetGatewayId: awssdk.String("igw-047b487f5c60fca99")}, @@ -747,11 +749,11 @@ func TestEC2InternetGateway(t *testing.T) { { test: "cannot list internet gateways", dirName: "aws_ec2_internet_gateway_list", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllInternetGateways").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsInternetGatewayResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsInternetGatewayResourceType, resourceaws.AwsInternetGatewayResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsInternetGatewayResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsInternetGatewayResourceType, resourceaws.AwsInternetGatewayResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -759,7 +761,7 @@ func TestEC2InternetGateway(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -771,15 +773,15 @@ func TestEC2InternetGateway(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockEC2Repository{} + fakeRepo := &repository2.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.EC2Repository = fakeRepo + var repo repository2.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -795,13 +797,13 @@ func TestEC2InternetGateway(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewEC2Repository(sess, cache.New(0)) + repo = repository2.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewEC2InternetGatewayEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsInternetGatewayResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsInternetGatewayResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewEC2InternetGatewayEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsInternetGatewayResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsInternetGatewayResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -822,13 +824,13 @@ func TestVPC(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no VPC", dirName: "aws_vpc_empty", - mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { client.On("ListAllVPCs").Once().Return([]*ec2.Vpc{}, []*ec2.Vpc{}, nil) }, wantErr: nil, @@ -836,7 +838,7 @@ func TestVPC(t *testing.T) { { test: "VPC results", dirName: "aws_vpc", - mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { client.On("ListAllVPCs").Once().Return([]*ec2.Vpc{ { VpcId: awssdk.String("vpc-0768e1fd0029e3fc3"), @@ -861,11 +863,11 @@ func TestVPC(t *testing.T) { { test: "cannot list VPC", dirName: "aws_vpc_empty", - mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllVPCs").Once().Return(nil, nil, awsError) - alerter.On("SendAlert", resourceaws.AwsVpcResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsVpcResourceType, resourceaws.AwsVpcResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsVpcResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsVpcResourceType, resourceaws.AwsVpcResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -873,7 +875,7 @@ func TestVPC(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -885,15 +887,15 @@ func TestVPC(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockEC2Repository{} + fakeRepo := &repository2.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.EC2Repository = fakeRepo + var repo repository2.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -909,13 +911,13 @@ func TestVPC(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewEC2Repository(sess, cache.New(0)) + repo = repository2.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewVPCEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsVpcResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsVpcResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewVPCEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsVpcResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsVpcResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -936,13 +938,13 @@ func TestDefaultVPC(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no VPC", dirName: "aws_vpc_empty", - mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { client.On("ListAllVPCs").Once().Return([]*ec2.Vpc{}, []*ec2.Vpc{}, nil) }, wantErr: nil, @@ -950,7 +952,7 @@ func TestDefaultVPC(t *testing.T) { { test: "default VPC results", dirName: "aws_default_vpc", - mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { client.On("ListAllVPCs").Once().Return([]*ec2.Vpc{ { VpcId: awssdk.String("vpc-0768e1fd0029e3fc3"), @@ -972,11 +974,11 @@ func TestDefaultVPC(t *testing.T) { { test: "cannot list VPC", dirName: "aws_vpc_empty", - mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllVPCs").Once().Return(nil, nil, awsError) - alerter.On("SendAlert", resourceaws.AwsDefaultVpcResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsDefaultVpcResourceType, resourceaws.AwsDefaultVpcResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsDefaultVpcResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsDefaultVpcResourceType, resourceaws.AwsDefaultVpcResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -984,7 +986,7 @@ func TestDefaultVPC(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -996,15 +998,15 @@ func TestDefaultVPC(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockEC2Repository{} + fakeRepo := &repository2.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.EC2Repository = fakeRepo + var repo repository2.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -1020,13 +1022,13 @@ func TestDefaultVPC(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewEC2Repository(sess, cache.New(0)) + repo = repository2.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewDefaultVPCEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultVpcResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDefaultVpcResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewDefaultVPCEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultVpcResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsDefaultVpcResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -1046,13 +1048,13 @@ func TestEC2RouteTableAssociation(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no route table associations (test for nil values)", dirName: "aws_ec2_route_table_association_empty", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return([]*ec2.RouteTable{ { RouteTableId: awssdk.String("assoc_with_nil"), @@ -1074,7 +1076,7 @@ func TestEC2RouteTableAssociation(t *testing.T) { { test: "multiple route table associations (mixed subnet and gateway associations)", dirName: "aws_ec2_route_table_association_multiple", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return([]*ec2.RouteTable{ { RouteTableId: awssdk.String("rtb-05aa6c5673311a17b"), // route @@ -1138,11 +1140,11 @@ func TestEC2RouteTableAssociation(t *testing.T) { { test: "cannot list route table associations", dirName: "aws_ec2_route_table_association_list", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllRouteTables").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsRouteTableAssociationResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRouteTableAssociationResourceType, resourceaws.AwsRouteTableResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsRouteTableAssociationResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRouteTableAssociationResourceType, resourceaws.AwsRouteTableResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -1150,7 +1152,7 @@ func TestEC2RouteTableAssociation(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1162,15 +1164,15 @@ func TestEC2RouteTableAssociation(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockEC2Repository{} + fakeRepo := &repository2.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.EC2Repository = fakeRepo + var repo repository2.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -1186,13 +1188,13 @@ func TestEC2RouteTableAssociation(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewEC2Repository(sess, cache.New(0)) + repo = repository2.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewEC2RouteTableAssociationEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsRouteTableAssociationResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsRouteTableAssociationResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewEC2RouteTableAssociationEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsRouteTableAssociationResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsRouteTableAssociationResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -1212,20 +1214,20 @@ func TestEC2Subnet(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no subnets", dirName: "aws_ec2_subnet_empty", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllSubnets").Return([]*ec2.Subnet{}, []*ec2.Subnet{}, nil) }, }, { test: "multiple subnets", dirName: "aws_ec2_subnet_multiple", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllSubnets").Return([]*ec2.Subnet{ { SubnetId: awssdk.String("subnet-05810d3f933925f6d"), // subnet1 @@ -1258,11 +1260,11 @@ func TestEC2Subnet(t *testing.T) { { test: "cannot list subnets", dirName: "aws_ec2_subnet_list", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllSubnets").Return(nil, nil, awsError) - alerter.On("SendAlert", resourceaws.AwsSubnetResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSubnetResourceType, resourceaws.AwsSubnetResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsSubnetResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSubnetResourceType, resourceaws.AwsSubnetResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -1270,7 +1272,7 @@ func TestEC2Subnet(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1282,15 +1284,15 @@ func TestEC2Subnet(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockEC2Repository{} + fakeRepo := &repository2.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.EC2Repository = fakeRepo + var repo repository2.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -1306,13 +1308,13 @@ func TestEC2Subnet(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewEC2Repository(sess, cache.New(0)) + repo = repository2.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewEC2SubnetEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsSubnetResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSubnetResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewEC2SubnetEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsSubnetResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsSubnetResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -1332,20 +1334,20 @@ func TestEC2DefaultSubnet(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no default subnets", dirName: "aws_ec2_default_subnet_empty", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllSubnets").Return([]*ec2.Subnet{}, []*ec2.Subnet{}, nil) }, }, { test: "multiple default subnets", dirName: "aws_ec2_default_subnet_multiple", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllSubnets").Return([]*ec2.Subnet{ { SubnetId: awssdk.String("subnet-05810d3f933925f6d"), // subnet1 @@ -1378,11 +1380,11 @@ func TestEC2DefaultSubnet(t *testing.T) { { test: "cannot list default subnets", dirName: "aws_ec2_default_subnet_list", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllSubnets").Return(nil, nil, awsError) - alerter.On("SendAlert", resourceaws.AwsDefaultSubnetResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsDefaultSubnetResourceType, resourceaws.AwsDefaultSubnetResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsDefaultSubnetResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsDefaultSubnetResourceType, resourceaws.AwsDefaultSubnetResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -1390,7 +1392,7 @@ func TestEC2DefaultSubnet(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1402,15 +1404,15 @@ func TestEC2DefaultSubnet(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockEC2Repository{} + fakeRepo := &repository2.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.EC2Repository = fakeRepo + var repo repository2.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -1426,13 +1428,13 @@ func TestEC2DefaultSubnet(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewEC2Repository(sess, cache.New(0)) + repo = repository2.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewEC2DefaultSubnetEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultSubnetResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDefaultSubnetResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewEC2DefaultSubnetEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultSubnetResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsDefaultSubnetResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -1452,20 +1454,20 @@ func TestEC2RouteTable(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no route tables", dirName: "aws_ec2_route_table_empty", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return([]*ec2.RouteTable{}, nil) }, }, { test: "multiple route tables", dirName: "aws_ec2_route_table_multiple", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return([]*ec2.RouteTable{ {RouteTableId: awssdk.String("rtb-08b7b71af15e183ce")}, // table1 {RouteTableId: awssdk.String("rtb-0002ac731f6fdea55")}, // table2 @@ -1485,11 +1487,11 @@ func TestEC2RouteTable(t *testing.T) { { test: "cannot list route tables", dirName: "aws_ec2_route_table_list", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllRouteTables").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsRouteTableResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRouteTableResourceType, resourceaws.AwsRouteTableResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsRouteTableResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRouteTableResourceType, resourceaws.AwsRouteTableResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -1497,7 +1499,7 @@ func TestEC2RouteTable(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1509,15 +1511,15 @@ func TestEC2RouteTable(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockEC2Repository{} + fakeRepo := &repository2.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.EC2Repository = fakeRepo + var repo repository2.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -1533,13 +1535,13 @@ func TestEC2RouteTable(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewEC2Repository(sess, cache.New(0)) + repo = repository2.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewEC2RouteTableEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsRouteTableResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsRouteTableResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewEC2RouteTableEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsRouteTableResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsRouteTableResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -1559,20 +1561,20 @@ func TestEC2DefaultRouteTable(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no default route tables", dirName: "aws_ec2_default_route_table_empty", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return([]*ec2.RouteTable{}, nil) }, }, { test: "multiple default route tables", dirName: "aws_ec2_default_route_table_single", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return([]*ec2.RouteTable{ {RouteTableId: awssdk.String("rtb-08b7b71af15e183ce")}, // table1 {RouteTableId: awssdk.String("rtb-0002ac731f6fdea55")}, // table2 @@ -1592,11 +1594,11 @@ func TestEC2DefaultRouteTable(t *testing.T) { { test: "cannot list default route tables", dirName: "aws_ec2_default_route_table_list", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllRouteTables").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsDefaultRouteTableResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsDefaultRouteTableResourceType, resourceaws.AwsDefaultRouteTableResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsDefaultRouteTableResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsDefaultRouteTableResourceType, resourceaws.AwsDefaultRouteTableResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -1604,7 +1606,7 @@ func TestEC2DefaultRouteTable(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1616,15 +1618,15 @@ func TestEC2DefaultRouteTable(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockEC2Repository{} + fakeRepo := &repository2.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.EC2Repository = fakeRepo + var repo repository2.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -1640,13 +1642,13 @@ func TestEC2DefaultRouteTable(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewEC2Repository(sess, cache.New(0)) + repo = repository2.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewEC2DefaultRouteTableEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultRouteTableResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDefaultRouteTableResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewEC2DefaultRouteTableEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultRouteTableResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsDefaultRouteTableResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -1667,13 +1669,13 @@ func TestVpcSecurityGroup(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no security groups", dirName: "aws_vpc_security_group_empty", - mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { client.On("ListAllSecurityGroups").Once().Return([]*ec2.SecurityGroup{}, []*ec2.SecurityGroup{}, nil) }, wantErr: nil, @@ -1681,7 +1683,7 @@ func TestVpcSecurityGroup(t *testing.T) { { test: "with security groups", dirName: "aws_vpc_security_group_multiple", - mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { client.On("ListAllSecurityGroups").Once().Return([]*ec2.SecurityGroup{ { GroupId: awssdk.String("sg-0254c038e32f25530"), @@ -1699,11 +1701,11 @@ func TestVpcSecurityGroup(t *testing.T) { { test: "cannot list security groups", dirName: "aws_vpc_security_group_empty", - mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllSecurityGroups").Return(nil, nil, awsError) - alerter.On("SendAlert", resourceaws.AwsSecurityGroupResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSecurityGroupResourceType, resourceaws.AwsSecurityGroupResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsSecurityGroupResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSecurityGroupResourceType, resourceaws.AwsSecurityGroupResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -1711,7 +1713,7 @@ func TestVpcSecurityGroup(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1723,15 +1725,15 @@ func TestVpcSecurityGroup(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockEC2Repository{} + fakeRepo := &repository2.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.EC2Repository = fakeRepo + var repo repository2.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -1747,13 +1749,13 @@ func TestVpcSecurityGroup(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewEC2Repository(sess, cache.New(0)) + repo = repository2.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewVPCSecurityGroupEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsSecurityGroupResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSecurityGroupResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewVPCSecurityGroupEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsSecurityGroupResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsSecurityGroupResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -1774,13 +1776,13 @@ func TestVpcDefaultSecurityGroup(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no security groups", dirName: "aws_vpc_default_security_group_empty", - mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { client.On("ListAllSecurityGroups").Once().Return([]*ec2.SecurityGroup{}, []*ec2.SecurityGroup{}, nil) }, wantErr: nil, @@ -1788,7 +1790,7 @@ func TestVpcDefaultSecurityGroup(t *testing.T) { { test: "with security groups", dirName: "aws_vpc_default_security_group_multiple", - mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { client.On("ListAllSecurityGroups").Once().Return([]*ec2.SecurityGroup{ { GroupId: awssdk.String("sg-0254c038e32f25530"), @@ -1806,11 +1808,11 @@ func TestVpcDefaultSecurityGroup(t *testing.T) { { test: "cannot list security groups", dirName: "aws_vpc_default_security_group_empty", - mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllSecurityGroups").Return(nil, nil, awsError) - alerter.On("SendAlert", resourceaws.AwsDefaultSecurityGroupResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsDefaultSecurityGroupResourceType, resourceaws.AwsDefaultSecurityGroupResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsDefaultSecurityGroupResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsDefaultSecurityGroupResourceType, resourceaws.AwsDefaultSecurityGroupResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -1818,7 +1820,7 @@ func TestVpcDefaultSecurityGroup(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1830,15 +1832,15 @@ func TestVpcDefaultSecurityGroup(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockEC2Repository{} + fakeRepo := &repository2.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.EC2Repository = fakeRepo + var repo repository2.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -1854,13 +1856,13 @@ func TestVpcDefaultSecurityGroup(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewEC2Repository(sess, cache.New(0)) + repo = repository2.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewVPCDefaultSecurityGroupEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultSecurityGroupResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDefaultSecurityGroupResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewVPCDefaultSecurityGroupEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultSecurityGroupResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsDefaultSecurityGroupResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -1880,20 +1882,20 @@ func TestEC2NatGateway(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no nat gateways", dirName: "aws_ec2_nat_gateway_empty", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllNatGateways").Return([]*ec2.NatGateway{}, nil) }, }, { test: "single nat gateway", dirName: "aws_ec2_nat_gateway_single", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllNatGateways").Return([]*ec2.NatGateway{ {NatGatewayId: awssdk.String("nat-0a5408508b19ef490")}, }, nil) @@ -1902,11 +1904,11 @@ func TestEC2NatGateway(t *testing.T) { { test: "cannot list nat gateways", dirName: "aws_ec2_nat_gateway_list", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllNatGateways").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsNatGatewayResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsNatGatewayResourceType, resourceaws.AwsNatGatewayResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsNatGatewayResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsNatGatewayResourceType, resourceaws.AwsNatGatewayResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -1914,7 +1916,7 @@ func TestEC2NatGateway(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1926,15 +1928,15 @@ func TestEC2NatGateway(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockEC2Repository{} + fakeRepo := &repository2.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.EC2Repository = fakeRepo + var repo repository2.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -1950,13 +1952,13 @@ func TestEC2NatGateway(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewEC2Repository(sess, cache.New(0)) + repo = repository2.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewEC2NatGatewayEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsNatGatewayResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsNatGatewayResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewEC2NatGatewayEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsNatGatewayResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsNatGatewayResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -1976,20 +1978,20 @@ func TestEC2NetworkACL(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no network ACL", dirName: "aws_ec2_network_acl_empty", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllNetworkACLs").Return([]*ec2.NetworkAcl{}, nil) }, }, { test: "network acl", dirName: "aws_ec2_network_acl", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllNetworkACLs").Return([]*ec2.NetworkAcl{ { NetworkAclId: awssdk.String("acl-043880b4682d2366b"), @@ -2009,14 +2011,14 @@ func TestEC2NetworkACL(t *testing.T) { { test: "cannot list network acl", dirName: "aws_ec2_network_acl_empty", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllNetworkACLs").Return(nil, awsError) alerter.On("SendAlert", resourceaws.AwsNetworkACLResourceType, alerts.NewRemoteAccessDeniedAlert( - common.RemoteAWSTerraform, + common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType( awsError, resourceaws.AwsNetworkACLResourceType, @@ -2032,7 +2034,7 @@ func TestEC2NetworkACL(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -2044,15 +2046,15 @@ func TestEC2NetworkACL(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockEC2Repository{} + fakeRepo := &repository2.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.EC2Repository = fakeRepo + var repo repository2.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -2068,13 +2070,13 @@ func TestEC2NetworkACL(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewEC2Repository(sess, cache.New(0)) + repo = repository2.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewEC2NetworkACLEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsNetworkACLResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsNetworkACLResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewEC2NetworkACLEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsNetworkACLResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsNetworkACLResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -2094,20 +2096,20 @@ func TestEC2NetworkACLRule(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no network ACL", dirName: "aws_ec2_network_acl_rule_empty", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllNetworkACLs").Return([]*ec2.NetworkAcl{}, nil) }, }, { test: "network acl rules", dirName: "aws_ec2_network_acl_rule", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllNetworkACLs").Return([]*ec2.NetworkAcl{ { NetworkAclId: awssdk.String("acl-0ad6d657494d17ee2"), // test @@ -2162,14 +2164,14 @@ func TestEC2NetworkACLRule(t *testing.T) { { test: "cannot list network acl", dirName: "aws_ec2_network_acl_rule_empty", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllNetworkACLs").Return(nil, awsError) alerter.On("SendAlert", resourceaws.AwsNetworkACLRuleResourceType, alerts.NewRemoteAccessDeniedAlert( - common.RemoteAWSTerraform, + common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType( awsError, resourceaws.AwsNetworkACLRuleResourceType, @@ -2186,7 +2188,7 @@ func TestEC2NetworkACLRule(t *testing.T) { version := "3.19.0" schemaRepository := testresource.InitFakeSchemaRepository("aws", version) resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -2194,15 +2196,15 @@ func TestEC2NetworkACLRule(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockEC2Repository{} + fakeRepo := &repository2.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.EC2Repository = fakeRepo + var repo repository2.EC2Repository = fakeRepo providerVersion := version realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -2220,10 +2222,10 @@ func TestEC2NetworkACLRule(t *testing.T) { provider.ShouldUpdate() } - remoteLibrary.AddEnumerator(aws.NewEC2NetworkACLRuleEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsNetworkACLRuleResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsNetworkACLRuleResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewEC2NetworkACLRuleEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsNetworkACLRuleResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsNetworkACLRuleResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -2243,13 +2245,13 @@ func TestEC2DefaultNetworkACL(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no network ACL", dirName: "aws_ec2_default_network_acl_empty", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllNetworkACLs").Return([]*ec2.NetworkAcl{}, nil) }, }, @@ -2276,14 +2278,14 @@ func TestEC2DefaultNetworkACL(t *testing.T) { { test: "cannot list default network acl", dirName: "aws_ec2_default_network_acl_empty", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllNetworkACLs").Return(nil, awsError) alerter.On("SendAlert", resourceaws.AwsDefaultNetworkACLResourceType, alerts.NewRemoteAccessDeniedAlert( - common.RemoteAWSTerraform, + common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType( awsError, resourceaws.AwsDefaultNetworkACLResourceType, @@ -2299,7 +2301,7 @@ func TestEC2DefaultNetworkACL(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -2311,15 +2313,15 @@ func TestEC2DefaultNetworkACL(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockEC2Repository{} + fakeRepo := &repository2.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.EC2Repository = fakeRepo + var repo repository2.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -2335,13 +2337,13 @@ func TestEC2DefaultNetworkACL(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewEC2Repository(sess, cache.New(0)) + repo = repository2.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewEC2DefaultNetworkACLEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultNetworkACLResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDefaultNetworkACLResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewEC2DefaultNetworkACLEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultNetworkACLResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsDefaultNetworkACLResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -2361,7 +2363,7 @@ func TestEC2Route(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { @@ -2369,14 +2371,14 @@ func TestEC2Route(t *testing.T) { // as a default route will always be present in each route table test: "no routes", dirName: "aws_ec2_route_empty", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return([]*ec2.RouteTable{}, nil) }, }, { test: "multiple routes (mixed default_route_table and route_table)", dirName: "aws_ec2_route_multiple", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return([]*ec2.RouteTable{ { RouteTableId: awssdk.String("rtb-096bdfb69309c54c3"), // table1 @@ -2456,11 +2458,11 @@ func TestEC2Route(t *testing.T) { { test: "cannot list routes", dirName: "aws_ec2_route_list", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllRouteTables").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsRouteResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRouteResourceType, resourceaws.AwsRouteTableResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsRouteResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRouteResourceType, resourceaws.AwsRouteTableResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -2468,7 +2470,7 @@ func TestEC2Route(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -2480,15 +2482,15 @@ func TestEC2Route(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockEC2Repository{} + fakeRepo := &repository2.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.EC2Repository = fakeRepo + var repo repository2.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -2504,13 +2506,13 @@ func TestEC2Route(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewEC2Repository(sess, cache.New(0)) + repo = repository2.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewEC2RouteEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsRouteResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsRouteResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewEC2RouteEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsRouteResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsRouteResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -2531,13 +2533,13 @@ func TestVpcSecurityGroupRule(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no security group rules", dirName: "aws_vpc_security_group_rule_empty", - mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { client.On("ListAllSecurityGroups").Once().Return([]*ec2.SecurityGroup{ { GroupId: awssdk.String("sg-0254c038e32f25530"), @@ -2551,7 +2553,7 @@ func TestVpcSecurityGroupRule(t *testing.T) { { test: "with security group rules", dirName: "aws_vpc_security_group_rule_multiple", - mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { client.On("ListAllSecurityGroups").Once().Return([]*ec2.SecurityGroup{ { GroupId: awssdk.String("sg-0254c038e32f25530"), @@ -2647,11 +2649,11 @@ func TestVpcSecurityGroupRule(t *testing.T) { { test: "cannot list security group rules", dirName: "aws_vpc_security_group_rule_empty", - mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllSecurityGroups").Once().Return(nil, nil, awsError) - alerter.On("SendAlert", resourceaws.AwsSecurityGroupRuleResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSecurityGroupRuleResourceType, resourceaws.AwsSecurityGroupResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsSecurityGroupRuleResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSecurityGroupRuleResourceType, resourceaws.AwsSecurityGroupResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -2659,7 +2661,7 @@ func TestVpcSecurityGroupRule(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -2671,15 +2673,15 @@ func TestVpcSecurityGroupRule(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockEC2Repository{} + fakeRepo := &repository2.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.EC2Repository = fakeRepo + var repo repository2.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -2695,13 +2697,13 @@ func TestVpcSecurityGroupRule(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewEC2Repository(sess, cache.New(0)) + repo = repository2.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewVPCSecurityGroupRuleEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsSecurityGroupRuleResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSecurityGroupRuleResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewVPCSecurityGroupRuleEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsSecurityGroupRuleResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsSecurityGroupRuleResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -2721,20 +2723,20 @@ func TestEC2LaunchTemplate(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no launch template", dirName: "aws_launch_template", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("DescribeLaunchTemplates").Return([]*ec2.LaunchTemplate{}, nil) }, }, { test: "multiple launch templates", dirName: "aws_launch_template_multiple", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { launchTemplates := []*ec2.LaunchTemplate{ {LaunchTemplateId: awssdk.String("lt-0ed993d09ce6afc67"), LatestVersionNumber: awssdk.Int64(1)}, {LaunchTemplateId: awssdk.String("lt-00b2d18c6cee7fe23"), LatestVersionNumber: awssdk.Int64(1)}, @@ -2746,11 +2748,11 @@ func TestEC2LaunchTemplate(t *testing.T) { { test: "cannot list launch templates", dirName: "aws_launch_template", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("DescribeLaunchTemplates").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsLaunchTemplateResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsLaunchTemplateResourceType, resourceaws.AwsLaunchTemplateResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsLaunchTemplateResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsLaunchTemplateResourceType, resourceaws.AwsLaunchTemplateResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -2758,7 +2760,7 @@ func TestEC2LaunchTemplate(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -2770,15 +2772,15 @@ func TestEC2LaunchTemplate(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockEC2Repository{} + fakeRepo := &repository2.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.EC2Repository = fakeRepo + var repo repository2.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -2794,13 +2796,13 @@ func TestEC2LaunchTemplate(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewEC2Repository(sess, cache.New(0)) + repo = repository2.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewLaunchTemplateEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsLaunchTemplateResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsLaunchTemplateResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewLaunchTemplateEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsLaunchTemplateResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsLaunchTemplateResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -2821,24 +2823,24 @@ func TestEC2EbsEncryptionByDefault(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no encryption by default resource", dirName: "aws_ebs_encryption_by_default_list", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("IsEbsEncryptionEnabledByDefault").Return(false, nil) }, }, { test: "cannot list encryption by default resources", dirName: "aws_ebs_encryption_by_default_error", - mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("IsEbsEncryptionEnabledByDefault").Return(false, awsError) - alerter.On("SendAlert", resourceaws.AwsEbsEncryptionByDefaultResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsEbsEncryptionByDefaultResourceType, resourceaws.AwsEbsEncryptionByDefaultResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsEbsEncryptionByDefaultResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsEbsEncryptionByDefaultResourceType, resourceaws.AwsEbsEncryptionByDefaultResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -2846,7 +2848,7 @@ func TestEC2EbsEncryptionByDefault(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -2858,15 +2860,15 @@ func TestEC2EbsEncryptionByDefault(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockEC2Repository{} + fakeRepo := &repository2.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.EC2Repository = fakeRepo + var repo repository2.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -2882,13 +2884,13 @@ func TestEC2EbsEncryptionByDefault(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewEC2Repository(sess, cache.New(0)) + repo = repository2.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewEC2EbsEncryptionByDefaultEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsEbsEncryptionByDefaultResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEbsEncryptionByDefaultResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewEC2EbsEncryptionByDefaultEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsEbsEncryptionByDefaultResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsEbsEncryptionByDefaultResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/aws_ecr_scanner_test.go b/enumeration/remote/aws_ecr_scanner_test.go similarity index 68% rename from pkg/remote/aws_ecr_scanner_test.go rename to enumeration/remote/aws_ecr_scanner_test.go index d7a97d49d..3f4b7e46e 100644 --- a/pkg/remote/aws_ecr_scanner_test.go +++ b/enumeration/remote/aws_ecr_scanner_test.go @@ -3,22 +3,24 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + aws2 "github.com/snyk/driftctl/enumeration/remote/aws" + repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + terraform3 "github.com/snyk/driftctl/enumeration/terraform" + awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ecr" "github.com/pkg/errors" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/aws" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" testresource "github.com/snyk/driftctl/test/resource" @@ -31,13 +33,13 @@ func TestECRRepository(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockECRRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockECRRepository, *mocks.AlerterInterface) err error }{ { test: "no repository", dirName: "aws_ecr_repository_empty", - mocks: func(client *repository.MockECRRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockECRRepository, alerter *mocks.AlerterInterface) { client.On("ListAllRepositories").Return([]*ecr.Repository{}, nil) }, err: nil, @@ -45,7 +47,7 @@ func TestECRRepository(t *testing.T) { { test: "multiple repositories", dirName: "aws_ecr_repository_multiple", - mocks: func(client *repository.MockECRRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockECRRepository, alerter *mocks.AlerterInterface) { client.On("ListAllRepositories").Return([]*ecr.Repository{ {RepositoryName: awssdk.String("test_ecr")}, {RepositoryName: awssdk.String("bar")}, @@ -56,11 +58,11 @@ func TestECRRepository(t *testing.T) { { test: "cannot list repository", dirName: "aws_ecr_repository_empty", - mocks: func(client *repository.MockECRRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockECRRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllRepositories").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsEcrRepositoryResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsEcrRepositoryResourceType, resourceaws.AwsEcrRepositoryResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsEcrRepositoryResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsEcrRepositoryResourceType, resourceaws.AwsEcrRepositoryResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -68,7 +70,7 @@ func TestECRRepository(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -80,15 +82,15 @@ func TestECRRepository(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockECRRepository{} + fakeRepo := &repository2.MockECRRepository{} c.mocks(fakeRepo, alerter) - var repo repository.ECRRepository = fakeRepo + var repo repository2.ECRRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -104,13 +106,13 @@ func TestECRRepository(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewECRRepository(sess, cache.New(0)) + repo = repository2.NewECRRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewECRRepositoryEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsEcrRepositoryResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEcrRepositoryResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewECRRepositoryEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsEcrRepositoryResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsEcrRepositoryResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -129,13 +131,13 @@ func TestECRRepository(t *testing.T) { func TestECRRepositoryPolicy(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockECRRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockECRRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) err error }{ { test: "single repository policy", - mocks: func(client *repository.MockECRRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockECRRepository, alerter *mocks.AlerterInterface) { client.On("ListAllRepositories").Return([]*ecr.Repository{ {RepositoryName: awssdk.String("test_ecr_repo_policy")}, {RepositoryName: awssdk.String("test_ecr_repo_without_policy")}, @@ -162,23 +164,23 @@ func TestECRRepositoryPolicy(t *testing.T) { providerVersion := "3.19.0" schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockECRRepository{} + fakeRepo := &repository2.MockECRRepository{} c.mocks(fakeRepo, alerter) - var repo repository.ECRRepository = fakeRepo + var repo repository2.ECRRepository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewECRRepositoryPolicyEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewECRRepositoryPolicyEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/aws_elasticache_scanner_test.go b/enumeration/remote/aws_elasticache_scanner_test.go similarity index 65% rename from pkg/remote/aws_elasticache_scanner_test.go rename to enumeration/remote/aws_elasticache_scanner_test.go index 59a728079..299a6d2f6 100644 --- a/pkg/remote/aws_elasticache_scanner_test.go +++ b/enumeration/remote/aws_elasticache_scanner_test.go @@ -4,19 +4,21 @@ import ( "errors" "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/aws" + repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/terraform" + awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/elasticache" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/aws" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" + testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -27,13 +29,13 @@ func TestElastiCacheCluster(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockElastiCacheRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockElastiCacheRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no elasticache clusters", - mocks: func(repository *repository.MockElastiCacheRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockElastiCacheRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllCacheClusters").Return([]*elasticache.CacheCluster{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -42,7 +44,7 @@ func TestElastiCacheCluster(t *testing.T) { }, { test: "should list elasticache clusters", - mocks: func(repository *repository.MockElastiCacheRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockElastiCacheRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllCacheClusters").Return([]*elasticache.CacheCluster{ {CacheClusterId: awssdk.String("cluster-foo")}, }, nil) @@ -55,10 +57,10 @@ func TestElastiCacheCluster(t *testing.T) { }, { test: "cannot list elasticache clusters (403)", - mocks: func(repository *repository.MockElastiCacheRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockElastiCacheRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllCacheClusters").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsElastiCacheClusterResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsElastiCacheClusterResourceType, resourceaws.AwsElastiCacheClusterResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsElastiCacheClusterResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsElastiCacheClusterResourceType, resourceaws.AwsElastiCacheClusterResourceType), alerts.EnumerationPhase)).Return() }, assertExpected: func(t *testing.T, got []*resource.Resource) { assert.Len(t, got, 0) @@ -66,7 +68,7 @@ func TestElastiCacheCluster(t *testing.T) { }, { test: "cannot list elasticache clusters (dummy error)", - mocks: func(repository *repository.MockElastiCacheRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockElastiCacheRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllCacheClusters").Return(nil, dummyError) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -84,18 +86,18 @@ func TestElastiCacheCluster(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockElastiCacheRepository{} + fakeRepo := &repository2.MockElastiCacheRepository{} c.mocks(fakeRepo, alerter) - var repo repository.ElastiCacheRepository = fakeRepo + var repo repository2.ElastiCacheRepository = fakeRepo remoteLibrary.AddEnumerator(aws.NewElastiCacheClusterEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/aws_elb_scanner_test.go b/enumeration/remote/aws_elb_scanner_test.go similarity index 66% rename from pkg/remote/aws_elb_scanner_test.go rename to enumeration/remote/aws_elb_scanner_test.go index 7104778e3..f4ae592eb 100644 --- a/pkg/remote/aws_elb_scanner_test.go +++ b/enumeration/remote/aws_elb_scanner_test.go @@ -4,19 +4,21 @@ import ( "errors" "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/aws" + repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/terraform" + awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/elb" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/aws" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" + testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -27,13 +29,13 @@ func TestELB_LoadBalancer(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockELBRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockELBRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no load balancer", - mocks: func(repository *repository.MockELBRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockELBRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllLoadBalancers").Return([]*elb.LoadBalancerDescription{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -42,7 +44,7 @@ func TestELB_LoadBalancer(t *testing.T) { }, { test: "should list load balancers", - mocks: func(repository *repository.MockELBRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockELBRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllLoadBalancers").Return([]*elb.LoadBalancerDescription{ { LoadBalancerName: awssdk.String("acc-test-lb-tf"), @@ -57,11 +59,11 @@ func TestELB_LoadBalancer(t *testing.T) { }, { test: "cannot list load balancers", - mocks: func(repository *repository.MockELBRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockELBRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllLoadBalancers").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsClassicLoadBalancerResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsClassicLoadBalancerResourceType, resourceaws.AwsClassicLoadBalancerResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsClassicLoadBalancerResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsClassicLoadBalancerResourceType, resourceaws.AwsClassicLoadBalancerResourceType), alerts.EnumerationPhase)).Return() }, assertExpected: func(t *testing.T, got []*resource.Resource) { assert.Len(t, got, 0) @@ -69,7 +71,7 @@ func TestELB_LoadBalancer(t *testing.T) { }, { test: "cannot list load balancers (dummy error)", - mocks: func(repository *repository.MockELBRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockELBRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllLoadBalancers").Return(nil, dummyError) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -87,18 +89,18 @@ func TestELB_LoadBalancer(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockELBRepository{} + fakeRepo := &repository2.MockELBRepository{} c.mocks(fakeRepo, alerter) - var repo repository.ELBRepository = fakeRepo + var repo repository2.ELBRepository = fakeRepo remoteLibrary.AddEnumerator(aws.NewClassicLoadBalancerEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/aws_elbv2_scanner_test.go b/enumeration/remote/aws_elbv2_scanner_test.go similarity index 69% rename from pkg/remote/aws_elbv2_scanner_test.go rename to enumeration/remote/aws_elbv2_scanner_test.go index 61371a5ee..a59d53f71 100644 --- a/pkg/remote/aws_elbv2_scanner_test.go +++ b/enumeration/remote/aws_elbv2_scanner_test.go @@ -4,19 +4,21 @@ import ( "errors" "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + aws2 "github.com/snyk/driftctl/enumeration/remote/aws" + repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/terraform" + awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/elbv2" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/aws" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" + testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -27,13 +29,13 @@ func TestELBV2_LoadBalancer(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockELBV2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockELBV2Repository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no load balancer", - mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockELBV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllLoadBalancers").Return([]*elbv2.LoadBalancer{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -42,7 +44,7 @@ func TestELBV2_LoadBalancer(t *testing.T) { }, { test: "should list load balancers", - mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockELBV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllLoadBalancers").Return([]*elbv2.LoadBalancer{ { LoadBalancerArn: awssdk.String("arn:aws:elasticloadbalancing:us-east-1:533948124879:loadbalancer/app/acc-test-lb-tf/9114c60e08560420"), @@ -58,11 +60,11 @@ func TestELBV2_LoadBalancer(t *testing.T) { }, { test: "cannot list load balancers (403)", - mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockELBV2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllLoadBalancers").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsLoadBalancerResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsLoadBalancerResourceType, resourceaws.AwsLoadBalancerResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsLoadBalancerResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsLoadBalancerResourceType, resourceaws.AwsLoadBalancerResourceType), alerts.EnumerationPhase)).Return() }, assertExpected: func(t *testing.T, got []*resource.Resource) { assert.Len(t, got, 0) @@ -70,7 +72,7 @@ func TestELBV2_LoadBalancer(t *testing.T) { }, { test: "cannot list load balancers (dummy error)", - mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockELBV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllLoadBalancers").Return(nil, dummyError) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -88,18 +90,18 @@ func TestELBV2_LoadBalancer(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockELBV2Repository{} + fakeRepo := &repository2.MockELBV2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.ELBV2Repository = fakeRepo + var repo repository2.ELBV2Repository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewLoadBalancerEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewLoadBalancerEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -121,13 +123,13 @@ func TestELBV2_LoadBalancerListener(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockELBV2Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockELBV2Repository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no load balancer listener", - mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockELBV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllLoadBalancers").Return([]*elbv2.LoadBalancer{ { LoadBalancerArn: awssdk.String("test-lb"), @@ -141,7 +143,7 @@ func TestELBV2_LoadBalancerListener(t *testing.T) { }, { test: "should list load balancer listener", - mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockELBV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllLoadBalancers").Return([]*elbv2.LoadBalancer{ { LoadBalancerArn: awssdk.String("test-lb"), @@ -162,7 +164,7 @@ func TestELBV2_LoadBalancerListener(t *testing.T) { }, { test: "cannot list load balancer listeners (403)", - mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockELBV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllLoadBalancers").Return([]*elbv2.LoadBalancer{ { LoadBalancerArn: awssdk.String("test-lb"), @@ -172,7 +174,7 @@ func TestELBV2_LoadBalancerListener(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllLoadBalancerListeners", "test-lb").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsLoadBalancerListenerResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingError(awsError, resourceaws.AwsLoadBalancerListenerResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsLoadBalancerListenerResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingError(awsError, resourceaws.AwsLoadBalancerListenerResourceType), alerts.EnumerationPhase)).Return() }, assertExpected: func(t *testing.T, got []*resource.Resource) { assert.Len(t, got, 0) @@ -180,11 +182,11 @@ func TestELBV2_LoadBalancerListener(t *testing.T) { }, { test: "cannot list load balancers (403)", - mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockELBV2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllLoadBalancers").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsLoadBalancerListenerResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsLoadBalancerListenerResourceType, resourceaws.AwsLoadBalancerResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsLoadBalancerListenerResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsLoadBalancerListenerResourceType, resourceaws.AwsLoadBalancerResourceType), alerts.EnumerationPhase)).Return() }, assertExpected: func(t *testing.T, got []*resource.Resource) { assert.Len(t, got, 0) @@ -192,7 +194,7 @@ func TestELBV2_LoadBalancerListener(t *testing.T) { }, { test: "cannot list load balancer listeners (dummy error)", - mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockELBV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllLoadBalancers").Return([]*elbv2.LoadBalancer{ { LoadBalancerArn: awssdk.String("test-lb"), @@ -216,18 +218,18 @@ func TestELBV2_LoadBalancerListener(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockELBV2Repository{} + fakeRepo := &repository2.MockELBV2Repository{} c.mocks(fakeRepo, alerter) - var repo repository.ELBV2Repository = fakeRepo + var repo repository2.ELBV2Repository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewLoadBalancerListenerEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws2.NewLoadBalancerListenerEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/aws_iam_scanner_test.go b/enumeration/remote/aws_iam_scanner_test.go similarity index 73% rename from pkg/remote/aws_iam_scanner_test.go rename to enumeration/remote/aws_iam_scanner_test.go index e84ee457c..78adf7758 100644 --- a/pkg/remote/aws_iam_scanner_test.go +++ b/enumeration/remote/aws_iam_scanner_test.go @@ -3,22 +3,24 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + aws2 "github.com/snyk/driftctl/enumeration/remote/aws" + repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + terraform3 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/iam" "github.com/pkg/errors" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - remoteaws "github.com/snyk/driftctl/pkg/remote/aws" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" testresource "github.com/snyk/driftctl/test/resource" @@ -32,13 +34,13 @@ func TestIamUser(t *testing.T) { cases := []struct { test string dirName string - mocks func(*repository.MockIAMRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockIAMRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no iam user", dirName: "aws_iam_user_empty", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllUsers").Return([]*iam.User{}, nil) }, wantErr: nil, @@ -46,7 +48,7 @@ func TestIamUser(t *testing.T) { { test: "iam multiples users", dirName: "aws_iam_user_multiple", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllUsers").Return([]*iam.User{ { UserName: aws.String("test-driftctl-0"), @@ -64,18 +66,18 @@ func TestIamUser(t *testing.T) { { test: "cannot list iam user", dirName: "aws_iam_user_empty", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllUsers").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsIamUserResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamUserResourceType, resourceaws.AwsIamUserResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsIamUserResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamUserResourceType, resourceaws.AwsIamUserResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, } schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -87,15 +89,15 @@ func TestIamUser(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockIAMRepository{} + fakeRepo := &repository2.MockIAMRepository{} c.mocks(fakeRepo, alerter) - var repo repository.IAMRepository = fakeRepo + var repo repository2.IAMRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -111,13 +113,13 @@ func TestIamUser(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewIAMRepository(sess, cache.New(0)) + repo = repository2.NewIAMRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(remoteaws.NewIamUserEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamUserResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsIamUserResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewIamUserEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamUserResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsIamUserResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -138,13 +140,13 @@ func TestIamUserPolicy(t *testing.T) { cases := []struct { test string dirName string - mocks func(*repository.MockIAMRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockIAMRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no iam user policy", dirName: "aws_iam_user_policy_empty", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { users := []*iam.User{ { UserName: aws.String("loadbalancer"), @@ -158,7 +160,7 @@ func TestIamUserPolicy(t *testing.T) { { test: "iam multiples users multiple policies", dirName: "aws_iam_user_policy_multiple", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { users := []*iam.User{ { UserName: aws.String("loadbalancer"), @@ -191,30 +193,30 @@ func TestIamUserPolicy(t *testing.T) { { test: "cannot list user", dirName: "aws_iam_user_policy_empty", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllUsers").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsIamUserPolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamUserPolicyResourceType, resourceaws.AwsIamUserResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsIamUserPolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamUserPolicyResourceType, resourceaws.AwsIamUserResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, { test: "cannot list user policy", dirName: "aws_iam_user_policy_empty", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllUsers").Once().Return([]*iam.User{}, nil) awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllUserPolicies", mock.Anything).Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsIamUserPolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamUserPolicyResourceType, resourceaws.AwsIamUserPolicyResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsIamUserPolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamUserPolicyResourceType, resourceaws.AwsIamUserPolicyResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, } schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -226,15 +228,15 @@ func TestIamUserPolicy(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockIAMRepository{} + fakeRepo := &repository2.MockIAMRepository{} c.mocks(fakeRepo, alerter) - var repo repository.IAMRepository = fakeRepo + var repo repository2.IAMRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -250,13 +252,13 @@ func TestIamUserPolicy(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewIAMRepository(sess, cache.New(0)) + repo = repository2.NewIAMRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(remoteaws.NewIamUserPolicyEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamUserPolicyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsIamUserPolicyResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewIamUserPolicyEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamUserPolicyResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsIamUserPolicyResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -277,13 +279,13 @@ func TestIamPolicy(t *testing.T) { cases := []struct { test string dirName string - mocks func(*repository.MockIAMRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockIAMRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no iam custom policies", dirName: "aws_iam_policy_empty", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllPolicies").Once().Return([]*iam.Policy{}, nil) }, wantErr: nil, @@ -291,7 +293,7 @@ func TestIamPolicy(t *testing.T) { { test: "iam multiples custom policies", dirName: "aws_iam_policy_multiple", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllPolicies").Once().Return([]*iam.Policy{ { Arn: aws.String("arn:aws:iam::929327065333:policy/policy-0"), @@ -309,11 +311,11 @@ func TestIamPolicy(t *testing.T) { { test: "cannot list iam custom policies", dirName: "aws_iam_policy_empty", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllPolicies").Once().Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsIamPolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamPolicyResourceType, resourceaws.AwsIamPolicyResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsIamPolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamPolicyResourceType, resourceaws.AwsIamPolicyResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -321,7 +323,7 @@ func TestIamPolicy(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -333,15 +335,15 @@ func TestIamPolicy(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockIAMRepository{} + fakeRepo := &repository2.MockIAMRepository{} c.mocks(fakeRepo, alerter) - var repo repository.IAMRepository = fakeRepo + var repo repository2.IAMRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -357,13 +359,13 @@ func TestIamPolicy(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewIAMRepository(sess, cache.New(0)) + repo = repository2.NewIAMRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(remoteaws.NewIamPolicyEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamPolicyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsIamPolicyResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewIamPolicyEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamPolicyResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsIamPolicyResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -384,13 +386,13 @@ func TestIamRole(t *testing.T) { cases := []struct { test string dirName string - mocks func(*repository.MockIAMRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockIAMRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no iam roles", dirName: "aws_iam_role_empty", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRoles").Return([]*iam.Role{}, nil) }, wantErr: nil, @@ -398,7 +400,7 @@ func TestIamRole(t *testing.T) { { test: "iam multiples roles", dirName: "aws_iam_role_multiple", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRoles").Return([]*iam.Role{ { RoleName: aws.String("test_role_0"), @@ -419,7 +421,7 @@ func TestIamRole(t *testing.T) { { test: "iam roles ignore services roles", dirName: "aws_iam_role_ignore_services_roles", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRoles").Return([]*iam.Role{ { RoleName: aws.String("AWSServiceRoleForOrganizations"), @@ -441,7 +443,7 @@ func TestIamRole(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -453,15 +455,15 @@ func TestIamRole(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockIAMRepository{} + fakeRepo := &repository2.MockIAMRepository{} c.mocks(fakeRepo, alerter) - var repo repository.IAMRepository = fakeRepo + var repo repository2.IAMRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -477,13 +479,13 @@ func TestIamRole(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewIAMRepository(sess, cache.New(0)) + repo = repository2.NewIAMRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(remoteaws.NewIamRoleEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamRoleResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsIamRoleResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewIamRoleEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamRoleResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsIamRoleResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -504,27 +506,27 @@ func TestIamRolePolicyAttachment(t *testing.T) { cases := []struct { test string dirName string - mocks func(*repository.MockIAMRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockIAMRepository, *mocks.AlerterInterface) err error }{ { test: "no iam role policy", dirName: "aws_aws_iam_role_policy_empty", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { roles := []*iam.Role{ { RoleName: aws.String("test-role"), }, } repo.On("ListAllRoles").Return(roles, nil) - repo.On("ListAllRolePolicyAttachments", roles).Return([]*repository.AttachedRolePolicy{}, nil) + repo.On("ListAllRolePolicyAttachments", roles).Return([]*repository2.AttachedRolePolicy{}, nil) }, err: nil, }, { test: "iam multiples roles multiple policies", dirName: "aws_iam_role_policy_attachment_multiple", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { roles := []*iam.Role{ { RoleName: aws.String("test-role"), @@ -534,7 +536,7 @@ func TestIamRolePolicyAttachment(t *testing.T) { }, } repo.On("ListAllRoles").Return(roles, nil) - repo.On("ListAllRolePolicyAttachments", roles).Return([]*repository.AttachedRolePolicy{ + repo.On("ListAllRolePolicyAttachments", roles).Return([]*repository2.AttachedRolePolicy{ { AttachedPolicy: iam.AttachedPolicy{ PolicyArn: aws.String("arn:aws:iam::929327065333:policy/test-policy"), @@ -584,7 +586,7 @@ func TestIamRolePolicyAttachment(t *testing.T) { { test: "iam multiples roles for ignored roles", dirName: "aws_iam_role_policy_attachment_empty", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { roles := []*iam.Role{ { RoleName: aws.String("AWSServiceRoleForSupport"), @@ -602,29 +604,29 @@ func TestIamRolePolicyAttachment(t *testing.T) { { test: "Cannot list roles", dirName: "aws_iam_role_policy_attachment_empty", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllRoles").Once().Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsIamRolePolicyAttachmentResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamRolePolicyAttachmentResourceType, resourceaws.AwsIamRoleResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsIamRolePolicyAttachmentResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamRolePolicyAttachmentResourceType, resourceaws.AwsIamRoleResourceType), alerts.EnumerationPhase)).Return() }, }, { test: "Cannot list roles policy attachment", dirName: "aws_iam_role_policy_attachment_empty", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRoles").Once().Return([]*iam.Role{{RoleName: aws.String("test")}}, nil) awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllRolePolicyAttachments", mock.Anything).Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsIamRolePolicyAttachmentResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamRolePolicyAttachmentResourceType, resourceaws.AwsIamRolePolicyAttachmentResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsIamRolePolicyAttachmentResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamRolePolicyAttachmentResourceType, resourceaws.AwsIamRolePolicyAttachmentResourceType), alerts.EnumerationPhase)).Return() }, }, } schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -636,15 +638,15 @@ func TestIamRolePolicyAttachment(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockIAMRepository{} + fakeRepo := &repository2.MockIAMRepository{} c.mocks(fakeRepo, alerter) - var repo repository.IAMRepository = fakeRepo + var repo repository2.IAMRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -660,13 +662,13 @@ func TestIamRolePolicyAttachment(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewIAMRepository(sess, cache.New(0)) + repo = repository2.NewIAMRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(remoteaws.NewIamRolePolicyAttachmentEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamRolePolicyAttachmentResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsIamRolePolicyAttachmentResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewIamRolePolicyAttachmentEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamRolePolicyAttachmentResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsIamRolePolicyAttachmentResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -687,13 +689,13 @@ func TestIamAccessKey(t *testing.T) { cases := []struct { test string dirName string - mocks func(*repository.MockIAMRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockIAMRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no iam access_key", dirName: "aws_iam_access_key_empty", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { users := []*iam.User{ { UserName: aws.String("test-driftctl"), @@ -707,7 +709,7 @@ func TestIamAccessKey(t *testing.T) { { test: "iam multiples keys for multiples users", dirName: "aws_iam_access_key_multiple", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { users := []*iam.User{ { UserName: aws.String("test-driftctl"), @@ -738,23 +740,23 @@ func TestIamAccessKey(t *testing.T) { { test: "Cannot list iam user", dirName: "aws_iam_access_key_empty", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllUsers").Once().Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsIamAccessKeyResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamAccessKeyResourceType, resourceaws.AwsIamUserResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsIamAccessKeyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamAccessKeyResourceType, resourceaws.AwsIamUserResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, { test: "Cannot list iam access_key", dirName: "aws_iam_access_key_empty", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllUsers").Once().Return([]*iam.User{}, nil) awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllAccessKeys", mock.Anything).Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsIamAccessKeyResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamAccessKeyResourceType, resourceaws.AwsIamAccessKeyResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsIamAccessKeyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamAccessKeyResourceType, resourceaws.AwsIamAccessKeyResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -762,7 +764,7 @@ func TestIamAccessKey(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -774,15 +776,15 @@ func TestIamAccessKey(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockIAMRepository{} + fakeRepo := &repository2.MockIAMRepository{} c.mocks(fakeRepo, alerter) - var repo repository.IAMRepository = fakeRepo + var repo repository2.IAMRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -798,13 +800,13 @@ func TestIamAccessKey(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewIAMRepository(sess, cache.New(0)) + repo = repository2.NewIAMRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(remoteaws.NewIamAccessKeyEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamAccessKeyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsIamAccessKeyResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewIamAccessKeyEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamAccessKeyResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsIamAccessKeyResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -825,27 +827,27 @@ func TestIamUserPolicyAttachment(t *testing.T) { cases := []struct { test string dirName string - mocks func(*repository.MockIAMRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockIAMRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no iam user policy", dirName: "aws_iam_user_policy_empty", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { users := []*iam.User{ { UserName: aws.String("loadbalancer"), }, } repo.On("ListAllUsers").Return(users, nil) - repo.On("ListAllUserPolicyAttachments", users).Return([]*repository.AttachedUserPolicy{}, nil) + repo.On("ListAllUserPolicyAttachments", users).Return([]*repository2.AttachedUserPolicy{}, nil) }, wantErr: nil, }, { test: "iam multiples users multiple policies", dirName: "aws_iam_user_policy_attachment_multiple", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { users := []*iam.User{ { UserName: aws.String("loadbalancer"), @@ -858,7 +860,7 @@ func TestIamUserPolicyAttachment(t *testing.T) { }, } repo.On("ListAllUsers").Return(users, nil) - repo.On("ListAllUserPolicyAttachments", users).Return([]*repository.AttachedUserPolicy{ + repo.On("ListAllUserPolicyAttachments", users).Return([]*repository2.AttachedUserPolicy{ { AttachedPolicy: iam.AttachedPolicy{ PolicyArn: aws.String("arn:aws:iam::726421854799:policy/test"), @@ -951,23 +953,23 @@ func TestIamUserPolicyAttachment(t *testing.T) { { test: "cannot list user", dirName: "aws_iam_user_policy_empty", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllUsers").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsIamUserPolicyAttachmentResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamUserPolicyAttachmentResourceType, resourceaws.AwsIamUserResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsIamUserPolicyAttachmentResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamUserPolicyAttachmentResourceType, resourceaws.AwsIamUserResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, { test: "cannot list user policies attachment", dirName: "aws_iam_user_policy_empty", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllUsers").Once().Return([]*iam.User{}, nil) awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllUserPolicyAttachments", mock.Anything).Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsIamUserPolicyAttachmentResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamUserPolicyAttachmentResourceType, resourceaws.AwsIamUserPolicyAttachmentResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsIamUserPolicyAttachmentResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamUserPolicyAttachmentResourceType, resourceaws.AwsIamUserPolicyAttachmentResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -975,7 +977,7 @@ func TestIamUserPolicyAttachment(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -987,15 +989,15 @@ func TestIamUserPolicyAttachment(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockIAMRepository{} + fakeRepo := &repository2.MockIAMRepository{} c.mocks(fakeRepo, alerter) - var repo repository.IAMRepository = fakeRepo + var repo repository2.IAMRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -1011,13 +1013,13 @@ func TestIamUserPolicyAttachment(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewIAMRepository(sess, cache.New(0)) + repo = repository2.NewIAMRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(remoteaws.NewIamUserPolicyAttachmentEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamUserPolicyAttachmentResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsIamUserPolicyAttachmentResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewIamUserPolicyAttachmentEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamUserPolicyAttachmentResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsIamUserPolicyAttachmentResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -1038,27 +1040,27 @@ func TestIamRolePolicy(t *testing.T) { cases := []struct { test string dirName string - mocks func(*repository.MockIAMRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockIAMRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no iam role policy", dirName: "aws_iam_role_policy_empty", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { roles := []*iam.Role{ { RoleName: aws.String("test_role"), }, } repo.On("ListAllRoles").Return(roles, nil) - repo.On("ListAllRolePolicies", roles).Return([]repository.RolePolicy{}, nil) + repo.On("ListAllRolePolicies", roles).Return([]repository2.RolePolicy{}, nil) }, wantErr: nil, }, { test: "multiples roles with inline policies", dirName: "aws_iam_role_policy_multiple", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { roles := []*iam.Role{ { RoleName: aws.String("test_role_0"), @@ -1068,7 +1070,7 @@ func TestIamRolePolicy(t *testing.T) { }, } repo.On("ListAllRoles").Return(roles, nil) - repo.On("ListAllRolePolicies", roles).Return([]repository.RolePolicy{ + repo.On("ListAllRolePolicies", roles).Return([]repository2.RolePolicy{ {Policy: "policy-role0-0", RoleName: "test_role_0"}, {Policy: "policy-role0-1", RoleName: "test_role_0"}, {Policy: "policy-role0-2", RoleName: "test_role_0"}, @@ -1082,23 +1084,23 @@ func TestIamRolePolicy(t *testing.T) { { test: "Cannot list roles", dirName: "aws_iam_role_policy_empty", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllRoles").Once().Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsIamRolePolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamRolePolicyResourceType, resourceaws.AwsIamRoleResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsIamRolePolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamRolePolicyResourceType, resourceaws.AwsIamRoleResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, { test: "cannot list role policy", dirName: "aws_iam_role_policy_empty", - mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRoles").Once().Return([]*iam.Role{}, nil) awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllRolePolicies", mock.Anything).Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsIamRolePolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamRolePolicyResourceType, resourceaws.AwsIamRolePolicyResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsIamRolePolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamRolePolicyResourceType, resourceaws.AwsIamRolePolicyResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -1106,7 +1108,7 @@ func TestIamRolePolicy(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -1118,15 +1120,15 @@ func TestIamRolePolicy(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockIAMRepository{} + fakeRepo := &repository2.MockIAMRepository{} c.mocks(fakeRepo, alerter) - var repo repository.IAMRepository = fakeRepo + var repo repository2.IAMRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -1142,13 +1144,13 @@ func TestIamRolePolicy(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewIAMRepository(sess, cache.New(0)) + repo = repository2.NewIAMRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(remoteaws.NewIamRolePolicyEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamRolePolicyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsIamRolePolicyResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewIamRolePolicyEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamRolePolicyResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsIamRolePolicyResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -1169,13 +1171,13 @@ func TestIamGroupPolicy(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockIAMRepository) + mocks func(*repository2.MockIAMRepository) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "multiple groups, with multiples policies", - mocks: func(repository *repository.MockIAMRepository) { + mocks: func(repository *repository2.MockIAMRepository) { repository.On("ListAllGroups").Return(nil, nil) repository.On("ListAllGroupPolicies", []*iam.Group(nil)). Return([]string{"group1:policy1", "group2:policy2"}, nil) @@ -1190,14 +1192,14 @@ func TestIamGroupPolicy(t *testing.T) { }, { test: "cannot list groups", - mocks: func(repository *repository.MockIAMRepository) { + mocks: func(repository *repository2.MockIAMRepository) { repository.On("ListAllGroups").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsIamGroupPolicyResourceType, resourceaws.AwsIamGroupResourceType), }, { test: "cannot list policies", - mocks: func(repository *repository.MockIAMRepository) { + mocks: func(repository *repository2.MockIAMRepository) { repository.On("ListAllGroups").Return(nil, nil) repository.On("ListAllGroupPolicies", []*iam.Group(nil)).Return(nil, dummyError) }, @@ -1208,25 +1210,25 @@ func TestIamGroupPolicy(t *testing.T) { providerVersion := "3.19.0" schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockIAMRepository{} + fakeRepo := &repository2.MockIAMRepository{} c.mocks(fakeRepo) - var repo repository.IAMRepository = fakeRepo + var repo repository2.IAMRepository = fakeRepo - remoteLibrary.AddEnumerator(remoteaws.NewIamGroupPolicyEnumerator( + remoteLibrary.AddEnumerator(aws2.NewIamGroupPolicyEnumerator( repo, factory, )) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -1249,13 +1251,13 @@ func TestIamGroup(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockIAMRepository) + mocks func(*repository2.MockIAMRepository) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "multiple groups, with multiples groups", - mocks: func(repository *repository.MockIAMRepository) { + mocks: func(repository *repository2.MockIAMRepository) { repository.On("ListAllGroups").Return([]*iam.Group{ { GroupName: aws.String("group1"), @@ -1275,7 +1277,7 @@ func TestIamGroup(t *testing.T) { }, { test: "cannot list groups", - mocks: func(repository *repository.MockIAMRepository) { + mocks: func(repository *repository2.MockIAMRepository) { repository.On("ListAllGroups").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsIamGroupResourceType), @@ -1285,25 +1287,25 @@ func TestIamGroup(t *testing.T) { providerVersion := "3.19.0" schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockIAMRepository{} + fakeRepo := &repository2.MockIAMRepository{} c.mocks(fakeRepo) - var repo repository.IAMRepository = fakeRepo + var repo repository2.IAMRepository = fakeRepo - remoteLibrary.AddEnumerator(remoteaws.NewIamGroupEnumerator( + remoteLibrary.AddEnumerator(aws2.NewIamGroupEnumerator( repo, factory, )) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/aws_kms_scanner_test.go b/enumeration/remote/aws_kms_scanner_test.go similarity index 65% rename from pkg/remote/aws_kms_scanner_test.go rename to enumeration/remote/aws_kms_scanner_test.go index 90f4bdfc4..166f62fab 100644 --- a/pkg/remote/aws_kms_scanner_test.go +++ b/enumeration/remote/aws_kms_scanner_test.go @@ -3,22 +3,24 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + aws2 "github.com/snyk/driftctl/enumeration/remote/aws" + repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + terraform3 "github.com/snyk/driftctl/enumeration/terraform" + awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/kms" "github.com/pkg/errors" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/aws" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" testresource "github.com/snyk/driftctl/test/resource" @@ -31,20 +33,20 @@ func TestKMSKey(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockKMSRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockKMSRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no keys", dirName: "aws_kms_key_empty", - mocks: func(repository *repository.MockKMSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockKMSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllKeys").Return([]*kms.KeyListEntry{}, nil) }, }, { test: "multiple keys", dirName: "aws_kms_key_multiple", - mocks: func(repository *repository.MockKMSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockKMSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllKeys").Return([]*kms.KeyListEntry{ {KeyId: awssdk.String("8ee21d91-c000-428c-8032-235aac55da36")}, {KeyId: awssdk.String("5d765f32-bfdc-4610-b6ab-f82db5d0601b")}, @@ -55,11 +57,11 @@ func TestKMSKey(t *testing.T) { { test: "cannot list keys", dirName: "aws_kms_key_list", - mocks: func(repository *repository.MockKMSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockKMSRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllKeys").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsKmsKeyResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsKmsKeyResourceType, resourceaws.AwsKmsKeyResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsKmsKeyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsKmsKeyResourceType, resourceaws.AwsKmsKeyResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -67,7 +69,7 @@ func TestKMSKey(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -79,15 +81,15 @@ func TestKMSKey(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockKMSRepository{} + fakeRepo := &repository2.MockKMSRepository{} c.mocks(fakeRepo, alerter) - var repo repository.KMSRepository = fakeRepo + var repo repository2.KMSRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -103,13 +105,13 @@ func TestKMSKey(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewKMSRepository(sess, cache.New(0)) + repo = repository2.NewKMSRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewKMSKeyEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsKmsKeyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsKmsKeyResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewKMSKeyEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsKmsKeyResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsKmsKeyResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -129,20 +131,20 @@ func TestKMSAlias(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockKMSRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockKMSRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no aliases", dirName: "aws_kms_alias_empty", - mocks: func(repository *repository.MockKMSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockKMSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllAliases").Return([]*kms.AliasListEntry{}, nil) }, }, { test: "multiple aliases", dirName: "aws_kms_alias_multiple", - mocks: func(repository *repository.MockKMSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockKMSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllAliases").Return([]*kms.AliasListEntry{ {AliasName: awssdk.String("alias/foo")}, {AliasName: awssdk.String("alias/bar")}, @@ -153,11 +155,11 @@ func TestKMSAlias(t *testing.T) { { test: "cannot list aliases", dirName: "aws_kms_alias_list", - mocks: func(repository *repository.MockKMSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockKMSRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllAliases").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsKmsAliasResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsKmsAliasResourceType, resourceaws.AwsKmsAliasResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsKmsAliasResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsKmsAliasResourceType, resourceaws.AwsKmsAliasResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -165,7 +167,7 @@ func TestKMSAlias(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -177,15 +179,15 @@ func TestKMSAlias(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockKMSRepository{} + fakeRepo := &repository2.MockKMSRepository{} c.mocks(fakeRepo, alerter) - var repo repository.KMSRepository = fakeRepo + var repo repository2.KMSRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -201,13 +203,13 @@ func TestKMSAlias(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewKMSRepository(sess, cache.New(0)) + repo = repository2.NewKMSRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewKMSAliasEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsKmsAliasResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsKmsAliasResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewKMSAliasEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsKmsAliasResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsKmsAliasResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/aws_lambda_scanner_test.go b/enumeration/remote/aws_lambda_scanner_test.go similarity index 66% rename from pkg/remote/aws_lambda_scanner_test.go rename to enumeration/remote/aws_lambda_scanner_test.go index f29001b18..5025d796c 100644 --- a/pkg/remote/aws_lambda_scanner_test.go +++ b/enumeration/remote/aws_lambda_scanner_test.go @@ -3,27 +3,29 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + aws2 "github.com/snyk/driftctl/enumeration/remote/aws" + repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + terraform3 "github.com/snyk/driftctl/enumeration/terraform" + awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/lambda" "github.com/pkg/errors" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/aws" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" + testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/mock" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" "github.com/stretchr/testify/assert" @@ -34,13 +36,13 @@ func TestScanLambdaFunction(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockLambdaRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockLambdaRepository, *mocks.AlerterInterface) err error }{ { test: "no lambda functions", dirName: "aws_lambda_function_empty", - mocks: func(repo *repository.MockLambdaRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockLambdaRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllLambdaFunctions").Return([]*lambda.FunctionConfiguration{}, nil) }, err: nil, @@ -48,7 +50,7 @@ func TestScanLambdaFunction(t *testing.T) { { test: "with lambda functions", dirName: "aws_lambda_function_multiple", - mocks: func(repo *repository.MockLambdaRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockLambdaRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllLambdaFunctions").Return([]*lambda.FunctionConfiguration{ { FunctionName: awssdk.String("foo"), @@ -63,7 +65,7 @@ func TestScanLambdaFunction(t *testing.T) { { test: "One lambda with signing", dirName: "aws_lambda_function_signed", - mocks: func(repo *repository.MockLambdaRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockLambdaRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllLambdaFunctions").Return([]*lambda.FunctionConfiguration{ { FunctionName: awssdk.String("foo"), @@ -75,11 +77,11 @@ func TestScanLambdaFunction(t *testing.T) { { test: "cannot list lambda functions", dirName: "aws_lambda_function_empty", - mocks: func(repo *repository.MockLambdaRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockLambdaRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllLambdaFunctions").Return([]*lambda.FunctionConfiguration{}, awsError) - alerter.On("SendAlert", resourceaws.AwsLambdaFunctionResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsLambdaFunctionResourceType, resourceaws.AwsLambdaFunctionResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsLambdaFunctionResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsLambdaFunctionResourceType, resourceaws.AwsLambdaFunctionResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -87,7 +89,7 @@ func TestScanLambdaFunction(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -99,15 +101,15 @@ func TestScanLambdaFunction(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockLambdaRepository{} + fakeRepo := &repository2.MockLambdaRepository{} c.mocks(fakeRepo, alerter) - var repo repository.LambdaRepository = fakeRepo + var repo repository2.LambdaRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -123,13 +125,13 @@ func TestScanLambdaFunction(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewLambdaRepository(session, cache.New(0)) + repo = repository2.NewLambdaRepository(session, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewLambdaFunctionEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsLambdaFunctionResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsLambdaFunctionResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewLambdaFunctionEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsLambdaFunctionResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsLambdaFunctionResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -150,13 +152,13 @@ func TestScanLambdaEventSourceMapping(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockLambdaRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockLambdaRepository, *mocks.AlerterInterface) err error }{ { test: "no EventSourceMapping", dirName: "aws_lambda_source_mapping_empty", - mocks: func(repo *repository.MockLambdaRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockLambdaRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllLambdaEventSourceMappings").Return([]*lambda.EventSourceMappingConfiguration{}, nil) }, err: nil, @@ -164,7 +166,7 @@ func TestScanLambdaEventSourceMapping(t *testing.T) { { test: "with 2 sqs EventSourceMapping", dirName: "aws_lambda_source_mapping_sqs_multiple", - mocks: func(repo *repository.MockLambdaRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockLambdaRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllLambdaEventSourceMappings").Return([]*lambda.EventSourceMappingConfiguration{ { UUID: awssdk.String("13ff66f8-37eb-4ad6-a0a8-594fea72df4f"), @@ -179,7 +181,7 @@ func TestScanLambdaEventSourceMapping(t *testing.T) { { test: "with dynamo EventSourceMapping", dirName: "aws_lambda_source_mapping_dynamo_multiple", - mocks: func(repo *repository.MockLambdaRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockLambdaRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllLambdaEventSourceMappings").Return([]*lambda.EventSourceMappingConfiguration{ { UUID: awssdk.String("1aa9c4a0-060b-41c1-a9ae-dc304ebcdb00"), @@ -191,11 +193,11 @@ func TestScanLambdaEventSourceMapping(t *testing.T) { { test: "cannot list lambda functions", dirName: "aws_lambda_function_empty", - mocks: func(repo *repository.MockLambdaRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository2.MockLambdaRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllLambdaEventSourceMappings").Return([]*lambda.EventSourceMappingConfiguration{}, awsError) - alerter.On("SendAlert", resourceaws.AwsLambdaEventSourceMappingResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsLambdaEventSourceMappingResourceType, resourceaws.AwsLambdaEventSourceMappingResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsLambdaEventSourceMappingResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsLambdaEventSourceMappingResourceType, resourceaws.AwsLambdaEventSourceMappingResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -203,7 +205,7 @@ func TestScanLambdaEventSourceMapping(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -215,15 +217,15 @@ func TestScanLambdaEventSourceMapping(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockLambdaRepository{} + fakeRepo := &repository2.MockLambdaRepository{} c.mocks(fakeRepo, alerter) - var repo repository.LambdaRepository = fakeRepo + var repo repository2.LambdaRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -239,13 +241,13 @@ func TestScanLambdaEventSourceMapping(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewLambdaRepository(session, cache.New(0)) + repo = repository2.NewLambdaRepository(session, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewLambdaEventSourceMappingEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsLambdaEventSourceMappingResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsLambdaEventSourceMappingResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewLambdaEventSourceMappingEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsLambdaEventSourceMappingResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsLambdaEventSourceMappingResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/aws_rds_scanner_test.go b/enumeration/remote/aws_rds_scanner_test.go similarity index 66% rename from pkg/remote/aws_rds_scanner_test.go rename to enumeration/remote/aws_rds_scanner_test.go index cb0618e11..594c5a9c5 100644 --- a/pkg/remote/aws_rds_scanner_test.go +++ b/enumeration/remote/aws_rds_scanner_test.go @@ -3,22 +3,24 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + aws2 "github.com/snyk/driftctl/enumeration/remote/aws" + repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + terraform3 "github.com/snyk/driftctl/enumeration/terraform" + awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/rds" "github.com/pkg/errors" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/aws" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" testresource "github.com/snyk/driftctl/test/resource" @@ -31,20 +33,20 @@ func TestRDSDBInstance(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockRDSRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockRDSRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no db instances", dirName: "aws_rds_db_instance_empty", - mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDBInstances").Return([]*rds.DBInstance{}, nil) }, }, { test: "single db instance", dirName: "aws_rds_db_instance_single", - mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDBInstances").Return([]*rds.DBInstance{ {DBInstanceIdentifier: awssdk.String("terraform-20201015115018309600000001")}, }, nil) @@ -53,7 +55,7 @@ func TestRDSDBInstance(t *testing.T) { { test: "multiple mixed db instances", dirName: "aws_rds_db_instance_multiple", - mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDBInstances").Return([]*rds.DBInstance{ {DBInstanceIdentifier: awssdk.String("terraform-20201015115018309600000001")}, {DBInstanceIdentifier: awssdk.String("database-1")}, @@ -63,11 +65,11 @@ func TestRDSDBInstance(t *testing.T) { { test: "cannot list db instances", dirName: "aws_rds_db_instance_list", - mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllDBInstances").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsDbInstanceResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsDbInstanceResourceType, resourceaws.AwsDbInstanceResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsDbInstanceResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsDbInstanceResourceType, resourceaws.AwsDbInstanceResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -75,7 +77,7 @@ func TestRDSDBInstance(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -87,15 +89,15 @@ func TestRDSDBInstance(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockRDSRepository{} + fakeRepo := &repository2.MockRDSRepository{} c.mocks(fakeRepo, alerter) - var repo repository.RDSRepository = fakeRepo + var repo repository2.RDSRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -111,13 +113,13 @@ func TestRDSDBInstance(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewRDSRepository(sess, cache.New(0)) + repo = repository2.NewRDSRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewRDSDBInstanceEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsDbInstanceResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDbInstanceResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewRDSDBInstanceEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsDbInstanceResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsDbInstanceResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -137,20 +139,20 @@ func TestRDSDBSubnetGroup(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockRDSRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockRDSRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no db subnet groups", dirName: "aws_rds_db_subnet_group_empty", - mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDBSubnetGroups").Return([]*rds.DBSubnetGroup{}, nil) }, }, { test: "multiple db subnet groups", dirName: "aws_rds_db_subnet_group_multiple", - mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDBSubnetGroups").Return([]*rds.DBSubnetGroup{ {DBSubnetGroupName: awssdk.String("foo")}, {DBSubnetGroupName: awssdk.String("bar")}, @@ -160,11 +162,11 @@ func TestRDSDBSubnetGroup(t *testing.T) { { test: "cannot list db subnet groups", dirName: "aws_rds_db_subnet_group_list", - mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllDBSubnetGroups").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsDbSubnetGroupResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsDbSubnetGroupResourceType, resourceaws.AwsDbSubnetGroupResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsDbSubnetGroupResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsDbSubnetGroupResourceType, resourceaws.AwsDbSubnetGroupResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -172,7 +174,7 @@ func TestRDSDBSubnetGroup(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -184,15 +186,15 @@ func TestRDSDBSubnetGroup(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockRDSRepository{} + fakeRepo := &repository2.MockRDSRepository{} c.mocks(fakeRepo, alerter) - var repo repository.RDSRepository = fakeRepo + var repo repository2.RDSRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -208,13 +210,13 @@ func TestRDSDBSubnetGroup(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewRDSRepository(sess, cache.New(0)) + repo = repository2.NewRDSRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewRDSDBSubnetGroupEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsDbSubnetGroupResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDbSubnetGroupResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewRDSDBSubnetGroupEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsDbSubnetGroupResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsDbSubnetGroupResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -234,20 +236,20 @@ func TestRDSCluster(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockRDSRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockRDSRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no cluster", dirName: "aws_rds_cluster_empty", - mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDBClusters").Return([]*rds.DBCluster{}, nil) }, }, { test: "should return one result", dirName: "aws_rds_clusters_results", - mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDBClusters").Return([]*rds.DBCluster{ { DBClusterIdentifier: awssdk.String("aurora-cluster-demo"), @@ -262,11 +264,11 @@ func TestRDSCluster(t *testing.T) { { test: "cannot list clusters", dirName: "aws_rds_cluster_denied", - mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 400, "") repository.On("ListAllDBClusters").Return(nil, awsError).Once() - alerter.On("SendAlert", resourceaws.AwsRDSClusterResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRDSClusterResourceType, resourceaws.AwsRDSClusterResourceType), alerts.EnumerationPhase)).Return().Once() + alerter.On("SendAlert", resourceaws.AwsRDSClusterResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRDSClusterResourceType, resourceaws.AwsRDSClusterResourceType), alerts.EnumerationPhase)).Return().Once() }, wantErr: nil, }, @@ -274,7 +276,7 @@ func TestRDSCluster(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -286,15 +288,15 @@ func TestRDSCluster(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockRDSRepository{} + fakeRepo := &repository2.MockRDSRepository{} c.mocks(fakeRepo, alerter) - var repo repository.RDSRepository = fakeRepo + var repo repository2.RDSRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -310,13 +312,13 @@ func TestRDSCluster(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewRDSRepository(sess, cache.New(0)) + repo = repository2.NewRDSRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewRDSClusterEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsRDSClusterResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsRDSClusterResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewRDSClusterEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsRDSClusterResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsRDSClusterResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/aws_route53_scanner_test.go b/enumeration/remote/aws_route53_scanner_test.go similarity index 70% rename from pkg/remote/aws_route53_scanner_test.go rename to enumeration/remote/aws_route53_scanner_test.go index 61dce0832..5ccedb449 100644 --- a/pkg/remote/aws_route53_scanner_test.go +++ b/enumeration/remote/aws_route53_scanner_test.go @@ -1,6 +1,14 @@ package remote import ( + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + aws2 "github.com/snyk/driftctl/enumeration/remote/aws" + repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + terraform3 "github.com/snyk/driftctl/enumeration/terraform" "testing" awssdk "github.com/aws/aws-sdk-go/aws" @@ -9,21 +17,14 @@ import ( "github.com/aws/aws-sdk-go/service/route53" "github.com/pkg/errors" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/aws" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" + testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/mock" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" "github.com/stretchr/testify/assert" @@ -34,13 +35,13 @@ func TestRoute53_HealthCheck(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockRoute53Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockRoute53Repository, *mocks.AlerterInterface) err error }{ { test: "no health check", dirName: "aws_route53_health_check_empty", - mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) { client.On("ListAllHealthChecks").Return([]*route53.HealthCheck{}, nil) }, err: nil, @@ -48,7 +49,7 @@ func TestRoute53_HealthCheck(t *testing.T) { { test: "Multiple health check", dirName: "aws_route53_health_check_multiple", - mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) { client.On("ListAllHealthChecks").Return([]*route53.HealthCheck{ {Id: awssdk.String("7001a9df-ded4-4802-9909-668eb80b972b")}, {Id: awssdk.String("84fc318a-2e0d-41d6-b638-280e2f0f4e26")}, @@ -59,11 +60,11 @@ func TestRoute53_HealthCheck(t *testing.T) { { test: "cannot list health check", dirName: "aws_route53_health_check_empty", - mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllHealthChecks").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsRoute53HealthCheckResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRoute53HealthCheckResourceType, resourceaws.AwsRoute53HealthCheckResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsRoute53HealthCheckResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRoute53HealthCheckResourceType, resourceaws.AwsRoute53HealthCheckResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -71,7 +72,7 @@ func TestRoute53_HealthCheck(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -83,15 +84,15 @@ func TestRoute53_HealthCheck(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockRoute53Repository{} + fakeRepo := &repository2.MockRoute53Repository{} c.mocks(fakeRepo, alerter) - var repo repository.Route53Repository = fakeRepo + var repo repository2.Route53Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -107,13 +108,13 @@ func TestRoute53_HealthCheck(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewRoute53Repository(session, cache.New(0)) + repo = repository2.NewRoute53Repository(session, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewRoute53HealthCheckEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsRoute53HealthCheckResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsRoute53HealthCheckResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewRoute53HealthCheckEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsRoute53HealthCheckResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsRoute53HealthCheckResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -134,13 +135,13 @@ func TestRoute53_Zone(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockRoute53Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockRoute53Repository, *mocks.AlerterInterface) err error }{ { test: "no zones", dirName: "aws_route53_zone_empty", - mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) { client.On("ListAllZones").Return( []*route53.HostedZone{}, nil, @@ -151,7 +152,7 @@ func TestRoute53_Zone(t *testing.T) { { test: "single zone", dirName: "aws_route53_zone_single", - mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) { client.On("ListAllZones").Return( []*route53.HostedZone{ { @@ -167,7 +168,7 @@ func TestRoute53_Zone(t *testing.T) { { test: "multiples zone (test pagination)", dirName: "aws_route53_zone_multiples", - mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) { client.On("ListAllZones").Return( []*route53.HostedZone{ { @@ -191,14 +192,14 @@ func TestRoute53_Zone(t *testing.T) { { test: "cannot list zones", dirName: "aws_route53_zone_empty", - mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllZones").Return( []*route53.HostedZone{}, awsError, ) - alerter.On("SendAlert", resourceaws.AwsRoute53ZoneResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRoute53ZoneResourceType, resourceaws.AwsRoute53ZoneResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsRoute53ZoneResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRoute53ZoneResourceType, resourceaws.AwsRoute53ZoneResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -206,7 +207,7 @@ func TestRoute53_Zone(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -218,15 +219,15 @@ func TestRoute53_Zone(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockRoute53Repository{} + fakeRepo := &repository2.MockRoute53Repository{} c.mocks(fakeRepo, alerter) - var repo repository.Route53Repository = fakeRepo + var repo repository2.Route53Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -242,13 +243,13 @@ func TestRoute53_Zone(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewRoute53Repository(session, cache.New(0)) + repo = repository2.NewRoute53Repository(session, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewRoute53ZoneEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsRoute53ZoneResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsRoute53ZoneResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewRoute53ZoneEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsRoute53ZoneResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsRoute53ZoneResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -269,13 +270,13 @@ func TestRoute53_Record(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockRoute53Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockRoute53Repository, *mocks.AlerterInterface) err error }{ { test: "no records", dirName: "aws_route53_zone_with_no_record", - mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) { client.On("ListAllZones").Return( []*route53.HostedZone{ { @@ -292,7 +293,7 @@ func TestRoute53_Record(t *testing.T) { { test: "multiples records in multiples zones", dirName: "aws_route53_record_multiples", - mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) { client.On("ListAllZones").Return( []*route53.HostedZone{ { @@ -340,7 +341,7 @@ func TestRoute53_Record(t *testing.T) { { test: "explicit subdomain records", dirName: "aws_route53_record_explicit_subdomain", - mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) { client.On("ListAllZones").Return( []*route53.HostedZone{ { @@ -382,20 +383,20 @@ func TestRoute53_Record(t *testing.T) { { test: "cannot list zones", dirName: "aws_route53_zone_with_no_record", - mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllZones").Return( []*route53.HostedZone{}, awsError) - alerter.On("SendAlert", resourceaws.AwsRoute53RecordResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRoute53RecordResourceType, resourceaws.AwsRoute53ZoneResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsRoute53RecordResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRoute53RecordResourceType, resourceaws.AwsRoute53ZoneResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, { test: "cannot list records", dirName: "aws_route53_zone_with_no_record", - mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) { client.On("ListAllZones").Return( []*route53.HostedZone{ { @@ -408,7 +409,7 @@ func TestRoute53_Record(t *testing.T) { client.On("ListRecordsForZone", "Z06486383UC8WYSBZTWFM").Return( []*route53.ResourceRecordSet{}, awsError) - alerter.On("SendAlert", resourceaws.AwsRoute53RecordResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRoute53RecordResourceType, resourceaws.AwsRoute53RecordResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsRoute53RecordResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRoute53RecordResourceType, resourceaws.AwsRoute53RecordResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -416,7 +417,7 @@ func TestRoute53_Record(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -428,15 +429,15 @@ func TestRoute53_Record(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockRoute53Repository{} + fakeRepo := &repository2.MockRoute53Repository{} c.mocks(fakeRepo, alerter) - var repo repository.Route53Repository = fakeRepo + var repo repository2.Route53Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -452,13 +453,13 @@ func TestRoute53_Record(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewRoute53Repository(session, cache.New(0)) + repo = repository2.NewRoute53Repository(session, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewRoute53RecordEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsRoute53RecordResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsRoute53RecordResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewRoute53RecordEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsRoute53RecordResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsRoute53RecordResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/aws_s3_scanner_test.go b/enumeration/remote/aws_s3_scanner_test.go similarity index 72% rename from pkg/remote/aws_s3_scanner_test.go rename to enumeration/remote/aws_s3_scanner_test.go index 453b2e03f..1616460f6 100644 --- a/pkg/remote/aws_s3_scanner_test.go +++ b/enumeration/remote/aws_s3_scanner_test.go @@ -3,29 +3,31 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + aws2 "github.com/snyk/driftctl/enumeration/remote/aws" + "github.com/snyk/driftctl/enumeration/remote/aws/client" + repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + tf "github.com/snyk/driftctl/enumeration/remote/terraform" + terraform3 "github.com/snyk/driftctl/enumeration/terraform" + awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/s3" "github.com/pkg/errors" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/aws" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - tf "github.com/snyk/driftctl/pkg/remote/terraform" + testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/mock" - "github.com/snyk/driftctl/pkg/remote/aws/client" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" "github.com/stretchr/testify/assert" @@ -36,12 +38,12 @@ func TestS3Bucket(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockS3Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockS3Repository, *mocks.AlerterInterface) wantErr error }{ { test: "multiple bucket", dirName: "aws_s3_bucket_multiple", - mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On( "ListAllBuckets", ).Return([]*s3.Bucket{ @@ -77,11 +79,11 @@ func TestS3Bucket(t *testing.T) { }, { test: "cannot list bucket", dirName: "aws_s3_bucket_list", - mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllBuckets").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsS3BucketResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketResourceType, resourceaws.AwsS3BucketResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsS3BucketResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketResourceType, resourceaws.AwsS3BucketResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -89,7 +91,7 @@ func TestS3Bucket(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -101,14 +103,14 @@ func TestS3Bucket(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockS3Repository{} + fakeRepo := &repository2.MockS3Repository{} c.mocks(fakeRepo, alerter) - var repo repository.S3Repository = fakeRepo + var repo repository2.S3Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -124,16 +126,16 @@ func TestS3Bucket(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) + repo = repository2.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewS3BucketEnumerator(repo, factory, tf.TerraformProviderConfig{ + remoteLibrary.AddEnumerator(aws2.NewS3BucketEnumerator(repo, factory, tf.TerraformProviderConfig{ Name: "test", DefaultAlias: "eu-west-3", }, alerter)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsS3BucketResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsS3BucketResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -154,12 +156,12 @@ func TestS3BucketInventory(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockS3Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockS3Repository, *mocks.AlerterInterface) wantErr error }{ { test: "multiple bucket with multiple inventories", dirName: "aws_s3_bucket_inventories_multiple", - mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On( "ListAllBuckets", ).Return([]*s3.Bucket{ @@ -207,17 +209,17 @@ func TestS3BucketInventory(t *testing.T) { }, { test: "cannot list bucket", dirName: "aws_s3_bucket_inventories_list_bucket", - mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllBuckets").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsS3BucketInventoryResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketInventoryResourceType, resourceaws.AwsS3BucketResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsS3BucketInventoryResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketInventoryResourceType, resourceaws.AwsS3BucketResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, { test: "cannot list bucket inventories", dirName: "aws_s3_bucket_inventories_list_inventories", - mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllBuckets").Return( []*s3.Bucket{ {Name: awssdk.String("bucket-martin-test-drift")}, @@ -241,7 +243,7 @@ func TestS3BucketInventory(t *testing.T) { awsError, ) - alerter.On("SendAlert", resourceaws.AwsS3BucketInventoryResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketInventoryResourceType, resourceaws.AwsS3BucketInventoryResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsS3BucketInventoryResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketInventoryResourceType, resourceaws.AwsS3BucketInventoryResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -249,7 +251,7 @@ func TestS3BucketInventory(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -261,14 +263,14 @@ func TestS3BucketInventory(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockS3Repository{} + fakeRepo := &repository2.MockS3Repository{} c.mocks(fakeRepo, alerter) - var repo repository.S3Repository = fakeRepo + var repo repository2.S3Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -284,16 +286,16 @@ func TestS3BucketInventory(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) + repo = repository2.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewS3BucketInventoryEnumerator(repo, factory, tf.TerraformProviderConfig{ + remoteLibrary.AddEnumerator(aws2.NewS3BucketInventoryEnumerator(repo, factory, tf.TerraformProviderConfig{ Name: "test", DefaultAlias: "eu-west-3", }, alerter)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketInventoryResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsS3BucketInventoryResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketInventoryResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsS3BucketInventoryResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -314,13 +316,13 @@ func TestS3BucketNotification(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockS3Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockS3Repository, *mocks.AlerterInterface) wantErr error }{ { test: "single bucket without notifications", dirName: "aws_s3_bucket_notifications_no_notif", - mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On( "ListAllBuckets", ).Return([]*s3.Bucket{ @@ -347,7 +349,7 @@ func TestS3BucketNotification(t *testing.T) { }, { test: "multiple bucket with notifications", dirName: "aws_s3_bucket_notifications_multiple", - mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On( "ListAllBuckets", ).Return([]*s3.Bucket{ @@ -401,7 +403,7 @@ func TestS3BucketNotification(t *testing.T) { }, { test: "Cannot get bucket notification", dirName: "aws_s3_bucket_notifications_list_bucket", - mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On( "ListAllBuckets", ).Return([]*s3.Bucket{ @@ -417,17 +419,17 @@ func TestS3BucketNotification(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("GetBucketNotification", "dritftctl-test-notifications-error", "eu-west-3").Return(nil, awsError) - alerter.On("SendAlert", "aws_s3_bucket_notification.dritftctl-test-notifications-error", alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, "aws_s3_bucket_notification.dritftctl-test-notifications-error", resourceaws.AwsS3BucketNotificationResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", "aws_s3_bucket_notification.dritftctl-test-notifications-error", alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, "aws_s3_bucket_notification.dritftctl-test-notifications-error", resourceaws.AwsS3BucketNotificationResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, { test: "Cannot list bucket", dirName: "aws_s3_bucket_notifications_list_bucket", - mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllBuckets").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsS3BucketNotificationResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketNotificationResourceType, resourceaws.AwsS3BucketResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsS3BucketNotificationResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketNotificationResourceType, resourceaws.AwsS3BucketResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -435,7 +437,7 @@ func TestS3BucketNotification(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -447,14 +449,14 @@ func TestS3BucketNotification(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockS3Repository{} + fakeRepo := &repository2.MockS3Repository{} c.mocks(fakeRepo, alerter) - var repo repository.S3Repository = fakeRepo + var repo repository2.S3Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -470,16 +472,16 @@ func TestS3BucketNotification(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) + repo = repository2.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewS3BucketNotificationEnumerator(repo, factory, tf.TerraformProviderConfig{ + remoteLibrary.AddEnumerator(aws2.NewS3BucketNotificationEnumerator(repo, factory, tf.TerraformProviderConfig{ Name: "test", DefaultAlias: "eu-west-3", }, alerter)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketNotificationResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsS3BucketNotificationResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketNotificationResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsS3BucketNotificationResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -500,12 +502,12 @@ func TestS3BucketMetrics(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockS3Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockS3Repository, *mocks.AlerterInterface) wantErr error }{ { test: "multiple bucket with multiple metrics", dirName: "aws_s3_bucket_metrics_multiple", - mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On( "ListAllBuckets", ).Return([]*s3.Bucket{ @@ -553,17 +555,17 @@ func TestS3BucketMetrics(t *testing.T) { }, { test: "cannot list bucket", dirName: "aws_s3_bucket_metrics_list_bucket", - mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllBuckets").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsS3BucketMetricResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketMetricResourceType, resourceaws.AwsS3BucketResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsS3BucketMetricResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketMetricResourceType, resourceaws.AwsS3BucketResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, { test: "cannot list metrics", dirName: "aws_s3_bucket_metrics_list_metrics", - mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllBuckets").Return( []*s3.Bucket{ {Name: awssdk.String("bucket-martin-test-drift")}, @@ -588,7 +590,7 @@ func TestS3BucketMetrics(t *testing.T) { awsError, ) - alerter.On("SendAlert", resourceaws.AwsS3BucketMetricResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketMetricResourceType, resourceaws.AwsS3BucketMetricResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsS3BucketMetricResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketMetricResourceType, resourceaws.AwsS3BucketMetricResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -596,7 +598,7 @@ func TestS3BucketMetrics(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -608,14 +610,14 @@ func TestS3BucketMetrics(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockS3Repository{} + fakeRepo := &repository2.MockS3Repository{} c.mocks(fakeRepo, alerter) - var repo repository.S3Repository = fakeRepo + var repo repository2.S3Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -631,16 +633,16 @@ func TestS3BucketMetrics(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) + repo = repository2.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewS3BucketMetricsEnumerator(repo, factory, tf.TerraformProviderConfig{ + remoteLibrary.AddEnumerator(aws2.NewS3BucketMetricsEnumerator(repo, factory, tf.TerraformProviderConfig{ Name: "test", DefaultAlias: "eu-west-3", }, alerter)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketMetricResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsS3BucketMetricResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketMetricResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsS3BucketMetricResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -661,13 +663,13 @@ func TestS3BucketPolicy(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockS3Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockS3Repository, *mocks.AlerterInterface) wantErr error }{ { test: "single bucket without policy", dirName: "aws_s3_bucket_policy_no_policy", - mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On( "ListAllBuckets", ).Return([]*s3.Bucket{ @@ -694,7 +696,7 @@ func TestS3BucketPolicy(t *testing.T) { }, { test: "multiple bucket with policies", dirName: "aws_s3_bucket_policies_multiple", - mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On( "ListAllBuckets", ).Return([]*s3.Bucket{ @@ -742,11 +744,11 @@ func TestS3BucketPolicy(t *testing.T) { }, { test: "cannot list bucket", dirName: "aws_s3_bucket_policies_list_bucket", - mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllBuckets").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsS3BucketPolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketPolicyResourceType, resourceaws.AwsS3BucketResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsS3BucketPolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketPolicyResourceType, resourceaws.AwsS3BucketResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -754,7 +756,7 @@ func TestS3BucketPolicy(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -766,14 +768,14 @@ func TestS3BucketPolicy(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockS3Repository{} + fakeRepo := &repository2.MockS3Repository{} c.mocks(fakeRepo, alerter) - var repo repository.S3Repository = fakeRepo + var repo repository2.S3Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -789,16 +791,16 @@ func TestS3BucketPolicy(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) + repo = repository2.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewS3BucketPolicyEnumerator(repo, factory, tf.TerraformProviderConfig{ + remoteLibrary.AddEnumerator(aws2.NewS3BucketPolicyEnumerator(repo, factory, tf.TerraformProviderConfig{ Name: "test", DefaultAlias: "eu-west-3", }, alerter)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketPolicyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsS3BucketPolicyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketPolicyResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsS3BucketPolicyResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -819,13 +821,13 @@ func TestS3BucketPublicAccessBlock(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockS3Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockS3Repository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "multiple bucket, one with access block", - mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllBuckets").Return([]*s3.Bucket{ {Name: awssdk.String("bucket-with-public-access-block")}, {Name: awssdk.String("bucket-without-public-access-block")}, @@ -859,18 +861,18 @@ func TestS3BucketPublicAccessBlock(t *testing.T) { }, { test: "cannot list bucket", - mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllBuckets").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsS3BucketPublicAccessBlockResourceType, resourceaws.AwsS3BucketResourceType), }, { test: "cannot list public access block", - mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllBuckets").Return([]*s3.Bucket{{Name: awssdk.String("foobar")}}, nil) repository.On("GetBucketLocation", "foobar").Return("us-east-1", nil) repository.On("GetBucketPublicAccessBlock", "foobar", "us-east-1").Return(nil, dummyError) - alerter.On("SendAlert", "aws_s3_bucket_public_access_block.foobar", alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceScanningError(dummyError, resourceaws.AwsS3BucketPublicAccessBlockResourceType, "foobar"), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", "aws_s3_bucket_public_access_block.foobar", alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceScanningError(dummyError, resourceaws.AwsS3BucketPublicAccessBlockResourceType, "foobar"), alerts.EnumerationPhase)).Return() }, assertExpected: func(t *testing.T, got []*resource.Resource) { assert.Len(t, got, 0) @@ -881,27 +883,27 @@ func TestS3BucketPublicAccessBlock(t *testing.T) { providerVersion := "3.19.0" schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockS3Repository{} + fakeRepo := &repository2.MockS3Repository{} c.mocks(fakeRepo, alerter) - var repo repository.S3Repository = fakeRepo + var repo repository2.S3Repository = fakeRepo - remoteLibrary.AddEnumerator(aws.NewS3BucketPublicAccessBlockEnumerator( + remoteLibrary.AddEnumerator(aws2.NewS3BucketPublicAccessBlockEnumerator( repo, factory, tf.TerraformProviderConfig{DefaultAlias: "us-east-1"}, alerter, )) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -924,13 +926,13 @@ func TestS3BucketAnalytic(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockS3Repository, *mocks.AlerterInterface) + mocks func(*repository2.MockS3Repository, *mocks.AlerterInterface) wantErr error }{ { test: "multiple bucket with multiple analytics", dirName: "aws_s3_bucket_analytics_multiple", - mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On( "ListAllBuckets", ).Return([]*s3.Bucket{ @@ -978,17 +980,17 @@ func TestS3BucketAnalytic(t *testing.T) { }, { test: "cannot list bucket", dirName: "aws_s3_bucket_analytics_list_bucket", - mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllBuckets").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsS3BucketAnalyticsConfigurationResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketAnalyticsConfigurationResourceType, resourceaws.AwsS3BucketResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsS3BucketAnalyticsConfigurationResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketAnalyticsConfigurationResourceType, resourceaws.AwsS3BucketResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, { test: "cannot list Analytics", dirName: "aws_s3_bucket_analytics_list_analytics", - mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllBuckets").Return( []*s3.Bucket{ {Name: awssdk.String("bucket-martin-test-drift")}, @@ -1013,7 +1015,7 @@ func TestS3BucketAnalytic(t *testing.T) { awsError, ) - alerter.On("SendAlert", resourceaws.AwsS3BucketAnalyticsConfigurationResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketAnalyticsConfigurationResourceType, resourceaws.AwsS3BucketAnalyticsConfigurationResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsS3BucketAnalyticsConfigurationResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketAnalyticsConfigurationResourceType, resourceaws.AwsS3BucketAnalyticsConfigurationResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -1021,7 +1023,7 @@ func TestS3BucketAnalytic(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1033,14 +1035,14 @@ func TestS3BucketAnalytic(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockS3Repository{} + fakeRepo := &repository2.MockS3Repository{} c.mocks(fakeRepo, alerter) - var repo repository.S3Repository = fakeRepo + var repo repository2.S3Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -1056,16 +1058,16 @@ func TestS3BucketAnalytic(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) + repo = repository2.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewS3BucketAnalyticEnumerator(repo, factory, tf.TerraformProviderConfig{ + remoteLibrary.AddEnumerator(aws2.NewS3BucketAnalyticEnumerator(repo, factory, tf.TerraformProviderConfig{ Name: "test", DefaultAlias: "eu-west-3", }, alerter)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketAnalyticsConfigurationResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsS3BucketAnalyticsConfigurationResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketAnalyticsConfigurationResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsS3BucketAnalyticsConfigurationResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/aws_sns_scanner_test.go b/enumeration/remote/aws_sns_scanner_test.go similarity index 67% rename from pkg/remote/aws_sns_scanner_test.go rename to enumeration/remote/aws_sns_scanner_test.go index 781d62451..9ed38085a 100644 --- a/pkg/remote/aws_sns_scanner_test.go +++ b/enumeration/remote/aws_sns_scanner_test.go @@ -3,27 +3,29 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + aws2 "github.com/snyk/driftctl/enumeration/remote/aws" + repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + terraform3 "github.com/snyk/driftctl/enumeration/terraform" + awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/sns" "github.com/pkg/errors" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/aws" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" + testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/mock" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" "github.com/stretchr/testify/assert" @@ -34,13 +36,13 @@ func TestScanSNSTopic(t *testing.T) { cases := []struct { test string dirName string - mocks func(*repository.MockSNSRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockSNSRepository, *mocks.AlerterInterface) err error }{ { test: "no SNS Topic", dirName: "aws_sns_topic_empty", - mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) { client.On("ListAllTopics").Return([]*sns.Topic{}, nil) }, err: nil, @@ -48,7 +50,7 @@ func TestScanSNSTopic(t *testing.T) { { test: "Multiple SNSTopic", dirName: "aws_sns_topic_multiple", - mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) { client.On("ListAllTopics").Return([]*sns.Topic{ {TopicArn: awssdk.String("arn:aws:sns:eu-west-3:526954929923:user-updates-topic")}, {TopicArn: awssdk.String("arn:aws:sns:eu-west-3:526954929923:user-updates-topic2")}, @@ -60,11 +62,11 @@ func TestScanSNSTopic(t *testing.T) { { test: "cannot list SNSTopic", dirName: "aws_sns_topic_empty", - mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllTopics").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsSnsTopicResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSnsTopicResourceType, resourceaws.AwsSnsTopicResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsSnsTopicResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSnsTopicResourceType, resourceaws.AwsSnsTopicResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -72,7 +74,7 @@ func TestScanSNSTopic(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -84,15 +86,15 @@ func TestScanSNSTopic(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockSNSRepository{} + fakeRepo := &repository2.MockSNSRepository{} c.mocks(fakeRepo, alerter) - var repo repository.SNSRepository = fakeRepo + var repo repository2.SNSRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -108,13 +110,13 @@ func TestScanSNSTopic(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewSNSRepository(sess, cache.New(0)) + repo = repository2.NewSNSRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewSNSTopicEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsSnsTopicResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSnsTopicResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewSNSTopicEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsSnsTopicResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsSnsTopicResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -135,13 +137,13 @@ func TestSNSTopicPolicyScan(t *testing.T) { cases := []struct { test string dirName string - mocks func(*repository.MockSNSRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockSNSRepository, *mocks.AlerterInterface) err error }{ { test: "no SNS Topic policy", dirName: "aws_sns_topic_policy_empty", - mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) { client.On("ListAllTopics").Return([]*sns.Topic{}, nil) }, err: nil, @@ -149,7 +151,7 @@ func TestSNSTopicPolicyScan(t *testing.T) { { test: "Multiple SNSTopicPolicy", dirName: "aws_sns_topic_policy_multiple", - mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) { client.On("ListAllTopics").Return([]*sns.Topic{ {TopicArn: awssdk.String("arn:aws:sns:us-east-1:526954929923:my-topic-with-policy")}, {TopicArn: awssdk.String("arn:aws:sns:us-east-1:526954929923:my-topic-with-policy2")}, @@ -160,11 +162,11 @@ func TestSNSTopicPolicyScan(t *testing.T) { { test: "cannot list SNSTopic", dirName: "aws_sns_topic_policy_topic_list", - mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllTopics").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsSnsTopicPolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSnsTopicPolicyResourceType, resourceaws.AwsSnsTopicResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsSnsTopicPolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSnsTopicPolicyResourceType, resourceaws.AwsSnsTopicResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -172,7 +174,7 @@ func TestSNSTopicPolicyScan(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -184,15 +186,15 @@ func TestSNSTopicPolicyScan(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockSNSRepository{} + fakeRepo := &repository2.MockSNSRepository{} c.mocks(fakeRepo, alerter) - var repo repository.SNSRepository = fakeRepo + var repo repository2.SNSRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -208,13 +210,13 @@ func TestSNSTopicPolicyScan(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewSNSRepository(sess, cache.New(0)) + repo = repository2.NewSNSRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewSNSTopicPolicyEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsSnsTopicPolicyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSnsTopicPolicyResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewSNSTopicPolicyEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsSnsTopicPolicyResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsSnsTopicPolicyResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -235,13 +237,13 @@ func TestSNSTopicSubscriptionScan(t *testing.T) { cases := []struct { test string dirName string - mocks func(*repository.MockSNSRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockSNSRepository, *mocks.AlerterInterface) err error }{ { test: "no SNS Topic Subscription", dirName: "aws_sns_topic_subscription_empty", - mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) { client.On("ListAllSubscriptions").Return([]*sns.Subscription{}, nil) }, err: nil, @@ -249,7 +251,7 @@ func TestSNSTopicSubscriptionScan(t *testing.T) { { test: "Multiple SNSTopic Subscription", dirName: "aws_sns_topic_subscription_multiple", - mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) { client.On("ListAllSubscriptions").Return([]*sns.Subscription{ {SubscriptionArn: awssdk.String("arn:aws:sns:us-east-1:526954929923:user-updates-topic2:c0f794c5-a009-4db4-9147-4c55959787fa")}, {SubscriptionArn: awssdk.String("arn:aws:sns:us-east-1:526954929923:user-updates-topic:b6e66147-2b31-4486-8d4b-2a2272264c8e")}, @@ -260,7 +262,7 @@ func TestSNSTopicSubscriptionScan(t *testing.T) { { test: "Multiple SNSTopic Subscription with one pending and one incorrect", dirName: "aws_sns_topic_subscription_multiple", - mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) { client.On("ListAllSubscriptions").Return([]*sns.Subscription{ {SubscriptionArn: awssdk.String("PendingConfirmation"), Endpoint: awssdk.String("TEST")}, {SubscriptionArn: awssdk.String("Incorrect"), Endpoint: awssdk.String("INCORRECT")}, @@ -268,20 +270,20 @@ func TestSNSTopicSubscriptionScan(t *testing.T) { {SubscriptionArn: awssdk.String("arn:aws:sns:us-east-1:526954929923:user-updates-topic:b6e66147-2b31-4486-8d4b-2a2272264c8e")}, }, nil) - alerter.On("SendAlert", "aws_sns_topic_subscription.PendingConfirmation", aws.NewWrongArnTopicAlert("PendingConfirmation", awssdk.String("TEST"))).Return() + alerter.On("SendAlert", "aws_sns_topic_subscription.PendingConfirmation", aws2.NewWrongArnTopicAlert("PendingConfirmation", awssdk.String("TEST"))).Return() - alerter.On("SendAlert", "aws_sns_topic_subscription.Incorrect", aws.NewWrongArnTopicAlert("Incorrect", awssdk.String("INCORRECT"))).Return() + alerter.On("SendAlert", "aws_sns_topic_subscription.Incorrect", aws2.NewWrongArnTopicAlert("Incorrect", awssdk.String("INCORRECT"))).Return() }, err: nil, }, { test: "cannot list SNSTopic subscription", dirName: "aws_sns_topic_subscription_list", - mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllSubscriptions").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsSnsTopicSubscriptionResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSnsTopicSubscriptionResourceType, resourceaws.AwsSnsTopicSubscriptionResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsSnsTopicSubscriptionResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSnsTopicSubscriptionResourceType, resourceaws.AwsSnsTopicSubscriptionResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -289,7 +291,7 @@ func TestSNSTopicSubscriptionScan(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -301,15 +303,15 @@ func TestSNSTopicSubscriptionScan(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockSNSRepository{} + fakeRepo := &repository2.MockSNSRepository{} c.mocks(fakeRepo, alerter) - var repo repository.SNSRepository = fakeRepo + var repo repository2.SNSRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -325,13 +327,13 @@ func TestSNSTopicSubscriptionScan(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewSNSRepository(sess, cache.New(0)) + repo = repository2.NewSNSRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewSNSTopicSubscriptionEnumerator(repo, factory, alerter)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsSnsTopicSubscriptionResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSnsTopicSubscriptionResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewSNSTopicSubscriptionEnumerator(repo, factory, alerter)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsSnsTopicSubscriptionResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsSnsTopicSubscriptionResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/aws_sqs_scanner_test.go b/enumeration/remote/aws_sqs_scanner_test.go similarity index 69% rename from pkg/remote/aws_sqs_scanner_test.go rename to enumeration/remote/aws_sqs_scanner_test.go index dd60d6c0a..72b7345ab 100644 --- a/pkg/remote/aws_sqs_scanner_test.go +++ b/enumeration/remote/aws_sqs_scanner_test.go @@ -3,22 +3,24 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + aws2 "github.com/snyk/driftctl/enumeration/remote/aws" + repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + terraform3 "github.com/snyk/driftctl/enumeration/terraform" + awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/sqs" "github.com/pkg/errors" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/aws" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" testresource "github.com/snyk/driftctl/test/resource" @@ -31,13 +33,13 @@ func TestSQSQueue(t *testing.T) { cases := []struct { test string dirName string - mocks func(*repository.MockSQSRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockSQSRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no sqs queues", dirName: "aws_sqs_queue_empty", - mocks: func(client *repository.MockSQSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockSQSRepository, alerter *mocks.AlerterInterface) { client.On("ListAllQueues").Return([]*string{}, nil) }, wantErr: nil, @@ -45,7 +47,7 @@ func TestSQSQueue(t *testing.T) { { test: "multiple sqs queues", dirName: "aws_sqs_queue_multiple", - mocks: func(client *repository.MockSQSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockSQSRepository, alerter *mocks.AlerterInterface) { client.On("ListAllQueues").Return([]*string{ awssdk.String("https://sqs.eu-west-3.amazonaws.com/047081014315/bar.fifo"), awssdk.String("https://sqs.eu-west-3.amazonaws.com/047081014315/foo"), @@ -56,11 +58,11 @@ func TestSQSQueue(t *testing.T) { { test: "cannot list sqs queues", dirName: "aws_sqs_queue_empty", - mocks: func(client *repository.MockSQSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockSQSRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllQueues").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsSqsQueueResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSqsQueueResourceType, resourceaws.AwsSqsQueueResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsSqsQueueResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSqsQueueResourceType, resourceaws.AwsSqsQueueResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -68,7 +70,7 @@ func TestSQSQueue(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -80,14 +82,14 @@ func TestSQSQueue(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockSQSRepository{} + fakeRepo := &repository2.MockSQSRepository{} c.mocks(fakeRepo, alerter) - var repo repository.SQSRepository = fakeRepo + var repo repository2.SQSRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -103,13 +105,13 @@ func TestSQSQueue(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewSQSRepository(sess, cache.New(0)) + repo = repository2.NewSQSRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewSQSQueueEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsSqsQueueResourceType, aws.NewSQSQueueDetailsFetcher(provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewSQSQueueEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsSqsQueueResourceType, aws2.NewSQSQueueDetailsFetcher(provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -129,7 +131,7 @@ func TestSQSQueuePolicy(t *testing.T) { cases := []struct { test string dirName string - mocks func(*repository.MockSQSRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockSQSRepository, *mocks.AlerterInterface) wantErr error }{ { @@ -137,7 +139,7 @@ func TestSQSQueuePolicy(t *testing.T) { // as a default SQSDefaultPolicy (e.g. policy="") will always be present in each queue test: "no sqs queue policies", dirName: "aws_sqs_queue_policy_empty", - mocks: func(client *repository.MockSQSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockSQSRepository, alerter *mocks.AlerterInterface) { client.On("ListAllQueues").Return([]*string{}, nil) }, wantErr: nil, @@ -145,7 +147,7 @@ func TestSQSQueuePolicy(t *testing.T) { { test: "multiple sqs queue policies (default or not)", dirName: "aws_sqs_queue_policy_multiple", - mocks: func(client *repository.MockSQSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockSQSRepository, alerter *mocks.AlerterInterface) { client.On("ListAllQueues").Return([]*string{ awssdk.String("https://sqs.eu-west-3.amazonaws.com/047081014315/bar.fifo"), awssdk.String("https://sqs.eu-west-3.amazonaws.com/047081014315/foo"), @@ -166,7 +168,7 @@ func TestSQSQueuePolicy(t *testing.T) { { test: "multiple sqs queue policies (with nil attributes)", dirName: "aws_sqs_queue_policy_multiple", - mocks: func(client *repository.MockSQSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockSQSRepository, alerter *mocks.AlerterInterface) { client.On("ListAllQueues").Return([]*string{ awssdk.String("https://sqs.eu-west-3.amazonaws.com/047081014315/bar.fifo"), awssdk.String("https://sqs.eu-west-3.amazonaws.com/047081014315/foo"), @@ -183,11 +185,11 @@ func TestSQSQueuePolicy(t *testing.T) { { test: "cannot list sqs queues, thus sqs queue policies", dirName: "aws_sqs_queue_policy_empty", - mocks: func(client *repository.MockSQSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository2.MockSQSRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllQueues").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsSqsQueuePolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSqsQueuePolicyResourceType, resourceaws.AwsSqsQueueResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsSqsQueuePolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSqsQueuePolicyResourceType, resourceaws.AwsSqsQueueResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -195,7 +197,7 @@ func TestSQSQueuePolicy(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -207,14 +209,14 @@ func TestSQSQueuePolicy(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockSQSRepository{} + fakeRepo := &repository2.MockSQSRepository{} c.mocks(fakeRepo, alerter) - var repo repository.SQSRepository = fakeRepo + var repo repository2.SQSRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -230,13 +232,13 @@ func TestSQSQueuePolicy(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository.NewSQSRepository(sess, cache.New(0)) + repo = repository2.NewSQSRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws.NewSQSQueuePolicyEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsSqsQueuePolicyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSqsQueuePolicyResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(aws2.NewSQSQueuePolicyEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsSqsQueuePolicyResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsSqsQueuePolicyResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/azurerm/azurerm_container_registry_enumerator.go b/enumeration/remote/azurerm/azurerm_container_registry_enumerator.go similarity index 82% rename from pkg/remote/azurerm/azurerm_container_registry_enumerator.go rename to enumeration/remote/azurerm/azurerm_container_registry_enumerator.go index 6c997f206..66ed08e91 100644 --- a/pkg/remote/azurerm/azurerm_container_registry_enumerator.go +++ b/enumeration/remote/azurerm/azurerm_container_registry_enumerator.go @@ -1,10 +1,10 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) type AzurermContainerRegistryEnumerator struct { diff --git a/pkg/remote/azurerm/azurerm_firewalls_enumerator.go b/enumeration/remote/azurerm/azurerm_firewalls_enumerator.go similarity index 81% rename from pkg/remote/azurerm/azurerm_firewalls_enumerator.go rename to enumeration/remote/azurerm/azurerm_firewalls_enumerator.go index 101893d7c..6487acdde 100644 --- a/pkg/remote/azurerm/azurerm_firewalls_enumerator.go +++ b/enumeration/remote/azurerm/azurerm_firewalls_enumerator.go @@ -1,10 +1,10 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) type AzurermFirewallsEnumerator struct { diff --git a/pkg/remote/azurerm/azurerm_image_enumerator.go b/enumeration/remote/azurerm/azurerm_image_enumerator.go similarity index 86% rename from pkg/remote/azurerm/azurerm_image_enumerator.go rename to enumeration/remote/azurerm/azurerm_image_enumerator.go index cad988844..0fe11379d 100644 --- a/pkg/remote/azurerm/azurerm_image_enumerator.go +++ b/enumeration/remote/azurerm/azurerm_image_enumerator.go @@ -1,14 +1,14 @@ package azurerm import ( + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" "strings" "github.com/Azure/go-autorest/autorest/azure" "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) type AzurermImageEnumerator struct { diff --git a/pkg/remote/azurerm/azurerm_lb_enumerator.go b/enumeration/remote/azurerm/azurerm_lb_enumerator.go similarity index 81% rename from pkg/remote/azurerm/azurerm_lb_enumerator.go rename to enumeration/remote/azurerm/azurerm_lb_enumerator.go index 8d966aa24..5ea34df32 100644 --- a/pkg/remote/azurerm/azurerm_lb_enumerator.go +++ b/enumeration/remote/azurerm/azurerm_lb_enumerator.go @@ -1,10 +1,10 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) type AzurermLoadBalancerEnumerator struct { diff --git a/pkg/remote/azurerm/azurerm_lb_rule_enumerator.go b/enumeration/remote/azurerm/azurerm_lb_rule_enumerator.go similarity index 85% rename from pkg/remote/azurerm/azurerm_lb_rule_enumerator.go rename to enumeration/remote/azurerm/azurerm_lb_rule_enumerator.go index e601f10c3..01a781fec 100644 --- a/pkg/remote/azurerm/azurerm_lb_rule_enumerator.go +++ b/enumeration/remote/azurerm/azurerm_lb_rule_enumerator.go @@ -1,10 +1,10 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) type AzurermLoadBalancerRuleEnumerator struct { diff --git a/pkg/remote/azurerm/azurerm_network_security_group_enumerator.go b/enumeration/remote/azurerm/azurerm_network_security_group_enumerator.go similarity index 83% rename from pkg/remote/azurerm/azurerm_network_security_group_enumerator.go rename to enumeration/remote/azurerm/azurerm_network_security_group_enumerator.go index 69925f77c..aede96440 100644 --- a/pkg/remote/azurerm/azurerm_network_security_group_enumerator.go +++ b/enumeration/remote/azurerm/azurerm_network_security_group_enumerator.go @@ -1,10 +1,10 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) type AzurermNetworkSecurityGroupEnumerator struct { diff --git a/pkg/remote/azurerm/azurerm_postgresql_database_enumerator.go b/enumeration/remote/azurerm/azurerm_postgresql_database_enumerator.go similarity index 85% rename from pkg/remote/azurerm/azurerm_postgresql_database_enumerator.go rename to enumeration/remote/azurerm/azurerm_postgresql_database_enumerator.go index d1818e20f..2283ec38b 100644 --- a/pkg/remote/azurerm/azurerm_postgresql_database_enumerator.go +++ b/enumeration/remote/azurerm/azurerm_postgresql_database_enumerator.go @@ -1,10 +1,10 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) type AzurermPostgresqlDatabaseEnumerator struct { diff --git a/pkg/remote/azurerm/azurerm_postgresql_server_enumerator.go b/enumeration/remote/azurerm/azurerm_postgresql_server_enumerator.go similarity index 81% rename from pkg/remote/azurerm/azurerm_postgresql_server_enumerator.go rename to enumeration/remote/azurerm/azurerm_postgresql_server_enumerator.go index 3646e128c..a874f921a 100644 --- a/pkg/remote/azurerm/azurerm_postgresql_server_enumerator.go +++ b/enumeration/remote/azurerm/azurerm_postgresql_server_enumerator.go @@ -1,10 +1,10 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) type AzurermPostgresqlServerEnumerator struct { diff --git a/pkg/remote/azurerm/azurerm_private_dns_cname_record_enumerator.go b/enumeration/remote/azurerm/azurerm_private_dns_cname_record_enumerator.go similarity index 85% rename from pkg/remote/azurerm/azurerm_private_dns_cname_record_enumerator.go rename to enumeration/remote/azurerm/azurerm_private_dns_cname_record_enumerator.go index 16ee70e7c..0a69dac14 100644 --- a/pkg/remote/azurerm/azurerm_private_dns_cname_record_enumerator.go +++ b/enumeration/remote/azurerm/azurerm_private_dns_cname_record_enumerator.go @@ -1,10 +1,10 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) type AzurermPrivateDNSCNameRecordEnumerator struct { diff --git a/pkg/remote/azurerm/azurerm_privatedns_a_record_enumerator.go b/enumeration/remote/azurerm/azurerm_privatedns_a_record_enumerator.go similarity index 85% rename from pkg/remote/azurerm/azurerm_privatedns_a_record_enumerator.go rename to enumeration/remote/azurerm/azurerm_privatedns_a_record_enumerator.go index 1ef54d833..6dc1fb250 100644 --- a/pkg/remote/azurerm/azurerm_privatedns_a_record_enumerator.go +++ b/enumeration/remote/azurerm/azurerm_privatedns_a_record_enumerator.go @@ -1,10 +1,10 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) type AzurermPrivateDNSARecordEnumerator struct { diff --git a/pkg/remote/azurerm/azurerm_privatedns_aaaa_record_enumerator.go b/enumeration/remote/azurerm/azurerm_privatedns_aaaa_record_enumerator.go similarity index 85% rename from pkg/remote/azurerm/azurerm_privatedns_aaaa_record_enumerator.go rename to enumeration/remote/azurerm/azurerm_privatedns_aaaa_record_enumerator.go index db7a04fff..b14223bb3 100644 --- a/pkg/remote/azurerm/azurerm_privatedns_aaaa_record_enumerator.go +++ b/enumeration/remote/azurerm/azurerm_privatedns_aaaa_record_enumerator.go @@ -1,10 +1,10 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) type AzurermPrivateDNSAAAARecordEnumerator struct { diff --git a/pkg/remote/azurerm/azurerm_privatedns_mx_record_enumerator.go b/enumeration/remote/azurerm/azurerm_privatedns_mx_record_enumerator.go similarity index 85% rename from pkg/remote/azurerm/azurerm_privatedns_mx_record_enumerator.go rename to enumeration/remote/azurerm/azurerm_privatedns_mx_record_enumerator.go index 915f9d8c4..5c532e832 100644 --- a/pkg/remote/azurerm/azurerm_privatedns_mx_record_enumerator.go +++ b/enumeration/remote/azurerm/azurerm_privatedns_mx_record_enumerator.go @@ -1,10 +1,10 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) type AzurermPrivateDNSMXRecordEnumerator struct { diff --git a/pkg/remote/azurerm/azurerm_privatedns_ptr_record_enumerator.go b/enumeration/remote/azurerm/azurerm_privatedns_ptr_record_enumerator.go similarity index 85% rename from pkg/remote/azurerm/azurerm_privatedns_ptr_record_enumerator.go rename to enumeration/remote/azurerm/azurerm_privatedns_ptr_record_enumerator.go index 224e8f9c7..fdfbd1361 100644 --- a/pkg/remote/azurerm/azurerm_privatedns_ptr_record_enumerator.go +++ b/enumeration/remote/azurerm/azurerm_privatedns_ptr_record_enumerator.go @@ -1,10 +1,10 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) type AzurermPrivateDNSPTRRecordEnumerator struct { diff --git a/pkg/remote/azurerm/azurerm_privatedns_srv_record_enumerator.go b/enumeration/remote/azurerm/azurerm_privatedns_srv_record_enumerator.go similarity index 85% rename from pkg/remote/azurerm/azurerm_privatedns_srv_record_enumerator.go rename to enumeration/remote/azurerm/azurerm_privatedns_srv_record_enumerator.go index 5855a789b..fdb998535 100644 --- a/pkg/remote/azurerm/azurerm_privatedns_srv_record_enumerator.go +++ b/enumeration/remote/azurerm/azurerm_privatedns_srv_record_enumerator.go @@ -1,10 +1,10 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) type AzurermPrivateDNSSRVRecordEnumerator struct { diff --git a/pkg/remote/azurerm/azurerm_privatedns_txt_record_enumerator.go b/enumeration/remote/azurerm/azurerm_privatedns_txt_record_enumerator.go similarity index 85% rename from pkg/remote/azurerm/azurerm_privatedns_txt_record_enumerator.go rename to enumeration/remote/azurerm/azurerm_privatedns_txt_record_enumerator.go index dd56f6c30..ec0047fb8 100644 --- a/pkg/remote/azurerm/azurerm_privatedns_txt_record_enumerator.go +++ b/enumeration/remote/azurerm/azurerm_privatedns_txt_record_enumerator.go @@ -1,10 +1,10 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) type AzurermPrivateDNSTXTRecordEnumerator struct { diff --git a/pkg/remote/azurerm/azurerm_privatedns_zone_enumerator.go b/enumeration/remote/azurerm/azurerm_privatedns_zone_enumerator.go similarity index 81% rename from pkg/remote/azurerm/azurerm_privatedns_zone_enumerator.go rename to enumeration/remote/azurerm/azurerm_privatedns_zone_enumerator.go index a1e010971..afa152a04 100644 --- a/pkg/remote/azurerm/azurerm_privatedns_zone_enumerator.go +++ b/enumeration/remote/azurerm/azurerm_privatedns_zone_enumerator.go @@ -1,10 +1,10 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) type AzurermPrivateDNSZoneEnumerator struct { diff --git a/pkg/remote/azurerm/azurerm_public_ip_enumerator.go b/enumeration/remote/azurerm/azurerm_public_ip_enumerator.go similarity index 81% rename from pkg/remote/azurerm/azurerm_public_ip_enumerator.go rename to enumeration/remote/azurerm/azurerm_public_ip_enumerator.go index 4a3c45c89..9b9dfe748 100644 --- a/pkg/remote/azurerm/azurerm_public_ip_enumerator.go +++ b/enumeration/remote/azurerm/azurerm_public_ip_enumerator.go @@ -1,10 +1,10 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) type AzurermPublicIPEnumerator struct { diff --git a/pkg/remote/azurerm/azurerm_resource_group_enumerator.go b/enumeration/remote/azurerm/azurerm_resource_group_enumerator.go similarity index 81% rename from pkg/remote/azurerm/azurerm_resource_group_enumerator.go rename to enumeration/remote/azurerm/azurerm_resource_group_enumerator.go index 0867cca73..07a0a23b2 100644 --- a/pkg/remote/azurerm/azurerm_resource_group_enumerator.go +++ b/enumeration/remote/azurerm/azurerm_resource_group_enumerator.go @@ -1,10 +1,10 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) type AzurermResourceGroupEnumerator struct { diff --git a/pkg/remote/azurerm/azurerm_route_enumerator.go b/enumeration/remote/azurerm/azurerm_route_enumerator.go similarity index 83% rename from pkg/remote/azurerm/azurerm_route_enumerator.go rename to enumeration/remote/azurerm/azurerm_route_enumerator.go index 6f3ce148b..72883051b 100644 --- a/pkg/remote/azurerm/azurerm_route_enumerator.go +++ b/enumeration/remote/azurerm/azurerm_route_enumerator.go @@ -1,10 +1,10 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) type AzurermRouteEnumerator struct { diff --git a/pkg/remote/azurerm/azurerm_route_table_enumerator.go b/enumeration/remote/azurerm/azurerm_route_table_enumerator.go similarity index 81% rename from pkg/remote/azurerm/azurerm_route_table_enumerator.go rename to enumeration/remote/azurerm/azurerm_route_table_enumerator.go index 6731de6cb..85a5bec4b 100644 --- a/pkg/remote/azurerm/azurerm_route_table_enumerator.go +++ b/enumeration/remote/azurerm/azurerm_route_table_enumerator.go @@ -1,10 +1,10 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) type AzurermRouteTableEnumerator struct { diff --git a/pkg/remote/azurerm/azurerm_ssh_public_key_enumerator.go b/enumeration/remote/azurerm/azurerm_ssh_public_key_enumerator.go similarity index 81% rename from pkg/remote/azurerm/azurerm_ssh_public_key_enumerator.go rename to enumeration/remote/azurerm/azurerm_ssh_public_key_enumerator.go index 604f8cf35..0ea0326de 100644 --- a/pkg/remote/azurerm/azurerm_ssh_public_key_enumerator.go +++ b/enumeration/remote/azurerm/azurerm_ssh_public_key_enumerator.go @@ -1,10 +1,10 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) type AzurermSSHPublicKeyEnumerator struct { diff --git a/pkg/remote/azurerm/azurerm_storage_account_enumerator.go b/enumeration/remote/azurerm/azurerm_storage_account_enumerator.go similarity index 81% rename from pkg/remote/azurerm/azurerm_storage_account_enumerator.go rename to enumeration/remote/azurerm/azurerm_storage_account_enumerator.go index ba6a18779..0b1a8947e 100644 --- a/pkg/remote/azurerm/azurerm_storage_account_enumerator.go +++ b/enumeration/remote/azurerm/azurerm_storage_account_enumerator.go @@ -1,10 +1,10 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) type AzurermStorageAccountEnumerator struct { diff --git a/pkg/remote/azurerm/azurerm_storage_container_enumerator.go b/enumeration/remote/azurerm/azurerm_storage_container_enumerator.go similarity index 84% rename from pkg/remote/azurerm/azurerm_storage_container_enumerator.go rename to enumeration/remote/azurerm/azurerm_storage_container_enumerator.go index 09bb9b355..58729e6ef 100644 --- a/pkg/remote/azurerm/azurerm_storage_container_enumerator.go +++ b/enumeration/remote/azurerm/azurerm_storage_container_enumerator.go @@ -1,10 +1,10 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) type AzurermStorageContainerEnumerator struct { diff --git a/pkg/remote/azurerm/azurerm_subnets_enumerator.go b/enumeration/remote/azurerm/azurerm_subnets_enumerator.go similarity index 83% rename from pkg/remote/azurerm/azurerm_subnets_enumerator.go rename to enumeration/remote/azurerm/azurerm_subnets_enumerator.go index 64f72523f..4f2bffa59 100644 --- a/pkg/remote/azurerm/azurerm_subnets_enumerator.go +++ b/enumeration/remote/azurerm/azurerm_subnets_enumerator.go @@ -1,10 +1,10 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) type AzurermSubnetEnumerator struct { diff --git a/pkg/remote/azurerm/azurerm_virtual_network_enumerator.go b/enumeration/remote/azurerm/azurerm_virtual_network_enumerator.go similarity index 81% rename from pkg/remote/azurerm/azurerm_virtual_network_enumerator.go rename to enumeration/remote/azurerm/azurerm_virtual_network_enumerator.go index 5069539eb..b55c8a78d 100644 --- a/pkg/remote/azurerm/azurerm_virtual_network_enumerator.go +++ b/enumeration/remote/azurerm/azurerm_virtual_network_enumerator.go @@ -1,10 +1,10 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) type AzurermVirtualNetworkEnumerator struct { diff --git a/pkg/remote/azurerm/common/config.go b/enumeration/remote/azurerm/common/config.go similarity index 100% rename from pkg/remote/azurerm/common/config.go rename to enumeration/remote/azurerm/common/config.go diff --git a/pkg/remote/azurerm/init.go b/enumeration/remote/azurerm/init.go similarity index 62% rename from pkg/remote/azurerm/init.go rename to enumeration/remote/azurerm/init.go index 23523eeee..a0eb44803 100644 --- a/pkg/remote/azurerm/init.go +++ b/enumeration/remote/azurerm/init.go @@ -3,22 +3,22 @@ package azurerm import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/snyk/driftctl/pkg/alerter" - "github.com/snyk/driftctl/pkg/output" - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/alerter" + repository2 "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" + "github.com/snyk/driftctl/enumeration/terraform" ) func Init( version string, alerter *alerter.Alerter, providerLibrary *terraform.ProviderLibrary, - remoteLibrary *common.RemoteLibrary, - progress output.Progress, + remoteLibrary *common2.RemoteLibrary, + progress enumeration.ProgressCounter, resourceSchemaRepository *resource.SchemaRepository, factory resource.ResourceFactory, configDir string) error { @@ -45,13 +45,13 @@ func Init( c := cache.New(100) - storageAccountRepo := repository.NewStorageRepository(cred, clientOptions, providerConfig, c) - networkRepo := repository.NewNetworkRepository(cred, clientOptions, providerConfig, c) - resourcesRepo := repository.NewResourcesRepository(cred, clientOptions, providerConfig, c) - containerRegistryRepo := repository.NewContainerRegistryRepository(cred, clientOptions, providerConfig, c) - postgresqlRepo := repository.NewPostgresqlRepository(cred, clientOptions, providerConfig, c) - privateDNSRepo := repository.NewPrivateDNSRepository(cred, clientOptions, providerConfig, c) - computeRepo := repository.NewComputeRepository(cred, clientOptions, providerConfig, c) + storageAccountRepo := repository2.NewStorageRepository(cred, clientOptions, providerConfig, c) + networkRepo := repository2.NewNetworkRepository(cred, clientOptions, providerConfig, c) + resourcesRepo := repository2.NewResourcesRepository(cred, clientOptions, providerConfig, c) + containerRegistryRepo := repository2.NewContainerRegistryRepository(cred, clientOptions, providerConfig, c) + postgresqlRepo := repository2.NewPostgresqlRepository(cred, clientOptions, providerConfig, c) + privateDNSRepo := repository2.NewPrivateDNSRepository(cred, clientOptions, providerConfig, c) + computeRepo := repository2.NewComputeRepository(cred, clientOptions, providerConfig, c) providerLibrary.AddProvider(terraform.AZURE, provider) deserializer := resource.NewDeserializer(factory) @@ -69,31 +69,31 @@ func Init( remoteLibrary.AddEnumerator(NewAzurermPublicIPEnumerator(networkRepo, factory)) remoteLibrary.AddEnumerator(NewAzurermPostgresqlDatabaseEnumerator(postgresqlRepo, factory)) remoteLibrary.AddEnumerator(NewAzurermNetworkSecurityGroupEnumerator(networkRepo, factory)) - remoteLibrary.AddDetailsFetcher(azurerm.AzureNetworkSecurityGroupResourceType, common.NewGenericDetailsFetcher(azurerm.AzureNetworkSecurityGroupResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(azurerm.AzureNetworkSecurityGroupResourceType, common2.NewGenericDetailsFetcher(azurerm.AzureNetworkSecurityGroupResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewAzurermLoadBalancerEnumerator(networkRepo, factory)) remoteLibrary.AddEnumerator(NewAzurermLoadBalancerRuleEnumerator(networkRepo, factory)) - remoteLibrary.AddDetailsFetcher(azurerm.AzureLoadBalancerRuleResourceType, common.NewGenericDetailsFetcher(azurerm.AzureLoadBalancerRuleResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(azurerm.AzureLoadBalancerRuleResourceType, common2.NewGenericDetailsFetcher(azurerm.AzureLoadBalancerRuleResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewAzurermPrivateDNSZoneEnumerator(privateDNSRepo, factory)) - remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSZoneResourceType, common.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSZoneResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSZoneResourceType, common2.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSZoneResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewAzurermPrivateDNSARecordEnumerator(privateDNSRepo, factory)) - remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSARecordResourceType, common.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSARecordResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSARecordResourceType, common2.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSARecordResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewAzurermPrivateDNSAAAARecordEnumerator(privateDNSRepo, factory)) - remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSAAAARecordResourceType, common.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSAAAARecordResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSAAAARecordResourceType, common2.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSAAAARecordResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewAzurermPrivateDNSMXRecordEnumerator(privateDNSRepo, factory)) - remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSMXRecordResourceType, common.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSMXRecordResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSMXRecordResourceType, common2.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSMXRecordResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewAzurermPrivateDNSCNameRecordEnumerator(privateDNSRepo, factory)) - remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSCNameRecordResourceType, common.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSCNameRecordResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSCNameRecordResourceType, common2.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSCNameRecordResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewAzurermPrivateDNSPTRRecordEnumerator(privateDNSRepo, factory)) - remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSPTRRecordResourceType, common.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSPTRRecordResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSPTRRecordResourceType, common2.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSPTRRecordResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewAzurermPrivateDNSSRVRecordEnumerator(privateDNSRepo, factory)) - remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSSRVRecordResourceType, common.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSSRVRecordResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSSRVRecordResourceType, common2.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSSRVRecordResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewAzurermPrivateDNSTXTRecordEnumerator(privateDNSRepo, factory)) - remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSTXTRecordResourceType, common.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSTXTRecordResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSTXTRecordResourceType, common2.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSTXTRecordResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewAzurermImageEnumerator(computeRepo, factory)) remoteLibrary.AddEnumerator(NewAzurermSSHPublicKeyEnumerator(computeRepo, factory)) - remoteLibrary.AddDetailsFetcher(azurerm.AzureSSHPublicKeyResourceType, common.NewGenericDetailsFetcher(azurerm.AzureSSHPublicKeyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(azurerm.AzureSSHPublicKeyResourceType, common2.NewGenericDetailsFetcher(azurerm.AzureSSHPublicKeyResourceType, provider, deserializer)) err = resourceSchemaRepository.Init(terraform.AZURE, provider.Version(), provider.Schema()) if err != nil { diff --git a/pkg/remote/azurerm/provider.go b/enumeration/remote/azurerm/provider.go similarity index 83% rename from pkg/remote/azurerm/provider.go rename to enumeration/remote/azurerm/provider.go index b9a3bc8b4..f516fa49b 100644 --- a/pkg/remote/azurerm/provider.go +++ b/enumeration/remote/azurerm/provider.go @@ -7,10 +7,10 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/snyk/driftctl/pkg/output" - "github.com/snyk/driftctl/pkg/remote/azurerm/common" - "github.com/snyk/driftctl/pkg/remote/terraform" - tf "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/azurerm/common" + "github.com/snyk/driftctl/enumeration/remote/terraform" + terraform2 "github.com/snyk/driftctl/enumeration/terraform" ) type AzureTerraformProvider struct { @@ -19,17 +19,17 @@ type AzureTerraformProvider struct { version string } -func NewAzureTerraformProvider(version string, progress output.Progress, configDir string) (*AzureTerraformProvider, error) { +func NewAzureTerraformProvider(version string, progress enumeration.ProgressCounter, configDir string) (*AzureTerraformProvider, error) { if version == "" { version = "2.71.0" } // Just pass your version and name p := &AzureTerraformProvider{ version: version, - name: tf.AZURE, + name: terraform2.AZURE, } // Use TerraformProviderInstaller to retrieve the provider if needed - installer, err := tf.NewProviderInstaller(tf.ProviderConfig{ + installer, err := terraform2.NewProviderInstaller(terraform2.ProviderConfig{ Key: p.name, Version: version, ConfigDir: configDir, diff --git a/pkg/remote/azurerm/repository/compute.go b/enumeration/remote/azurerm/repository/compute.go similarity index 96% rename from pkg/remote/azurerm/repository/compute.go rename to enumeration/remote/azurerm/repository/compute.go index 31aa65447..414995329 100644 --- a/pkg/remote/azurerm/repository/compute.go +++ b/enumeration/remote/azurerm/repository/compute.go @@ -2,12 +2,12 @@ package repository import ( "context" + "github.com/snyk/driftctl/enumeration/remote/azurerm/common" + "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute" - "github.com/snyk/driftctl/pkg/remote/azurerm/common" - "github.com/snyk/driftctl/pkg/remote/cache" ) type ComputeRepository interface { diff --git a/pkg/remote/azurerm/repository/compute_test.go b/enumeration/remote/azurerm/repository/compute_test.go similarity index 99% rename from pkg/remote/azurerm/repository/compute_test.go rename to enumeration/remote/azurerm/repository/compute_test.go index 8d416bcd8..2769be5d3 100644 --- a/pkg/remote/azurerm/repository/compute_test.go +++ b/enumeration/remote/azurerm/repository/compute_test.go @@ -1,13 +1,13 @@ package repository import ( + "github.com/snyk/driftctl/enumeration/remote/cache" "reflect" "testing" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute" "github.com/pkg/errors" - "github.com/snyk/driftctl/pkg/remote/cache" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) diff --git a/pkg/remote/azurerm/repository/containerregistry.go b/enumeration/remote/azurerm/repository/containerregistry.go similarity index 94% rename from pkg/remote/azurerm/repository/containerregistry.go rename to enumeration/remote/azurerm/repository/containerregistry.go index fd1b35b5b..99245a9b5 100644 --- a/pkg/remote/azurerm/repository/containerregistry.go +++ b/enumeration/remote/azurerm/repository/containerregistry.go @@ -2,12 +2,12 @@ package repository import ( "context" + "github.com/snyk/driftctl/enumeration/remote/azurerm/common" + "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry" - "github.com/snyk/driftctl/pkg/remote/azurerm/common" - "github.com/snyk/driftctl/pkg/remote/cache" ) type ContainerRegistryRepository interface { diff --git a/pkg/remote/azurerm/repository/containerregistry_test.go b/enumeration/remote/azurerm/repository/containerregistry_test.go similarity index 98% rename from pkg/remote/azurerm/repository/containerregistry_test.go rename to enumeration/remote/azurerm/repository/containerregistry_test.go index 5df8159df..a204b2948 100644 --- a/pkg/remote/azurerm/repository/containerregistry_test.go +++ b/enumeration/remote/azurerm/repository/containerregistry_test.go @@ -1,13 +1,13 @@ package repository import ( + "github.com/snyk/driftctl/enumeration/remote/cache" "reflect" "testing" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry" "github.com/pkg/errors" - "github.com/snyk/driftctl/pkg/remote/cache" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) diff --git a/pkg/remote/azurerm/repository/mock_ComputeRepository.go b/enumeration/remote/azurerm/repository/mock_ComputeRepository.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_ComputeRepository.go rename to enumeration/remote/azurerm/repository/mock_ComputeRepository.go diff --git a/pkg/remote/azurerm/repository/mock_ContainerRegistryRepository.go b/enumeration/remote/azurerm/repository/mock_ContainerRegistryRepository.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_ContainerRegistryRepository.go rename to enumeration/remote/azurerm/repository/mock_ContainerRegistryRepository.go diff --git a/pkg/remote/azurerm/repository/mock_NetworkRepository.go b/enumeration/remote/azurerm/repository/mock_NetworkRepository.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_NetworkRepository.go rename to enumeration/remote/azurerm/repository/mock_NetworkRepository.go diff --git a/pkg/remote/azurerm/repository/mock_PostgresqlRespository.go b/enumeration/remote/azurerm/repository/mock_PostgresqlRespository.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_PostgresqlRespository.go rename to enumeration/remote/azurerm/repository/mock_PostgresqlRespository.go diff --git a/pkg/remote/azurerm/repository/mock_PrivateDNSRepository.go b/enumeration/remote/azurerm/repository/mock_PrivateDNSRepository.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_PrivateDNSRepository.go rename to enumeration/remote/azurerm/repository/mock_PrivateDNSRepository.go diff --git a/pkg/remote/azurerm/repository/mock_ResourcesRepository.go b/enumeration/remote/azurerm/repository/mock_ResourcesRepository.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_ResourcesRepository.go rename to enumeration/remote/azurerm/repository/mock_ResourcesRepository.go diff --git a/pkg/remote/azurerm/repository/mock_StorageRespository.go b/enumeration/remote/azurerm/repository/mock_StorageRespository.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_StorageRespository.go rename to enumeration/remote/azurerm/repository/mock_StorageRespository.go diff --git a/pkg/remote/azurerm/repository/mock_blobContainerClient.go b/enumeration/remote/azurerm/repository/mock_blobContainerClient.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_blobContainerClient.go rename to enumeration/remote/azurerm/repository/mock_blobContainerClient.go diff --git a/pkg/remote/azurerm/repository/mock_blobContainerListPager.go b/enumeration/remote/azurerm/repository/mock_blobContainerListPager.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_blobContainerListPager.go rename to enumeration/remote/azurerm/repository/mock_blobContainerListPager.go diff --git a/pkg/remote/azurerm/repository/mock_firewallsClient.go b/enumeration/remote/azurerm/repository/mock_firewallsClient.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_firewallsClient.go rename to enumeration/remote/azurerm/repository/mock_firewallsClient.go diff --git a/pkg/remote/azurerm/repository/mock_firewallsListAllPager.go b/enumeration/remote/azurerm/repository/mock_firewallsListAllPager.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_firewallsListAllPager.go rename to enumeration/remote/azurerm/repository/mock_firewallsListAllPager.go diff --git a/pkg/remote/azurerm/repository/mock_imagesClient.go b/enumeration/remote/azurerm/repository/mock_imagesClient.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_imagesClient.go rename to enumeration/remote/azurerm/repository/mock_imagesClient.go diff --git a/pkg/remote/azurerm/repository/mock_imagesListPager.go b/enumeration/remote/azurerm/repository/mock_imagesListPager.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_imagesListPager.go rename to enumeration/remote/azurerm/repository/mock_imagesListPager.go diff --git a/pkg/remote/azurerm/repository/mock_loadBalancerRulesClient.go b/enumeration/remote/azurerm/repository/mock_loadBalancerRulesClient.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_loadBalancerRulesClient.go rename to enumeration/remote/azurerm/repository/mock_loadBalancerRulesClient.go diff --git a/pkg/remote/azurerm/repository/mock_loadBalancerRulesListAllPager.go b/enumeration/remote/azurerm/repository/mock_loadBalancerRulesListAllPager.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_loadBalancerRulesListAllPager.go rename to enumeration/remote/azurerm/repository/mock_loadBalancerRulesListAllPager.go diff --git a/pkg/remote/azurerm/repository/mock_loadBalancersClient.go b/enumeration/remote/azurerm/repository/mock_loadBalancersClient.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_loadBalancersClient.go rename to enumeration/remote/azurerm/repository/mock_loadBalancersClient.go diff --git a/pkg/remote/azurerm/repository/mock_loadBalancersListAllPager.go b/enumeration/remote/azurerm/repository/mock_loadBalancersListAllPager.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_loadBalancersListAllPager.go rename to enumeration/remote/azurerm/repository/mock_loadBalancersListAllPager.go diff --git a/pkg/remote/azurerm/repository/mock_networkSecurityGroupsClient.go b/enumeration/remote/azurerm/repository/mock_networkSecurityGroupsClient.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_networkSecurityGroupsClient.go rename to enumeration/remote/azurerm/repository/mock_networkSecurityGroupsClient.go diff --git a/pkg/remote/azurerm/repository/mock_networkSecurityGroupsListAllPager.go b/enumeration/remote/azurerm/repository/mock_networkSecurityGroupsListAllPager.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_networkSecurityGroupsListAllPager.go rename to enumeration/remote/azurerm/repository/mock_networkSecurityGroupsListAllPager.go diff --git a/pkg/remote/azurerm/repository/mock_postgresqlDatabaseClient.go b/enumeration/remote/azurerm/repository/mock_postgresqlDatabaseClient.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_postgresqlDatabaseClient.go rename to enumeration/remote/azurerm/repository/mock_postgresqlDatabaseClient.go diff --git a/pkg/remote/azurerm/repository/mock_postgresqlServersClient.go b/enumeration/remote/azurerm/repository/mock_postgresqlServersClient.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_postgresqlServersClient.go rename to enumeration/remote/azurerm/repository/mock_postgresqlServersClient.go diff --git a/pkg/remote/azurerm/repository/mock_privateDNSRecordSetListPager.go b/enumeration/remote/azurerm/repository/mock_privateDNSRecordSetListPager.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_privateDNSRecordSetListPager.go rename to enumeration/remote/azurerm/repository/mock_privateDNSRecordSetListPager.go diff --git a/pkg/remote/azurerm/repository/mock_privateDNSZoneListPager.go b/enumeration/remote/azurerm/repository/mock_privateDNSZoneListPager.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_privateDNSZoneListPager.go rename to enumeration/remote/azurerm/repository/mock_privateDNSZoneListPager.go diff --git a/pkg/remote/azurerm/repository/mock_privateRecordSetClient.go b/enumeration/remote/azurerm/repository/mock_privateRecordSetClient.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_privateRecordSetClient.go rename to enumeration/remote/azurerm/repository/mock_privateRecordSetClient.go diff --git a/pkg/remote/azurerm/repository/mock_privateZonesClient.go b/enumeration/remote/azurerm/repository/mock_privateZonesClient.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_privateZonesClient.go rename to enumeration/remote/azurerm/repository/mock_privateZonesClient.go diff --git a/pkg/remote/azurerm/repository/mock_publicIPAddressesClient.go b/enumeration/remote/azurerm/repository/mock_publicIPAddressesClient.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_publicIPAddressesClient.go rename to enumeration/remote/azurerm/repository/mock_publicIPAddressesClient.go diff --git a/pkg/remote/azurerm/repository/mock_publicIPAddressesListAllPager.go b/enumeration/remote/azurerm/repository/mock_publicIPAddressesListAllPager.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_publicIPAddressesListAllPager.go rename to enumeration/remote/azurerm/repository/mock_publicIPAddressesListAllPager.go diff --git a/pkg/remote/azurerm/repository/mock_registryClient.go b/enumeration/remote/azurerm/repository/mock_registryClient.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_registryClient.go rename to enumeration/remote/azurerm/repository/mock_registryClient.go diff --git a/pkg/remote/azurerm/repository/mock_registryListAllPager.go b/enumeration/remote/azurerm/repository/mock_registryListAllPager.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_registryListAllPager.go rename to enumeration/remote/azurerm/repository/mock_registryListAllPager.go diff --git a/pkg/remote/azurerm/repository/mock_resourcesClient.go b/enumeration/remote/azurerm/repository/mock_resourcesClient.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_resourcesClient.go rename to enumeration/remote/azurerm/repository/mock_resourcesClient.go diff --git a/pkg/remote/azurerm/repository/mock_resourcesListPager.go b/enumeration/remote/azurerm/repository/mock_resourcesListPager.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_resourcesListPager.go rename to enumeration/remote/azurerm/repository/mock_resourcesListPager.go diff --git a/pkg/remote/azurerm/repository/mock_routeTablesClient.go b/enumeration/remote/azurerm/repository/mock_routeTablesClient.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_routeTablesClient.go rename to enumeration/remote/azurerm/repository/mock_routeTablesClient.go diff --git a/pkg/remote/azurerm/repository/mock_routeTablesListAllPager.go b/enumeration/remote/azurerm/repository/mock_routeTablesListAllPager.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_routeTablesListAllPager.go rename to enumeration/remote/azurerm/repository/mock_routeTablesListAllPager.go diff --git a/pkg/remote/azurerm/repository/mock_sshPublicKeyClient.go b/enumeration/remote/azurerm/repository/mock_sshPublicKeyClient.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_sshPublicKeyClient.go rename to enumeration/remote/azurerm/repository/mock_sshPublicKeyClient.go diff --git a/pkg/remote/azurerm/repository/mock_sshPublicKeyListPager.go b/enumeration/remote/azurerm/repository/mock_sshPublicKeyListPager.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_sshPublicKeyListPager.go rename to enumeration/remote/azurerm/repository/mock_sshPublicKeyListPager.go diff --git a/pkg/remote/azurerm/repository/mock_storageAccountClient.go b/enumeration/remote/azurerm/repository/mock_storageAccountClient.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_storageAccountClient.go rename to enumeration/remote/azurerm/repository/mock_storageAccountClient.go diff --git a/pkg/remote/azurerm/repository/mock_storageAccountListPager.go b/enumeration/remote/azurerm/repository/mock_storageAccountListPager.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_storageAccountListPager.go rename to enumeration/remote/azurerm/repository/mock_storageAccountListPager.go diff --git a/pkg/remote/azurerm/repository/mock_subnetsClient.go b/enumeration/remote/azurerm/repository/mock_subnetsClient.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_subnetsClient.go rename to enumeration/remote/azurerm/repository/mock_subnetsClient.go diff --git a/pkg/remote/azurerm/repository/mock_subnetsListPager.go b/enumeration/remote/azurerm/repository/mock_subnetsListPager.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_subnetsListPager.go rename to enumeration/remote/azurerm/repository/mock_subnetsListPager.go diff --git a/pkg/remote/azurerm/repository/mock_virtualNetworkClient.go b/enumeration/remote/azurerm/repository/mock_virtualNetworkClient.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_virtualNetworkClient.go rename to enumeration/remote/azurerm/repository/mock_virtualNetworkClient.go diff --git a/pkg/remote/azurerm/repository/mock_virtualNetworksListAllPager.go b/enumeration/remote/azurerm/repository/mock_virtualNetworksListAllPager.go similarity index 100% rename from pkg/remote/azurerm/repository/mock_virtualNetworksListAllPager.go rename to enumeration/remote/azurerm/repository/mock_virtualNetworksListAllPager.go diff --git a/pkg/remote/azurerm/repository/network.go b/enumeration/remote/azurerm/repository/network.go similarity index 99% rename from pkg/remote/azurerm/repository/network.go rename to enumeration/remote/azurerm/repository/network.go index da9c131e0..3c65d112e 100644 --- a/pkg/remote/azurerm/repository/network.go +++ b/enumeration/remote/azurerm/repository/network.go @@ -3,13 +3,13 @@ package repository import ( "context" "fmt" + "github.com/snyk/driftctl/enumeration/remote/azurerm/common" + "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork" "github.com/Azure/go-autorest/autorest/azure" - "github.com/snyk/driftctl/pkg/remote/azurerm/common" - "github.com/snyk/driftctl/pkg/remote/cache" ) type NetworkRepository interface { diff --git a/pkg/remote/azurerm/repository/network_test.go b/enumeration/remote/azurerm/repository/network_test.go similarity index 95% rename from pkg/remote/azurerm/repository/network_test.go rename to enumeration/remote/azurerm/repository/network_test.go index fa42fdfab..450064d9c 100644 --- a/pkg/remote/azurerm/repository/network_test.go +++ b/enumeration/remote/azurerm/repository/network_test.go @@ -3,13 +3,13 @@ package repository import ( "context" "fmt" + cache2 "github.com/snyk/driftctl/enumeration/remote/cache" "reflect" "testing" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork" "github.com/pkg/errors" - "github.com/snyk/driftctl/pkg/remote/cache" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -84,7 +84,7 @@ func Test_ListAllVirtualNetwork_MultiplesResults(t *testing.T) { fakeClient.On("ListAll", mock.Anything).Return(mockPager) - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("GetAndLock", "ListAllVirtualNetworks").Return(nil).Times(1) c.On("Unlock", "ListAllVirtualNetworks").Times(1) c.On("Put", "ListAllVirtualNetworks", expected).Return(true).Times(1) @@ -119,7 +119,7 @@ func Test_ListAllVirtualNetwork_MultiplesResults_WithCache(t *testing.T) { fakeClient := &mockVirtualNetworkClient{} - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("GetAndLock", "ListAllVirtualNetworks").Return(expected).Times(1) c.On("Unlock", "ListAllVirtualNetworks").Times(1) s := &networkRepository{ @@ -155,7 +155,7 @@ func Test_ListAllVirtualNetwork_Error_OnPageResponse(t *testing.T) { s := &networkRepository{ virtualNetworksClient: fakeClient, - cache: cache.New(0), + cache: cache2.New(0), } got, err := s.ListAllVirtualNetworks() @@ -180,7 +180,7 @@ func Test_ListAllVirtualNetwork_Error(t *testing.T) { s := &networkRepository{ virtualNetworksClient: fakeClient, - cache: cache.New(0), + cache: cache2.New(0), } got, err := s.ListAllVirtualNetworks() @@ -239,7 +239,7 @@ func Test_ListAllRouteTables_MultiplesResults(t *testing.T) { fakeClient.On("ListAll", mock.Anything).Return(mockPager) - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("GetAndLock", "ListAllRouteTables").Return(nil).Times(1) c.On("Unlock", "ListAllRouteTables").Times(1) c.On("Put", "ListAllRouteTables", expected).Return(true).Times(1) @@ -274,7 +274,7 @@ func Test_ListAllRouteTables_MultiplesResults_WithCache(t *testing.T) { fakeClient := &mockRouteTablesClient{} - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("GetAndLock", "ListAllRouteTables").Return(expected).Times(1) c.On("Unlock", "ListAllRouteTables").Times(1) s := &networkRepository{ @@ -310,7 +310,7 @@ func Test_ListAllRouteTables_Error_OnPageResponse(t *testing.T) { s := &networkRepository{ routeTableClient: fakeClient, - cache: cache.New(0), + cache: cache2.New(0), } got, err := s.ListAllRouteTables() @@ -335,7 +335,7 @@ func Test_ListAllRouteTables_Error(t *testing.T) { s := &networkRepository{ routeTableClient: fakeClient, - cache: cache.New(0), + cache: cache2.New(0), } got, err := s.ListAllRouteTables() @@ -423,7 +423,7 @@ func Test_ListAllSubnets_MultiplesResults(t *testing.T) { fakeClient.On("List", "test-dev", "network1", mock.Anything).Return(mockPager) - c := &cache.MockCache{} + c := &cache2.MockCache{} cacheKey := fmt.Sprintf("ListAllSubnets_%s", *network.ID) c.On("Get", cacheKey).Return(nil).Times(1) c.On("Put", cacheKey, expected).Return(true).Times(1) @@ -461,7 +461,7 @@ func Test_ListAllSubnets_MultiplesResults_WithCache(t *testing.T) { } fakeClient := &mockSubnetsClient{} - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("Get", "ListAllSubnets_networkID").Return(expected).Times(1) s := &networkRepository{ subnetsClient: fakeClient, @@ -503,7 +503,7 @@ func Test_ListAllSubnets_Error_OnPageResponse(t *testing.T) { s := &networkRepository{ subnetsClient: fakeClient, - cache: cache.New(0), + cache: cache2.New(0), } got, err := s.ListAllSubnets(network) @@ -535,7 +535,7 @@ func Test_ListAllSubnets_Error(t *testing.T) { s := &networkRepository{ subnetsClient: fakeClient, - cache: cache.New(0), + cache: cache2.New(0), } got, err := s.ListAllSubnets(network) @@ -561,7 +561,7 @@ func Test_ListAllSubnets_ErrorOnInvalidNetworkID(t *testing.T) { s := &networkRepository{ subnetsClient: fakeClient, - cache: cache.New(0), + cache: cache2.New(0), } got, err := s.ListAllSubnets(network) @@ -619,7 +619,7 @@ func Test_ListAllFirewalls_MultiplesResults(t *testing.T) { fakeClient.On("ListAll", mock.Anything).Return(mockPager) - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("Get", "ListAllFirewalls").Return(nil).Times(1) c.On("Put", "ListAllFirewalls", expected).Return(true).Times(1) s := &networkRepository{ @@ -653,7 +653,7 @@ func Test_ListAllFirewalls_MultiplesResults_WithCache(t *testing.T) { fakeClient := &mockFirewallsClient{} - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("Get", "ListAllFirewalls").Return(expected).Times(1) s := &networkRepository{ firewallsClient: fakeClient, @@ -688,7 +688,7 @@ func Test_ListAllFirewalls_Error_OnPageResponse(t *testing.T) { s := &networkRepository{ firewallsClient: fakeClient, - cache: cache.New(0), + cache: cache2.New(0), } got, err := s.ListAllFirewalls() @@ -713,7 +713,7 @@ func Test_ListAllFirewalls_Error(t *testing.T) { s := &networkRepository{ firewallsClient: fakeClient, - cache: cache.New(0), + cache: cache2.New(0), } got, err := s.ListAllFirewalls() @@ -772,7 +772,7 @@ func Test_ListAllPublicIPAddresses_MultiplesResults(t *testing.T) { fakeClient.On("ListAll", mock.Anything).Return(mockPager) - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("Get", "ListAllPublicIPAddresses").Return(nil).Times(1) c.On("Put", "ListAllPublicIPAddresses", expected).Return(true).Times(1) s := &networkRepository{ @@ -806,7 +806,7 @@ func Test_ListAllPublicIPAddresses_MultiplesResults_WithCache(t *testing.T) { fakeClient := &mockPublicIPAddressesClient{} - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("Get", "ListAllPublicIPAddresses").Return(expected).Times(1) s := &networkRepository{ publicIPAddressesClient: fakeClient, @@ -841,7 +841,7 @@ func Test_ListAllPublicIPAddresses_Error_OnPageResponse(t *testing.T) { s := &networkRepository{ publicIPAddressesClient: fakeClient, - cache: cache.New(0), + cache: cache2.New(0), } got, err := s.ListAllPublicIPAddresses() @@ -866,7 +866,7 @@ func Test_ListAllPublicIPAddresses_Error(t *testing.T) { s := &networkRepository{ publicIPAddressesClient: fakeClient, - cache: cache.New(0), + cache: cache2.New(0), } got, err := s.ListAllPublicIPAddresses() @@ -895,13 +895,13 @@ func Test_Network_ListAllSecurityGroups(t *testing.T) { testcases := []struct { name string - mocks func(*mockNetworkSecurityGroupsListAllPager, *cache.MockCache) + mocks func(*mockNetworkSecurityGroupsListAllPager, *cache2.MockCache) expected []*armnetwork.NetworkSecurityGroup wantErr string }{ { name: "should return security groups", - mocks: func(pager *mockNetworkSecurityGroupsListAllPager, mockCache *cache.MockCache) { + mocks: func(pager *mockNetworkSecurityGroupsListAllPager, mockCache *cache2.MockCache) { pager.On("NextPage", context.Background()).Return(true).Times(1) pager.On("NextPage", context.Background()).Return(false).Times(1) pager.On("PageResponse").Return(armnetwork.NetworkSecurityGroupsListAllResponse{ @@ -920,14 +920,14 @@ func Test_Network_ListAllSecurityGroups(t *testing.T) { }, { name: "should hit cache and return security groups", - mocks: func(pager *mockNetworkSecurityGroupsListAllPager, mockCache *cache.MockCache) { + mocks: func(pager *mockNetworkSecurityGroupsListAllPager, mockCache *cache2.MockCache) { mockCache.On("Get", "networkListAllSecurityGroups").Return(expectedResults).Times(1) }, expected: expectedResults, }, { name: "should return remote error", - mocks: func(pager *mockNetworkSecurityGroupsListAllPager, mockCache *cache.MockCache) { + mocks: func(pager *mockNetworkSecurityGroupsListAllPager, mockCache *cache2.MockCache) { pager.On("NextPage", context.Background()).Return(true).Times(1) pager.On("NextPage", context.Background()).Return(false).Times(1) pager.On("PageResponse").Return(armnetwork.NetworkSecurityGroupsListAllResponse{}).Times(1) @@ -943,7 +943,7 @@ func Test_Network_ListAllSecurityGroups(t *testing.T) { t.Run(tt.name, func(t *testing.T) { fakePager := &mockNetworkSecurityGroupsListAllPager{} fakeClient := &mockNetworkSecurityGroupsClient{} - mockCache := &cache.MockCache{} + mockCache := &cache2.MockCache{} fakeClient.On("ListAll", (*armnetwork.NetworkSecurityGroupsListAllOptions)(nil)).Return(fakePager).Maybe() @@ -988,13 +988,13 @@ func Test_Network_ListAllLoadBalancers(t *testing.T) { testcases := []struct { name string - mocks func(*mockLoadBalancersListAllPager, *cache.MockCache) + mocks func(*mockLoadBalancersListAllPager, *cache2.MockCache) expected []*armnetwork.LoadBalancer wantErr string }{ { name: "should return load balancers", - mocks: func(pager *mockLoadBalancersListAllPager, mockCache *cache.MockCache) { + mocks: func(pager *mockLoadBalancersListAllPager, mockCache *cache2.MockCache) { pager.On("NextPage", context.Background()).Return(true).Times(1) pager.On("NextPage", context.Background()).Return(false).Times(1) pager.On("PageResponse").Return(armnetwork.LoadBalancersListAllResponse{ @@ -1014,7 +1014,7 @@ func Test_Network_ListAllLoadBalancers(t *testing.T) { }, { name: "should hit cache and return load balancers", - mocks: func(pager *mockLoadBalancersListAllPager, mockCache *cache.MockCache) { + mocks: func(pager *mockLoadBalancersListAllPager, mockCache *cache2.MockCache) { mockCache.On("GetAndLock", "networkListAllLoadBalancers").Return(expectedResults).Times(1) mockCache.On("Unlock", "networkListAllLoadBalancers").Return(nil).Times(1) }, @@ -1022,7 +1022,7 @@ func Test_Network_ListAllLoadBalancers(t *testing.T) { }, { name: "should return remote error", - mocks: func(pager *mockLoadBalancersListAllPager, mockCache *cache.MockCache) { + mocks: func(pager *mockLoadBalancersListAllPager, mockCache *cache2.MockCache) { pager.On("NextPage", context.Background()).Return(true).Times(1) pager.On("NextPage", context.Background()).Return(false).Times(1) pager.On("PageResponse").Return(armnetwork.LoadBalancersListAllResponse{}).Times(1) @@ -1039,7 +1039,7 @@ func Test_Network_ListAllLoadBalancers(t *testing.T) { t.Run(tt.name, func(t *testing.T) { fakePager := &mockLoadBalancersListAllPager{} fakeClient := &mockLoadBalancersClient{} - mockCache := &cache.MockCache{} + mockCache := &cache2.MockCache{} fakeClient.On("ListAll", (*armnetwork.LoadBalancersListAllOptions)(nil)).Return(fakePager).Maybe() @@ -1085,7 +1085,7 @@ func Test_Network_ListLoadBalancerRules(t *testing.T) { testcases := []struct { name string loadBalancer *armnetwork.LoadBalancer - mocks func(*mockLoadBalancerRulesClient, *mockLoadBalancerRulesListAllPager, *cache.MockCache) + mocks func(*mockLoadBalancerRulesClient, *mockLoadBalancerRulesListAllPager, *cache2.MockCache) expected []*armnetwork.LoadBalancingRule wantErr string }{ @@ -1094,7 +1094,7 @@ func Test_Network_ListLoadBalancerRules(t *testing.T) { loadBalancer: &armnetwork.LoadBalancer{ Resource: armnetwork.Resource{ID: to.StringPtr("/subscriptions/xxx/resourceGroups/driftctl/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/frontendIPConfigurations/PublicIPAddress")}, }, - mocks: func(client *mockLoadBalancerRulesClient, pager *mockLoadBalancerRulesListAllPager, mockCache *cache.MockCache) { + mocks: func(client *mockLoadBalancerRulesClient, pager *mockLoadBalancerRulesListAllPager, mockCache *cache2.MockCache) { client.On("List", "driftctl", "PublicIPAddress", &armnetwork.LoadBalancerLoadBalancingRulesListOptions{}).Return(pager) pager.On("NextPage", context.Background()).Return(true).Times(1) @@ -1118,7 +1118,7 @@ func Test_Network_ListLoadBalancerRules(t *testing.T) { loadBalancer: &armnetwork.LoadBalancer{ Resource: armnetwork.Resource{ID: to.StringPtr("lb-1")}, }, - mocks: func(client *mockLoadBalancerRulesClient, pager *mockLoadBalancerRulesListAllPager, mockCache *cache.MockCache) { + mocks: func(client *mockLoadBalancerRulesClient, pager *mockLoadBalancerRulesListAllPager, mockCache *cache2.MockCache) { mockCache.On("Get", "networkListLoadBalancerRules_lb-1").Return(expectedResults).Times(1) }, expected: expectedResults, @@ -1128,7 +1128,7 @@ func Test_Network_ListLoadBalancerRules(t *testing.T) { loadBalancer: &armnetwork.LoadBalancer{ Resource: armnetwork.Resource{ID: to.StringPtr("/subscriptions/xxx/resourceGroups/driftctl/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/frontendIPConfigurations/PublicIPAddress")}, }, - mocks: func(client *mockLoadBalancerRulesClient, pager *mockLoadBalancerRulesListAllPager, mockCache *cache.MockCache) { + mocks: func(client *mockLoadBalancerRulesClient, pager *mockLoadBalancerRulesListAllPager, mockCache *cache2.MockCache) { client.On("List", "driftctl", "PublicIPAddress", &armnetwork.LoadBalancerLoadBalancingRulesListOptions{}).Return(pager) pager.On("NextPage", context.Background()).Return(true).Times(1) @@ -1146,7 +1146,7 @@ func Test_Network_ListLoadBalancerRules(t *testing.T) { t.Run(tt.name, func(t *testing.T) { fakePager := &mockLoadBalancerRulesListAllPager{} fakeClient := &mockLoadBalancerRulesClient{} - mockCache := &cache.MockCache{} + mockCache := &cache2.MockCache{} tt.mocks(fakeClient, fakePager, mockCache) diff --git a/pkg/remote/azurerm/repository/pager.go b/enumeration/remote/azurerm/repository/pager.go similarity index 100% rename from pkg/remote/azurerm/repository/pager.go rename to enumeration/remote/azurerm/repository/pager.go diff --git a/pkg/remote/azurerm/repository/postgresql.go b/enumeration/remote/azurerm/repository/postgresql.go similarity index 96% rename from pkg/remote/azurerm/repository/postgresql.go rename to enumeration/remote/azurerm/repository/postgresql.go index 644704ecf..f9024eaf7 100644 --- a/pkg/remote/azurerm/repository/postgresql.go +++ b/enumeration/remote/azurerm/repository/postgresql.go @@ -3,13 +3,13 @@ package repository import ( "context" "fmt" + "github.com/snyk/driftctl/enumeration/remote/azurerm/common" + "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresql" "github.com/Azure/go-autorest/autorest/azure" - "github.com/snyk/driftctl/pkg/remote/azurerm/common" - "github.com/snyk/driftctl/pkg/remote/cache" ) type PostgresqlRespository interface { diff --git a/pkg/remote/azurerm/repository/postgresql_test.go b/enumeration/remote/azurerm/repository/postgresql_test.go similarity index 99% rename from pkg/remote/azurerm/repository/postgresql_test.go rename to enumeration/remote/azurerm/repository/postgresql_test.go index d88e09348..2d6ac1703 100644 --- a/pkg/remote/azurerm/repository/postgresql_test.go +++ b/enumeration/remote/azurerm/repository/postgresql_test.go @@ -2,13 +2,13 @@ package repository import ( "context" + "github.com/snyk/driftctl/enumeration/remote/cache" "reflect" "testing" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresql" "github.com/pkg/errors" - "github.com/snyk/driftctl/pkg/remote/cache" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) diff --git a/pkg/remote/azurerm/repository/privatedns.go b/enumeration/remote/azurerm/repository/privatedns.go similarity index 98% rename from pkg/remote/azurerm/repository/privatedns.go rename to enumeration/remote/azurerm/repository/privatedns.go index a2a1fa4a7..59a9a333c 100644 --- a/pkg/remote/azurerm/repository/privatedns.go +++ b/enumeration/remote/azurerm/repository/privatedns.go @@ -3,13 +3,13 @@ package repository import ( "context" "fmt" + "github.com/snyk/driftctl/enumeration/remote/azurerm/common" + "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns" "github.com/Azure/go-autorest/autorest/azure" - "github.com/snyk/driftctl/pkg/remote/azurerm/common" - "github.com/snyk/driftctl/pkg/remote/cache" ) type PrivateDNSRepository interface { diff --git a/pkg/remote/azurerm/repository/privatedns_test.go b/enumeration/remote/azurerm/repository/privatedns_test.go similarity index 98% rename from pkg/remote/azurerm/repository/privatedns_test.go rename to enumeration/remote/azurerm/repository/privatedns_test.go index 0bcdbbbe7..fddcb0c43 100644 --- a/pkg/remote/azurerm/repository/privatedns_test.go +++ b/enumeration/remote/azurerm/repository/privatedns_test.go @@ -1,13 +1,13 @@ package repository import ( + cache2 "github.com/snyk/driftctl/enumeration/remote/cache" "reflect" "testing" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns" "github.com/pkg/errors" - "github.com/snyk/driftctl/pkg/remote/cache" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -99,7 +99,7 @@ func Test_ListAllPrivateZones_MultiplesResults(t *testing.T) { fakeClient.On("List", mock.Anything).Return(mockPager) - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("GetAndLock", "privateDNSListAllPrivateZones").Return(nil).Times(1) c.On("Unlock", "privateDNSListAllPrivateZones").Times(1) c.On("Put", "privateDNSListAllPrivateZones", expected).Return(true).Times(1) @@ -136,7 +136,7 @@ func Test_ListAllPrivateZones_MultiplesResults_WithCache(t *testing.T) { fakeClient := &mockPrivateZonesClient{} - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("GetAndLock", "privateDNSListAllPrivateZones").Return(expected).Times(1) c.On("Unlock", "privateDNSListAllPrivateZones").Times(1) @@ -173,7 +173,7 @@ func Test_ListAllPrivateZones_Error(t *testing.T) { s := &privateDNSRepository{ zoneClient: fakeClient, - cache: cache.New(0), + cache: cache2.New(0), } got, err := s.ListAllPrivateZones() @@ -281,7 +281,7 @@ func Test_ListAllARecords_MultiplesResults(t *testing.T) { fakeRecordSetClient.On("List", "rgid", "zone", (*armprivatedns.RecordSetsListOptions)(nil)).Return(mockPager) - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("GetAndLock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return(nil).Times(1) c.On("Unlock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return().Times(1) c.On("Put", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com", mock.Anything).Return(true).Times(1) @@ -330,7 +330,7 @@ func Test_ListAllARecords_MultiplesResults_WithCache(t *testing.T) { fakeRecordSetClient := &mockPrivateRecordSetClient{} - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("GetAndLock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return(expected).Times(1) c.On("Unlock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Times(1) s := &privateDNSRepository{ @@ -373,7 +373,7 @@ func Test_ListAllARecords_Error(t *testing.T) { s := &privateDNSRepository{ recordClient: fakeClient, - cache: cache.New(0), + cache: cache2.New(0), } got, err := s.ListAllARecords(&armprivatedns.PrivateZone{ TrackedResource: armprivatedns.TrackedResource{ @@ -488,7 +488,7 @@ func Test_ListAllAAAARecords_MultiplesResults(t *testing.T) { fakeRecordSetClient.On("List", "rgid", "zone", (*armprivatedns.RecordSetsListOptions)(nil)).Return(mockPager) - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("GetAndLock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return(nil).Times(1) c.On("Unlock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return().Times(1) c.On("Put", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com", mock.Anything).Return(true).Times(1) @@ -537,7 +537,7 @@ func Test_ListAllAAAARecords_MultiplesResults_WithCache(t *testing.T) { fakeRecordSetClient := &mockPrivateRecordSetClient{} - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("GetAndLock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return(expected).Times(1) c.On("Unlock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Times(1) s := &privateDNSRepository{ @@ -580,7 +580,7 @@ func Test_ListAllAAAARecords_Error(t *testing.T) { s := &privateDNSRepository{ recordClient: fakeClient, - cache: cache.New(0), + cache: cache2.New(0), } got, err := s.ListAllAAAARecords(&armprivatedns.PrivateZone{ TrackedResource: armprivatedns.TrackedResource{ @@ -695,7 +695,7 @@ func Test_ListAllCNAMERecords_MultiplesResults(t *testing.T) { fakeRecordSetClient.On("List", "rgid", "zone", (*armprivatedns.RecordSetsListOptions)(nil)).Return(mockPager) - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("GetAndLock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return(nil).Times(1) c.On("Unlock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return().Times(1) c.On("Put", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com", mock.Anything).Return(true).Times(1) @@ -744,7 +744,7 @@ func Test_ListAllCNAMERecords_MultiplesResults_WithCache(t *testing.T) { fakeRecordSetClient := &mockPrivateRecordSetClient{} - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("GetAndLock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return(expected).Times(1) c.On("Unlock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return().Times(1) @@ -789,7 +789,7 @@ func Test_ListAllCNAMERecords_Error(t *testing.T) { s := &privateDNSRepository{ recordClient: fakeClient, - cache: cache.New(0), + cache: cache2.New(0), } got, err := s.ListAllCNAMERecords(&armprivatedns.PrivateZone{ TrackedResource: armprivatedns.TrackedResource{ @@ -904,7 +904,7 @@ func Test_ListAllPTRRecords_MultiplesResults(t *testing.T) { fakeRecordSetClient.On("List", "rgid", "zone", (*armprivatedns.RecordSetsListOptions)(nil)).Return(mockPager) - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("GetAndLock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return(nil).Times(1) c.On("Unlock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return().Times(1) c.On("Put", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com", mock.Anything).Return(true).Times(1) @@ -953,7 +953,7 @@ func Test_ListAllPTRRecords_MultiplesResults_WithCache(t *testing.T) { fakeRecordSetClient := &mockPrivateRecordSetClient{} - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("GetAndLock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return(expected).Times(1) c.On("Unlock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Times(1) s := &privateDNSRepository{ @@ -996,7 +996,7 @@ func Test_ListAllPTRRecords_Error(t *testing.T) { s := &privateDNSRepository{ recordClient: fakeClient, - cache: cache.New(0), + cache: cache2.New(0), } got, err := s.ListAllPTRRecords(&armprivatedns.PrivateZone{ TrackedResource: armprivatedns.TrackedResource{ @@ -1110,7 +1110,7 @@ func Test_ListAllMXRecords_MultiplesResults(t *testing.T) { fakeRecordSetClient.On("List", "rgid", "zone", (*armprivatedns.RecordSetsListOptions)(nil)).Return(mockPager) - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("GetAndLock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return(nil).Times(1) c.On("Unlock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return().Times(1) c.On("Put", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com", mock.Anything).Return(true).Times(1) @@ -1158,7 +1158,7 @@ func Test_ListAllMXRecords_MultiplesResults_WithCache(t *testing.T) { fakeRecordSetClient := &mockPrivateRecordSetClient{} - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("GetAndLock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return(expected).Times(1) c.On("Unlock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Times(1) s := &privateDNSRepository{ @@ -1203,7 +1203,7 @@ func Test_ListAllMXRecords_Error(t *testing.T) { s := &privateDNSRepository{ recordClient: fakeClient, - cache: cache.New(0), + cache: cache2.New(0), } got, err := s.ListAllMXRecords(&armprivatedns.PrivateZone{ @@ -1319,7 +1319,7 @@ func Test_ListAllSRVRecords_MultiplesResults(t *testing.T) { fakeRecordSetClient.On("List", "rgid", "zone", (*armprivatedns.RecordSetsListOptions)(nil)).Return(mockPager) - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("GetAndLock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return(nil).Times(1) c.On("Unlock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return().Times(1) c.On("Put", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com", mock.Anything).Return(true).Times(1) @@ -1368,7 +1368,7 @@ func Test_ListAllSRVRecords_MultiplesResults_WithCache(t *testing.T) { fakeRecordSetClient := &mockPrivateRecordSetClient{} - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("GetAndLock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return(expected).Times(1) c.On("Unlock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Times(1) s := &privateDNSRepository{ @@ -1411,7 +1411,7 @@ func Test_ListAllSRVRecords_Error(t *testing.T) { s := &privateDNSRepository{ recordClient: fakeClient, - cache: cache.New(0), + cache: cache2.New(0), } got, err := s.ListAllSRVRecords(&armprivatedns.PrivateZone{ TrackedResource: armprivatedns.TrackedResource{ @@ -1526,7 +1526,7 @@ func Test_ListAllTXTRecords_MultiplesResults(t *testing.T) { fakeRecordSetClient.On("List", "rgid", "zone", (*armprivatedns.RecordSetsListOptions)(nil)).Return(mockPager) - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("GetAndLock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return(nil).Times(1) c.On("Unlock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return().Times(1) c.On("Put", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com", mock.Anything).Return(true).Times(1) @@ -1575,7 +1575,7 @@ func Test_ListAllTXTRecords_MultiplesResults_WithCache(t *testing.T) { fakeRecordSetClient := &mockPrivateRecordSetClient{} - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("GetAndLock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return(expected).Times(1) c.On("Unlock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Times(1) s := &privateDNSRepository{ @@ -1618,7 +1618,7 @@ func Test_ListAllTXTRecords_Error(t *testing.T) { s := &privateDNSRepository{ recordClient: fakeClient, - cache: cache.New(0), + cache: cache2.New(0), } got, err := s.ListAllTXTRecords(&armprivatedns.PrivateZone{ TrackedResource: armprivatedns.TrackedResource{ diff --git a/pkg/remote/azurerm/repository/resources.go b/enumeration/remote/azurerm/repository/resources.go similarity index 93% rename from pkg/remote/azurerm/repository/resources.go rename to enumeration/remote/azurerm/repository/resources.go index c7ba9bd09..768e91e01 100644 --- a/pkg/remote/azurerm/repository/resources.go +++ b/enumeration/remote/azurerm/repository/resources.go @@ -2,12 +2,12 @@ package repository import ( "context" + "github.com/snyk/driftctl/enumeration/remote/azurerm/common" + "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" - "github.com/snyk/driftctl/pkg/remote/azurerm/common" - "github.com/snyk/driftctl/pkg/remote/cache" ) type ResourcesRepository interface { diff --git a/pkg/remote/azurerm/repository/resources_test.go b/enumeration/remote/azurerm/repository/resources_test.go similarity index 98% rename from pkg/remote/azurerm/repository/resources_test.go rename to enumeration/remote/azurerm/repository/resources_test.go index 841ee8398..dcc97d945 100644 --- a/pkg/remote/azurerm/repository/resources_test.go +++ b/enumeration/remote/azurerm/repository/resources_test.go @@ -1,13 +1,13 @@ package repository import ( + "github.com/snyk/driftctl/enumeration/remote/cache" "reflect" "testing" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" "github.com/pkg/errors" - "github.com/snyk/driftctl/pkg/remote/cache" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) diff --git a/pkg/remote/azurerm/repository/storage.go b/enumeration/remote/azurerm/repository/storage.go similarity index 96% rename from pkg/remote/azurerm/repository/storage.go rename to enumeration/remote/azurerm/repository/storage.go index 11791ff62..94cc3e87d 100644 --- a/pkg/remote/azurerm/repository/storage.go +++ b/enumeration/remote/azurerm/repository/storage.go @@ -3,13 +3,13 @@ package repository import ( "context" "fmt" + "github.com/snyk/driftctl/enumeration/remote/azurerm/common" + "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage" "github.com/Azure/go-autorest/autorest/azure" - "github.com/snyk/driftctl/pkg/remote/azurerm/common" - "github.com/snyk/driftctl/pkg/remote/cache" ) type StorageRespository interface { diff --git a/pkg/remote/azurerm/repository/storage_test.go b/enumeration/remote/azurerm/repository/storage_test.go similarity index 97% rename from pkg/remote/azurerm/repository/storage_test.go rename to enumeration/remote/azurerm/repository/storage_test.go index b9dc424c1..9ec4bb483 100644 --- a/pkg/remote/azurerm/repository/storage_test.go +++ b/enumeration/remote/azurerm/repository/storage_test.go @@ -1,13 +1,13 @@ package repository import ( + cache2 "github.com/snyk/driftctl/enumeration/remote/cache" "reflect" "testing" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage" "github.com/pkg/errors" - "github.com/snyk/driftctl/pkg/remote/cache" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -98,7 +98,7 @@ func Test_ListAllStorageAccount_MultiplesResults(t *testing.T) { fakeClient.On("List", mock.Anything).Return(mockPager) - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("GetAndLock", "ListAllStorageAccount").Return(nil).Times(1) c.On("Unlock", "ListAllStorageAccount").Times(1) c.On("Put", "ListAllStorageAccount", expected).Return(true).Times(1) @@ -135,7 +135,7 @@ func Test_ListAllStorageAccount_MultiplesResults_WithCache(t *testing.T) { fakeClient := &mockStorageAccountClient{} - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("GetAndLock", "ListAllStorageAccount").Return(expected).Times(1) c.On("Unlock", "ListAllStorageAccount").Times(1) s := &storageRepository{ @@ -171,7 +171,7 @@ func Test_ListAllStorageAccount_Error(t *testing.T) { s := &storageRepository{ storageAccountsClient: fakeClient, - cache: cache.New(0), + cache: cache2.New(0), } got, err := s.ListAllStorageAccount() @@ -258,7 +258,7 @@ func Test_ListAllStorageContainer_MultiplesResults(t *testing.T) { fakeClient.On("List", "foobar", "testeliedriftctl", (*armstorage.BlobContainersListOptions)(nil)).Return(mockPager) - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("Get", "ListAllStorageContainer_testeliedriftctl").Return(nil).Times(1) c.On("Put", "ListAllStorageContainer_testeliedriftctl", expected).Return(true).Times(1) s := &storageRepository{ @@ -295,7 +295,7 @@ func Test_ListAllStorageContainer_MultiplesResults_WithCache(t *testing.T) { fakeClient := &mockBlobContainerClient{} - c := &cache.MockCache{} + c := &cache2.MockCache{} c.On("Get", "ListAllStorageContainer_testeliedriftctl").Return(expected).Times(1) s := &storageRepository{ blobContainerClient: fakeClient, @@ -328,7 +328,7 @@ func Test_ListAllStorageContainer_InvalidStorageAccountResourceID(t *testing.T) s := &storageRepository{ blobContainerClient: fakeClient, - cache: cache.New(0), + cache: cache2.New(0), } got, err := s.ListAllStorageContainer(&account) @@ -361,7 +361,7 @@ func Test_ListAllStorageContainer_Error(t *testing.T) { s := &storageRepository{ blobContainerClient: fakeClient, - cache: cache.New(0), + cache: cache2.New(0), } got, err := s.ListAllStorageContainer(&account) diff --git a/pkg/remote/azurerm_compute_scanner_test.go b/enumeration/remote/azurerm_compute_scanner_test.go similarity index 74% rename from pkg/remote/azurerm_compute_scanner_test.go rename to enumeration/remote/azurerm_compute_scanner_test.go index 1aa86a723..cb12ac8fd 100644 --- a/pkg/remote/azurerm_compute_scanner_test.go +++ b/enumeration/remote/azurerm_compute_scanner_test.go @@ -3,21 +3,23 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + azurerm2 "github.com/snyk/driftctl/enumeration/remote/azurerm" + repository2 "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + terraform3 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute" "github.com/pkg/errors" + "github.com/snyk/driftctl/enumeration/resource" + resourceazure "github.com/snyk/driftctl/enumeration/resource/azurerm" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/azurerm" - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceazure "github.com/snyk/driftctl/pkg/resource/azurerm" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" testresource "github.com/snyk/driftctl/test/resource" @@ -32,13 +34,13 @@ func TestAzurermCompute_Image(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockComputeRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockComputeRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no images", - mocks: func(repository *repository.MockComputeRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockComputeRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllImages").Return([]*armcompute.Image{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -47,14 +49,14 @@ func TestAzurermCompute_Image(t *testing.T) { }, { test: "error listing images", - mocks: func(repository *repository.MockComputeRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockComputeRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllImages").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceazure.AzureImageResourceType), }, { test: "multiple images including an invalid ID", - mocks: func(repository *repository.MockComputeRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockComputeRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllImages").Return([]*armcompute.Image{ { Resource: armcompute.Resource{ @@ -91,21 +93,21 @@ func TestAzurermCompute_Image(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockComputeRepository{} + fakeRepo := &repository2.MockComputeRepository{} c.mocks(fakeRepo, alerter) - remoteLibrary.AddEnumerator(azurerm.NewAzurermImageEnumerator(fakeRepo, factory)) + remoteLibrary.AddEnumerator(azurerm2.NewAzurermImageEnumerator(fakeRepo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -129,20 +131,20 @@ func TestAzurermCompute_SSHPublicKey(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockComputeRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockComputeRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no public key", dirName: "azurerm_ssh_public_key_empty", - mocks: func(repository *repository.MockComputeRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockComputeRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllSSHPublicKeys").Return([]*armcompute.SSHPublicKeyResource{}, nil) }, }, { test: "error listing public keys", dirName: "azurerm_ssh_public_key_empty", - mocks: func(repository *repository.MockComputeRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockComputeRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllSSHPublicKeys").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceazure.AzureSSHPublicKeyResourceType), @@ -150,7 +152,7 @@ func TestAzurermCompute_SSHPublicKey(t *testing.T) { { test: "multiple public keys", dirName: "azurerm_ssh_public_key_multiple", - mocks: func(repository *repository.MockComputeRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockComputeRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllSSHPublicKeys").Return([]*armcompute.SSHPublicKeyResource{ { Resource: armcompute.Resource{ @@ -172,7 +174,7 @@ func TestAzurermCompute_SSHPublicKey(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -180,15 +182,15 @@ func TestAzurermCompute_SSHPublicKey(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockComputeRepository{} + fakeRepo := &repository2.MockComputeRepository{} c.mocks(fakeRepo, alerter) - var repo repository.ComputeRepository = fakeRepo + var repo repository2.ComputeRepository = fakeRepo providerVersion := "2.71.0" realProvider, err := terraform2.InitTestAzureProvider(providerLibrary, providerVersion) if err != nil { @@ -209,13 +211,13 @@ func TestAzurermCompute_SSHPublicKey(t *testing.T) { t.Fatal(err) } clientOptions := &arm.ClientOptions{} - repo = repository.NewComputeRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) + repo = repository2.NewComputeRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(azurerm.NewAzurermSSHPublicKeyEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceazure.AzureSSHPublicKeyResourceType, common.NewGenericDetailsFetcher(resourceazure.AzureSSHPublicKeyResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(azurerm2.NewAzurermSSHPublicKeyEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceazure.AzureSSHPublicKeyResourceType, common2.NewGenericDetailsFetcher(resourceazure.AzureSSHPublicKeyResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/azurerm_containerregistry_scanner_test.go b/enumeration/remote/azurerm_containerregistry_scanner_test.go similarity index 72% rename from pkg/remote/azurerm_containerregistry_scanner_test.go rename to enumeration/remote/azurerm_containerregistry_scanner_test.go index 718b12824..070e77d6f 100644 --- a/pkg/remote/azurerm_containerregistry_scanner_test.go +++ b/enumeration/remote/azurerm_containerregistry_scanner_test.go @@ -3,18 +3,20 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/azurerm" + repository2 "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + "github.com/snyk/driftctl/enumeration/remote/common" + error2 "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/terraform" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry" "github.com/pkg/errors" + "github.com/snyk/driftctl/enumeration/resource" + resourceazure "github.com/snyk/driftctl/enumeration/resource/azurerm" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/azurerm" - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - "github.com/snyk/driftctl/pkg/remote/common" - error2 "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceazure "github.com/snyk/driftctl/pkg/resource/azurerm" - "github.com/snyk/driftctl/pkg/terraform" + testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -26,13 +28,13 @@ func TestAzurermContainerRegistry(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockContainerRegistryRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockContainerRegistryRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no container registry", - mocks: func(repository *repository.MockContainerRegistryRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockContainerRegistryRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllContainerRegistries").Return([]*armcontainerregistry.Registry{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -41,14 +43,14 @@ func TestAzurermContainerRegistry(t *testing.T) { }, { test: "error listing container registry", - mocks: func(repository *repository.MockContainerRegistryRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockContainerRegistryRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllContainerRegistries").Return(nil, dummyError) }, wantErr: error2.NewResourceListingError(dummyError, resourceazure.AzureContainerRegistryResourceType), }, { test: "multiple container registries", - mocks: func(repository *repository.MockContainerRegistryRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockContainerRegistryRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllContainerRegistries").Return([]*armcontainerregistry.Registry{ { Resource: armcontainerregistry.Resource{ @@ -87,14 +89,14 @@ func TestAzurermContainerRegistry(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockContainerRegistryRepository{} + fakeRepo := &repository2.MockContainerRegistryRepository{} c.mocks(fakeRepo, alerter) - var repo repository.ContainerRegistryRepository = fakeRepo + var repo repository2.ContainerRegistryRepository = fakeRepo remoteLibrary.AddEnumerator(azurerm.NewAzurermContainerRegistryEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/azurerm_network_scanner_test.go b/enumeration/remote/azurerm_network_scanner_test.go similarity index 77% rename from pkg/remote/azurerm_network_scanner_test.go rename to enumeration/remote/azurerm_network_scanner_test.go index fddf72677..629ce5a71 100644 --- a/pkg/remote/azurerm_network_scanner_test.go +++ b/enumeration/remote/azurerm_network_scanner_test.go @@ -3,21 +3,23 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + azurerm2 "github.com/snyk/driftctl/enumeration/remote/azurerm" + repository2 "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + error2 "github.com/snyk/driftctl/enumeration/remote/error" + terraform3 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork" "github.com/pkg/errors" + "github.com/snyk/driftctl/enumeration/resource" + resourceazure "github.com/snyk/driftctl/enumeration/resource/azurerm" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/azurerm" - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - error2 "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceazure "github.com/snyk/driftctl/pkg/resource/azurerm" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" testresource "github.com/snyk/driftctl/test/resource" @@ -32,13 +34,13 @@ func TestAzurermVirtualNetwork(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockNetworkRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockNetworkRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no virtual network", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllVirtualNetworks").Return([]*armnetwork.VirtualNetwork{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -47,14 +49,14 @@ func TestAzurermVirtualNetwork(t *testing.T) { }, { test: "error listing virtual network", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllVirtualNetworks").Return(nil, dummyError) }, wantErr: error2.NewResourceListingError(dummyError, resourceazure.AzureVirtualNetworkResourceType), }, { test: "multiple virtual network", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllVirtualNetworks").Return([]*armnetwork.VirtualNetwork{ { Resource: armnetwork.Resource{ @@ -85,24 +87,24 @@ func TestAzurermVirtualNetwork(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockNetworkRepository{} + fakeRepo := &repository2.MockNetworkRepository{} c.mocks(fakeRepo, alerter) - var repo repository.NetworkRepository = fakeRepo + var repo repository2.NetworkRepository = fakeRepo - remoteLibrary.AddEnumerator(azurerm.NewAzurermVirtualNetworkEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm2.NewAzurermVirtualNetworkEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -125,13 +127,13 @@ func TestAzurermRouteTables(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockNetworkRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockNetworkRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no route tables", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return([]*armnetwork.RouteTable{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -140,14 +142,14 @@ func TestAzurermRouteTables(t *testing.T) { }, { test: "error listing route tables", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return(nil, dummyError) }, wantErr: error2.NewResourceListingError(dummyError, resourceazure.AzureRouteTableResourceType), }, { test: "multiple route tables", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return([]*armnetwork.RouteTable{ { Resource: armnetwork.Resource{ @@ -178,24 +180,24 @@ func TestAzurermRouteTables(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockNetworkRepository{} + fakeRepo := &repository2.MockNetworkRepository{} c.mocks(fakeRepo, alerter) - var repo repository.NetworkRepository = fakeRepo + var repo repository2.NetworkRepository = fakeRepo - remoteLibrary.AddEnumerator(azurerm.NewAzurermRouteTableEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm2.NewAzurermRouteTableEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -218,13 +220,13 @@ func TestAzurermRoutes(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockNetworkRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockNetworkRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no route tables", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return([]*armnetwork.RouteTable{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -233,7 +235,7 @@ func TestAzurermRoutes(t *testing.T) { }, { test: "no routes", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return([]*armnetwork.RouteTable{ { Properties: &armnetwork.RouteTablePropertiesFormat{ @@ -253,14 +255,14 @@ func TestAzurermRoutes(t *testing.T) { }, { test: "error listing route tables", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return(nil, dummyError) }, wantErr: error2.NewResourceListingErrorWithType(dummyError, resourceazure.AzureRouteResourceType, resourceazure.AzureRouteTableResourceType), }, { test: "multiple routes", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return([]*armnetwork.RouteTable{ { Resource: armnetwork.Resource{ @@ -327,24 +329,24 @@ func TestAzurermRoutes(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockNetworkRepository{} + fakeRepo := &repository2.MockNetworkRepository{} c.mocks(fakeRepo, alerter) - var repo repository.NetworkRepository = fakeRepo + var repo repository2.NetworkRepository = fakeRepo - remoteLibrary.AddEnumerator(azurerm.NewAzurermRouteEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm2.NewAzurermRouteEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -380,13 +382,13 @@ func TestAzurermSubnets(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockNetworkRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockNetworkRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no subnets", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllVirtualNetworks").Return(networks, nil) repository.On("ListAllSubnets", networks[0]).Return([]*armnetwork.Subnet{}, nil).Times(1) repository.On("ListAllSubnets", networks[1]).Return([]*armnetwork.Subnet{}, nil).Times(1) @@ -397,14 +399,14 @@ func TestAzurermSubnets(t *testing.T) { }, { test: "error listing virtual network", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllVirtualNetworks").Return(nil, dummyError) }, wantErr: error2.NewResourceListingErrorWithType(dummyError, resourceazure.AzureSubnetResourceType, resourceazure.AzureVirtualNetworkResourceType), }, { test: "error listing subnets", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllVirtualNetworks").Return(networks, nil) repository.On("ListAllSubnets", networks[0]).Return(nil, dummyError).Times(1) }, @@ -412,7 +414,7 @@ func TestAzurermSubnets(t *testing.T) { }, { test: "multiple subnets", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllVirtualNetworks").Return(networks, nil) repository.On("ListAllSubnets", networks[0]).Return([]*armnetwork.Subnet{ { @@ -460,24 +462,24 @@ func TestAzurermSubnets(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockNetworkRepository{} + fakeRepo := &repository2.MockNetworkRepository{} c.mocks(fakeRepo, alerter) - var repo repository.NetworkRepository = fakeRepo + var repo repository2.NetworkRepository = fakeRepo - remoteLibrary.AddEnumerator(azurerm.NewAzurermSubnetEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm2.NewAzurermSubnetEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -500,13 +502,13 @@ func TestAzurermFirewalls(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockNetworkRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockNetworkRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no firewall", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllFirewalls").Return([]*armnetwork.AzureFirewall{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -515,14 +517,14 @@ func TestAzurermFirewalls(t *testing.T) { }, { test: "error listing firewalls", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllFirewalls").Return(nil, dummyError) }, wantErr: error2.NewResourceListingError(dummyError, resourceazure.AzureFirewallResourceType), }, { test: "multiple firewalls", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllFirewalls").Return([]*armnetwork.AzureFirewall{ { Resource: armnetwork.Resource{ @@ -553,24 +555,24 @@ func TestAzurermFirewalls(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockNetworkRepository{} + fakeRepo := &repository2.MockNetworkRepository{} c.mocks(fakeRepo, alerter) - var repo repository.NetworkRepository = fakeRepo + var repo repository2.NetworkRepository = fakeRepo - remoteLibrary.AddEnumerator(azurerm.NewAzurermFirewallsEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm2.NewAzurermFirewallsEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -593,13 +595,13 @@ func TestAzurermPublicIP(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockNetworkRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockNetworkRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no public IP", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPublicIPAddresses").Return([]*armnetwork.PublicIPAddress{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -608,14 +610,14 @@ func TestAzurermPublicIP(t *testing.T) { }, { test: "error listing public IPs", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPublicIPAddresses").Return(nil, dummyError) }, wantErr: error2.NewResourceListingError(dummyError, resourceazure.AzurePublicIPResourceType), }, { test: "multiple public IP", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPublicIPAddresses").Return([]*armnetwork.PublicIPAddress{ { Resource: armnetwork.Resource{ @@ -646,24 +648,24 @@ func TestAzurermPublicIP(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockNetworkRepository{} + fakeRepo := &repository2.MockNetworkRepository{} c.mocks(fakeRepo, alerter) - var repo repository.NetworkRepository = fakeRepo + var repo repository2.NetworkRepository = fakeRepo - remoteLibrary.AddEnumerator(azurerm.NewAzurermPublicIPEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm2.NewAzurermPublicIPEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -687,20 +689,20 @@ func TestAzurermSecurityGroups(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockNetworkRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockNetworkRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no security group", dirName: "azurerm_network_security_group_empty", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllSecurityGroups").Return([]*armnetwork.NetworkSecurityGroup{}, nil) }, }, { test: "error listing security groups", dirName: "azurerm_network_security_group_empty", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllSecurityGroups").Return(nil, dummyError) }, wantErr: error2.NewResourceListingError(dummyError, resourceazure.AzureNetworkSecurityGroupResourceType), @@ -708,7 +710,7 @@ func TestAzurermSecurityGroups(t *testing.T) { { test: "multiple security groups", dirName: "azurerm_network_security_group_multiple", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllSecurityGroups").Return([]*armnetwork.NetworkSecurityGroup{ { Resource: armnetwork.Resource{ @@ -730,7 +732,7 @@ func TestAzurermSecurityGroups(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -738,15 +740,15 @@ func TestAzurermSecurityGroups(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockNetworkRepository{} + fakeRepo := &repository2.MockNetworkRepository{} c.mocks(fakeRepo, alerter) - var repo repository.NetworkRepository = fakeRepo + var repo repository2.NetworkRepository = fakeRepo providerVersion := "2.71.0" realProvider, err := terraform2.InitTestAzureProvider(providerLibrary, providerVersion) if err != nil { @@ -767,13 +769,13 @@ func TestAzurermSecurityGroups(t *testing.T) { t.Fatal(err) } clientOptions := &arm.ClientOptions{} - repo = repository.NewNetworkRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) + repo = repository2.NewNetworkRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(azurerm.NewAzurermNetworkSecurityGroupEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceazure.AzureNetworkSecurityGroupResourceType, common.NewGenericDetailsFetcher(resourceazure.AzureNetworkSecurityGroupResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(azurerm2.NewAzurermNetworkSecurityGroupEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceazure.AzureNetworkSecurityGroupResourceType, common2.NewGenericDetailsFetcher(resourceazure.AzureNetworkSecurityGroupResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -796,13 +798,13 @@ func TestAzurermLoadBalancers(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockNetworkRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockNetworkRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no load balancer", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllLoadBalancers").Return([]*armnetwork.LoadBalancer{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -811,14 +813,14 @@ func TestAzurermLoadBalancers(t *testing.T) { }, { test: "error listing load balancers", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllLoadBalancers").Return(nil, dummyError) }, wantErr: error2.NewResourceListingError(dummyError, resourceazure.AzureLoadBalancerResourceType), }, { test: "multiple load balancers", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllLoadBalancers").Return([]*armnetwork.LoadBalancer{ { Resource: armnetwork.Resource{ @@ -849,24 +851,24 @@ func TestAzurermLoadBalancers(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockNetworkRepository{} + fakeRepo := &repository2.MockNetworkRepository{} c.mocks(fakeRepo, alerter) - var repo repository.NetworkRepository = fakeRepo + var repo repository2.NetworkRepository = fakeRepo - remoteLibrary.AddEnumerator(azurerm.NewAzurermLoadBalancerEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm2.NewAzurermLoadBalancerEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -890,13 +892,13 @@ func TestAzurermLoadBalancerRules(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockNetworkRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockNetworkRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no load balancer rule", dirName: "azurerm_lb_rule_empty", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { loadbalancer := &armnetwork.LoadBalancer{ Resource: armnetwork.Resource{ ID: to.StringPtr("/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/frontendIPConfigurations/PublicIPAddress"), @@ -912,7 +914,7 @@ func TestAzurermLoadBalancerRules(t *testing.T) { { test: "error listing load balancer rules", dirName: "azurerm_lb_rule_empty", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllLoadBalancers").Return(nil, dummyError) }, wantErr: error2.NewResourceListingErrorWithType(dummyError, resourceazure.AzureLoadBalancerRuleResourceType, resourceazure.AzureLoadBalancerResourceType), @@ -920,7 +922,7 @@ func TestAzurermLoadBalancerRules(t *testing.T) { { test: "multiple load balancer rules", dirName: "azurerm_lb_rule_multiple", - mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { loadbalancer := &armnetwork.LoadBalancer{ Resource: armnetwork.Resource{ ID: to.StringPtr("/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/frontendIPConfigurations/PublicIPAddress"), @@ -951,7 +953,7 @@ func TestAzurermLoadBalancerRules(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -959,15 +961,15 @@ func TestAzurermLoadBalancerRules(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockNetworkRepository{} + fakeRepo := &repository2.MockNetworkRepository{} c.mocks(fakeRepo, alerter) - var repo repository.NetworkRepository = fakeRepo + var repo repository2.NetworkRepository = fakeRepo providerVersion := "2.71.0" realProvider, err := terraform2.InitTestAzureProvider(providerLibrary, providerVersion) if err != nil { @@ -988,13 +990,13 @@ func TestAzurermLoadBalancerRules(t *testing.T) { t.Fatal(err) } clientOptions := &arm.ClientOptions{} - repo = repository.NewNetworkRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) + repo = repository2.NewNetworkRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(azurerm.NewAzurermLoadBalancerRuleEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceazure.AzureLoadBalancerRuleResourceType, common.NewGenericDetailsFetcher(resourceazure.AzureLoadBalancerRuleResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(azurerm2.NewAzurermLoadBalancerRuleEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceazure.AzureLoadBalancerRuleResourceType, common2.NewGenericDetailsFetcher(resourceazure.AzureLoadBalancerRuleResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/azurerm_postgresql_scanner_test.go b/enumeration/remote/azurerm_postgresql_scanner_test.go similarity index 77% rename from pkg/remote/azurerm_postgresql_scanner_test.go rename to enumeration/remote/azurerm_postgresql_scanner_test.go index 0ba882b80..9de49e5dd 100644 --- a/pkg/remote/azurerm_postgresql_scanner_test.go +++ b/enumeration/remote/azurerm_postgresql_scanner_test.go @@ -3,18 +3,20 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + azurerm2 "github.com/snyk/driftctl/enumeration/remote/azurerm" + repository2 "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/terraform" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresql" "github.com/pkg/errors" + "github.com/snyk/driftctl/enumeration/resource" + resourceazure "github.com/snyk/driftctl/enumeration/resource/azurerm" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/azurerm" - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceazure "github.com/snyk/driftctl/pkg/resource/azurerm" - "github.com/snyk/driftctl/pkg/terraform" + testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -26,13 +28,13 @@ func TestAzurermPostgresqlServer(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockPostgresqlRespository, *mocks.AlerterInterface) + mocks func(*repository2.MockPostgresqlRespository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no postgres server", - mocks: func(repository *repository.MockPostgresqlRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPostgresqlRespository, alerter *mocks.AlerterInterface) { repository.On("ListAllServers").Return([]*armpostgresql.Server{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -41,14 +43,14 @@ func TestAzurermPostgresqlServer(t *testing.T) { }, { test: "error listing postgres servers", - mocks: func(repository *repository.MockPostgresqlRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPostgresqlRespository, alerter *mocks.AlerterInterface) { repository.On("ListAllServers").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceazure.AzurePostgresqlServerResourceType), }, { test: "multiple postgres servers", - mocks: func(repository *repository.MockPostgresqlRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPostgresqlRespository, alerter *mocks.AlerterInterface) { repository.On("ListAllServers").Return([]*armpostgresql.Server{ { TrackedResource: armpostgresql.TrackedResource{ @@ -93,14 +95,14 @@ func TestAzurermPostgresqlServer(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockPostgresqlRespository{} + fakeRepo := &repository2.MockPostgresqlRespository{} c.mocks(fakeRepo, alerter) - var repo repository.PostgresqlRespository = fakeRepo + var repo repository2.PostgresqlRespository = fakeRepo - remoteLibrary.AddEnumerator(azurerm.NewAzurermPostgresqlServerEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm2.NewAzurermPostgresqlServerEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -123,13 +125,13 @@ func TestAzurermPostgresqlDatabase(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockPostgresqlRespository, *mocks.AlerterInterface) + mocks func(*repository2.MockPostgresqlRespository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no postgres database", - mocks: func(repository *repository.MockPostgresqlRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPostgresqlRespository, alerter *mocks.AlerterInterface) { repository.On("ListAllServers").Return([]*armpostgresql.Server{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -138,14 +140,14 @@ func TestAzurermPostgresqlDatabase(t *testing.T) { }, { test: "error listing postgres servers", - mocks: func(repository *repository.MockPostgresqlRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPostgresqlRespository, alerter *mocks.AlerterInterface) { repository.On("ListAllServers").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceazure.AzurePostgresqlDatabaseResourceType, resourceazure.AzurePostgresqlServerResourceType), }, { test: "error listing postgres databases", - mocks: func(repository *repository.MockPostgresqlRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPostgresqlRespository, alerter *mocks.AlerterInterface) { repository.On("ListAllServers").Return([]*armpostgresql.Server{ { TrackedResource: armpostgresql.TrackedResource{ @@ -163,7 +165,7 @@ func TestAzurermPostgresqlDatabase(t *testing.T) { }, { test: "multiple postgres databases", - mocks: func(repository *repository.MockPostgresqlRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPostgresqlRespository, alerter *mocks.AlerterInterface) { repository.On("ListAllServers").Return([]*armpostgresql.Server{ { TrackedResource: armpostgresql.TrackedResource{ @@ -219,14 +221,14 @@ func TestAzurermPostgresqlDatabase(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockPostgresqlRespository{} + fakeRepo := &repository2.MockPostgresqlRespository{} c.mocks(fakeRepo, alerter) - var repo repository.PostgresqlRespository = fakeRepo + var repo repository2.PostgresqlRespository = fakeRepo - remoteLibrary.AddEnumerator(azurerm.NewAzurermPostgresqlDatabaseEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm2.NewAzurermPostgresqlDatabaseEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/azurerm_privatedns_scanner_test.go b/enumeration/remote/azurerm_privatedns_scanner_test.go similarity index 80% rename from pkg/remote/azurerm_privatedns_scanner_test.go rename to enumeration/remote/azurerm_privatedns_scanner_test.go index a76bc30f9..e546d41eb 100644 --- a/pkg/remote/azurerm_privatedns_scanner_test.go +++ b/enumeration/remote/azurerm_privatedns_scanner_test.go @@ -3,21 +3,23 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + azurerm2 "github.com/snyk/driftctl/enumeration/remote/azurerm" + repository2 "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + terraform2 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns" "github.com/pkg/errors" + "github.com/snyk/driftctl/enumeration/resource" + resourceazure "github.com/snyk/driftctl/enumeration/resource/azurerm" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/azurerm" - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceazure "github.com/snyk/driftctl/pkg/resource/azurerm" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" testresource "github.com/snyk/driftctl/test/resource" @@ -33,20 +35,20 @@ func TestAzurermPrivateDNSZone(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockPrivateDNSRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockPrivateDNSRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no private zone", dirName: "azurerm_private_dns_private_zone_empty", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{}, nil) }, }, { test: "error listing private zones", dirName: "azurerm_private_dns_private_zone_empty", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceazure.AzurePrivateDNSZoneResourceType), @@ -54,7 +56,7 @@ func TestAzurermPrivateDNSZone(t *testing.T) { { test: "multiple private zones", dirName: "azurerm_private_dns_private_zone_multiple", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -88,7 +90,7 @@ func TestAzurermPrivateDNSZone(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform2.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -96,15 +98,15 @@ func TestAzurermPrivateDNSZone(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform2.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockPrivateDNSRepository{} + fakeRepo := &repository2.MockPrivateDNSRepository{} c.mocks(fakeRepo, alerter) - var repo repository.PrivateDNSRepository = fakeRepo + var repo repository2.PrivateDNSRepository = fakeRepo providerVersion := "2.71.0" realProvider, err := terraformtest.InitTestAzureProvider(providerLibrary, providerVersion) if err != nil { @@ -125,13 +127,13 @@ func TestAzurermPrivateDNSZone(t *testing.T) { t.Fatal(err) } clientOptions := &arm.ClientOptions{} - repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) + repo = repository2.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(azurerm.NewAzurermPrivateDNSZoneEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSZoneResourceType, common.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSZoneResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSZoneEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSZoneResourceType, common2.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSZoneResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -155,20 +157,20 @@ func TestAzurermPrivateDNSARecord(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockPrivateDNSRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockPrivateDNSRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no private a record", dirName: "azurerm_private_dns_a_record_empty", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{}, nil) }, }, { test: "error listing private zone", dirName: "azurerm_private_dns_a_record_empty", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceazure.AzurePrivateDNSARecordResourceType, resourceazure.AzurePrivateDNSZoneResourceType), @@ -176,7 +178,7 @@ func TestAzurermPrivateDNSARecord(t *testing.T) { { test: "error listing private a records", dirName: "azurerm_private_dns_a_record_empty", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -194,7 +196,7 @@ func TestAzurermPrivateDNSARecord(t *testing.T) { { test: "multiple private a records", dirName: "azurerm_private_dns_a_record_multiple", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -242,7 +244,7 @@ func TestAzurermPrivateDNSARecord(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform2.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -250,15 +252,15 @@ func TestAzurermPrivateDNSARecord(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform2.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockPrivateDNSRepository{} + fakeRepo := &repository2.MockPrivateDNSRepository{} c.mocks(fakeRepo, alerter) - var repo repository.PrivateDNSRepository = fakeRepo + var repo repository2.PrivateDNSRepository = fakeRepo providerVersion := "2.71.0" realProvider, err := terraformtest.InitTestAzureProvider(providerLibrary, providerVersion) if err != nil { @@ -279,13 +281,13 @@ func TestAzurermPrivateDNSARecord(t *testing.T) { t.Fatal(err) } clientOptions := &arm.ClientOptions{} - repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) + repo = repository2.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(azurerm.NewAzurermPrivateDNSARecordEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSARecordResourceType, common.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSARecordResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSARecordEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSARecordResourceType, common2.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSARecordResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -309,20 +311,20 @@ func TestAzurermPrivateDNSAAAARecord(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockPrivateDNSRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockPrivateDNSRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no private aaaa record", dirName: "azurerm_private_dns_aaaa_record_empty", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{}, nil) }, }, { test: "error listing private zone", dirName: "azurerm_private_dns_aaaa_record_empty", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceazure.AzurePrivateDNSAAAARecordResourceType, resourceazure.AzurePrivateDNSZoneResourceType), @@ -330,7 +332,7 @@ func TestAzurermPrivateDNSAAAARecord(t *testing.T) { { test: "error listing private aaaa records", dirName: "azurerm_private_dns_aaaa_record_empty", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -348,7 +350,7 @@ func TestAzurermPrivateDNSAAAARecord(t *testing.T) { { test: "multiple private aaaaa records", dirName: "azurerm_private_dns_aaaaa_record_multiple", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -397,7 +399,7 @@ func TestAzurermPrivateDNSAAAARecord(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform2.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -405,15 +407,15 @@ func TestAzurermPrivateDNSAAAARecord(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform2.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockPrivateDNSRepository{} + fakeRepo := &repository2.MockPrivateDNSRepository{} c.mocks(fakeRepo, alerter) - var repo repository.PrivateDNSRepository = fakeRepo + var repo repository2.PrivateDNSRepository = fakeRepo providerVersion := "2.71.0" realProvider, err := terraformtest.InitTestAzureProvider(providerLibrary, providerVersion) if err != nil { @@ -434,13 +436,13 @@ func TestAzurermPrivateDNSAAAARecord(t *testing.T) { t.Fatal(err) } clientOptions := &arm.ClientOptions{} - repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) + repo = repository2.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(azurerm.NewAzurermPrivateDNSAAAARecordEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSAAAARecordResourceType, common.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSAAAARecordResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSAAAARecordEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSAAAARecordResourceType, common2.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSAAAARecordResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -464,20 +466,20 @@ func TestAzurermPrivateDNSCNAMERecord(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockPrivateDNSRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockPrivateDNSRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no private cname record", dirName: "azurerm_private_dns_cname_record_empty", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{}, nil) }, }, { test: "error listing private zone", dirName: "azurerm_private_dns_cname_record_empty", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceazure.AzurePrivateDNSCNameRecordResourceType, resourceazure.AzurePrivateDNSZoneResourceType), @@ -485,7 +487,7 @@ func TestAzurermPrivateDNSCNAMERecord(t *testing.T) { { test: "error listing private cname records", dirName: "azurerm_private_dns_cname_record_empty", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -503,7 +505,7 @@ func TestAzurermPrivateDNSCNAMERecord(t *testing.T) { { test: "multiple private cname records", dirName: "azurerm_private_dns_cname_record_multiple", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -540,7 +542,7 @@ func TestAzurermPrivateDNSCNAMERecord(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform2.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -548,15 +550,15 @@ func TestAzurermPrivateDNSCNAMERecord(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform2.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockPrivateDNSRepository{} + fakeRepo := &repository2.MockPrivateDNSRepository{} c.mocks(fakeRepo, alerter) - var repo repository.PrivateDNSRepository = fakeRepo + var repo repository2.PrivateDNSRepository = fakeRepo providerVersion := "2.71.0" realProvider, err := terraformtest.InitTestAzureProvider(providerLibrary, providerVersion) if err != nil { @@ -577,13 +579,13 @@ func TestAzurermPrivateDNSCNAMERecord(t *testing.T) { t.Fatal(err) } clientOptions := &arm.ClientOptions{} - repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) + repo = repository2.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(azurerm.NewAzurermPrivateDNSCNameRecordEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSCNameRecordResourceType, common.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSCNameRecordResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSCNameRecordEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSCNameRecordResourceType, common2.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSCNameRecordResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -607,20 +609,20 @@ func TestAzurermPrivateDNSPTRRecord(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockPrivateDNSRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockPrivateDNSRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no private ptr record", dirName: "azurerm_private_dns_ptr_record_empty", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{}, nil) }, }, { test: "error listing private zone", dirName: "azurerm_private_dns_ptr_record_empty", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceazure.AzurePrivateDNSPTRRecordResourceType, resourceazure.AzurePrivateDNSZoneResourceType), @@ -628,7 +630,7 @@ func TestAzurermPrivateDNSPTRRecord(t *testing.T) { { test: "error listing private ptr records", dirName: "azurerm_private_dns_ptr_record_empty", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -646,7 +648,7 @@ func TestAzurermPrivateDNSPTRRecord(t *testing.T) { { test: "multiple private ptra records", dirName: "azurerm_private_dns_ptr_record_multiple", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -694,7 +696,7 @@ func TestAzurermPrivateDNSPTRRecord(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform2.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -702,15 +704,15 @@ func TestAzurermPrivateDNSPTRRecord(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform2.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockPrivateDNSRepository{} + fakeRepo := &repository2.MockPrivateDNSRepository{} c.mocks(fakeRepo, alerter) - var repo repository.PrivateDNSRepository = fakeRepo + var repo repository2.PrivateDNSRepository = fakeRepo providerVersion := "2.71.0" realProvider, err := terraformtest.InitTestAzureProvider(providerLibrary, providerVersion) if err != nil { @@ -731,13 +733,13 @@ func TestAzurermPrivateDNSPTRRecord(t *testing.T) { t.Fatal(err) } clientOptions := &arm.ClientOptions{} - repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) + repo = repository2.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(azurerm.NewAzurermPrivateDNSPTRRecordEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSPTRRecordResourceType, common.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSPTRRecordResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSPTRRecordEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSPTRRecordResourceType, common2.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSPTRRecordResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -761,20 +763,20 @@ func TestAzurermPrivateDNSMXRecord(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockPrivateDNSRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockPrivateDNSRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no private mx record", dirName: "azurerm_private_dns_mx_record_empty", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{}, nil) }, }, { test: "error listing private zone", dirName: "azurerm_private_dns_mx_record_empty", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceazure.AzurePrivateDNSMXRecordResourceType, resourceazure.AzurePrivateDNSZoneResourceType), @@ -782,7 +784,7 @@ func TestAzurermPrivateDNSMXRecord(t *testing.T) { { test: "error listing private mx records", dirName: "azurerm_private_dns_mx_record_empty", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -800,7 +802,7 @@ func TestAzurermPrivateDNSMXRecord(t *testing.T) { { test: "multiple private mx records", dirName: "azurerm_private_dns_mx_record_multiple", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -849,7 +851,7 @@ func TestAzurermPrivateDNSMXRecord(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform2.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -857,15 +859,15 @@ func TestAzurermPrivateDNSMXRecord(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform2.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockPrivateDNSRepository{} + fakeRepo := &repository2.MockPrivateDNSRepository{} c.mocks(fakeRepo, alerter) - var repo repository.PrivateDNSRepository = fakeRepo + var repo repository2.PrivateDNSRepository = fakeRepo providerVersion := "2.71.0" realProvider, err := terraformtest.InitTestAzureProvider(providerLibrary, providerVersion) if err != nil { @@ -886,13 +888,13 @@ func TestAzurermPrivateDNSMXRecord(t *testing.T) { t.Fatal(err) } clientOptions := &arm.ClientOptions{} - repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) + repo = repository2.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(azurerm.NewAzurermPrivateDNSMXRecordEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSMXRecordResourceType, common.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSMXRecordResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSMXRecordEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSMXRecordResourceType, common2.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSMXRecordResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -916,20 +918,20 @@ func TestAzurermPrivateDNSSRVRecord(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockPrivateDNSRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockPrivateDNSRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no private srv record", dirName: "azurerm_private_dns_srv_record_empty", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{}, nil) }, }, { test: "error listing private zone", dirName: "azurerm_private_dns_srv_record_empty", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceazure.AzurePrivateDNSSRVRecordResourceType, resourceazure.AzurePrivateDNSZoneResourceType), @@ -937,7 +939,7 @@ func TestAzurermPrivateDNSSRVRecord(t *testing.T) { { test: "error listing private srv records", dirName: "azurerm_private_dns_srv_record_empty", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -955,7 +957,7 @@ func TestAzurermPrivateDNSSRVRecord(t *testing.T) { { test: "multiple private srv records", dirName: "azurerm_private_dns_srv_record_multiple", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -1003,7 +1005,7 @@ func TestAzurermPrivateDNSSRVRecord(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform2.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1011,15 +1013,15 @@ func TestAzurermPrivateDNSSRVRecord(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform2.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockPrivateDNSRepository{} + fakeRepo := &repository2.MockPrivateDNSRepository{} c.mocks(fakeRepo, alerter) - var repo repository.PrivateDNSRepository = fakeRepo + var repo repository2.PrivateDNSRepository = fakeRepo providerVersion := "2.71.0" realProvider, err := terraformtest.InitTestAzureProvider(providerLibrary, providerVersion) if err != nil { @@ -1040,13 +1042,13 @@ func TestAzurermPrivateDNSSRVRecord(t *testing.T) { t.Fatal(err) } clientOptions := &arm.ClientOptions{} - repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) + repo = repository2.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(azurerm.NewAzurermPrivateDNSSRVRecordEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSSRVRecordResourceType, common.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSSRVRecordResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSSRVRecordEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSSRVRecordResourceType, common2.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSSRVRecordResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -1070,20 +1072,20 @@ func TestAzurermPrivateDNSTXTRecord(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository.MockPrivateDNSRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockPrivateDNSRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no private txt record", dirName: "azurerm_private_dns_txt_record_empty", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{}, nil) }, }, { test: "error listing private zone", dirName: "azurerm_private_dns_txt_record_empty", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceazure.AzurePrivateDNSTXTRecordResourceType, resourceazure.AzurePrivateDNSZoneResourceType), @@ -1091,7 +1093,7 @@ func TestAzurermPrivateDNSTXTRecord(t *testing.T) { { test: "error listing private txt records", dirName: "azurerm_private_dns_txt_record_empty", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -1109,7 +1111,7 @@ func TestAzurermPrivateDNSTXTRecord(t *testing.T) { { test: "multiple private txt records", dirName: "azurerm_private_dns_txt_record_multiple", - mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -1157,7 +1159,7 @@ func TestAzurermPrivateDNSTXTRecord(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform2.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1165,15 +1167,15 @@ func TestAzurermPrivateDNSTXTRecord(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform2.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockPrivateDNSRepository{} + fakeRepo := &repository2.MockPrivateDNSRepository{} c.mocks(fakeRepo, alerter) - var repo repository.PrivateDNSRepository = fakeRepo + var repo repository2.PrivateDNSRepository = fakeRepo providerVersion := "2.71.0" realProvider, err := terraformtest.InitTestAzureProvider(providerLibrary, providerVersion) if err != nil { @@ -1194,13 +1196,13 @@ func TestAzurermPrivateDNSTXTRecord(t *testing.T) { t.Fatal(err) } clientOptions := &arm.ClientOptions{} - repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) + repo = repository2.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(azurerm.NewAzurermPrivateDNSTXTRecordEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSTXTRecordResourceType, common.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSTXTRecordResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSTXTRecordEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSTXTRecordResourceType, common2.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSTXTRecordResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/azurerm_resources_scanner_test.go b/enumeration/remote/azurerm_resources_scanner_test.go similarity index 72% rename from pkg/remote/azurerm_resources_scanner_test.go rename to enumeration/remote/azurerm_resources_scanner_test.go index 44fca9085..40b427f9c 100644 --- a/pkg/remote/azurerm_resources_scanner_test.go +++ b/enumeration/remote/azurerm_resources_scanner_test.go @@ -3,18 +3,20 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/azurerm" + repository2 "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + "github.com/snyk/driftctl/enumeration/remote/common" + error2 "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/terraform" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" "github.com/pkg/errors" + "github.com/snyk/driftctl/enumeration/resource" + resourceazure "github.com/snyk/driftctl/enumeration/resource/azurerm" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/azurerm" - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - "github.com/snyk/driftctl/pkg/remote/common" - error2 "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceazure "github.com/snyk/driftctl/pkg/resource/azurerm" - "github.com/snyk/driftctl/pkg/terraform" + testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -26,13 +28,13 @@ func TestAzurermResourceGroups(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockResourcesRepository, *mocks.AlerterInterface) + mocks func(*repository2.MockResourcesRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no resource group", - mocks: func(repository *repository.MockResourcesRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockResourcesRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllResourceGroups").Return([]*armresources.ResourceGroup{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -41,14 +43,14 @@ func TestAzurermResourceGroups(t *testing.T) { }, { test: "error listing resource groups", - mocks: func(repository *repository.MockResourcesRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockResourcesRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllResourceGroups").Return(nil, dummyError) }, wantErr: error2.NewResourceListingError(dummyError, resourceazure.AzureResourceGroupResourceType), }, { test: "multiple resource groups", - mocks: func(repository *repository.MockResourcesRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockResourcesRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllResourceGroups").Return([]*armresources.ResourceGroup{ { ID: to.StringPtr("group1"), @@ -85,14 +87,14 @@ func TestAzurermResourceGroups(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockResourcesRepository{} + fakeRepo := &repository2.MockResourcesRepository{} c.mocks(fakeRepo, alerter) - var repo repository.ResourcesRepository = fakeRepo + var repo repository2.ResourcesRepository = fakeRepo remoteLibrary.AddEnumerator(azurerm.NewAzurermResourceGroupEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/azurerm_storage_scanner_test.go b/enumeration/remote/azurerm_storage_scanner_test.go similarity index 79% rename from pkg/remote/azurerm_storage_scanner_test.go rename to enumeration/remote/azurerm_storage_scanner_test.go index 548046409..581f1a540 100644 --- a/pkg/remote/azurerm_storage_scanner_test.go +++ b/enumeration/remote/azurerm_storage_scanner_test.go @@ -3,17 +3,19 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + azurerm2 "github.com/snyk/driftctl/enumeration/remote/azurerm" + repository2 "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + "github.com/snyk/driftctl/enumeration/remote/common" + error2 "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/terraform" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage" "github.com/pkg/errors" + "github.com/snyk/driftctl/enumeration/resource" + resourceazure "github.com/snyk/driftctl/enumeration/resource/azurerm" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/azurerm" - "github.com/snyk/driftctl/pkg/remote/azurerm/repository" - "github.com/snyk/driftctl/pkg/remote/common" - error2 "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - resourceazure "github.com/snyk/driftctl/pkg/resource/azurerm" - "github.com/snyk/driftctl/pkg/terraform" + testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -25,13 +27,13 @@ func TestAzurermStorageAccount(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockStorageRespository, *mocks.AlerterInterface) + mocks func(*repository2.MockStorageRespository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no storage accounts", - mocks: func(repository *repository.MockStorageRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockStorageRespository, alerter *mocks.AlerterInterface) { repository.On("ListAllStorageAccount").Return([]*armstorage.StorageAccount{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -40,14 +42,14 @@ func TestAzurermStorageAccount(t *testing.T) { }, { test: "error listing storage accounts", - mocks: func(repository *repository.MockStorageRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockStorageRespository, alerter *mocks.AlerterInterface) { repository.On("ListAllStorageAccount").Return(nil, dummyError) }, wantErr: error2.NewResourceListingError(dummyError, resourceazure.AzureStorageAccountResourceType), }, { test: "multiple storage accounts", - mocks: func(repository *repository.MockStorageRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockStorageRespository, alerter *mocks.AlerterInterface) { repository.On("ListAllStorageAccount").Return([]*armstorage.StorageAccount{ { TrackedResource: armstorage.TrackedResource{ @@ -90,14 +92,14 @@ func TestAzurermStorageAccount(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockStorageRespository{} + fakeRepo := &repository2.MockStorageRespository{} c.mocks(fakeRepo, alerter) - var repo repository.StorageRespository = fakeRepo + var repo repository2.StorageRespository = fakeRepo - remoteLibrary.AddEnumerator(azurerm.NewAzurermStorageAccountEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm2.NewAzurermStorageAccountEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -120,13 +122,13 @@ func TestAzurermStorageContainer(t *testing.T) { tests := []struct { test string - mocks func(*repository.MockStorageRespository, *mocks.AlerterInterface) + mocks func(*repository2.MockStorageRespository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no storage accounts", - mocks: func(repository *repository.MockStorageRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockStorageRespository, alerter *mocks.AlerterInterface) { repository.On("ListAllStorageAccount").Return([]*armstorage.StorageAccount{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -135,7 +137,7 @@ func TestAzurermStorageContainer(t *testing.T) { }, { test: "no storage containers", - mocks: func(repository *repository.MockStorageRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockStorageRespository, alerter *mocks.AlerterInterface) { account1 := &armstorage.StorageAccount{ TrackedResource: armstorage.TrackedResource{ Resource: armstorage.Resource{ @@ -163,14 +165,14 @@ func TestAzurermStorageContainer(t *testing.T) { }, { test: "error listing storage accounts", - mocks: func(repository *repository.MockStorageRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockStorageRespository, alerter *mocks.AlerterInterface) { repository.On("ListAllStorageAccount").Return(nil, dummyError) }, wantErr: error2.NewResourceListingErrorWithType(dummyError, resourceazure.AzureStorageContainerResourceType, resourceazure.AzureStorageAccountResourceType), }, { test: "error listing storage container", - mocks: func(repository *repository.MockStorageRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockStorageRespository, alerter *mocks.AlerterInterface) { account := &armstorage.StorageAccount{ TrackedResource: armstorage.TrackedResource{ Resource: armstorage.Resource{ @@ -185,7 +187,7 @@ func TestAzurermStorageContainer(t *testing.T) { }, { test: "multiple storage containers", - mocks: func(repository *repository.MockStorageRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository2.MockStorageRespository, alerter *mocks.AlerterInterface) { account1 := &armstorage.StorageAccount{ TrackedResource: armstorage.TrackedResource{ Resource: armstorage.Resource{ @@ -235,14 +237,14 @@ func TestAzurermStorageContainer(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository.MockStorageRespository{} + fakeRepo := &repository2.MockStorageRespository{} c.mocks(fakeRepo, alerter) - var repo repository.StorageRespository = fakeRepo + var repo repository2.StorageRespository = fakeRepo - remoteLibrary.AddEnumerator(azurerm.NewAzurermStorageContainerEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm2.NewAzurermStorageContainerEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/cache/cache.go b/enumeration/remote/cache/cache.go similarity index 100% rename from pkg/remote/cache/cache.go rename to enumeration/remote/cache/cache.go diff --git a/pkg/remote/cache/cache_test.go b/enumeration/remote/cache/cache_test.go similarity index 98% rename from pkg/remote/cache/cache_test.go rename to enumeration/remote/cache/cache_test.go index 9f2dc6309..0598bd099 100644 --- a/pkg/remote/cache/cache_test.go +++ b/enumeration/remote/cache/cache_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" "github.com/stretchr/testify/assert" ) diff --git a/pkg/remote/cache/mock_Cache.go b/enumeration/remote/cache/mock_Cache.go similarity index 100% rename from pkg/remote/cache/mock_Cache.go rename to enumeration/remote/cache/mock_Cache.go diff --git a/pkg/remote/common/details_fetcher.go b/enumeration/remote/common/details_fetcher.go similarity index 89% rename from pkg/remote/common/details_fetcher.go rename to enumeration/remote/common/details_fetcher.go index 6b72cd65c..f990a61b4 100644 --- a/pkg/remote/common/details_fetcher.go +++ b/enumeration/remote/common/details_fetcher.go @@ -2,9 +2,9 @@ package common import ( "github.com/sirupsen/logrus" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/terraform" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/terraform" ) type DetailsFetcher interface { diff --git a/pkg/remote/common/library.go b/enumeration/remote/common/library.go similarity index 94% rename from pkg/remote/common/library.go rename to enumeration/remote/common/library.go index f28e4ef21..4b0459ba4 100644 --- a/pkg/remote/common/library.go +++ b/enumeration/remote/common/library.go @@ -1,7 +1,7 @@ package common import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) type Enumerator interface { diff --git a/pkg/remote/common/mock_Enumerator.go b/enumeration/remote/common/mock_Enumerator.go similarity index 94% rename from pkg/remote/common/mock_Enumerator.go rename to enumeration/remote/common/mock_Enumerator.go index 339d5f6a2..98ef337ed 100644 --- a/pkg/remote/common/mock_Enumerator.go +++ b/enumeration/remote/common/mock_Enumerator.go @@ -3,7 +3,7 @@ package common import ( - resource "github.com/snyk/driftctl/pkg/resource" + resource "github.com/snyk/driftctl/enumeration/resource" mock "github.com/stretchr/testify/mock" ) diff --git a/pkg/remote/common/providers.go b/enumeration/remote/common/providers.go similarity index 85% rename from pkg/remote/common/providers.go rename to enumeration/remote/common/providers.go index c8d46904d..8afd7ab11 100644 --- a/pkg/remote/common/providers.go +++ b/enumeration/remote/common/providers.go @@ -1,8 +1,8 @@ package common import ( - tf "github.com/snyk/driftctl/pkg/terraform" - "github.com/snyk/driftctl/pkg/terraform/lock" + tf "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform/lock" ) type RemoteParameter string diff --git a/pkg/remote/error/errors.go b/enumeration/remote/error/errors.go similarity index 100% rename from pkg/remote/error/errors.go rename to enumeration/remote/error/errors.go diff --git a/pkg/remote/github/github_branch_protection_enumerator.go b/enumeration/remote/github/github_branch_protection_enumerator.go similarity index 85% rename from pkg/remote/github/github_branch_protection_enumerator.go rename to enumeration/remote/github/github_branch_protection_enumerator.go index ab05579b9..eddc4e757 100644 --- a/pkg/remote/github/github_branch_protection_enumerator.go +++ b/enumeration/remote/github/github_branch_protection_enumerator.go @@ -1,9 +1,9 @@ package github import ( - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/github" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/github" ) type GithubBranchProtectionEnumerator struct { diff --git a/pkg/remote/github/github_membership_enumerator.go b/enumeration/remote/github/github_membership_enumerator.go similarity index 84% rename from pkg/remote/github/github_membership_enumerator.go rename to enumeration/remote/github/github_membership_enumerator.go index 9c5db5b70..4322e39df 100644 --- a/pkg/remote/github/github_membership_enumerator.go +++ b/enumeration/remote/github/github_membership_enumerator.go @@ -1,9 +1,9 @@ package github import ( - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/github" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/github" ) type GithubMembershipEnumerator struct { diff --git a/pkg/remote/github/github_repository_enumerator.go b/enumeration/remote/github/github_repository_enumerator.go similarity index 84% rename from pkg/remote/github/github_repository_enumerator.go rename to enumeration/remote/github/github_repository_enumerator.go index 6d6244861..e5150ffae 100644 --- a/pkg/remote/github/github_repository_enumerator.go +++ b/enumeration/remote/github/github_repository_enumerator.go @@ -1,9 +1,9 @@ package github import ( - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/github" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/github" ) type GithubRepositoryEnumerator struct { diff --git a/pkg/remote/github/github_team_enumerator.go b/enumeration/remote/github/github_team_enumerator.go similarity index 85% rename from pkg/remote/github/github_team_enumerator.go rename to enumeration/remote/github/github_team_enumerator.go index 98b195b4b..c42211904 100644 --- a/pkg/remote/github/github_team_enumerator.go +++ b/enumeration/remote/github/github_team_enumerator.go @@ -2,10 +2,10 @@ package github import ( "fmt" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/github" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/github" ) type GithubTeamEnumerator struct { diff --git a/pkg/remote/github/github_team_membership_enumerator.go b/enumeration/remote/github/github_team_membership_enumerator.go similarity index 85% rename from pkg/remote/github/github_team_membership_enumerator.go rename to enumeration/remote/github/github_team_membership_enumerator.go index 7f87be72e..ae610c9bf 100644 --- a/pkg/remote/github/github_team_membership_enumerator.go +++ b/enumeration/remote/github/github_team_membership_enumerator.go @@ -1,9 +1,9 @@ package github import ( - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/github" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/github" ) type GithubTeamMembershipEnumerator struct { diff --git a/pkg/remote/github/init.go b/enumeration/remote/github/init.go similarity index 63% rename from pkg/remote/github/init.go rename to enumeration/remote/github/init.go index 68924cbd2..64a978519 100644 --- a/pkg/remote/github/init.go +++ b/enumeration/remote/github/init.go @@ -1,13 +1,13 @@ package github import ( - "github.com/snyk/driftctl/pkg/alerter" - "github.com/snyk/driftctl/pkg/output" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/github" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/alerter" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/github" + "github.com/snyk/driftctl/enumeration/terraform" ) /** @@ -17,8 +17,8 @@ import ( func Init(version string, alerter *alerter.Alerter, providerLibrary *terraform.ProviderLibrary, - remoteLibrary *common.RemoteLibrary, - progress output.Progress, + remoteLibrary *common2.RemoteLibrary, + progress enumeration.ProgressCounter, resourceSchemaRepository *resource.SchemaRepository, factory resource.ResourceFactory, configDir string) error { @@ -39,19 +39,19 @@ func Init(version string, alerter *alerter.Alerter, providerLibrary.AddProvider(terraform.GITHUB, provider) remoteLibrary.AddEnumerator(NewGithubTeamEnumerator(repository, factory)) - remoteLibrary.AddDetailsFetcher(github.GithubTeamResourceType, common.NewGenericDetailsFetcher(github.GithubTeamResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(github.GithubTeamResourceType, common2.NewGenericDetailsFetcher(github.GithubTeamResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewGithubRepositoryEnumerator(repository, factory)) - remoteLibrary.AddDetailsFetcher(github.GithubRepositoryResourceType, common.NewGenericDetailsFetcher(github.GithubRepositoryResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(github.GithubRepositoryResourceType, common2.NewGenericDetailsFetcher(github.GithubRepositoryResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewGithubMembershipEnumerator(repository, factory)) - remoteLibrary.AddDetailsFetcher(github.GithubMembershipResourceType, common.NewGenericDetailsFetcher(github.GithubMembershipResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(github.GithubMembershipResourceType, common2.NewGenericDetailsFetcher(github.GithubMembershipResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewGithubTeamMembershipEnumerator(repository, factory)) - remoteLibrary.AddDetailsFetcher(github.GithubTeamMembershipResourceType, common.NewGenericDetailsFetcher(github.GithubTeamMembershipResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(github.GithubTeamMembershipResourceType, common2.NewGenericDetailsFetcher(github.GithubTeamMembershipResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewGithubBranchProtectionEnumerator(repository, factory)) - remoteLibrary.AddDetailsFetcher(github.GithubBranchProtectionResourceType, common.NewGenericDetailsFetcher(github.GithubBranchProtectionResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(github.GithubBranchProtectionResourceType, common2.NewGenericDetailsFetcher(github.GithubBranchProtectionResourceType, provider, deserializer)) err = resourceSchemaRepository.Init(terraform.GITHUB, provider.Version(), provider.Schema()) if err != nil { diff --git a/pkg/remote/github/mock_GithubRepository.go b/enumeration/remote/github/mock_GithubRepository.go similarity index 100% rename from pkg/remote/github/mock_GithubRepository.go rename to enumeration/remote/github/mock_GithubRepository.go diff --git a/pkg/remote/github/provider.go b/enumeration/remote/github/provider.go similarity index 78% rename from pkg/remote/github/provider.go rename to enumeration/remote/github/provider.go index b893e5546..b2b595ad6 100644 --- a/pkg/remote/github/provider.go +++ b/enumeration/remote/github/provider.go @@ -3,9 +3,9 @@ package github import ( "os" - "github.com/snyk/driftctl/pkg/output" - "github.com/snyk/driftctl/pkg/remote/terraform" - tf "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/terraform" + terraform2 "github.com/snyk/driftctl/enumeration/terraform" ) type GithubTerraformProvider struct { @@ -20,7 +20,7 @@ type githubConfig struct { Organization string } -func NewGithubTerraformProvider(version string, progress output.Progress, configDir string) (*GithubTerraformProvider, error) { +func NewGithubTerraformProvider(version string, progress enumeration.ProgressCounter, configDir string) (*GithubTerraformProvider, error) { if version == "" { version = "4.4.0" } @@ -28,7 +28,7 @@ func NewGithubTerraformProvider(version string, progress output.Progress, config version: version, name: "github", } - installer, err := tf.NewProviderInstaller(tf.ProviderConfig{ + installer, err := terraform2.NewProviderInstaller(terraform2.ProviderConfig{ Key: p.name, Version: version, ConfigDir: configDir, diff --git a/pkg/remote/github/repository.go b/enumeration/remote/github/repository.go similarity index 99% rename from pkg/remote/github/repository.go rename to enumeration/remote/github/repository.go index 25bfdb542..80cfaed0f 100644 --- a/pkg/remote/github/repository.go +++ b/enumeration/remote/github/repository.go @@ -3,9 +3,9 @@ package github import ( "context" "fmt" + "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/shurcooL/githubv4" - "github.com/snyk/driftctl/pkg/remote/cache" "golang.org/x/oauth2" ) diff --git a/pkg/remote/github/repository_test.go b/enumeration/remote/github/repository_test.go similarity index 99% rename from pkg/remote/github/repository_test.go rename to enumeration/remote/github/repository_test.go index 8b95e64c5..215aafa26 100644 --- a/pkg/remote/github/repository_test.go +++ b/enumeration/remote/github/repository_test.go @@ -2,12 +2,12 @@ package github import ( "context" + "github.com/snyk/driftctl/enumeration/remote/cache" "testing" "github.com/pkg/errors" "github.com/shurcooL/githubv4" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/remote/cache" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) diff --git a/pkg/remote/github_branch_protection_scanner_test.go b/enumeration/remote/github_branch_protection_scanner_test.go similarity index 52% rename from pkg/remote/github_branch_protection_scanner_test.go rename to enumeration/remote/github_branch_protection_scanner_test.go index 8cf2b31dc..e28012856 100644 --- a/pkg/remote/github_branch_protection_scanner_test.go +++ b/enumeration/remote/github_branch_protection_scanner_test.go @@ -3,21 +3,23 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + github2 "github.com/snyk/driftctl/enumeration/remote/github" + terraform2 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/pkg/errors" + githubres "github.com/snyk/driftctl/enumeration/resource/github" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/github" - githubres "github.com/snyk/driftctl/pkg/resource/github" - "github.com/snyk/driftctl/pkg/terraform" + testresource "github.com/snyk/driftctl/test/resource" tftest "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/mock" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" "github.com/stretchr/testify/assert" @@ -28,13 +30,13 @@ func TestScanGithubBranchProtection(t *testing.T) { cases := []struct { test string dirName string - mocks func(*github.MockGithubRepository, *mocks.AlerterInterface) + mocks func(*github2.MockGithubRepository, *mocks.AlerterInterface) err error }{ { test: "no branch protection", dirName: "github_branch_protection_empty", - mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListBranchProtection").Return([]string{}, nil) }, err: nil, @@ -42,14 +44,14 @@ func TestScanGithubBranchProtection(t *testing.T) { { test: "Multiple branch protections", dirName: "github_branch_protection_multiples", - mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListBranchProtection").Return([]string{ - "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzI=", //"repo0:main" - "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0Nzg=", //"repo0:toto" - "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzQ=", //"repo1:main" - "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0ODA=", //"repo1:toto" - "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzE=", //"repo2:main" - "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0Nzc=", //"repo2:toto" + "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzI=", // "repo0:main" + "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0Nzg=", // "repo0:toto" + "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzQ=", // "repo1:main" + "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0ODA=", // "repo1:toto" + "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzE=", // "repo2:main" + "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0Nzc=", // "repo2:toto" }, nil) }, err: nil, @@ -57,10 +59,10 @@ func TestScanGithubBranchProtection(t *testing.T) { { test: "cannot list branch protections", dirName: "github_branch_protection_empty", - mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListBranchProtection").Return(nil, errors.New("Your token has not been granted the required scopes to execute this query.")) - alerter.On("SendAlert", githubres.GithubBranchProtectionResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), githubres.GithubBranchProtectionResourceType, githubres.GithubBranchProtectionResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", githubres.GithubBranchProtectionResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), githubres.GithubBranchProtectionResourceType, githubres.GithubBranchProtectionResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -68,7 +70,7 @@ func TestScanGithubBranchProtection(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("github", "4.4.0") githubres.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform2.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -77,15 +79,15 @@ func TestScanGithubBranchProtection(t *testing.T) { scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform2.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - mockedRepo := github.MockGithubRepository{} + mockedRepo := github2.MockGithubRepository{} c.mocks(&mockedRepo, alerter) - var repo github.GithubRepository = &mockedRepo + var repo github2.GithubRepository = &mockedRepo realProvider, err := tftest.InitTestGithubProvider(providerLibrary, "4.4.0") if err != nil { @@ -100,13 +102,13 @@ func TestScanGithubBranchProtection(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = github.NewGithubRepository(realProvider.GetConfig(), cache.New(0)) + repo = github2.NewGithubRepository(realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(github.NewGithubBranchProtectionEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(githubres.GithubBranchProtectionResourceType, common.NewGenericDetailsFetcher(githubres.GithubBranchProtectionResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(github2.NewGithubBranchProtectionEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(githubres.GithubBranchProtectionResourceType, common2.NewGenericDetailsFetcher(githubres.GithubBranchProtectionResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/github_membership_scanner_test.go b/enumeration/remote/github_membership_scanner_test.go similarity index 58% rename from pkg/remote/github_membership_scanner_test.go rename to enumeration/remote/github_membership_scanner_test.go index c3fbda9d9..acb9a6871 100644 --- a/pkg/remote/github_membership_scanner_test.go +++ b/enumeration/remote/github_membership_scanner_test.go @@ -4,20 +4,22 @@ import ( "errors" "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + github2 "github.com/snyk/driftctl/enumeration/remote/github" + terraform2 "github.com/snyk/driftctl/enumeration/terraform" + + githubres "github.com/snyk/driftctl/enumeration/resource/github" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/github" - githubres "github.com/snyk/driftctl/pkg/resource/github" - "github.com/snyk/driftctl/pkg/terraform" + testresource "github.com/snyk/driftctl/test/resource" tftest "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/mock" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" "github.com/stretchr/testify/assert" @@ -28,13 +30,13 @@ func TestScanGithubMembership(t *testing.T) { cases := []struct { test string dirName string - mocks func(*github.MockGithubRepository, *mocks.AlerterInterface) + mocks func(*github2.MockGithubRepository, *mocks.AlerterInterface) err error }{ { test: "no members", dirName: "github_membership_empty", - mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListMembership").Return([]string{}, nil) }, err: nil, @@ -42,7 +44,7 @@ func TestScanGithubMembership(t *testing.T) { { test: "Multiple membership with admin and member roles", dirName: "github_membership_multiple", - mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListMembership").Return([]string{ "driftctl-test:driftctl-acceptance-tester", "driftctl-test:eliecharra", @@ -53,10 +55,10 @@ func TestScanGithubMembership(t *testing.T) { { test: "cannot list membership", dirName: "github_membership_empty", - mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListMembership").Return(nil, errors.New("Your token has not been granted the required scopes to execute this query.")) - alerter.On("SendAlert", githubres.GithubMembershipResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), githubres.GithubMembershipResourceType, githubres.GithubMembershipResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", githubres.GithubMembershipResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), githubres.GithubMembershipResourceType, githubres.GithubMembershipResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -64,7 +66,7 @@ func TestScanGithubMembership(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("github", "4.4.0") githubres.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform2.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -73,15 +75,15 @@ func TestScanGithubMembership(t *testing.T) { scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform2.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - mockedRepo := github.MockGithubRepository{} + mockedRepo := github2.MockGithubRepository{} c.mocks(&mockedRepo, alerter) - var repo github.GithubRepository = &mockedRepo + var repo github2.GithubRepository = &mockedRepo realProvider, err := tftest.InitTestGithubProvider(providerLibrary, "4.4.0") if err != nil { @@ -96,13 +98,13 @@ func TestScanGithubMembership(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = github.NewGithubRepository(realProvider.GetConfig(), cache.New(0)) + repo = github2.NewGithubRepository(realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(github.NewGithubMembershipEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(githubres.GithubMembershipResourceType, common.NewGenericDetailsFetcher(githubres.GithubMembershipResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(github2.NewGithubMembershipEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(githubres.GithubMembershipResourceType, common2.NewGenericDetailsFetcher(githubres.GithubMembershipResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/github_repository_scanner_test.go b/enumeration/remote/github_repository_scanner_test.go similarity index 58% rename from pkg/remote/github_repository_scanner_test.go rename to enumeration/remote/github_repository_scanner_test.go index f0b2a8c12..14bac7c47 100644 --- a/pkg/remote/github_repository_scanner_test.go +++ b/enumeration/remote/github_repository_scanner_test.go @@ -4,20 +4,22 @@ import ( "errors" "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + github2 "github.com/snyk/driftctl/enumeration/remote/github" + terraform2 "github.com/snyk/driftctl/enumeration/terraform" + + githubres "github.com/snyk/driftctl/enumeration/resource/github" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/github" - githubres "github.com/snyk/driftctl/pkg/resource/github" - "github.com/snyk/driftctl/pkg/terraform" + testresource "github.com/snyk/driftctl/test/resource" tftest "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/mock" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" "github.com/stretchr/testify/assert" @@ -28,13 +30,13 @@ func TestScanGithubRepository(t *testing.T) { tests := []struct { test string dirName string - mocks func(*github.MockGithubRepository, *mocks.AlerterInterface) + mocks func(*github2.MockGithubRepository, *mocks.AlerterInterface) err error }{ { test: "no github repos", dirName: "github_repository_empty", - mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListRepositories").Return([]string{}, nil) }, err: nil, @@ -42,7 +44,7 @@ func TestScanGithubRepository(t *testing.T) { { test: "Multiple github repos Table", dirName: "github_repository_multiple", - mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListRepositories").Return([]string{ "driftctl", "driftctl-demos", @@ -53,10 +55,10 @@ func TestScanGithubRepository(t *testing.T) { { test: "cannot list repositories", dirName: "github_repository_empty", - mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListRepositories").Return(nil, errors.New("Your token has not been granted the required scopes to execute this query.")) - alerter.On("SendAlert", githubres.GithubRepositoryResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), githubres.GithubRepositoryResourceType, githubres.GithubRepositoryResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", githubres.GithubRepositoryResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), githubres.GithubRepositoryResourceType, githubres.GithubRepositoryResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -64,7 +66,7 @@ func TestScanGithubRepository(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("github", "4.4.0") githubres.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform2.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -73,15 +75,15 @@ func TestScanGithubRepository(t *testing.T) { scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform2.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - mockedRepo := github.MockGithubRepository{} + mockedRepo := github2.MockGithubRepository{} c.mocks(&mockedRepo, alerter) - var repo github.GithubRepository = &mockedRepo + var repo github2.GithubRepository = &mockedRepo realProvider, err := tftest.InitTestGithubProvider(providerLibrary, "4.4.0") if err != nil { @@ -96,13 +98,13 @@ func TestScanGithubRepository(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = github.NewGithubRepository(realProvider.GetConfig(), cache.New(0)) + repo = github2.NewGithubRepository(realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(github.NewGithubRepositoryEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(githubres.GithubRepositoryResourceType, common.NewGenericDetailsFetcher(githubres.GithubRepositoryResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(github2.NewGithubRepositoryEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(githubres.GithubRepositoryResourceType, common2.NewGenericDetailsFetcher(githubres.GithubRepositoryResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/github_team_membership_scanner_test.go b/enumeration/remote/github_team_membership_scanner_test.go similarity index 58% rename from pkg/remote/github_team_membership_scanner_test.go rename to enumeration/remote/github_team_membership_scanner_test.go index d2c5f1b0b..5bb078e75 100644 --- a/pkg/remote/github_team_membership_scanner_test.go +++ b/enumeration/remote/github_team_membership_scanner_test.go @@ -4,20 +4,22 @@ import ( "errors" "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + github2 "github.com/snyk/driftctl/enumeration/remote/github" + terraform2 "github.com/snyk/driftctl/enumeration/terraform" + + githubres "github.com/snyk/driftctl/enumeration/resource/github" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/github" - githubres "github.com/snyk/driftctl/pkg/resource/github" - "github.com/snyk/driftctl/pkg/terraform" + testresource "github.com/snyk/driftctl/test/resource" tftest "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/mock" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" "github.com/stretchr/testify/assert" @@ -28,13 +30,13 @@ func TestScanGithubTeamMembership(t *testing.T) { cases := []struct { test string dirName string - mocks func(*github.MockGithubRepository, *mocks.AlerterInterface) + mocks func(*github2.MockGithubRepository, *mocks.AlerterInterface) err error }{ { test: "no github team memberships", dirName: "github_team_membership_empty", - mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListTeamMemberships").Return([]string{}, nil) }, err: nil, @@ -42,7 +44,7 @@ func TestScanGithubTeamMembership(t *testing.T) { { test: "multiple github team memberships", dirName: "github_team_membership_multiple", - mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListTeamMemberships").Return([]string{ "4570529:driftctl-acceptance-tester", "4570529:wbeuil", @@ -53,10 +55,10 @@ func TestScanGithubTeamMembership(t *testing.T) { { test: "cannot list team membership", dirName: "github_team_membership_empty", - mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListTeamMemberships").Return(nil, errors.New("Your token has not been granted the required scopes to execute this query.")) - alerter.On("SendAlert", githubres.GithubTeamMembershipResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), githubres.GithubTeamMembershipResourceType, githubres.GithubTeamMembershipResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", githubres.GithubTeamMembershipResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), githubres.GithubTeamMembershipResourceType, githubres.GithubTeamMembershipResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -64,7 +66,7 @@ func TestScanGithubTeamMembership(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("github", "4.4.0") githubres.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform2.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -73,15 +75,15 @@ func TestScanGithubTeamMembership(t *testing.T) { scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform2.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - mockedRepo := github.MockGithubRepository{} + mockedRepo := github2.MockGithubRepository{} c.mocks(&mockedRepo, alerter) - var repo github.GithubRepository = &mockedRepo + var repo github2.GithubRepository = &mockedRepo realProvider, err := tftest.InitTestGithubProvider(providerLibrary, "4.4.0") if err != nil { @@ -96,13 +98,13 @@ func TestScanGithubTeamMembership(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = github.NewGithubRepository(realProvider.GetConfig(), cache.New(0)) + repo = github2.NewGithubRepository(realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(github.NewGithubTeamMembershipEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(githubres.GithubTeamMembershipResourceType, common.NewGenericDetailsFetcher(githubres.GithubTeamMembershipResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(github2.NewGithubTeamMembershipEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(githubres.GithubTeamMembershipResourceType, common2.NewGenericDetailsFetcher(githubres.GithubTeamMembershipResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/github_team_scanner_test.go b/enumeration/remote/github_team_scanner_test.go similarity index 56% rename from pkg/remote/github_team_scanner_test.go rename to enumeration/remote/github_team_scanner_test.go index 6dc517225..f99f3c2d2 100644 --- a/pkg/remote/github_team_scanner_test.go +++ b/enumeration/remote/github_team_scanner_test.go @@ -4,20 +4,22 @@ import ( "errors" "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + github2 "github.com/snyk/driftctl/enumeration/remote/github" + terraform2 "github.com/snyk/driftctl/enumeration/terraform" + + githubres "github.com/snyk/driftctl/enumeration/resource/github" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/github" - githubres "github.com/snyk/driftctl/pkg/resource/github" - "github.com/snyk/driftctl/pkg/terraform" + testresource "github.com/snyk/driftctl/test/resource" tftest "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/mock" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" "github.com/stretchr/testify/assert" @@ -28,22 +30,22 @@ func TestScanGithubTeam(t *testing.T) { tests := []struct { test string dirName string - mocks func(*github.MockGithubRepository, *mocks.AlerterInterface) + mocks func(*github2.MockGithubRepository, *mocks.AlerterInterface) err error }{ { test: "no github teams", dirName: "github_teams_empty", - mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { - client.On("ListTeams").Return([]github.Team{}, nil) + mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { + client.On("ListTeams").Return([]github2.Team{}, nil) }, err: nil, }, { test: "Multiple github teams with parent", dirName: "github_teams_multiple", - mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { - client.On("ListTeams").Return([]github.Team{ + mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { + client.On("ListTeams").Return([]github2.Team{ {DatabaseId: 4556811}, // github_team.team1 {DatabaseId: 4556812}, // github_team.team2 {DatabaseId: 4556814}, // github_team.with_parent @@ -54,10 +56,10 @@ func TestScanGithubTeam(t *testing.T) { { test: "cannot list teams", dirName: "github_teams_empty", - mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListTeams").Return(nil, errors.New("Your token has not been granted the required scopes to execute this query.")) - alerter.On("SendAlert", githubres.GithubTeamResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), githubres.GithubTeamResourceType, githubres.GithubTeamResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", githubres.GithubTeamResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), githubres.GithubTeamResourceType, githubres.GithubTeamResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -65,7 +67,7 @@ func TestScanGithubTeam(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("github", "4.4.0") githubres.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform2.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -74,15 +76,15 @@ func TestScanGithubTeam(t *testing.T) { scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform2.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - mockedRepo := github.MockGithubRepository{} + mockedRepo := github2.MockGithubRepository{} c.mocks(&mockedRepo, alerter) - var repo github.GithubRepository = &mockedRepo + var repo github2.GithubRepository = &mockedRepo realProvider, err := tftest.InitTestGithubProvider(providerLibrary, "4.4.0") if err != nil { @@ -97,13 +99,13 @@ func TestScanGithubTeam(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = github.NewGithubRepository(realProvider.GetConfig(), cache.New(0)) + repo = github2.NewGithubRepository(realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(github.NewGithubTeamEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(githubres.GithubTeamResourceType, common.NewGenericDetailsFetcher(githubres.GithubTeamResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(github2.NewGithubTeamEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(githubres.GithubTeamResourceType, common2.NewGenericDetailsFetcher(githubres.GithubTeamResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/google/config/config.go b/enumeration/remote/google/config/config.go similarity index 100% rename from pkg/remote/google/config/config.go rename to enumeration/remote/google/config/config.go diff --git a/pkg/remote/google/google_bigquery_dataset_enumerator.go b/enumeration/remote/google/google_bigquery_dataset_enumerator.go similarity index 82% rename from pkg/remote/google/google_bigquery_dataset_enumerator.go rename to enumeration/remote/google/google_bigquery_dataset_enumerator.go index a3d9276a8..1c799aa93 100644 --- a/pkg/remote/google/google_bigquery_dataset_enumerator.go +++ b/enumeration/remote/google/google_bigquery_dataset_enumerator.go @@ -1,10 +1,10 @@ package google import ( - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google/repository" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) type GoogleBigqueryDatasetEnumerator struct { diff --git a/pkg/remote/google/google_bigquery_table_enumerator.go b/enumeration/remote/google/google_bigquery_table_enumerator.go similarity index 82% rename from pkg/remote/google/google_bigquery_table_enumerator.go rename to enumeration/remote/google/google_bigquery_table_enumerator.go index 465db9732..6b4dbea17 100644 --- a/pkg/remote/google/google_bigquery_table_enumerator.go +++ b/enumeration/remote/google/google_bigquery_table_enumerator.go @@ -1,10 +1,10 @@ package google import ( - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google/repository" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) type GoogleBigqueryTableEnumerator struct { diff --git a/pkg/remote/google/google_bigtable_instance_enumerator.go b/enumeration/remote/google/google_bigtable_instance_enumerator.go similarity index 84% rename from pkg/remote/google/google_bigtable_instance_enumerator.go rename to enumeration/remote/google/google_bigtable_instance_enumerator.go index 9bce37d1b..ef4fed108 100644 --- a/pkg/remote/google/google_bigtable_instance_enumerator.go +++ b/enumeration/remote/google/google_bigtable_instance_enumerator.go @@ -2,10 +2,10 @@ package google import ( "github.com/sirupsen/logrus" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google/repository" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) type GoogleBigTableInstanceEnumerator struct { diff --git a/pkg/remote/google/google_bigtable_table_enumerator.go b/enumeration/remote/google/google_bigtable_table_enumerator.go similarity index 84% rename from pkg/remote/google/google_bigtable_table_enumerator.go rename to enumeration/remote/google/google_bigtable_table_enumerator.go index 1257bd691..32dc677bb 100644 --- a/pkg/remote/google/google_bigtable_table_enumerator.go +++ b/enumeration/remote/google/google_bigtable_table_enumerator.go @@ -2,10 +2,10 @@ package google import ( "github.com/sirupsen/logrus" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google/repository" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) type GoogleBigtableTableEnumerator struct { diff --git a/pkg/remote/google/google_cloudfunctions_function_enumerator.go b/enumeration/remote/google/google_cloudfunctions_function_enumerator.go similarity index 85% rename from pkg/remote/google/google_cloudfunctions_function_enumerator.go rename to enumeration/remote/google/google_cloudfunctions_function_enumerator.go index 21a9513a4..914ac6b90 100644 --- a/pkg/remote/google/google_cloudfunctions_function_enumerator.go +++ b/enumeration/remote/google/google_cloudfunctions_function_enumerator.go @@ -2,10 +2,10 @@ package google import ( "github.com/sirupsen/logrus" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google/repository" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) type GoogleCloudFunctionsFunctionEnumerator struct { diff --git a/pkg/remote/google/google_cloudrun_service_enumerator.go b/enumeration/remote/google/google_cloudrun_service_enumerator.go similarity index 86% rename from pkg/remote/google/google_cloudrun_service_enumerator.go rename to enumeration/remote/google/google_cloudrun_service_enumerator.go index a3db094f8..2a8cdc0e7 100644 --- a/pkg/remote/google/google_cloudrun_service_enumerator.go +++ b/enumeration/remote/google/google_cloudrun_service_enumerator.go @@ -1,13 +1,13 @@ package google import ( + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google/repository" "strings" "github.com/sirupsen/logrus" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) type GoogleCloudRunServiceEnumerator struct { diff --git a/pkg/remote/google/google_compute_address_enumerator.go b/enumeration/remote/google/google_compute_address_enumerator.go similarity index 85% rename from pkg/remote/google/google_compute_address_enumerator.go rename to enumeration/remote/google/google_compute_address_enumerator.go index 419d3aa5d..93a193827 100644 --- a/pkg/remote/google/google_compute_address_enumerator.go +++ b/enumeration/remote/google/google_compute_address_enumerator.go @@ -1,10 +1,10 @@ package google import ( - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google/repository" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) type GoogleComputeAddressEnumerator struct { diff --git a/pkg/remote/google/google_compute_disk_enumerator.go b/enumeration/remote/google/google_compute_disk_enumerator.go similarity index 81% rename from pkg/remote/google/google_compute_disk_enumerator.go rename to enumeration/remote/google/google_compute_disk_enumerator.go index a7786db02..856eac25d 100644 --- a/pkg/remote/google/google_compute_disk_enumerator.go +++ b/enumeration/remote/google/google_compute_disk_enumerator.go @@ -1,10 +1,10 @@ package google import ( - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google/repository" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) type GoogleComputeDiskEnumerator struct { diff --git a/pkg/remote/google/google_compute_firewall_enumerator.go b/enumeration/remote/google/google_compute_firewall_enumerator.go similarity index 85% rename from pkg/remote/google/google_compute_firewall_enumerator.go rename to enumeration/remote/google/google_compute_firewall_enumerator.go index b6b71568c..b0a75a7a2 100644 --- a/pkg/remote/google/google_compute_firewall_enumerator.go +++ b/enumeration/remote/google/google_compute_firewall_enumerator.go @@ -1,13 +1,13 @@ package google import ( + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google/repository" "strings" "github.com/sirupsen/logrus" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) type GoogleComputeFirewallEnumerator struct { diff --git a/pkg/remote/google/google_compute_forwarding_rule_enumerator.go b/enumeration/remote/google/google_compute_forwarding_rule_enumerator.go similarity index 82% rename from pkg/remote/google/google_compute_forwarding_rule_enumerator.go rename to enumeration/remote/google/google_compute_forwarding_rule_enumerator.go index 99561491e..1da141618 100644 --- a/pkg/remote/google/google_compute_forwarding_rule_enumerator.go +++ b/enumeration/remote/google/google_compute_forwarding_rule_enumerator.go @@ -1,10 +1,10 @@ package google import ( - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google/repository" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) type GoogleComputeForwardingRuleEnumerator struct { diff --git a/pkg/remote/google/google_compute_global_address_enumerator.go b/enumeration/remote/google/google_compute_global_address_enumerator.go similarity index 86% rename from pkg/remote/google/google_compute_global_address_enumerator.go rename to enumeration/remote/google/google_compute_global_address_enumerator.go index 0980e2be7..6dc0647b3 100644 --- a/pkg/remote/google/google_compute_global_address_enumerator.go +++ b/enumeration/remote/google/google_compute_global_address_enumerator.go @@ -2,10 +2,10 @@ package google import ( "github.com/sirupsen/logrus" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google/repository" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) type GoogleComputeGlobalAddressEnumerator struct { diff --git a/pkg/remote/google/google_compute_global_forwarding_rule_enumerator.go b/enumeration/remote/google/google_compute_global_forwarding_rule_enumerator.go similarity index 83% rename from pkg/remote/google/google_compute_global_forwarding_rule_enumerator.go rename to enumeration/remote/google/google_compute_global_forwarding_rule_enumerator.go index 8e293a2d3..54fedb286 100644 --- a/pkg/remote/google/google_compute_global_forwarding_rule_enumerator.go +++ b/enumeration/remote/google/google_compute_global_forwarding_rule_enumerator.go @@ -1,10 +1,10 @@ package google import ( - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google/repository" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) type GoogleComputeGlobalForwardingRuleEnumerator struct { diff --git a/pkg/remote/google/google_compute_health_check_enumerator.go b/enumeration/remote/google/google_compute_health_check_enumerator.go similarity index 82% rename from pkg/remote/google/google_compute_health_check_enumerator.go rename to enumeration/remote/google/google_compute_health_check_enumerator.go index 046315600..275e4e0b9 100644 --- a/pkg/remote/google/google_compute_health_check_enumerator.go +++ b/enumeration/remote/google/google_compute_health_check_enumerator.go @@ -1,10 +1,10 @@ package google import ( - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google/repository" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) type GoogleComputeHealthCheckEnumerator struct { diff --git a/pkg/remote/google/google_compute_image_enumerator.go b/enumeration/remote/google/google_compute_image_enumerator.go similarity index 82% rename from pkg/remote/google/google_compute_image_enumerator.go rename to enumeration/remote/google/google_compute_image_enumerator.go index 7ee88314d..7dbf3de2a 100644 --- a/pkg/remote/google/google_compute_image_enumerator.go +++ b/enumeration/remote/google/google_compute_image_enumerator.go @@ -1,10 +1,10 @@ package google import ( - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google/repository" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) type GoogleComputeImageEnumerator struct { diff --git a/pkg/remote/google/google_compute_instance_enumerator.go b/enumeration/remote/google/google_compute_instance_enumerator.go similarity index 81% rename from pkg/remote/google/google_compute_instance_enumerator.go rename to enumeration/remote/google/google_compute_instance_enumerator.go index 05f87830e..547c8a3f7 100644 --- a/pkg/remote/google/google_compute_instance_enumerator.go +++ b/enumeration/remote/google/google_compute_instance_enumerator.go @@ -1,10 +1,10 @@ package google import ( - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google/repository" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) type GoogleComputeInstanceEnumerator struct { diff --git a/pkg/remote/google/google_compute_instance_group_enumerator.go b/enumeration/remote/google/google_compute_instance_group_enumerator.go similarity index 86% rename from pkg/remote/google/google_compute_instance_group_enumerator.go rename to enumeration/remote/google/google_compute_instance_group_enumerator.go index eadc4e6aa..dfa987c34 100644 --- a/pkg/remote/google/google_compute_instance_group_enumerator.go +++ b/enumeration/remote/google/google_compute_instance_group_enumerator.go @@ -1,13 +1,13 @@ package google import ( + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google/repository" "strings" "github.com/sirupsen/logrus" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) type GoogleComputeInstanceGroupEnumerator struct { diff --git a/pkg/remote/google/google_compute_instance_group_manager_enumerator.go b/enumeration/remote/google/google_compute_instance_group_manager_enumerator.go similarity index 85% rename from pkg/remote/google/google_compute_instance_group_manager_enumerator.go rename to enumeration/remote/google/google_compute_instance_group_manager_enumerator.go index 6c466aea0..3257cc708 100644 --- a/pkg/remote/google/google_compute_instance_group_manager_enumerator.go +++ b/enumeration/remote/google/google_compute_instance_group_manager_enumerator.go @@ -1,13 +1,13 @@ package google import ( + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google/repository" "strings" "github.com/sirupsen/logrus" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) type GoogleComputeInstanceGroupManagerEnumerator struct { diff --git a/pkg/remote/google/google_compute_network_enumerator.go b/enumeration/remote/google/google_compute_network_enumerator.go similarity index 82% rename from pkg/remote/google/google_compute_network_enumerator.go rename to enumeration/remote/google/google_compute_network_enumerator.go index 07e0e2620..a58a29ac4 100644 --- a/pkg/remote/google/google_compute_network_enumerator.go +++ b/enumeration/remote/google/google_compute_network_enumerator.go @@ -1,10 +1,10 @@ package google import ( - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google/repository" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) type GoogleComputeNetworkEnumerator struct { diff --git a/pkg/remote/google/google_compute_node_group_enumerator.go b/enumeration/remote/google/google_compute_node_group_enumerator.go similarity index 82% rename from pkg/remote/google/google_compute_node_group_enumerator.go rename to enumeration/remote/google/google_compute_node_group_enumerator.go index 910b93722..fe2d724fc 100644 --- a/pkg/remote/google/google_compute_node_group_enumerator.go +++ b/enumeration/remote/google/google_compute_node_group_enumerator.go @@ -1,10 +1,10 @@ package google import ( - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google/repository" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) type GoogleComputeNodeGroupEnumerator struct { diff --git a/pkg/remote/google/google_compute_router_enumerator.go b/enumeration/remote/google/google_compute_router_enumerator.go similarity index 81% rename from pkg/remote/google/google_compute_router_enumerator.go rename to enumeration/remote/google/google_compute_router_enumerator.go index 8b8ec8023..7c2d3f184 100644 --- a/pkg/remote/google/google_compute_router_enumerator.go +++ b/enumeration/remote/google/google_compute_router_enumerator.go @@ -1,10 +1,10 @@ package google import ( - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google/repository" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) type GoogleComputeRouterEnumerator struct { diff --git a/pkg/remote/google/google_compute_subnetwork_enumerator.go b/enumeration/remote/google/google_compute_subnetwork_enumerator.go similarity index 82% rename from pkg/remote/google/google_compute_subnetwork_enumerator.go rename to enumeration/remote/google/google_compute_subnetwork_enumerator.go index 307eee79d..19d4fabeb 100644 --- a/pkg/remote/google/google_compute_subnetwork_enumerator.go +++ b/enumeration/remote/google/google_compute_subnetwork_enumerator.go @@ -1,10 +1,10 @@ package google import ( - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google/repository" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) type GoogleComputeSubnetworkEnumerator struct { diff --git a/pkg/remote/google/google_dns_managed_zone_enumerator.go b/enumeration/remote/google/google_dns_managed_zone_enumerator.go similarity index 86% rename from pkg/remote/google/google_dns_managed_zone_enumerator.go rename to enumeration/remote/google/google_dns_managed_zone_enumerator.go index aa9953d78..ea872d485 100644 --- a/pkg/remote/google/google_dns_managed_zone_enumerator.go +++ b/enumeration/remote/google/google_dns_managed_zone_enumerator.go @@ -1,13 +1,13 @@ package google import ( + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google/repository" "strings" "github.com/sirupsen/logrus" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) type GoogleDNSManagedZoneEnumerator struct { diff --git a/pkg/remote/google/google_project_iam_member_enumerator.go b/enumeration/remote/google/google_project_iam_member_enumerator.go similarity index 85% rename from pkg/remote/google/google_project_iam_member_enumerator.go rename to enumeration/remote/google/google_project_iam_member_enumerator.go index 44f40d9c7..5af564299 100644 --- a/pkg/remote/google/google_project_iam_member_enumerator.go +++ b/enumeration/remote/google/google_project_iam_member_enumerator.go @@ -2,11 +2,11 @@ package google import ( "fmt" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) type GoogleProjectIamMemberEnumerator struct { diff --git a/pkg/remote/google/google_sql_database_instance_enumerator.go b/enumeration/remote/google/google_sql_database_instance_enumerator.go similarity index 84% rename from pkg/remote/google/google_sql_database_instance_enumerator.go rename to enumeration/remote/google/google_sql_database_instance_enumerator.go index 524b09c29..fe0eb5caa 100644 --- a/pkg/remote/google/google_sql_database_instance_enumerator.go +++ b/enumeration/remote/google/google_sql_database_instance_enumerator.go @@ -2,10 +2,10 @@ package google import ( "github.com/sirupsen/logrus" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google/repository" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) type GoogleSQLDatabaseInstanceEnumerator struct { diff --git a/pkg/remote/google/google_storage_bucket_enumerator.go b/enumeration/remote/google/google_storage_bucket_enumerator.go similarity index 81% rename from pkg/remote/google/google_storage_bucket_enumerator.go rename to enumeration/remote/google/google_storage_bucket_enumerator.go index a2f1ee107..03237cb38 100644 --- a/pkg/remote/google/google_storage_bucket_enumerator.go +++ b/enumeration/remote/google/google_storage_bucket_enumerator.go @@ -1,10 +1,10 @@ package google import ( - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google/repository" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) type GoogleStorageBucketEnumerator struct { diff --git a/pkg/remote/google/google_storage_bucket_iam_member_enumerator.go b/enumeration/remote/google/google_storage_bucket_iam_member_enumerator.go similarity index 73% rename from pkg/remote/google/google_storage_bucket_iam_member_enumerator.go rename to enumeration/remote/google/google_storage_bucket_iam_member_enumerator.go index badf0d812..1006bb434 100644 --- a/pkg/remote/google/google_storage_bucket_iam_member_enumerator.go +++ b/enumeration/remote/google/google_storage_bucket_iam_member_enumerator.go @@ -2,20 +2,20 @@ package google import ( "fmt" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + repository2 "github.com/snyk/driftctl/enumeration/remote/google/repository" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) type GoogleStorageBucketIamMemberEnumerator struct { - repository repository.AssetRepository - storageRepository repository.StorageRepository + repository repository2.AssetRepository + storageRepository repository2.StorageRepository factory resource.ResourceFactory } -func NewGoogleStorageBucketIamMemberEnumerator(repo repository.AssetRepository, storageRepo repository.StorageRepository, factory resource.ResourceFactory) *GoogleStorageBucketIamMemberEnumerator { +func NewGoogleStorageBucketIamMemberEnumerator(repo repository2.AssetRepository, storageRepo repository2.StorageRepository, factory resource.ResourceFactory) *GoogleStorageBucketIamMemberEnumerator { return &GoogleStorageBucketIamMemberEnumerator{ repository: repo, storageRepository: storageRepo, diff --git a/pkg/remote/google/init.go b/enumeration/remote/google/init.go similarity index 71% rename from pkg/remote/google/init.go rename to enumeration/remote/google/init.go index caaaa642e..be795acd1 100644 --- a/pkg/remote/google/init.go +++ b/enumeration/remote/google/init.go @@ -3,23 +3,25 @@ package google import ( "context" + "github.com/snyk/driftctl/enumeration" + + "github.com/snyk/driftctl/enumeration/alerter" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + repository2 "github.com/snyk/driftctl/enumeration/remote/google/repository" + "github.com/snyk/driftctl/enumeration/terraform" + asset "cloud.google.com/go/asset/apiv1" "cloud.google.com/go/storage" - "github.com/snyk/driftctl/pkg/alerter" - "github.com/snyk/driftctl/pkg/output" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" "google.golang.org/api/cloudresourcemanager/v1" ) func Init(version string, alerter *alerter.Alerter, providerLibrary *terraform.ProviderLibrary, - remoteLibrary *common.RemoteLibrary, - progress output.Progress, + remoteLibrary *common2.RemoteLibrary, + progress enumeration.ProgressCounter, resourceSchemaRepository *resource.SchemaRepository, factory resource.ResourceFactory, configDir string) error { @@ -57,39 +59,39 @@ func Init(version string, alerter *alerter.Alerter, return err } - assetRepository := repository.NewAssetRepository(assetClient, provider.GetConfig(), repositoryCache) - storageRepository := repository.NewStorageRepository(storageClient, repositoryCache) - iamRepository := repository.NewCloudResourceManagerRepository(crmService, provider.GetConfig(), repositoryCache) + assetRepository := repository2.NewAssetRepository(assetClient, provider.GetConfig(), repositoryCache) + storageRepository := repository2.NewStorageRepository(storageClient, repositoryCache) + iamRepository := repository2.NewCloudResourceManagerRepository(crmService, provider.GetConfig(), repositoryCache) providerLibrary.AddProvider(terraform.GOOGLE, provider) deserializer := resource.NewDeserializer(factory) remoteLibrary.AddEnumerator(NewGoogleStorageBucketEnumerator(assetRepository, factory)) - remoteLibrary.AddDetailsFetcher(google.GoogleStorageBucketResourceType, common.NewGenericDetailsFetcher(google.GoogleStorageBucketResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(google.GoogleStorageBucketResourceType, common2.NewGenericDetailsFetcher(google.GoogleStorageBucketResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewGoogleComputeFirewallEnumerator(assetRepository, factory)) - remoteLibrary.AddDetailsFetcher(google.GoogleComputeFirewallResourceType, common.NewGenericDetailsFetcher(google.GoogleComputeFirewallResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(google.GoogleComputeFirewallResourceType, common2.NewGenericDetailsFetcher(google.GoogleComputeFirewallResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewGoogleComputeRouterEnumerator(assetRepository, factory)) remoteLibrary.AddEnumerator(NewGoogleComputeInstanceEnumerator(assetRepository, factory)) remoteLibrary.AddEnumerator(NewGoogleProjectIamMemberEnumerator(iamRepository, factory)) - remoteLibrary.AddDetailsFetcher(google.GoogleProjectIamMemberResourceType, common.NewGenericDetailsFetcher(google.GoogleProjectIamMemberResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(google.GoogleProjectIamMemberResourceType, common2.NewGenericDetailsFetcher(google.GoogleProjectIamMemberResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewGoogleStorageBucketIamMemberEnumerator(assetRepository, storageRepository, factory)) - remoteLibrary.AddDetailsFetcher(google.GoogleStorageBucketIamMemberResourceType, common.NewGenericDetailsFetcher(google.GoogleStorageBucketIamMemberResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(google.GoogleStorageBucketIamMemberResourceType, common2.NewGenericDetailsFetcher(google.GoogleStorageBucketIamMemberResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewGoogleComputeNetworkEnumerator(assetRepository, factory)) - remoteLibrary.AddDetailsFetcher(google.GoogleComputeNetworkResourceType, common.NewGenericDetailsFetcher(google.GoogleComputeNetworkResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(google.GoogleComputeNetworkResourceType, common2.NewGenericDetailsFetcher(google.GoogleComputeNetworkResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewGoogleComputeSubnetworkEnumerator(assetRepository, factory)) - remoteLibrary.AddDetailsFetcher(google.GoogleComputeSubnetworkResourceType, common.NewGenericDetailsFetcher(google.GoogleComputeSubnetworkResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(google.GoogleComputeSubnetworkResourceType, common2.NewGenericDetailsFetcher(google.GoogleComputeSubnetworkResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewGoogleDNSManagedZoneEnumerator(assetRepository, factory)) remoteLibrary.AddEnumerator(NewGoogleComputeInstanceGroupEnumerator(assetRepository, factory)) - remoteLibrary.AddDetailsFetcher(google.GoogleComputeInstanceGroupResourceType, common.NewGenericDetailsFetcher(google.GoogleComputeInstanceGroupResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(google.GoogleComputeInstanceGroupResourceType, common2.NewGenericDetailsFetcher(google.GoogleComputeInstanceGroupResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewGoogleBigqueryDatasetEnumerator(assetRepository, factory)) remoteLibrary.AddEnumerator(NewGoogleBigqueryTableEnumerator(assetRepository, factory)) diff --git a/pkg/remote/google/provider.go b/enumeration/remote/google/provider.go similarity index 75% rename from pkg/remote/google/provider.go rename to enumeration/remote/google/provider.go index 35995fce3..276634b24 100644 --- a/pkg/remote/google/provider.go +++ b/enumeration/remote/google/provider.go @@ -5,11 +5,12 @@ import ( "errors" "os" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/google/config" + "github.com/snyk/driftctl/enumeration/remote/terraform" + terraform2 "github.com/snyk/driftctl/enumeration/terraform" + asset "cloud.google.com/go/asset/apiv1" - "github.com/snyk/driftctl/pkg/output" - "github.com/snyk/driftctl/pkg/remote/google/config" - "github.com/snyk/driftctl/pkg/remote/terraform" - tf "github.com/snyk/driftctl/pkg/terraform" ) type GCPTerraformProvider struct { @@ -18,15 +19,15 @@ type GCPTerraformProvider struct { version string } -func NewGCPTerraformProvider(version string, progress output.Progress, configDir string) (*GCPTerraformProvider, error) { +func NewGCPTerraformProvider(version string, progress enumeration.ProgressCounter, configDir string) (*GCPTerraformProvider, error) { if version == "" { version = "3.78.0" } p := &GCPTerraformProvider{ version: version, - name: tf.GOOGLE, + name: terraform2.GOOGLE, } - installer, err := tf.NewProviderInstaller(tf.ProviderConfig{ + installer, err := terraform2.NewProviderInstaller(terraform2.ProviderConfig{ Key: p.name, Version: version, ConfigDir: configDir, diff --git a/pkg/remote/google/repository/asset.go b/enumeration/remote/google/repository/asset.go similarity index 98% rename from pkg/remote/google/repository/asset.go rename to enumeration/remote/google/repository/asset.go index 5e3474c34..153d0d468 100644 --- a/pkg/remote/google/repository/asset.go +++ b/enumeration/remote/google/repository/asset.go @@ -3,10 +3,10 @@ package repository import ( "context" "fmt" + "github.com/snyk/driftctl/enumeration/remote/cache" + "github.com/snyk/driftctl/enumeration/remote/google/config" asset "cloud.google.com/go/asset/apiv1" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/google/config" "google.golang.org/api/iterator" assetpb "google.golang.org/genproto/googleapis/cloud/asset/v1" ) diff --git a/pkg/remote/google/repository/asset_test.go b/enumeration/remote/google/repository/asset_test.go similarity index 93% rename from pkg/remote/google/repository/asset_test.go rename to enumeration/remote/google/repository/asset_test.go index 4db980a60..b831a1773 100644 --- a/pkg/remote/google/repository/asset_test.go +++ b/enumeration/remote/google/repository/asset_test.go @@ -1,10 +1,10 @@ package repository import ( + "github.com/snyk/driftctl/enumeration/remote/cache" + "github.com/snyk/driftctl/enumeration/remote/google/config" "testing" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/google/config" "github.com/snyk/driftctl/test/google" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" diff --git a/pkg/remote/google/repository/cloudresourcemanager.go b/enumeration/remote/google/repository/cloudresourcemanager.go similarity index 92% rename from pkg/remote/google/repository/cloudresourcemanager.go rename to enumeration/remote/google/repository/cloudresourcemanager.go index 1c7f4e3bb..09507a046 100644 --- a/pkg/remote/google/repository/cloudresourcemanager.go +++ b/enumeration/remote/google/repository/cloudresourcemanager.go @@ -1,8 +1,8 @@ package repository import ( - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/google/config" + "github.com/snyk/driftctl/enumeration/remote/cache" + "github.com/snyk/driftctl/enumeration/remote/google/config" "google.golang.org/api/cloudresourcemanager/v1" ) diff --git a/pkg/remote/google/repository/mock_AssetRepository.go b/enumeration/remote/google/repository/mock_AssetRepository.go similarity index 100% rename from pkg/remote/google/repository/mock_AssetRepository.go rename to enumeration/remote/google/repository/mock_AssetRepository.go diff --git a/pkg/remote/google/repository/mock_CloudResourceManagerRepository.go b/enumeration/remote/google/repository/mock_CloudResourceManagerRepository.go similarity index 100% rename from pkg/remote/google/repository/mock_CloudResourceManagerRepository.go rename to enumeration/remote/google/repository/mock_CloudResourceManagerRepository.go diff --git a/pkg/remote/google/repository/mock_StorageRepository.go b/enumeration/remote/google/repository/mock_StorageRepository.go similarity index 100% rename from pkg/remote/google/repository/mock_StorageRepository.go rename to enumeration/remote/google/repository/mock_StorageRepository.go diff --git a/pkg/remote/google/repository/storage.go b/enumeration/remote/google/repository/storage.go similarity index 95% rename from pkg/remote/google/repository/storage.go rename to enumeration/remote/google/repository/storage.go index 3679c131a..ae33bc101 100644 --- a/pkg/remote/google/repository/storage.go +++ b/enumeration/remote/google/repository/storage.go @@ -3,10 +3,10 @@ package repository import ( "context" "fmt" + "github.com/snyk/driftctl/enumeration/remote/cache" "sync" "cloud.google.com/go/storage" - "github.com/snyk/driftctl/pkg/remote/cache" ) type StorageRepository interface { diff --git a/pkg/remote/google/util.go b/enumeration/remote/google/util.go similarity index 100% rename from pkg/remote/google/util.go rename to enumeration/remote/google/util.go diff --git a/pkg/remote/google_bigquery_scanner_test.go b/enumeration/remote/google_bigquery_scanner_test.go similarity index 82% rename from pkg/remote/google_bigquery_scanner_test.go rename to enumeration/remote/google_bigquery_scanner_test.go index c37e42874..6f8b754e3 100644 --- a/pkg/remote/google_bigquery_scanner_test.go +++ b/enumeration/remote/google_bigquery_scanner_test.go @@ -3,17 +3,19 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + google2 "github.com/snyk/driftctl/enumeration/remote/google" + "github.com/snyk/driftctl/enumeration/remote/google/repository" + terraform3 "github.com/snyk/driftctl/enumeration/terraform" + + "github.com/snyk/driftctl/enumeration/resource" + googleresource "github.com/snyk/driftctl/enumeration/resource/google" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - googleresource "github.com/snyk/driftctl/pkg/resource/google" - "github.com/snyk/driftctl/pkg/terraform" + testgoogle "github.com/snyk/driftctl/test/google" testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" @@ -66,7 +68,7 @@ func TestGoogleBigqueryDataset(t *testing.T) { "SendAlert", "google_bigquery_dataset", alerts.NewRemoteAccessDeniedAlert( - common.RemoteGoogleTerraform, + common2.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_bigquery_dataset", @@ -81,13 +83,13 @@ func TestGoogleBigqueryDataset(t *testing.T) { providerVersion := "3.78.0" schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -107,9 +109,9 @@ func TestGoogleBigqueryDataset(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google.NewGoogleBigqueryDatasetEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google2.NewGoogleBigqueryDatasetEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -169,7 +171,7 @@ func TestGoogleBigqueryTable(t *testing.T) { "SendAlert", "google_bigquery_table", alerts.NewRemoteAccessDeniedAlert( - common.RemoteGoogleTerraform, + common2.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_bigquery_table", @@ -184,13 +186,13 @@ func TestGoogleBigqueryTable(t *testing.T) { providerVersion := "3.78.0" schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -210,9 +212,9 @@ func TestGoogleBigqueryTable(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google.NewGoogleBigqueryTableEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google2.NewGoogleBigqueryTableEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/google_bigtable_scanner_test.go b/enumeration/remote/google_bigtable_scanner_test.go similarity index 86% rename from pkg/remote/google_bigtable_scanner_test.go rename to enumeration/remote/google_bigtable_scanner_test.go index f75798cda..3bec37acb 100644 --- a/pkg/remote/google_bigtable_scanner_test.go +++ b/enumeration/remote/google_bigtable_scanner_test.go @@ -3,17 +3,19 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + google2 "github.com/snyk/driftctl/enumeration/remote/google" + "github.com/snyk/driftctl/enumeration/remote/google/repository" + terraform3 "github.com/snyk/driftctl/enumeration/terraform" + + "github.com/snyk/driftctl/enumeration/resource" + googleresource "github.com/snyk/driftctl/enumeration/resource/google" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - googleresource "github.com/snyk/driftctl/pkg/resource/google" - "github.com/snyk/driftctl/pkg/terraform" + testgoogle "github.com/snyk/driftctl/test/google" testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" @@ -103,7 +105,7 @@ func TestGoogleBigtableInstance(t *testing.T) { "SendAlert", "google_bigtable_instance", alerts.NewRemoteAccessDeniedAlert( - common.RemoteGoogleTerraform, + common2.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_bigtable_instance", @@ -118,13 +120,13 @@ func TestGoogleBigtableInstance(t *testing.T) { providerVersion := "3.78.0" schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -144,9 +146,9 @@ func TestGoogleBigtableInstance(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google.NewGoogleBigTableInstanceEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google2.NewGoogleBigTableInstanceEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -229,7 +231,7 @@ func TestGoogleBigtableTable(t *testing.T) { "SendAlert", "google_bigtable_table", alerts.NewRemoteAccessDeniedAlert( - common.RemoteGoogleTerraform, + common2.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_bigtable_table", @@ -244,13 +246,13 @@ func TestGoogleBigtableTable(t *testing.T) { providerVersion := "3.78.0" schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -270,9 +272,9 @@ func TestGoogleBigtableTable(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google.NewGoogleBigtableTableEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google2.NewGoogleBigtableTableEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/google_cloudfunctions_scanner_test.go b/enumeration/remote/google_cloudfunctions_scanner_test.go similarity index 83% rename from pkg/remote/google_cloudfunctions_scanner_test.go rename to enumeration/remote/google_cloudfunctions_scanner_test.go index bec5fb240..a0b631703 100644 --- a/pkg/remote/google_cloudfunctions_scanner_test.go +++ b/enumeration/remote/google_cloudfunctions_scanner_test.go @@ -3,17 +3,19 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google" + "github.com/snyk/driftctl/enumeration/remote/google/repository" + terraform3 "github.com/snyk/driftctl/enumeration/terraform" + + "github.com/snyk/driftctl/enumeration/resource" + googleresource "github.com/snyk/driftctl/enumeration/resource/google" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - googleresource "github.com/snyk/driftctl/pkg/resource/google" - "github.com/snyk/driftctl/pkg/terraform" + testgoogle "github.com/snyk/driftctl/test/google" testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" @@ -90,7 +92,7 @@ func TestGoogleCloudFunctionsFunction(t *testing.T) { "SendAlert", "google_cloudfunctions_function", alerts.NewRemoteAccessDeniedAlert( - common.RemoteGoogleTerraform, + common2.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_cloudfunctions_function", @@ -105,13 +107,13 @@ func TestGoogleCloudFunctionsFunction(t *testing.T) { providerVersion := "3.78.0" schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -133,7 +135,7 @@ func TestGoogleCloudFunctionsFunction(t *testing.T) { remoteLibrary.AddEnumerator(google.NewGoogleCloudFunctionsFunctionEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/google_cloudrun_scanner_test.go b/enumeration/remote/google_cloudrun_scanner_test.go similarity index 83% rename from pkg/remote/google_cloudrun_scanner_test.go rename to enumeration/remote/google_cloudrun_scanner_test.go index 032752ec2..51c7a0f5a 100644 --- a/pkg/remote/google_cloudrun_scanner_test.go +++ b/enumeration/remote/google_cloudrun_scanner_test.go @@ -3,17 +3,19 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google" + "github.com/snyk/driftctl/enumeration/remote/google/repository" + terraform3 "github.com/snyk/driftctl/enumeration/terraform" + + "github.com/snyk/driftctl/enumeration/resource" + googleresource "github.com/snyk/driftctl/enumeration/resource/google" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - googleresource "github.com/snyk/driftctl/pkg/resource/google" - "github.com/snyk/driftctl/pkg/terraform" + testgoogle "github.com/snyk/driftctl/test/google" testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" @@ -82,7 +84,7 @@ func TestGoogleCloudRunService(t *testing.T) { "SendAlert", googleresource.GoogleCloudRunServiceResourceType, alerts.NewRemoteAccessDeniedAlert( - common.RemoteGoogleTerraform, + common2.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), googleresource.GoogleCloudRunServiceResourceType, @@ -100,13 +102,13 @@ func TestGoogleCloudRunService(t *testing.T) { providerVersion := "3.78.0" schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -128,7 +130,7 @@ func TestGoogleCloudRunService(t *testing.T) { remoteLibrary.AddEnumerator(google.NewGoogleCloudRunServiceEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/google_compute_scanner_test.go b/enumeration/remote/google_compute_scanner_test.go similarity index 89% rename from pkg/remote/google_compute_scanner_test.go rename to enumeration/remote/google_compute_scanner_test.go index bd2fa0bc6..27651c6bd 100644 --- a/pkg/remote/google_compute_scanner_test.go +++ b/enumeration/remote/google_compute_scanner_test.go @@ -3,17 +3,19 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + google2 "github.com/snyk/driftctl/enumeration/remote/google" + "github.com/snyk/driftctl/enumeration/remote/google/repository" + terraform3 "github.com/snyk/driftctl/enumeration/terraform" + + "github.com/snyk/driftctl/enumeration/resource" + googleresource "github.com/snyk/driftctl/enumeration/resource/google" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - googleresource "github.com/snyk/driftctl/pkg/resource/google" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" testgoogle "github.com/snyk/driftctl/test/google" @@ -74,7 +76,7 @@ func TestGoogleComputeFirewall(t *testing.T) { "SendAlert", "google_compute_firewall", alerts.NewRemoteAccessDeniedAlert( - common.RemoteGoogleTerraform, + common2.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_compute_firewall", @@ -91,7 +93,7 @@ func TestGoogleComputeFirewall(t *testing.T) { resType := resource.ResourceType(googleresource.GoogleComputeFirewallResourceType) schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -99,8 +101,8 @@ func TestGoogleComputeFirewall(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -131,10 +133,10 @@ func TestGoogleComputeFirewall(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google.NewGoogleComputeFirewallEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resType, common.NewGenericDetailsFetcher(resType, provider, deserializer)) + remoteLibrary.AddEnumerator(google2.NewGoogleComputeFirewallEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resType, common2.NewGenericDetailsFetcher(resType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -210,7 +212,7 @@ func TestGoogleComputeRouter(t *testing.T) { "SendAlert", googleresource.GoogleComputeRouterResourceType, alerts.NewRemoteAccessDeniedAlert( - common.RemoteGoogleTerraform, + common2.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), googleresource.GoogleComputeRouterResourceType, @@ -228,13 +230,13 @@ func TestGoogleComputeRouter(t *testing.T) { providerVersion := "3.78.0" schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -254,9 +256,9 @@ func TestGoogleComputeRouter(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google.NewGoogleComputeRouterEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google2.NewGoogleComputeRouterEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -317,7 +319,7 @@ func TestGoogleComputeInstance(t *testing.T) { "SendAlert", "google_compute_instance", alerts.NewRemoteAccessDeniedAlert( - common.RemoteGoogleTerraform, + common2.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_compute_instance", @@ -332,13 +334,13 @@ func TestGoogleComputeInstance(t *testing.T) { providerVersion := "3.78.0" schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -358,9 +360,9 @@ func TestGoogleComputeInstance(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google.NewGoogleComputeInstanceEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google2.NewGoogleComputeInstanceEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -425,7 +427,7 @@ func TestGoogleComputeNetwork(t *testing.T) { "SendAlert", "google_compute_network", alerts.NewRemoteAccessDeniedAlert( - common.RemoteGoogleTerraform, + common2.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_compute_network", @@ -442,7 +444,7 @@ func TestGoogleComputeNetwork(t *testing.T) { resType := resource.ResourceType(googleresource.GoogleComputeNetworkResourceType) schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -450,8 +452,8 @@ func TestGoogleComputeNetwork(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -482,10 +484,10 @@ func TestGoogleComputeNetwork(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google.NewGoogleComputeNetworkEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resType, common.NewGenericDetailsFetcher(resType, provider, deserializer)) + remoteLibrary.AddEnumerator(google2.NewGoogleComputeNetworkEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resType, common2.NewGenericDetailsFetcher(resType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -547,7 +549,7 @@ func TestGoogleComputeInstanceGroup(t *testing.T) { "SendAlert", "google_compute_instance_group", alerts.NewRemoteAccessDeniedAlert( - common.RemoteGoogleTerraform, + common2.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_compute_instance_group", @@ -564,7 +566,7 @@ func TestGoogleComputeInstanceGroup(t *testing.T) { resType := resource.ResourceType(googleresource.GoogleComputeInstanceGroupResourceType) schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -572,8 +574,8 @@ func TestGoogleComputeInstanceGroup(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -604,10 +606,10 @@ func TestGoogleComputeInstanceGroup(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google.NewGoogleComputeInstanceGroupEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(googleresource.GoogleComputeInstanceGroupResourceType, common.NewGenericDetailsFetcher(googleresource.GoogleComputeInstanceGroupResourceType, provider, deserializer)) + remoteLibrary.AddEnumerator(google2.NewGoogleComputeInstanceGroupEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(googleresource.GoogleComputeInstanceGroupResourceType, common2.NewGenericDetailsFetcher(googleresource.GoogleComputeInstanceGroupResourceType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -684,7 +686,7 @@ func TestGoogleComputeAddress(t *testing.T) { "SendAlert", "google_compute_address", alerts.NewRemoteAccessDeniedAlert( - common.RemoteGoogleTerraform, + common2.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_compute_address", @@ -699,13 +701,13 @@ func TestGoogleComputeAddress(t *testing.T) { providerVersion := "3.78.0" schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -725,9 +727,9 @@ func TestGoogleComputeAddress(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google.NewGoogleComputeAddressEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google2.NewGoogleComputeAddressEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -810,7 +812,7 @@ func TestGoogleComputeGlobalAddress(t *testing.T) { "SendAlert", "google_compute_global_address", alerts.NewRemoteAccessDeniedAlert( - common.RemoteGoogleTerraform, + common2.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_compute_global_address", @@ -825,13 +827,13 @@ func TestGoogleComputeGlobalAddress(t *testing.T) { providerVersion := "3.78.0" schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -851,9 +853,9 @@ func TestGoogleComputeGlobalAddress(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google.NewGoogleComputeGlobalAddressEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google2.NewGoogleComputeGlobalAddressEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -918,7 +920,7 @@ func TestGoogleComputeSubnetwork(t *testing.T) { "SendAlert", "google_compute_subnetwork", alerts.NewRemoteAccessDeniedAlert( - common.RemoteGoogleTerraform, + common2.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_compute_subnetwork", @@ -935,7 +937,7 @@ func TestGoogleComputeSubnetwork(t *testing.T) { resType := resource.ResourceType(googleresource.GoogleComputeSubnetworkResourceType) schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -943,8 +945,8 @@ func TestGoogleComputeSubnetwork(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -975,10 +977,10 @@ func TestGoogleComputeSubnetwork(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google.NewGoogleComputeSubnetworkEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resType, common.NewGenericDetailsFetcher(resType, provider, deserializer)) + remoteLibrary.AddEnumerator(google2.NewGoogleComputeSubnetworkEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resType, common2.NewGenericDetailsFetcher(resType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -1043,7 +1045,7 @@ func TestGoogleComputeDisk(t *testing.T) { "SendAlert", "google_compute_disk", alerts.NewRemoteAccessDeniedAlert( - common.RemoteGoogleTerraform, + common2.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_compute_disk", @@ -1058,13 +1060,13 @@ func TestGoogleComputeDisk(t *testing.T) { providerVersion := "3.78.0" schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1084,9 +1086,9 @@ func TestGoogleComputeDisk(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google.NewGoogleComputeDiskEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google2.NewGoogleComputeDiskEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -1153,7 +1155,7 @@ func TestGoogleComputeImage(t *testing.T) { "SendAlert", "google_compute_image", alerts.NewRemoteAccessDeniedAlert( - common.RemoteGoogleTerraform, + common2.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_compute_image", @@ -1168,13 +1170,13 @@ func TestGoogleComputeImage(t *testing.T) { providerVersion := "3.78.0" schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1194,9 +1196,9 @@ func TestGoogleComputeImage(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google.NewGoogleComputeImageEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google2.NewGoogleComputeImageEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -1263,7 +1265,7 @@ func TestGoogleComputeHealthCheck(t *testing.T) { "SendAlert", "google_compute_health_check", alerts.NewRemoteAccessDeniedAlert( - common.RemoteGoogleTerraform, + common2.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_compute_health_check", @@ -1276,15 +1278,15 @@ func TestGoogleComputeHealthCheck(t *testing.T) { } providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository(terraform.GOOGLE, providerVersion) + schemaRepository := testresource.InitFakeSchemaRepository(terraform3.GOOGLE, providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1304,9 +1306,9 @@ func TestGoogleComputeHealthCheck(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google.NewGoogleComputeHealthCheckEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google2.NewGoogleComputeHealthCheckEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -1373,7 +1375,7 @@ func TestGoogleComputeNodeGroup(t *testing.T) { "SendAlert", "google_compute_node_group", alerts.NewRemoteAccessDeniedAlert( - common.RemoteGoogleTerraform, + common2.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_compute_node_group", @@ -1386,15 +1388,15 @@ func TestGoogleComputeNodeGroup(t *testing.T) { } providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository(terraform.GOOGLE, providerVersion) + schemaRepository := testresource.InitFakeSchemaRepository(terraform3.GOOGLE, providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1414,9 +1416,9 @@ func TestGoogleComputeNodeGroup(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google.NewGoogleComputeNodeGroupEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google2.NewGoogleComputeNodeGroupEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -1482,7 +1484,7 @@ func TestGoogleComputeForwardingRule(t *testing.T) { "SendAlert", "google_compute_forwarding_rule", alerts.NewRemoteAccessDeniedAlert( - common.RemoteGoogleTerraform, + common2.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_compute_forwarding_rule", @@ -1495,15 +1497,15 @@ func TestGoogleComputeForwardingRule(t *testing.T) { } providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository(terraform.GOOGLE, providerVersion) + schemaRepository := testresource.InitFakeSchemaRepository(terraform3.GOOGLE, providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1523,9 +1525,9 @@ func TestGoogleComputeForwardingRule(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google.NewGoogleComputeForwardingRuleEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google2.NewGoogleComputeForwardingRuleEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -1592,7 +1594,7 @@ func TestGoogleComputeInstanceGroupManager(t *testing.T) { "SendAlert", "google_compute_instance_group_manager", alerts.NewRemoteAccessDeniedAlert( - common.RemoteGoogleTerraform, + common2.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_compute_instance_group_manager", @@ -1605,15 +1607,15 @@ func TestGoogleComputeInstanceGroupManager(t *testing.T) { } providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository(terraform.GOOGLE, providerVersion) + schemaRepository := testresource.InitFakeSchemaRepository(terraform3.GOOGLE, providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1633,9 +1635,9 @@ func TestGoogleComputeInstanceGroupManager(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google.NewGoogleComputeInstanceGroupManagerEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google2.NewGoogleComputeInstanceGroupManagerEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -1701,7 +1703,7 @@ func TestGoogleComputeGlobalForwardingRule(t *testing.T) { "SendAlert", "google_compute_global_forwarding_rule", alerts.NewRemoteAccessDeniedAlert( - common.RemoteGoogleTerraform, + common2.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_compute_global_forwarding_rule", @@ -1714,15 +1716,15 @@ func TestGoogleComputeGlobalForwardingRule(t *testing.T) { } providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository(terraform.GOOGLE, providerVersion) + schemaRepository := testresource.InitFakeSchemaRepository(terraform3.GOOGLE, providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1742,9 +1744,9 @@ func TestGoogleComputeGlobalForwardingRule(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google.NewGoogleComputeGlobalForwardingRuleEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google2.NewGoogleComputeGlobalForwardingRuleEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/google_network_scanner_test.go b/enumeration/remote/google_network_scanner_test.go similarity index 84% rename from pkg/remote/google_network_scanner_test.go rename to enumeration/remote/google_network_scanner_test.go index 08cf9332d..2956c0041 100644 --- a/pkg/remote/google_network_scanner_test.go +++ b/enumeration/remote/google_network_scanner_test.go @@ -3,17 +3,19 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google" + "github.com/snyk/driftctl/enumeration/remote/google/repository" + terraform3 "github.com/snyk/driftctl/enumeration/terraform" + + "github.com/snyk/driftctl/enumeration/resource" + googleresource "github.com/snyk/driftctl/enumeration/resource/google" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - googleresource "github.com/snyk/driftctl/pkg/resource/google" - "github.com/snyk/driftctl/pkg/terraform" + testgoogle "github.com/snyk/driftctl/test/google" testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" @@ -88,7 +90,7 @@ func TestGoogleDNSNanagedZone(t *testing.T) { "SendAlert", googleresource.GoogleDNSManagedZoneResourceType, alerts.NewRemoteAccessDeniedAlert( - common.RemoteGoogleTerraform, + common2.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), googleresource.GoogleDNSManagedZoneResourceType, @@ -106,13 +108,13 @@ func TestGoogleDNSNanagedZone(t *testing.T) { providerVersion := "3.78.0" schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -134,7 +136,7 @@ func TestGoogleDNSNanagedZone(t *testing.T) { remoteLibrary.AddEnumerator(google.NewGoogleDNSManagedZoneEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/google_project_scanner_test.go b/enumeration/remote/google_project_scanner_test.go similarity index 84% rename from pkg/remote/google_project_scanner_test.go rename to enumeration/remote/google_project_scanner_test.go index abd65f4fa..c839dc941 100644 --- a/pkg/remote/google_project_scanner_test.go +++ b/enumeration/remote/google_project_scanner_test.go @@ -3,17 +3,19 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google" + "github.com/snyk/driftctl/enumeration/remote/google/repository" + terraform3 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/pkg/errors" + "github.com/snyk/driftctl/enumeration/resource" + googleresource "github.com/snyk/driftctl/enumeration/resource/google" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - googleresource "github.com/snyk/driftctl/pkg/resource/google" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" testresource "github.com/snyk/driftctl/test/resource" @@ -53,7 +55,7 @@ func TestGoogleProjectIAMMember(t *testing.T) { "SendAlert", "google_project_iam_member", alerts.NewRemoteAccessDeniedAlert( - common.RemoteGoogleTerraform, + common2.RemoteGoogleTerraform, remoteerr.NewResourceListingError( errors.New("googleapi: Error 403: driftctl-acc-circle@driftctl-qa-1.iam.gserviceaccount.com does not have project.getIamPolicy access., forbidden"), "google_project_iam_member", @@ -89,7 +91,7 @@ func TestGoogleProjectIAMMember(t *testing.T) { resType := resource.ResourceType(googleresource.GoogleProjectIamMemberResourceType) schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -98,8 +100,8 @@ func TestGoogleProjectIAMMember(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -121,7 +123,7 @@ func TestGoogleProjectIAMMember(t *testing.T) { remoteLibrary.AddEnumerator(google.NewGoogleProjectIamMemberEnumerator(managerRepository, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/google_sql_scanner_test.go b/enumeration/remote/google_sql_scanner_test.go similarity index 81% rename from pkg/remote/google_sql_scanner_test.go rename to enumeration/remote/google_sql_scanner_test.go index 650374428..bcb05499a 100644 --- a/pkg/remote/google_sql_scanner_test.go +++ b/enumeration/remote/google_sql_scanner_test.go @@ -3,17 +3,19 @@ package remote import ( "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/snyk/driftctl/enumeration/remote/google" + "github.com/snyk/driftctl/enumeration/remote/google/repository" + terraform3 "github.com/snyk/driftctl/enumeration/terraform" + + "github.com/snyk/driftctl/enumeration/resource" + googleresource "github.com/snyk/driftctl/enumeration/resource/google" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - googleresource "github.com/snyk/driftctl/pkg/resource/google" - "github.com/snyk/driftctl/pkg/terraform" + testgoogle "github.com/snyk/driftctl/test/google" testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" @@ -88,7 +90,7 @@ func TestGoogleSQLDatabaseInstance(t *testing.T) { "SendAlert", "google_sql_database_instance", alerts.NewRemoteAccessDeniedAlert( - common.RemoteGoogleTerraform, + common2.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_sql_database_instance", @@ -103,13 +105,13 @@ func TestGoogleSQLDatabaseInstance(t *testing.T) { providerVersion := "3.78.0" schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -131,7 +133,7 @@ func TestGoogleSQLDatabaseInstance(t *testing.T) { remoteLibrary.AddEnumerator(google.NewGoogleSQLDatabaseInstanceEnumerator(repo, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/google_storage_scanner_test.go b/enumeration/remote/google_storage_scanner_test.go similarity index 77% rename from pkg/remote/google_storage_scanner_test.go rename to enumeration/remote/google_storage_scanner_test.go index cb7180164..57f7a76fc 100644 --- a/pkg/remote/google_storage_scanner_test.go +++ b/enumeration/remote/google_storage_scanner_test.go @@ -4,20 +4,22 @@ import ( "context" "testing" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/cache" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + google2 "github.com/snyk/driftctl/enumeration/remote/google" + repository2 "github.com/snyk/driftctl/enumeration/remote/google/repository" + terraform3 "github.com/snyk/driftctl/enumeration/terraform" + asset "cloud.google.com/go/asset/apiv1" "cloud.google.com/go/storage" "github.com/pkg/errors" + "github.com/snyk/driftctl/enumeration/resource" + googleresource "github.com/snyk/driftctl/enumeration/resource/google" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/cache" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/remote/google" - "github.com/snyk/driftctl/pkg/remote/google/repository" - "github.com/snyk/driftctl/pkg/resource" - googleresource "github.com/snyk/driftctl/pkg/resource/google" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" testgoogle "github.com/snyk/driftctl/test/google" @@ -74,7 +76,7 @@ func TestGoogleStorageBucket(t *testing.T) { "SendAlert", "google_storage_bucket", alerts.NewRemoteAccessDeniedAlert( - common.RemoteGoogleTerraform, + common2.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_storage_bucket", @@ -91,7 +93,7 @@ func TestGoogleStorageBucket(t *testing.T) { resType := resource.ResourceType(googleresource.GoogleStorageBucketResourceType) schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -99,8 +101,8 @@ func TestGoogleStorageBucket(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -138,12 +140,12 @@ func TestGoogleStorageBucket(t *testing.T) { provider.ShouldUpdate() } - repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) + repo := repository2.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google.NewGoogleStorageBucketEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resType, common.NewGenericDetailsFetcher(resType, provider, deserializer)) + remoteLibrary.AddEnumerator(google2.NewGoogleStorageBucketEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resType, common2.NewGenericDetailsFetcher(resType, provider, deserializer)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) @@ -164,8 +166,8 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { cases := []struct { test string dirName string - assetRepositoryMock func(assetRepository *repository.MockAssetRepository) - storageRepositoryMock func(storageRepository *repository.MockStorageRepository) + assetRepositoryMock func(assetRepository *repository2.MockAssetRepository) + storageRepositoryMock func(storageRepository *repository2.MockStorageRepository) responseErr error setupAlerterMock func(alerter *mocks.AlerterInterface) wantErr error @@ -173,7 +175,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { { test: "no storage buckets", dirName: "google_storage_bucket_member_empty", - assetRepositoryMock: func(assetRepository *repository.MockAssetRepository) { + assetRepositoryMock: func(assetRepository *repository2.MockAssetRepository) { assetRepository.On("SearchAllBuckets").Return([]*assetpb.ResourceSearchResult{}, nil) }, wantErr: nil, @@ -181,7 +183,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { { test: "multiples storage buckets, no bindings", dirName: "google_storage_bucket_member_empty", - assetRepositoryMock: func(assetRepository *repository.MockAssetRepository) { + assetRepositoryMock: func(assetRepository *repository2.MockAssetRepository) { assetRepository.On("SearchAllBuckets").Return([]*assetpb.ResourceSearchResult{ { AssetType: "storage.googleapis.com/Bucket", @@ -193,7 +195,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { }, }, nil) }, - storageRepositoryMock: func(storageRepository *repository.MockStorageRepository) { + storageRepositoryMock: func(storageRepository *repository2.MockStorageRepository) { storageRepository.On("ListAllBindings", "dctlgstoragebucketiambinding-1").Return(map[string][]string{}, nil) storageRepository.On("ListAllBindings", "dctlgstoragebucketiambinding-2").Return(map[string][]string{}, nil) }, @@ -202,7 +204,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { { test: "Cannot list bindings", dirName: "google_storage_bucket_member_listing_error", - assetRepositoryMock: func(assetRepository *repository.MockAssetRepository) { + assetRepositoryMock: func(assetRepository *repository2.MockAssetRepository) { assetRepository.On("SearchAllBuckets").Return([]*assetpb.ResourceSearchResult{ { AssetType: "storage.googleapis.com/Bucket", @@ -210,7 +212,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { }, }, nil) }, - storageRepositoryMock: func(storageRepository *repository.MockStorageRepository) { + storageRepositoryMock: func(storageRepository *repository2.MockStorageRepository) { storageRepository.On("ListAllBindings", "dctlgstoragebucketiambinding-1").Return( map[string][]string{}, errors.New("googleapi: Error 403: driftctl-acc-circle@driftctl-qa-1.iam.gserviceaccount.com does not have storage.buckets.getIamPolicy access to the Google Cloud Storage bucket., forbidden")) @@ -220,7 +222,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { "SendAlert", "google_storage_bucket_iam_member", alerts.NewRemoteAccessDeniedAlert( - common.RemoteGoogleTerraform, + common2.RemoteGoogleTerraform, remoteerr.NewResourceListingError( errors.New("googleapi: Error 403: driftctl-acc-circle@driftctl-qa-1.iam.gserviceaccount.com does not have storage.buckets.getIamPolicy access to the Google Cloud Storage bucket., forbidden"), "google_storage_bucket_iam_member", @@ -234,7 +236,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { { test: "multiples storage buckets, multiple bindings", dirName: "google_storage_bucket_member_listing_multiple", - assetRepositoryMock: func(assetRepository *repository.MockAssetRepository) { + assetRepositoryMock: func(assetRepository *repository2.MockAssetRepository) { assetRepository.On("SearchAllBuckets").Return([]*assetpb.ResourceSearchResult{ { AssetType: "storage.googleapis.com/Bucket", @@ -246,7 +248,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { }, }, nil) }, - storageRepositoryMock: func(storageRepository *repository.MockStorageRepository) { + storageRepositoryMock: func(storageRepository *repository2.MockStorageRepository) { storageRepository.On("ListAllBindings", "dctlgstoragebucketiambinding-1").Return(map[string][]string{ "roles/storage.admin": {"user:elie.charra@cloudskiff.com"}, "roles/storage.objectViewer": {"user:william.beuil@cloudskiff.com"}, @@ -265,7 +267,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { resType := resource.ResourceType(googleresource.GoogleStorageBucketIamMemberResourceType) schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform3.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -275,8 +277,8 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform.NewProviderLibrary() - remoteLibrary := common.NewRemoteLibrary() + providerLibrary := terraform3.NewProviderLibrary() + remoteLibrary := common2.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -284,24 +286,24 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { c.setupAlerterMock(alerter) } - storageRepo := &repository.MockStorageRepository{} + storageRepo := &repository2.MockStorageRepository{} if c.storageRepositoryMock != nil { c.storageRepositoryMock(storageRepo) } - var storageRepository repository.StorageRepository = storageRepo + var storageRepository repository2.StorageRepository = storageRepo if shouldUpdate { storageClient, err := storage.NewClient(context.Background()) if err != nil { panic(err) } - storageRepository = repository.NewStorageRepository(storageClient, repositoryCache) + storageRepository = repository2.NewStorageRepository(storageClient, repositoryCache) } - assetRepo := &repository.MockAssetRepository{} + assetRepo := &repository2.MockAssetRepository{} if c.assetRepositoryMock != nil { c.assetRepositoryMock(assetRepo) } - var assetRepository repository.AssetRepository = assetRepo + var assetRepository repository2.AssetRepository = assetRepo realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion) if err != nil { @@ -310,9 +312,9 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { provider := terraform2.NewFakeTerraformProvider(realProvider) provider.WithResponse(c.dirName) - remoteLibrary.AddEnumerator(google.NewGoogleStorageBucketIamMemberEnumerator(assetRepository, storageRepository, factory)) + remoteLibrary.AddEnumerator(google2.NewGoogleStorageBucketIamMemberEnumerator(assetRepository, storageRepository, factory)) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) s := NewScanner(remoteLibrary, alerter, scanOptions, testFilter) diff --git a/pkg/remote/remote.go b/enumeration/remote/remote.go similarity index 57% rename from pkg/remote/remote.go rename to enumeration/remote/remote.go index 30f4b1122..eb2f38162 100644 --- a/pkg/remote/remote.go +++ b/enumeration/remote/remote.go @@ -2,22 +2,22 @@ package remote import ( "github.com/pkg/errors" - "github.com/snyk/driftctl/pkg/alerter" - "github.com/snyk/driftctl/pkg/output" - "github.com/snyk/driftctl/pkg/remote/aws" - "github.com/snyk/driftctl/pkg/remote/azurerm" - "github.com/snyk/driftctl/pkg/remote/common" - "github.com/snyk/driftctl/pkg/remote/github" - "github.com/snyk/driftctl/pkg/remote/google" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/alerter" + "github.com/snyk/driftctl/enumeration/remote/aws" + "github.com/snyk/driftctl/enumeration/remote/azurerm" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/github" + "github.com/snyk/driftctl/enumeration/remote/google" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/terraform" ) var supportedRemotes = []string{ - common.RemoteAWSTerraform, - common.RemoteGithubTerraform, - common.RemoteGoogleTerraform, - common.RemoteAzureTerraform, + common2.RemoteAWSTerraform, + common2.RemoteGithubTerraform, + common2.RemoteGoogleTerraform, + common2.RemoteAzureTerraform, } func IsSupported(remote string) bool { @@ -31,19 +31,19 @@ func IsSupported(remote string) bool { func Activate(remote, version string, alerter *alerter.Alerter, providerLibrary *terraform.ProviderLibrary, - remoteLibrary *common.RemoteLibrary, - progress output.Progress, + remoteLibrary *common2.RemoteLibrary, + progress enumeration.ProgressCounter, resourceSchemaRepository *resource.SchemaRepository, factory resource.ResourceFactory, configDir string) error { switch remote { - case common.RemoteAWSTerraform: + case common2.RemoteAWSTerraform: return aws.Init(version, alerter, providerLibrary, remoteLibrary, progress, resourceSchemaRepository, factory, configDir) - case common.RemoteGithubTerraform: + case common2.RemoteGithubTerraform: return github.Init(version, alerter, providerLibrary, remoteLibrary, progress, resourceSchemaRepository, factory, configDir) - case common.RemoteGoogleTerraform: + case common2.RemoteGoogleTerraform: return google.Init(version, alerter, providerLibrary, remoteLibrary, progress, resourceSchemaRepository, factory, configDir) - case common.RemoteAzureTerraform: + case common2.RemoteAzureTerraform: return azurerm.Init(version, alerter, providerLibrary, remoteLibrary, progress, resourceSchemaRepository, factory, configDir) default: diff --git a/pkg/remote/resource_enumeration_error_handler.go b/enumeration/remote/resource_enumeration_error_handler.go similarity index 94% rename from pkg/remote/resource_enumeration_error_handler.go rename to enumeration/remote/resource_enumeration_error_handler.go index 25e16ba8c..c2d09274a 100644 --- a/pkg/remote/resource_enumeration_error_handler.go +++ b/enumeration/remote/resource_enumeration_error_handler.go @@ -3,11 +3,12 @@ package remote import ( "strings" + "github.com/snyk/driftctl/enumeration/alerter" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/common" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/aws/aws-sdk-go/aws/awserr" - "github.com/snyk/driftctl/pkg/alerter" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerror "github.com/snyk/driftctl/pkg/remote/error" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) diff --git a/pkg/remote/resource_enumeration_error_handler_test.go b/enumeration/remote/resource_enumeration_error_handler_test.go similarity index 72% rename from pkg/remote/resource_enumeration_error_handler_test.go rename to enumeration/remote/resource_enumeration_error_handler_test.go index 4ce747492..fcf3162f4 100644 --- a/pkg/remote/resource_enumeration_error_handler_test.go +++ b/enumeration/remote/resource_enumeration_error_handler_test.go @@ -4,19 +4,19 @@ import ( "errors" "testing" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - resourcegithub "github.com/snyk/driftctl/pkg/resource/github" + alerter2 "github.com/snyk/driftctl/enumeration/alerter" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + + resourcegithub "github.com/snyk/driftctl/enumeration/resource/github" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "github.com/stretchr/testify/assert" "github.com/aws/aws-sdk-go/aws/awserr" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" - - "github.com/snyk/driftctl/pkg/alerter" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" ) func TestHandleAwsEnumerationErrors(t *testing.T) { @@ -24,55 +24,55 @@ func TestHandleAwsEnumerationErrors(t *testing.T) { tests := []struct { name string err error - wantAlerts alerter.Alerts + wantAlerts alerter2.Alerts wantErr bool }{ { name: "Handled error 403", err: remoteerr.NewResourceListingError(awserr.NewRequestFailure(awserr.New("", "", errors.New("")), 403, ""), resourceaws.AwsVpcResourceType), - wantAlerts: alerter.Alerts{"aws_vpc": []alerter.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awserr.NewRequestFailure(awserr.New("", "", errors.New("")), 403, ""), "aws_vpc", "aws_vpc"), alerts.EnumerationPhase)}}, + wantAlerts: alerter2.Alerts{"aws_vpc": []alerter2.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awserr.NewRequestFailure(awserr.New("", "", errors.New("")), 403, ""), "aws_vpc", "aws_vpc"), alerts.EnumerationPhase)}}, wantErr: false, }, { name: "Handled error AccessDenied", err: remoteerr.NewResourceListingError(awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, ""), resourceaws.AwsDynamodbTableResourceType), - wantAlerts: alerter.Alerts{"aws_dynamodb_table": []alerter.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, ""), "aws_dynamodb_table", "aws_dynamodb_table"), alerts.EnumerationPhase)}}, + wantAlerts: alerter2.Alerts{"aws_dynamodb_table": []alerter2.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, ""), "aws_dynamodb_table", "aws_dynamodb_table"), alerts.EnumerationPhase)}}, wantErr: false, }, { name: "Not Handled error code", err: remoteerr.NewResourceListingError(awserr.NewRequestFailure(awserr.New("", "", errors.New("")), 404, ""), resourceaws.AwsVpcResourceType), - wantAlerts: map[string][]alerter.Alert{}, + wantAlerts: map[string][]alerter2.Alert{}, wantErr: true, }, { name: "Not Handled error type", err: errors.New("error"), - wantAlerts: map[string][]alerter.Alert{}, + wantAlerts: map[string][]alerter2.Alert{}, wantErr: true, }, { name: "Not Handled root error type", err: remoteerr.NewResourceListingError(errors.New("error"), resourceaws.AwsVpcResourceType), - wantAlerts: map[string][]alerter.Alert{}, + wantAlerts: map[string][]alerter2.Alert{}, wantErr: true, }, { name: "Handle AccessDenied error", err: remoteerr.NewResourceListingError(errors.New("an error occured: AccessDenied: 403"), resourceaws.AwsVpcResourceType), - wantAlerts: alerter.Alerts{"aws_vpc": []alerter.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("an error occured: AccessDenied: 403"), "aws_vpc", "aws_vpc"), alerts.EnumerationPhase)}}, + wantAlerts: alerter2.Alerts{"aws_vpc": []alerter2.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("an error occured: AccessDenied: 403"), "aws_vpc", "aws_vpc"), alerts.EnumerationPhase)}}, wantErr: false, }, { name: "Access denied error on a single resource", err: remoteerr.NewResourceScanningError(errors.New("Error: AccessDenied: 403 ..."), resourceaws.AwsS3BucketResourceType, "my-bucket"), - wantAlerts: alerter.Alerts{"aws_s3_bucket.my-bucket": []alerter.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Error: AccessDenied: 403 ..."), "aws_s3_bucket.my-bucket", "aws_s3_bucket"), alerts.EnumerationPhase)}}, + wantAlerts: alerter2.Alerts{"aws_s3_bucket.my-bucket": []alerter2.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Error: AccessDenied: 403 ..."), "aws_s3_bucket.my-bucket", "aws_s3_bucket"), alerts.EnumerationPhase)}}, wantErr: false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - alertr := alerter.NewAlerter() + alertr := alerter2.NewAlerter() gotErr := HandleResourceEnumerationError(tt.err, alertr) assert.Equal(t, tt.wantErr, gotErr != nil) @@ -88,31 +88,31 @@ func TestHandleGithubEnumerationErrors(t *testing.T) { tests := []struct { name string err error - wantAlerts alerter.Alerts + wantAlerts alerter2.Alerts wantErr bool }{ { name: "Handled graphql error", err: remoteerr.NewResourceListingError(errors.New("Your token has not been granted the required scopes to execute this query."), resourcegithub.GithubTeamResourceType), - wantAlerts: alerter.Alerts{"github_team": []alerter.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), "github_team", "github_team"), alerts.EnumerationPhase)}}, + wantAlerts: alerter2.Alerts{"github_team": []alerter2.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), "github_team", "github_team"), alerts.EnumerationPhase)}}, wantErr: false, }, { name: "Not handled graphql error", err: remoteerr.NewResourceListingError(errors.New("This is a not handler graphql error"), resourcegithub.GithubTeamResourceType), - wantAlerts: map[string][]alerter.Alert{}, + wantAlerts: map[string][]alerter2.Alert{}, wantErr: true, }, { name: "Not Handled error type", err: errors.New("error"), - wantAlerts: map[string][]alerter.Alert{}, + wantAlerts: map[string][]alerter2.Alert{}, wantErr: true, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - alertr := alerter.NewAlerter() + alertr := alerter2.NewAlerter() gotErr := HandleResourceEnumerationError(tt.err, alertr) assert.Equal(t, tt.wantErr, gotErr != nil) @@ -127,31 +127,31 @@ func TestHandleGoogleEnumerationErrors(t *testing.T) { tests := []struct { name string err error - wantAlerts alerter.Alerts + wantAlerts alerter2.Alerts wantErr bool }{ { name: "Handled 403 error", err: remoteerr.NewResourceListingError(status.Error(codes.PermissionDenied, "useless message"), "google_type"), - wantAlerts: alerter.Alerts{"google_type": []alerter.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteGoogleTerraform, remoteerr.NewResourceListingErrorWithType(status.Error(codes.PermissionDenied, "useless message"), "google_type", "google_type"), alerts.EnumerationPhase)}}, + wantAlerts: alerter2.Alerts{"google_type": []alerter2.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteGoogleTerraform, remoteerr.NewResourceListingErrorWithType(status.Error(codes.PermissionDenied, "useless message"), "google_type", "google_type"), alerts.EnumerationPhase)}}, wantErr: false, }, { name: "Not handled non 403 error", err: status.Error(codes.Unknown, ""), - wantAlerts: map[string][]alerter.Alert{}, + wantAlerts: map[string][]alerter2.Alert{}, wantErr: true, }, { name: "Not Handled error type", err: errors.New("error"), - wantAlerts: map[string][]alerter.Alert{}, + wantAlerts: map[string][]alerter2.Alert{}, wantErr: true, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - alertr := alerter.NewAlerter() + alertr := alerter2.NewAlerter() gotErr := HandleResourceEnumerationError(tt.err, alertr) assert.Equal(t, tt.wantErr, gotErr != nil) @@ -167,43 +167,43 @@ func TestHandleAwsDetailsFetchingErrors(t *testing.T) { tests := []struct { name string err error - wantAlerts alerter.Alerts + wantAlerts alerter2.Alerts wantErr bool }{ { name: "Handle AccessDeniedException error", err: remoteerr.NewResourceListingError(awserr.NewRequestFailure(awserr.New("AccessDeniedException", "test", errors.New("")), 403, ""), resourceaws.AwsVpcResourceType), - wantAlerts: alerter.Alerts{"aws_vpc": []alerter.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awserr.NewRequestFailure(awserr.New("AccessDeniedException", "test", errors.New("")), 403, ""), "aws_vpc", "aws_vpc"), alerts.DetailsFetchingPhase)}}, + wantAlerts: alerter2.Alerts{"aws_vpc": []alerter2.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awserr.NewRequestFailure(awserr.New("AccessDeniedException", "test", errors.New("")), 403, ""), "aws_vpc", "aws_vpc"), alerts.DetailsFetchingPhase)}}, wantErr: false, }, { name: "Handle AccessDenied error", err: remoteerr.NewResourceListingError(awserr.NewRequestFailure(awserr.New("test", "error: AccessDenied", errors.New("")), 403, ""), resourceaws.AwsVpcResourceType), - wantAlerts: alerter.Alerts{"aws_vpc": []alerter.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awserr.NewRequestFailure(awserr.New("test", "error: AccessDenied", errors.New("")), 403, ""), "aws_vpc", "aws_vpc"), alerts.DetailsFetchingPhase)}}, + wantAlerts: alerter2.Alerts{"aws_vpc": []alerter2.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awserr.NewRequestFailure(awserr.New("test", "error: AccessDenied", errors.New("")), 403, ""), "aws_vpc", "aws_vpc"), alerts.DetailsFetchingPhase)}}, wantErr: false, }, { name: "Handle AuthorizationError error", err: remoteerr.NewResourceListingError(awserr.NewRequestFailure(awserr.New("test", "error: AuthorizationError", errors.New("")), 403, ""), resourceaws.AwsVpcResourceType), - wantAlerts: alerter.Alerts{"aws_vpc": []alerter.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awserr.NewRequestFailure(awserr.New("test", "error: AuthorizationError", errors.New("")), 403, ""), "aws_vpc", "aws_vpc"), alerts.DetailsFetchingPhase)}}, + wantAlerts: alerter2.Alerts{"aws_vpc": []alerter2.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awserr.NewRequestFailure(awserr.New("test", "error: AuthorizationError", errors.New("")), 403, ""), "aws_vpc", "aws_vpc"), alerts.DetailsFetchingPhase)}}, wantErr: false, }, { name: "Unhandled error", err: remoteerr.NewResourceListingError(awserr.NewRequestFailure(awserr.New("test", "error: dummy error", errors.New("")), 403, ""), resourceaws.AwsVpcResourceType), - wantAlerts: alerter.Alerts{}, + wantAlerts: alerter2.Alerts{}, wantErr: true, }, { name: "Not Handled error type", err: errors.New("error"), - wantAlerts: map[string][]alerter.Alert{}, + wantAlerts: map[string][]alerter2.Alert{}, wantErr: true, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - alertr := alerter.NewAlerter() + alertr := alerter2.NewAlerter() gotErr := HandleResourceDetailsFetchingError(tt.err, alertr) assert.Equal(t, tt.wantErr, gotErr != nil) @@ -219,7 +219,7 @@ func TestHandleGoogleDetailsFetchingErrors(t *testing.T) { tests := []struct { name string err error - wantAlerts alerter.Alerts + wantAlerts alerter2.Alerts wantErr bool }{ { @@ -229,7 +229,7 @@ func TestHandleGoogleDetailsFetchingErrors(t *testing.T) { "google_type", "resource_id", ), - wantAlerts: alerter.Alerts{"google_type.resource_id": []alerter.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteGoogleTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Error when reading or editing Storage Bucket \"driftctl-unittest-1\": googleapi: Error 403: driftctl@elie-dev.iam.gserviceaccount.com does not have storage.buckets.get access to the Google Cloud Storage bucket., forbidden"), "google_type.resource_id", "google_type"), alerts.DetailsFetchingPhase)}}, + wantAlerts: alerter2.Alerts{"google_type.resource_id": []alerter2.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteGoogleTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Error when reading or editing Storage Bucket \"driftctl-unittest-1\": googleapi: Error 403: driftctl@elie-dev.iam.gserviceaccount.com does not have storage.buckets.get access to the Google Cloud Storage bucket., forbidden"), "google_type.resource_id", "google_type"), alerts.DetailsFetchingPhase)}}, wantErr: false, }, { @@ -238,7 +238,7 @@ func TestHandleGoogleDetailsFetchingErrors(t *testing.T) { errors.New("this string does not contains g o o g l e a p i string and thus should not be matched"), "google_type", "resource_id", - ), wantAlerts: alerter.Alerts{}, + ), wantAlerts: alerter2.Alerts{}, wantErr: true, }, { @@ -247,19 +247,19 @@ func TestHandleGoogleDetailsFetchingErrors(t *testing.T) { errors.New("Error when reading or editing Storage Bucket \"driftctl-unittest-1\": googleapi: Error 404: not found"), "google_type", "resource_id", - ), wantAlerts: alerter.Alerts{}, + ), wantAlerts: alerter2.Alerts{}, wantErr: true, }, { name: "Not Handled error type", err: errors.New("error"), - wantAlerts: map[string][]alerter.Alert{}, + wantAlerts: map[string][]alerter2.Alert{}, wantErr: true, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - alertr := alerter.NewAlerter() + alertr := alerter2.NewAlerter() gotErr := HandleResourceDetailsFetchingError(tt.err, alertr) assert.Equal(t, tt.wantErr, gotErr != nil) diff --git a/pkg/remote/scanner.go b/enumeration/remote/scanner.go similarity index 89% rename from pkg/remote/scanner.go rename to enumeration/remote/scanner.go index 38ca0ce6a..5d52a9138 100644 --- a/pkg/remote/scanner.go +++ b/enumeration/remote/scanner.go @@ -3,13 +3,14 @@ package remote import ( "context" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/alerter" + "github.com/snyk/driftctl/enumeration/parallel" + "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/pkg/errors" "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/alerter" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/parallel" - "github.com/snyk/driftctl/pkg/remote/common" - "github.com/snyk/driftctl/pkg/resource" ) type ScannerOptions struct { @@ -22,10 +23,10 @@ type Scanner struct { remoteLibrary *common.RemoteLibrary alerter alerter.AlerterInterface options ScannerOptions - filter filter.Filter + filter enumeration.Filter } -func NewScanner(remoteLibrary *common.RemoteLibrary, alerter alerter.AlerterInterface, options ScannerOptions, filter filter.Filter) *Scanner { +func NewScanner(remoteLibrary *common.RemoteLibrary, alerter alerter.AlerterInterface, options ScannerOptions, filter enumeration.Filter) *Scanner { return &Scanner{ enumeratorRunner: parallel.NewParallelRunner(context.TODO(), 10), detailsFetcherRunner: parallel.NewParallelRunner(context.TODO(), 10), diff --git a/pkg/remote/scanner_test.go b/enumeration/remote/scanner_test.go similarity index 64% rename from pkg/remote/scanner_test.go rename to enumeration/remote/scanner_test.go index 77d2cebf6..5e14f1da7 100644 --- a/pkg/remote/scanner_test.go +++ b/enumeration/remote/scanner_test.go @@ -3,10 +3,12 @@ package remote import ( "testing" - "github.com/snyk/driftctl/pkg/alerter" - "github.com/snyk/driftctl/pkg/filter" - "github.com/snyk/driftctl/pkg/remote/common" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/alerter" + common2 "github.com/snyk/driftctl/enumeration/remote/common" + + "github.com/snyk/driftctl/enumeration/resource" + "github.com/stretchr/testify/assert" ) @@ -14,14 +16,14 @@ func TestScannerShouldIgnoreType(t *testing.T) { // Initialize mocks alerter := alerter.NewAlerter() - fakeEnumerator := &common.MockEnumerator{} + fakeEnumerator := &common2.MockEnumerator{} fakeEnumerator.On("SupportedType").Return(resource.ResourceType("FakeType")) fakeEnumerator.AssertNotCalled(t, "Enumerate") - remoteLibrary := common.NewRemoteLibrary() + remoteLibrary := common2.NewRemoteLibrary() remoteLibrary.AddEnumerator(fakeEnumerator) - testFilter := &filter.MockFilter{} + testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", resource.ResourceType("FakeType")).Return(true) s := NewScanner(remoteLibrary, alerter, ScannerOptions{}, testFilter) diff --git a/pkg/remote/terraform/provider.go b/enumeration/remote/terraform/provider.go similarity index 89% rename from pkg/remote/terraform/provider.go rename to enumeration/remote/terraform/provider.go index a7ad22de8..28c913f75 100644 --- a/pkg/remote/terraform/provider.go +++ b/enumeration/remote/terraform/provider.go @@ -15,15 +15,15 @@ import ( "github.com/hashicorp/terraform/terraform" "github.com/pkg/errors" "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/cmd/scan" - "github.com/snyk/driftctl/pkg/output" + progress2 "github.com/snyk/driftctl/enumeration" + "github.com/snyk/driftctl/enumeration/parallel" + terraform2 "github.com/snyk/driftctl/enumeration/terraform" "github.com/zclconf/go-cty/cty" "github.com/zclconf/go-cty/cty/gocty" - - "github.com/snyk/driftctl/pkg/parallel" - tf "github.com/snyk/driftctl/pkg/terraform" ) +const EXIT_ERROR = 3 + // "alias" in these struct are a way to namespace gRPC clients. // For example, if we need to read S3 bucket from multiple AWS region, // we'll have an alias per region, and the alias IS the region itself. @@ -36,15 +36,15 @@ type TerraformProviderConfig struct { type TerraformProvider struct { lock sync.Mutex - providerInstaller *tf.ProviderInstaller + providerInstaller *terraform2.ProviderInstaller grpcProviders map[string]*plugin.GRPCProvider schemas map[string]providers.Schema Config TerraformProviderConfig runner *parallel.ParallelRunner - progress output.Progress + progress progress2.ProgressCounter } -func NewTerraformProvider(installer *tf.ProviderInstaller, config TerraformProviderConfig, progress output.Progress) (*TerraformProvider, error) { +func NewTerraformProvider(installer *terraform2.ProviderInstaller, config TerraformProviderConfig, progress progress2.ProgressCounter) (*TerraformProvider, error) { p := TerraformProvider{ providerInstaller: installer, runner: parallel.NewParallelRunner(context.TODO(), 10), @@ -64,7 +64,7 @@ func (p *TerraformProvider) Init() error { case <-c: logrus.Warn("Detected interrupt during terraform provider configuration, cleanup ...") p.Cleanup() - os.Exit(scan.EXIT_ERROR) + os.Exit(EXIT_ERROR) case <-stopCh: return } @@ -97,7 +97,7 @@ func (p *TerraformProvider) configure(alias string) error { logrus.WithFields(logrus.Fields{ "alias": alias, }).Debug("Starting gRPC client") - GRPCProvider, err := tf.NewGRPCProvider(discovery.PluginMeta{ + GRPCProvider, err := terraform2.NewGRPCProvider(discovery.PluginMeta{ Path: providerPath, }) @@ -142,7 +142,7 @@ func (p *TerraformProvider) configure(alias string) error { return nil } -func (p *TerraformProvider) ReadResource(args tf.ReadResourceArgs) (*cty.Value, error) { +func (p *TerraformProvider) ReadResource(args terraform2.ReadResourceArgs) (*cty.Value, error) { logrus.WithFields(logrus.Fields{ "id": args.ID, diff --git a/pkg/remote/test/aws_appautoscaling_policy_single/aws_appautoscaling_policy-DynamoDBReadCapacityUtilization_table_GameScores-DynamoDBReadCapacityUtilization_table_GameScores-table_GameScores-dynamodb_table_ReadCapacityUnits-dynamodb.res.golden.json b/enumeration/remote/test/aws_appautoscaling_policy_single/aws_appautoscaling_policy-DynamoDBReadCapacityUtilization_table_GameScores-DynamoDBReadCapacityUtilization_table_GameScores-table_GameScores-dynamodb_table_ReadCapacityUnits-dynamodb.res.golden.json similarity index 100% rename from pkg/remote/test/aws_appautoscaling_policy_single/aws_appautoscaling_policy-DynamoDBReadCapacityUtilization_table_GameScores-DynamoDBReadCapacityUtilization_table_GameScores-table_GameScores-dynamodb_table_ReadCapacityUnits-dynamodb.res.golden.json rename to enumeration/remote/test/aws_appautoscaling_policy_single/aws_appautoscaling_policy-DynamoDBReadCapacityUtilization_table_GameScores-DynamoDBReadCapacityUtilization_table_GameScores-table_GameScores-dynamodb_table_ReadCapacityUnits-dynamodb.res.golden.json diff --git a/pkg/remote/test/aws_appautoscaling_policy_single/results.golden.json b/enumeration/remote/test/aws_appautoscaling_policy_single/results.golden.json similarity index 100% rename from pkg/remote/test/aws_appautoscaling_policy_single/results.golden.json rename to enumeration/remote/test/aws_appautoscaling_policy_single/results.golden.json diff --git a/pkg/remote/test/aws_appautoscaling_target_single/aws_appautoscaling_target-table_GameScores-dynamodb_table_ReadCapacityUnits-dynamodb.res.golden.json b/enumeration/remote/test/aws_appautoscaling_target_single/aws_appautoscaling_target-table_GameScores-dynamodb_table_ReadCapacityUnits-dynamodb.res.golden.json similarity index 100% rename from pkg/remote/test/aws_appautoscaling_target_single/aws_appautoscaling_target-table_GameScores-dynamodb_table_ReadCapacityUnits-dynamodb.res.golden.json rename to enumeration/remote/test/aws_appautoscaling_target_single/aws_appautoscaling_target-table_GameScores-dynamodb_table_ReadCapacityUnits-dynamodb.res.golden.json diff --git a/pkg/remote/test/aws_appautoscaling_target_single/results.golden.json b/enumeration/remote/test/aws_appautoscaling_target_single/results.golden.json similarity index 100% rename from pkg/remote/test/aws_appautoscaling_target_single/results.golden.json rename to enumeration/remote/test/aws_appautoscaling_target_single/results.golden.json diff --git a/pkg/remote/test/aws_cloudformation_stack_multiple/aws_cloudformation_stack-arn_aws_cloudformation_us-east-1_047081014315_stack_bar-stack_c7a96e70-0f21-11ec-bd2a-0a2d95c2b2ab.res.golden.json b/enumeration/remote/test/aws_cloudformation_stack_multiple/aws_cloudformation_stack-arn_aws_cloudformation_us-east-1_047081014315_stack_bar-stack_c7a96e70-0f21-11ec-bd2a-0a2d95c2b2ab.res.golden.json similarity index 100% rename from pkg/remote/test/aws_cloudformation_stack_multiple/aws_cloudformation_stack-arn_aws_cloudformation_us-east-1_047081014315_stack_bar-stack_c7a96e70-0f21-11ec-bd2a-0a2d95c2b2ab.res.golden.json rename to enumeration/remote/test/aws_cloudformation_stack_multiple/aws_cloudformation_stack-arn_aws_cloudformation_us-east-1_047081014315_stack_bar-stack_c7a96e70-0f21-11ec-bd2a-0a2d95c2b2ab.res.golden.json diff --git a/pkg/remote/test/aws_cloudformation_stack_multiple/aws_cloudformation_stack-arn_aws_cloudformation_us-east-1_047081014315_stack_foo-stack_c7aa0ab0-0f21-11ec-ba25-129d8c0b3757.res.golden.json b/enumeration/remote/test/aws_cloudformation_stack_multiple/aws_cloudformation_stack-arn_aws_cloudformation_us-east-1_047081014315_stack_foo-stack_c7aa0ab0-0f21-11ec-ba25-129d8c0b3757.res.golden.json similarity index 100% rename from pkg/remote/test/aws_cloudformation_stack_multiple/aws_cloudformation_stack-arn_aws_cloudformation_us-east-1_047081014315_stack_foo-stack_c7aa0ab0-0f21-11ec-ba25-129d8c0b3757.res.golden.json rename to enumeration/remote/test/aws_cloudformation_stack_multiple/aws_cloudformation_stack-arn_aws_cloudformation_us-east-1_047081014315_stack_foo-stack_c7aa0ab0-0f21-11ec-ba25-129d8c0b3757.res.golden.json diff --git a/pkg/remote/test/aws_cloudformation_stack_multiple/iam.yml b/enumeration/remote/test/aws_cloudformation_stack_multiple/iam.yml similarity index 100% rename from pkg/remote/test/aws_cloudformation_stack_multiple/iam.yml rename to enumeration/remote/test/aws_cloudformation_stack_multiple/iam.yml diff --git a/pkg/remote/test/aws_cloudformation_stack_multiple/results.golden.json b/enumeration/remote/test/aws_cloudformation_stack_multiple/results.golden.json similarity index 97% rename from pkg/remote/test/aws_cloudformation_stack_multiple/results.golden.json rename to enumeration/remote/test/aws_cloudformation_stack_multiple/results.golden.json index d15c92372..7b25d7958 100755 --- a/pkg/remote/test/aws_cloudformation_stack_multiple/results.golden.json +++ b/enumeration/remote/test/aws_cloudformation_stack_multiple/results.golden.json @@ -17,7 +17,7 @@ "template_body": "{\"Parameters\":{\"VPCCidr\":{\"Default\":\"10.0.0.0/16\",\"Description\":\"Enter the CIDR block for the VPC. Default is 10.0.0.0/16.\",\"Type\":\"String\"}},\"Resources\":{\"myVpc\":{\"Properties\":{\"CidrBlock\":{\"Ref\":\"VPCCidr\"},\"Tags\":[{\"Key\":\"Name\",\"Value\":\"Primary_CF_VPC\"}]},\"Type\":\"AWS::EC2::VPC\"}}}", "template_url": null, "timeout_in_minutes": null, - "timeouts": null + "timeouts": {} }, { "capabilities": [ @@ -37,6 +37,6 @@ "template_body": "Resources:\n myUser:\n Type: AWS::IAM::User\n Properties:\n UserName: \"bar_cfn\"\n", "template_url": null, "timeout_in_minutes": null, - "timeouts": null + "timeouts": {} } ] \ No newline at end of file diff --git a/pkg/remote/test/aws_cloudformation_stack_multiple/terraform.tf b/enumeration/remote/test/aws_cloudformation_stack_multiple/terraform.tf similarity index 100% rename from pkg/remote/test/aws_cloudformation_stack_multiple/terraform.tf rename to enumeration/remote/test/aws_cloudformation_stack_multiple/terraform.tf diff --git a/pkg/remote/test/aws_cloudfront_distribution_single/aws_cloudfront_distribution-E1M9CNS0XSHI19.res.golden.json b/enumeration/remote/test/aws_cloudfront_distribution_single/aws_cloudfront_distribution-E1M9CNS0XSHI19.res.golden.json similarity index 100% rename from pkg/remote/test/aws_cloudfront_distribution_single/aws_cloudfront_distribution-E1M9CNS0XSHI19.res.golden.json rename to enumeration/remote/test/aws_cloudfront_distribution_single/aws_cloudfront_distribution-E1M9CNS0XSHI19.res.golden.json diff --git a/pkg/remote/test/aws_cloudfront_distribution_single/results.golden.json b/enumeration/remote/test/aws_cloudfront_distribution_single/results.golden.json similarity index 100% rename from pkg/remote/test/aws_cloudfront_distribution_single/results.golden.json rename to enumeration/remote/test/aws_cloudfront_distribution_single/results.golden.json diff --git a/pkg/remote/test/aws_cloudfront_distribution_single/terraform.tf b/enumeration/remote/test/aws_cloudfront_distribution_single/terraform.tf similarity index 100% rename from pkg/remote/test/aws_cloudfront_distribution_single/terraform.tf rename to enumeration/remote/test/aws_cloudfront_distribution_single/terraform.tf diff --git a/pkg/remote/test/aws_default_vpc/aws_default_vpc-vpc-a8c5d4c1.res.golden.json b/enumeration/remote/test/aws_default_vpc/aws_default_vpc-vpc-a8c5d4c1.res.golden.json similarity index 100% rename from pkg/remote/test/aws_default_vpc/aws_default_vpc-vpc-a8c5d4c1.res.golden.json rename to enumeration/remote/test/aws_default_vpc/aws_default_vpc-vpc-a8c5d4c1.res.golden.json diff --git a/pkg/remote/test/aws_default_vpc/results.golden.json b/enumeration/remote/test/aws_default_vpc/results.golden.json similarity index 100% rename from pkg/remote/test/aws_default_vpc/results.golden.json rename to enumeration/remote/test/aws_default_vpc/results.golden.json diff --git a/pkg/remote/test/aws_default_vpc/terraform.tf b/enumeration/remote/test/aws_default_vpc/terraform.tf similarity index 100% rename from pkg/remote/test/aws_default_vpc/terraform.tf rename to enumeration/remote/test/aws_default_vpc/terraform.tf diff --git a/pkg/remote/test/aws_dynamodb_table_multiple/aws_dynamodb_table-GameScores-GameScores.res.golden.json b/enumeration/remote/test/aws_dynamodb_table_multiple/aws_dynamodb_table-GameScores-GameScores.res.golden.json similarity index 100% rename from pkg/remote/test/aws_dynamodb_table_multiple/aws_dynamodb_table-GameScores-GameScores.res.golden.json rename to enumeration/remote/test/aws_dynamodb_table_multiple/aws_dynamodb_table-GameScores-GameScores.res.golden.json diff --git a/pkg/remote/test/aws_dynamodb_table_multiple/aws_dynamodb_table-example-example.res.golden.json b/enumeration/remote/test/aws_dynamodb_table_multiple/aws_dynamodb_table-example-example.res.golden.json similarity index 100% rename from pkg/remote/test/aws_dynamodb_table_multiple/aws_dynamodb_table-example-example.res.golden.json rename to enumeration/remote/test/aws_dynamodb_table_multiple/aws_dynamodb_table-example-example.res.golden.json diff --git a/pkg/remote/test/aws_dynamodb_table_multiple/results.golden.json b/enumeration/remote/test/aws_dynamodb_table_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_dynamodb_table_multiple/results.golden.json rename to enumeration/remote/test/aws_dynamodb_table_multiple/results.golden.json diff --git a/pkg/remote/test/aws_ebs_encryption_by_default_list/aws_ebs_encryption_by_default-ebs_encryption_default.res.golden.json b/enumeration/remote/test/aws_ebs_encryption_by_default_list/aws_ebs_encryption_by_default-ebs_encryption_default.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ebs_encryption_by_default_list/aws_ebs_encryption_by_default-ebs_encryption_default.res.golden.json rename to enumeration/remote/test/aws_ebs_encryption_by_default_list/aws_ebs_encryption_by_default-ebs_encryption_default.res.golden.json diff --git a/pkg/remote/test/aws_ebs_encryption_by_default_list/results.golden.json b/enumeration/remote/test/aws_ebs_encryption_by_default_list/results.golden.json similarity index 100% rename from pkg/remote/test/aws_ebs_encryption_by_default_list/results.golden.json rename to enumeration/remote/test/aws_ebs_encryption_by_default_list/results.golden.json diff --git a/pkg/remote/test/aws_ec2_ami_multiple/aws_ami-ami-025962fd8b456731f.res.golden.json b/enumeration/remote/test/aws_ec2_ami_multiple/aws_ami-ami-025962fd8b456731f.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_ami_multiple/aws_ami-ami-025962fd8b456731f.res.golden.json rename to enumeration/remote/test/aws_ec2_ami_multiple/aws_ami-ami-025962fd8b456731f.res.golden.json diff --git a/pkg/remote/test/aws_ec2_ami_multiple/aws_ami-ami-03a578b46f4c3081b.res.golden.json b/enumeration/remote/test/aws_ec2_ami_multiple/aws_ami-ami-03a578b46f4c3081b.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_ami_multiple/aws_ami-ami-03a578b46f4c3081b.res.golden.json rename to enumeration/remote/test/aws_ec2_ami_multiple/aws_ami-ami-03a578b46f4c3081b.res.golden.json diff --git a/pkg/remote/test/aws_ec2_ami_multiple/results.golden.json b/enumeration/remote/test/aws_ec2_ami_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_ami_multiple/results.golden.json rename to enumeration/remote/test/aws_ec2_ami_multiple/results.golden.json diff --git a/pkg/remote/test/aws_ec2_default_network_acl/aws_default_network_acl-acl-e88ee595.res.golden.json b/enumeration/remote/test/aws_ec2_default_network_acl/aws_default_network_acl-acl-e88ee595.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_default_network_acl/aws_default_network_acl-acl-e88ee595.res.golden.json rename to enumeration/remote/test/aws_ec2_default_network_acl/aws_default_network_acl-acl-e88ee595.res.golden.json diff --git a/pkg/remote/test/aws_ec2_default_network_acl/results.golden.json b/enumeration/remote/test/aws_ec2_default_network_acl/results.golden.json similarity index 80% rename from pkg/remote/test/aws_ec2_default_network_acl/results.golden.json rename to enumeration/remote/test/aws_ec2_default_network_acl/results.golden.json index 953ba5037..1df22de5e 100755 --- a/pkg/remote/test/aws_ec2_default_network_acl/results.golden.json +++ b/enumeration/remote/test/aws_ec2_default_network_acl/results.golden.json @@ -30,7 +30,14 @@ } ], "owner_id": "929327065333", - "subnet_ids": null, + "subnet_ids": [ + "subnet-0000ae0e", + "subnet-1138032f", + "subnet-44fe0c65", + "subnet-65e16628", + "subnet-ad17e3cb", + "subnet-afa656f0" + ], "tags": null, "vpc_id": "vpc-41d1d13b" } diff --git a/pkg/remote/test/aws_ec2_default_route_table_single/aws_default_route_table-rtb-0eabf071c709c0976-vpc-0b4a6b3536da20ecd.res.golden.json b/enumeration/remote/test/aws_ec2_default_route_table_single/aws_default_route_table-rtb-0eabf071c709c0976-vpc-0b4a6b3536da20ecd.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_default_route_table_single/aws_default_route_table-rtb-0eabf071c709c0976-vpc-0b4a6b3536da20ecd.res.golden.json rename to enumeration/remote/test/aws_ec2_default_route_table_single/aws_default_route_table-rtb-0eabf071c709c0976-vpc-0b4a6b3536da20ecd.res.golden.json diff --git a/pkg/remote/test/aws_ec2_default_route_table_single/results.golden.json b/enumeration/remote/test/aws_ec2_default_route_table_single/results.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_default_route_table_single/results.golden.json rename to enumeration/remote/test/aws_ec2_default_route_table_single/results.golden.json diff --git a/pkg/remote/test/aws_ec2_default_route_table_single/terraform.tf b/enumeration/remote/test/aws_ec2_default_route_table_single/terraform.tf similarity index 100% rename from pkg/remote/test/aws_ec2_default_route_table_single/terraform.tf rename to enumeration/remote/test/aws_ec2_default_route_table_single/terraform.tf diff --git a/pkg/remote/test/aws_ec2_default_subnet_multiple/aws_default_subnet-subnet-44fe0c65.res.golden.json b/enumeration/remote/test/aws_ec2_default_subnet_multiple/aws_default_subnet-subnet-44fe0c65.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_default_subnet_multiple/aws_default_subnet-subnet-44fe0c65.res.golden.json rename to enumeration/remote/test/aws_ec2_default_subnet_multiple/aws_default_subnet-subnet-44fe0c65.res.golden.json diff --git a/pkg/remote/test/aws_ec2_default_subnet_multiple/aws_default_subnet-subnet-65e16628.res.golden.json b/enumeration/remote/test/aws_ec2_default_subnet_multiple/aws_default_subnet-subnet-65e16628.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_default_subnet_multiple/aws_default_subnet-subnet-65e16628.res.golden.json rename to enumeration/remote/test/aws_ec2_default_subnet_multiple/aws_default_subnet-subnet-65e16628.res.golden.json diff --git a/pkg/remote/test/aws_ec2_default_subnet_multiple/aws_default_subnet-subnet-afa656f0.res.golden.json b/enumeration/remote/test/aws_ec2_default_subnet_multiple/aws_default_subnet-subnet-afa656f0.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_default_subnet_multiple/aws_default_subnet-subnet-afa656f0.res.golden.json rename to enumeration/remote/test/aws_ec2_default_subnet_multiple/aws_default_subnet-subnet-afa656f0.res.golden.json diff --git a/pkg/remote/test/aws_ec2_default_subnet_multiple/results.golden.json b/enumeration/remote/test/aws_ec2_default_subnet_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_default_subnet_multiple/results.golden.json rename to enumeration/remote/test/aws_ec2_default_subnet_multiple/results.golden.json diff --git a/pkg/remote/test/aws_ec2_default_subnet_multiple/terraform.tf b/enumeration/remote/test/aws_ec2_default_subnet_multiple/terraform.tf similarity index 100% rename from pkg/remote/test/aws_ec2_default_subnet_multiple/terraform.tf rename to enumeration/remote/test/aws_ec2_default_subnet_multiple/terraform.tf diff --git a/pkg/remote/test/aws_ec2_ebs_snapshot_multiple/aws_ebs_snapshot-snap-00672558cecd93a61.res.golden.json b/enumeration/remote/test/aws_ec2_ebs_snapshot_multiple/aws_ebs_snapshot-snap-00672558cecd93a61.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_ebs_snapshot_multiple/aws_ebs_snapshot-snap-00672558cecd93a61.res.golden.json rename to enumeration/remote/test/aws_ec2_ebs_snapshot_multiple/aws_ebs_snapshot-snap-00672558cecd93a61.res.golden.json diff --git a/pkg/remote/test/aws_ec2_ebs_snapshot_multiple/aws_ebs_snapshot-snap-0c509a2a880d95a39.res.golden.json b/enumeration/remote/test/aws_ec2_ebs_snapshot_multiple/aws_ebs_snapshot-snap-0c509a2a880d95a39.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_ebs_snapshot_multiple/aws_ebs_snapshot-snap-0c509a2a880d95a39.res.golden.json rename to enumeration/remote/test/aws_ec2_ebs_snapshot_multiple/aws_ebs_snapshot-snap-0c509a2a880d95a39.res.golden.json diff --git a/pkg/remote/test/aws_ec2_ebs_snapshot_multiple/results.golden.json b/enumeration/remote/test/aws_ec2_ebs_snapshot_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_ebs_snapshot_multiple/results.golden.json rename to enumeration/remote/test/aws_ec2_ebs_snapshot_multiple/results.golden.json diff --git a/pkg/remote/test/aws_ec2_ebs_volume_multiple/aws_ebs_volume-vol-01ddc91d3d9d1318b.res.golden.json b/enumeration/remote/test/aws_ec2_ebs_volume_multiple/aws_ebs_volume-vol-01ddc91d3d9d1318b.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_ebs_volume_multiple/aws_ebs_volume-vol-01ddc91d3d9d1318b.res.golden.json rename to enumeration/remote/test/aws_ec2_ebs_volume_multiple/aws_ebs_volume-vol-01ddc91d3d9d1318b.res.golden.json diff --git a/pkg/remote/test/aws_ec2_ebs_volume_multiple/aws_ebs_volume-vol-081c7272a57a09db1.res.golden.json b/enumeration/remote/test/aws_ec2_ebs_volume_multiple/aws_ebs_volume-vol-081c7272a57a09db1.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_ebs_volume_multiple/aws_ebs_volume-vol-081c7272a57a09db1.res.golden.json rename to enumeration/remote/test/aws_ec2_ebs_volume_multiple/aws_ebs_volume-vol-081c7272a57a09db1.res.golden.json diff --git a/pkg/remote/test/aws_ec2_ebs_volume_multiple/results.golden.json b/enumeration/remote/test/aws_ec2_ebs_volume_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_ebs_volume_multiple/results.golden.json rename to enumeration/remote/test/aws_ec2_ebs_volume_multiple/results.golden.json diff --git a/pkg/remote/test/aws_ec2_eip_association_single/aws_eip_association-eipassoc-0e9a7356e30f0c3d1.res.golden.json b/enumeration/remote/test/aws_ec2_eip_association_single/aws_eip_association-eipassoc-0e9a7356e30f0c3d1.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_eip_association_single/aws_eip_association-eipassoc-0e9a7356e30f0c3d1.res.golden.json rename to enumeration/remote/test/aws_ec2_eip_association_single/aws_eip_association-eipassoc-0e9a7356e30f0c3d1.res.golden.json diff --git a/pkg/remote/test/aws_ec2_eip_association_single/results.golden.json b/enumeration/remote/test/aws_ec2_eip_association_single/results.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_eip_association_single/results.golden.json rename to enumeration/remote/test/aws_ec2_eip_association_single/results.golden.json diff --git a/pkg/remote/test/aws_ec2_eip_multiple/aws_eip-eipalloc-017d5267e4dda73f1.res.golden.json b/enumeration/remote/test/aws_ec2_eip_multiple/aws_eip-eipalloc-017d5267e4dda73f1.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_eip_multiple/aws_eip-eipalloc-017d5267e4dda73f1.res.golden.json rename to enumeration/remote/test/aws_ec2_eip_multiple/aws_eip-eipalloc-017d5267e4dda73f1.res.golden.json diff --git a/pkg/remote/test/aws_ec2_eip_multiple/aws_eip-eipalloc-0cf714dc097c992cc.res.golden.json b/enumeration/remote/test/aws_ec2_eip_multiple/aws_eip-eipalloc-0cf714dc097c992cc.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_eip_multiple/aws_eip-eipalloc-0cf714dc097c992cc.res.golden.json rename to enumeration/remote/test/aws_ec2_eip_multiple/aws_eip-eipalloc-0cf714dc097c992cc.res.golden.json diff --git a/pkg/remote/test/aws_ec2_eip_multiple/results.golden.json b/enumeration/remote/test/aws_ec2_eip_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_eip_multiple/results.golden.json rename to enumeration/remote/test/aws_ec2_eip_multiple/results.golden.json diff --git a/pkg/remote/test/aws_ec2_instance_multiple/aws_instance-i-010376047a71419f1.res.golden.json b/enumeration/remote/test/aws_ec2_instance_multiple/aws_instance-i-010376047a71419f1.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_instance_multiple/aws_instance-i-010376047a71419f1.res.golden.json rename to enumeration/remote/test/aws_ec2_instance_multiple/aws_instance-i-010376047a71419f1.res.golden.json diff --git a/pkg/remote/test/aws_ec2_instance_multiple/aws_instance-i-0d3650a23f4e45dc0.res.golden.json b/enumeration/remote/test/aws_ec2_instance_multiple/aws_instance-i-0d3650a23f4e45dc0.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_instance_multiple/aws_instance-i-0d3650a23f4e45dc0.res.golden.json rename to enumeration/remote/test/aws_ec2_instance_multiple/aws_instance-i-0d3650a23f4e45dc0.res.golden.json diff --git a/pkg/remote/test/aws_ec2_instance_multiple/results.golden.json b/enumeration/remote/test/aws_ec2_instance_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_instance_multiple/results.golden.json rename to enumeration/remote/test/aws_ec2_instance_multiple/results.golden.json diff --git a/pkg/remote/test/aws_ec2_instance_terminated/aws_instance-i-0a3a7ed51ae2b4fa0.res.golden.json b/enumeration/remote/test/aws_ec2_instance_terminated/aws_instance-i-0a3a7ed51ae2b4fa0.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_instance_terminated/aws_instance-i-0a3a7ed51ae2b4fa0.res.golden.json rename to enumeration/remote/test/aws_ec2_instance_terminated/aws_instance-i-0a3a7ed51ae2b4fa0.res.golden.json diff --git a/pkg/remote/test/aws_ec2_instance_terminated/aws_instance-i-0e1543baf4f2cd990.res.golden.json b/enumeration/remote/test/aws_ec2_instance_terminated/aws_instance-i-0e1543baf4f2cd990.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_instance_terminated/aws_instance-i-0e1543baf4f2cd990.res.golden.json rename to enumeration/remote/test/aws_ec2_instance_terminated/aws_instance-i-0e1543baf4f2cd990.res.golden.json diff --git a/pkg/remote/test/aws_ec2_instance_terminated/results.golden.json b/enumeration/remote/test/aws_ec2_instance_terminated/results.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_instance_terminated/results.golden.json rename to enumeration/remote/test/aws_ec2_instance_terminated/results.golden.json diff --git a/pkg/remote/test/aws_ec2_internet_gateway_multiple/aws_internet_gateway-igw-0184eb41aadc62d1c.res.golden.json b/enumeration/remote/test/aws_ec2_internet_gateway_multiple/aws_internet_gateway-igw-0184eb41aadc62d1c.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_internet_gateway_multiple/aws_internet_gateway-igw-0184eb41aadc62d1c.res.golden.json rename to enumeration/remote/test/aws_ec2_internet_gateway_multiple/aws_internet_gateway-igw-0184eb41aadc62d1c.res.golden.json diff --git a/pkg/remote/test/aws_ec2_internet_gateway_multiple/aws_internet_gateway-igw-047b487f5c60fca99.res.golden.json b/enumeration/remote/test/aws_ec2_internet_gateway_multiple/aws_internet_gateway-igw-047b487f5c60fca99.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_internet_gateway_multiple/aws_internet_gateway-igw-047b487f5c60fca99.res.golden.json rename to enumeration/remote/test/aws_ec2_internet_gateway_multiple/aws_internet_gateway-igw-047b487f5c60fca99.res.golden.json diff --git a/pkg/remote/test/aws_ec2_internet_gateway_multiple/results.golden.json b/enumeration/remote/test/aws_ec2_internet_gateway_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_internet_gateway_multiple/results.golden.json rename to enumeration/remote/test/aws_ec2_internet_gateway_multiple/results.golden.json diff --git a/pkg/remote/test/aws_ec2_internet_gateway_multiple/terraform.tf b/enumeration/remote/test/aws_ec2_internet_gateway_multiple/terraform.tf similarity index 100% rename from pkg/remote/test/aws_ec2_internet_gateway_multiple/terraform.tf rename to enumeration/remote/test/aws_ec2_internet_gateway_multiple/terraform.tf diff --git a/pkg/remote/test/aws_ec2_key_pair_multiple/aws_key_pair-bar.res.golden.json b/enumeration/remote/test/aws_ec2_key_pair_multiple/aws_key_pair-bar.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_key_pair_multiple/aws_key_pair-bar.res.golden.json rename to enumeration/remote/test/aws_ec2_key_pair_multiple/aws_key_pair-bar.res.golden.json diff --git a/pkg/remote/test/aws_ec2_key_pair_multiple/aws_key_pair-test.res.golden.json b/enumeration/remote/test/aws_ec2_key_pair_multiple/aws_key_pair-test.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_key_pair_multiple/aws_key_pair-test.res.golden.json rename to enumeration/remote/test/aws_ec2_key_pair_multiple/aws_key_pair-test.res.golden.json diff --git a/pkg/remote/test/aws_ec2_key_pair_multiple/results.golden.json b/enumeration/remote/test/aws_ec2_key_pair_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_key_pair_multiple/results.golden.json rename to enumeration/remote/test/aws_ec2_key_pair_multiple/results.golden.json diff --git a/pkg/remote/test/aws_ec2_nat_gateway_single/aws_nat_gateway-nat-0a5408508b19ef490.res.golden.json b/enumeration/remote/test/aws_ec2_nat_gateway_single/aws_nat_gateway-nat-0a5408508b19ef490.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_nat_gateway_single/aws_nat_gateway-nat-0a5408508b19ef490.res.golden.json rename to enumeration/remote/test/aws_ec2_nat_gateway_single/aws_nat_gateway-nat-0a5408508b19ef490.res.golden.json diff --git a/pkg/remote/test/aws_ec2_nat_gateway_single/results.golden.json b/enumeration/remote/test/aws_ec2_nat_gateway_single/results.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_nat_gateway_single/results.golden.json rename to enumeration/remote/test/aws_ec2_nat_gateway_single/results.golden.json diff --git a/pkg/remote/test/aws_ec2_nat_gateway_single/terraform.tf b/enumeration/remote/test/aws_ec2_nat_gateway_single/terraform.tf similarity index 100% rename from pkg/remote/test/aws_ec2_nat_gateway_single/terraform.tf rename to enumeration/remote/test/aws_ec2_nat_gateway_single/terraform.tf diff --git a/pkg/remote/test/aws_ec2_network_acl/aws_network_acl-acl-043880b4682d2366b.res.golden.json b/enumeration/remote/test/aws_ec2_network_acl/aws_network_acl-acl-043880b4682d2366b.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_network_acl/aws_network_acl-acl-043880b4682d2366b.res.golden.json rename to enumeration/remote/test/aws_ec2_network_acl/aws_network_acl-acl-043880b4682d2366b.res.golden.json diff --git a/pkg/remote/test/aws_ec2_network_acl/aws_network_acl-acl-07a565dbe518c0713.res.golden.json b/enumeration/remote/test/aws_ec2_network_acl/aws_network_acl-acl-07a565dbe518c0713.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_network_acl/aws_network_acl-acl-07a565dbe518c0713.res.golden.json rename to enumeration/remote/test/aws_ec2_network_acl/aws_network_acl-acl-07a565dbe518c0713.res.golden.json diff --git a/pkg/remote/test/aws_ec2_network_acl/results.golden.json b/enumeration/remote/test/aws_ec2_network_acl/results.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_network_acl/results.golden.json rename to enumeration/remote/test/aws_ec2_network_acl/results.golden.json diff --git a/pkg/remote/test/aws_ec2_network_acl/terraform.tf b/enumeration/remote/test/aws_ec2_network_acl/terraform.tf similarity index 100% rename from pkg/remote/test/aws_ec2_network_acl/terraform.tf rename to enumeration/remote/test/aws_ec2_network_acl/terraform.tf diff --git a/pkg/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-2289824980-false-acl-0ad6d657494d17ee2-200.res.golden.json b/enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-2289824980-false-acl-0ad6d657494d17ee2-200.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-2289824980-false-acl-0ad6d657494d17ee2-200.res.golden.json rename to enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-2289824980-false-acl-0ad6d657494d17ee2-200.res.golden.json diff --git a/pkg/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-246660311-true-acl-0ad6d657494d17ee2-100.res.golden.json b/enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-246660311-true-acl-0ad6d657494d17ee2-100.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-246660311-true-acl-0ad6d657494d17ee2-100.res.golden.json rename to enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-246660311-true-acl-0ad6d657494d17ee2-100.res.golden.json diff --git a/pkg/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-4268384215-true-acl-0de54ef59074b622e-100.res.golden.json b/enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-4268384215-true-acl-0de54ef59074b622e-100.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-4268384215-true-acl-0de54ef59074b622e-100.res.golden.json rename to enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-4268384215-true-acl-0de54ef59074b622e-100.res.golden.json diff --git a/pkg/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-4293207588-false-acl-0ad6d657494d17ee2-100.res.golden.json b/enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-4293207588-false-acl-0ad6d657494d17ee2-100.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-4293207588-false-acl-0ad6d657494d17ee2-100.res.golden.json rename to enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-4293207588-false-acl-0ad6d657494d17ee2-100.res.golden.json diff --git a/pkg/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-515082162-false-acl-0de54ef59074b622e-100.res.golden.json b/enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-515082162-false-acl-0de54ef59074b622e-100.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-515082162-false-acl-0de54ef59074b622e-100.res.golden.json rename to enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-515082162-false-acl-0de54ef59074b622e-100.res.golden.json diff --git a/pkg/remote/test/aws_ec2_network_acl_rule/results.golden.json b/enumeration/remote/test/aws_ec2_network_acl_rule/results.golden.json similarity index 84% rename from pkg/remote/test/aws_ec2_network_acl_rule/results.golden.json rename to enumeration/remote/test/aws_ec2_network_acl_rule/results.golden.json index 7224a5c86..8c8788932 100755 --- a/pkg/remote/test/aws_ec2_network_acl_rule/results.golden.json +++ b/enumeration/remote/test/aws_ec2_network_acl_rule/results.golden.json @@ -6,15 +6,15 @@ "icmp_code": null, "icmp_type": null, "id": "nacl-246660311", - "ipv6_cidr_block": null, + "ipv6_cidr_block": "", "network_acl_id": "acl-0ad6d657494d17ee2", - "protocol": "17", + "protocol": "udp", "rule_action": "allow", "rule_number": 100, "to_port": 80 }, { - "cidr_block": null, + "cidr_block": "", "egress": false, "from_port": 80, "icmp_code": null, @@ -22,7 +22,7 @@ "id": "nacl-2289824980", "ipv6_cidr_block": "::/0", "network_acl_id": "acl-0ad6d657494d17ee2", - "protocol": "6", + "protocol": "tcp", "rule_action": "allow", "rule_number": 200, "to_port": 80 @@ -34,9 +34,9 @@ "icmp_code": null, "icmp_type": null, "id": "nacl-515082162", - "ipv6_cidr_block": null, + "ipv6_cidr_block": "", "network_acl_id": "acl-0de54ef59074b622e", - "protocol": "17", + "protocol": "udp", "rule_action": "allow", "rule_number": 100, "to_port": 80 @@ -48,9 +48,9 @@ "icmp_code": null, "icmp_type": null, "id": "nacl-4268384215", - "ipv6_cidr_block": null, + "ipv6_cidr_block": "", "network_acl_id": "acl-0de54ef59074b622e", - "protocol": "17", + "protocol": "udp", "rule_action": "allow", "rule_number": 100, "to_port": 80 @@ -62,9 +62,9 @@ "icmp_code": null, "icmp_type": null, "id": "nacl-4293207588", - "ipv6_cidr_block": null, + "ipv6_cidr_block": "", "network_acl_id": "acl-0ad6d657494d17ee2", - "protocol": "6", + "protocol": "tcp", "rule_action": "allow", "rule_number": 100, "to_port": 80 diff --git a/pkg/remote/test/aws_ec2_network_acl_rule/terraform.tf b/enumeration/remote/test/aws_ec2_network_acl_rule/terraform.tf similarity index 100% rename from pkg/remote/test/aws_ec2_network_acl_rule/terraform.tf rename to enumeration/remote/test/aws_ec2_network_acl_rule/terraform.tf diff --git a/pkg/remote/test/aws_ec2_route_multiple/aws_route-r-179966490-10.0.0.0_16-.res.golden.json b/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-179966490-10.0.0.0_16-.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_route_multiple/aws_route-r-179966490-10.0.0.0_16-.res.golden.json rename to enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-179966490-10.0.0.0_16-.res.golden.json diff --git a/pkg/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-0169b0937fd963ddc1080289494-0.0.0.0_0-rtb-0169b0937fd963ddc.res.golden.json b/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-0169b0937fd963ddc1080289494-0.0.0.0_0-rtb-0169b0937fd963ddc.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-0169b0937fd963ddc1080289494-0.0.0.0_0-rtb-0169b0937fd963ddc.res.golden.json rename to enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-0169b0937fd963ddc1080289494-0.0.0.0_0-rtb-0169b0937fd963ddc.res.golden.json diff --git a/pkg/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-0169b0937fd963ddc179966490-10.0.0.0_16-rtb-0169b0937fd963ddc.res.golden.json b/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-0169b0937fd963ddc179966490-10.0.0.0_16-rtb-0169b0937fd963ddc.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-0169b0937fd963ddc179966490-10.0.0.0_16-rtb-0169b0937fd963ddc.res.golden.json rename to enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-0169b0937fd963ddc179966490-10.0.0.0_16-rtb-0169b0937fd963ddc.res.golden.json diff --git a/pkg/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-0169b0937fd963ddc2750132062-___0-rtb-0169b0937fd963ddc.res.golden.json b/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-0169b0937fd963ddc2750132062-___0-rtb-0169b0937fd963ddc.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-0169b0937fd963ddc2750132062-___0-rtb-0169b0937fd963ddc.res.golden.json rename to enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-0169b0937fd963ddc2750132062-___0-rtb-0169b0937fd963ddc.res.golden.json diff --git a/pkg/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-02780c485f0be93c51325105504-10.1.2.0_24-rtb-02780c485f0be93c5.res.golden.json b/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-02780c485f0be93c51325105504-10.1.2.0_24-rtb-02780c485f0be93c5.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-02780c485f0be93c51325105504-10.1.2.0_24-rtb-02780c485f0be93c5.res.golden.json rename to enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-02780c485f0be93c51325105504-10.1.2.0_24-rtb-02780c485f0be93c5.res.golden.json diff --git a/pkg/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-02780c485f0be93c5179966490-10.0.0.0_16-rtb-02780c485f0be93c5.res.golden.json b/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-02780c485f0be93c5179966490-10.0.0.0_16-rtb-02780c485f0be93c5.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-02780c485f0be93c5179966490-10.0.0.0_16-rtb-02780c485f0be93c5.res.golden.json rename to enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-02780c485f0be93c5179966490-10.0.0.0_16-rtb-02780c485f0be93c5.res.golden.json diff --git a/pkg/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-02780c485f0be93c53362780110-10.1.1.0_24-rtb-02780c485f0be93c5.res.golden.json b/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-02780c485f0be93c53362780110-10.1.1.0_24-rtb-02780c485f0be93c5.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-02780c485f0be93c53362780110-10.1.1.0_24-rtb-02780c485f0be93c5.res.golden.json rename to enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-02780c485f0be93c53362780110-10.1.1.0_24-rtb-02780c485f0be93c5.res.golden.json diff --git a/pkg/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-096bdfb69309c54c3179966490-10.0.0.0_16-rtb-096bdfb69309c54c3.res.golden.json b/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-096bdfb69309c54c3179966490-10.0.0.0_16-rtb-096bdfb69309c54c3.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-096bdfb69309c54c3179966490-10.0.0.0_16-rtb-096bdfb69309c54c3.res.golden.json rename to enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-096bdfb69309c54c3179966490-10.0.0.0_16-rtb-096bdfb69309c54c3.res.golden.json diff --git a/pkg/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-096bdfb69309c54c3243279527-1.1.1.1_32-rtb-096bdfb69309c54c3.res.golden.json b/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-096bdfb69309c54c3243279527-1.1.1.1_32-rtb-096bdfb69309c54c3.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-096bdfb69309c54c3243279527-1.1.1.1_32-rtb-096bdfb69309c54c3.res.golden.json rename to enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-096bdfb69309c54c3243279527-1.1.1.1_32-rtb-096bdfb69309c54c3.res.golden.json diff --git a/pkg/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-096bdfb69309c54c32750132062-___0-rtb-096bdfb69309c54c3.res.golden.json b/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-096bdfb69309c54c32750132062-___0-rtb-096bdfb69309c54c3.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-096bdfb69309c54c32750132062-___0-rtb-096bdfb69309c54c3.res.golden.json rename to enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-096bdfb69309c54c32750132062-___0-rtb-096bdfb69309c54c3.res.golden.json diff --git a/pkg/remote/test/aws_ec2_route_multiple/results.golden.json b/enumeration/remote/test/aws_ec2_route_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_route_multiple/results.golden.json rename to enumeration/remote/test/aws_ec2_route_multiple/results.golden.json diff --git a/pkg/remote/test/aws_ec2_route_multiple/terraform.tf b/enumeration/remote/test/aws_ec2_route_multiple/terraform.tf similarity index 100% rename from pkg/remote/test/aws_ec2_route_multiple/terraform.tf rename to enumeration/remote/test/aws_ec2_route_multiple/terraform.tf diff --git a/pkg/remote/test/aws_ec2_route_table_association_multiple/aws_route_table_association-rtbassoc-01957791b2cfe6ea4-rtb-05aa6c5673311a17b.res.golden.json b/enumeration/remote/test/aws_ec2_route_table_association_multiple/aws_route_table_association-rtbassoc-01957791b2cfe6ea4-rtb-05aa6c5673311a17b.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_route_table_association_multiple/aws_route_table_association-rtbassoc-01957791b2cfe6ea4-rtb-05aa6c5673311a17b.res.golden.json rename to enumeration/remote/test/aws_ec2_route_table_association_multiple/aws_route_table_association-rtbassoc-01957791b2cfe6ea4-rtb-05aa6c5673311a17b.res.golden.json diff --git a/pkg/remote/test/aws_ec2_route_table_association_multiple/aws_route_table_association-rtbassoc-0809598f92dbec03b-rtb-05aa6c5673311a17b.res.golden.json b/enumeration/remote/test/aws_ec2_route_table_association_multiple/aws_route_table_association-rtbassoc-0809598f92dbec03b-rtb-05aa6c5673311a17b.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_route_table_association_multiple/aws_route_table_association-rtbassoc-0809598f92dbec03b-rtb-05aa6c5673311a17b.res.golden.json rename to enumeration/remote/test/aws_ec2_route_table_association_multiple/aws_route_table_association-rtbassoc-0809598f92dbec03b-rtb-05aa6c5673311a17b.res.golden.json diff --git a/pkg/remote/test/aws_ec2_route_table_association_multiple/aws_route_table_association-rtbassoc-0a79ccacfceb4944b-rtb-09df7cc9d16de9f8f.res.golden.json b/enumeration/remote/test/aws_ec2_route_table_association_multiple/aws_route_table_association-rtbassoc-0a79ccacfceb4944b-rtb-09df7cc9d16de9f8f.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_route_table_association_multiple/aws_route_table_association-rtbassoc-0a79ccacfceb4944b-rtb-09df7cc9d16de9f8f.res.golden.json rename to enumeration/remote/test/aws_ec2_route_table_association_multiple/aws_route_table_association-rtbassoc-0a79ccacfceb4944b-rtb-09df7cc9d16de9f8f.res.golden.json diff --git a/pkg/remote/test/aws_ec2_route_table_association_multiple/aws_route_table_association-rtbassoc-0b4f97ea57490e213-rtb-05aa6c5673311a17b.res.golden.json b/enumeration/remote/test/aws_ec2_route_table_association_multiple/aws_route_table_association-rtbassoc-0b4f97ea57490e213-rtb-05aa6c5673311a17b.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_route_table_association_multiple/aws_route_table_association-rtbassoc-0b4f97ea57490e213-rtb-05aa6c5673311a17b.res.golden.json rename to enumeration/remote/test/aws_ec2_route_table_association_multiple/aws_route_table_association-rtbassoc-0b4f97ea57490e213-rtb-05aa6c5673311a17b.res.golden.json diff --git a/pkg/remote/test/aws_ec2_route_table_association_multiple/results.golden.json b/enumeration/remote/test/aws_ec2_route_table_association_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_route_table_association_multiple/results.golden.json rename to enumeration/remote/test/aws_ec2_route_table_association_multiple/results.golden.json diff --git a/pkg/remote/test/aws_ec2_route_table_multiple/aws_route_table-rtb-0002ac731f6fdea55.res.golden.json b/enumeration/remote/test/aws_ec2_route_table_multiple/aws_route_table-rtb-0002ac731f6fdea55.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_route_table_multiple/aws_route_table-rtb-0002ac731f6fdea55.res.golden.json rename to enumeration/remote/test/aws_ec2_route_table_multiple/aws_route_table-rtb-0002ac731f6fdea55.res.golden.json diff --git a/pkg/remote/test/aws_ec2_route_table_multiple/aws_route_table-rtb-08b7b71af15e183ce.res.golden.json b/enumeration/remote/test/aws_ec2_route_table_multiple/aws_route_table-rtb-08b7b71af15e183ce.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_route_table_multiple/aws_route_table-rtb-08b7b71af15e183ce.res.golden.json rename to enumeration/remote/test/aws_ec2_route_table_multiple/aws_route_table-rtb-08b7b71af15e183ce.res.golden.json diff --git a/pkg/remote/test/aws_ec2_route_table_multiple/aws_route_table-rtb-0c55d55593f33fbac.res.golden.json b/enumeration/remote/test/aws_ec2_route_table_multiple/aws_route_table-rtb-0c55d55593f33fbac.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_route_table_multiple/aws_route_table-rtb-0c55d55593f33fbac.res.golden.json rename to enumeration/remote/test/aws_ec2_route_table_multiple/aws_route_table-rtb-0c55d55593f33fbac.res.golden.json diff --git a/pkg/remote/test/aws_ec2_route_table_multiple/results.golden.json b/enumeration/remote/test/aws_ec2_route_table_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_route_table_multiple/results.golden.json rename to enumeration/remote/test/aws_ec2_route_table_multiple/results.golden.json diff --git a/pkg/remote/test/aws_ec2_route_table_multiple/terraform.tf b/enumeration/remote/test/aws_ec2_route_table_multiple/terraform.tf similarity index 100% rename from pkg/remote/test/aws_ec2_route_table_multiple/terraform.tf rename to enumeration/remote/test/aws_ec2_route_table_multiple/terraform.tf diff --git a/pkg/remote/test/aws_ec2_subnet_multiple/aws_subnet-subnet-05810d3f933925f6d.res.golden.json b/enumeration/remote/test/aws_ec2_subnet_multiple/aws_subnet-subnet-05810d3f933925f6d.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_subnet_multiple/aws_subnet-subnet-05810d3f933925f6d.res.golden.json rename to enumeration/remote/test/aws_ec2_subnet_multiple/aws_subnet-subnet-05810d3f933925f6d.res.golden.json diff --git a/pkg/remote/test/aws_ec2_subnet_multiple/aws_subnet-subnet-0b13f1e0eacf67424.res.golden.json b/enumeration/remote/test/aws_ec2_subnet_multiple/aws_subnet-subnet-0b13f1e0eacf67424.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_subnet_multiple/aws_subnet-subnet-0b13f1e0eacf67424.res.golden.json rename to enumeration/remote/test/aws_ec2_subnet_multiple/aws_subnet-subnet-0b13f1e0eacf67424.res.golden.json diff --git a/pkg/remote/test/aws_ec2_subnet_multiple/aws_subnet-subnet-0c9b78001fe186e22.res.golden.json b/enumeration/remote/test/aws_ec2_subnet_multiple/aws_subnet-subnet-0c9b78001fe186e22.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_subnet_multiple/aws_subnet-subnet-0c9b78001fe186e22.res.golden.json rename to enumeration/remote/test/aws_ec2_subnet_multiple/aws_subnet-subnet-0c9b78001fe186e22.res.golden.json diff --git a/pkg/remote/test/aws_ec2_subnet_multiple/results.golden.json b/enumeration/remote/test/aws_ec2_subnet_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_ec2_subnet_multiple/results.golden.json rename to enumeration/remote/test/aws_ec2_subnet_multiple/results.golden.json diff --git a/pkg/remote/test/aws_ec2_subnet_multiple/terraform.tf b/enumeration/remote/test/aws_ec2_subnet_multiple/terraform.tf similarity index 100% rename from pkg/remote/test/aws_ec2_subnet_multiple/terraform.tf rename to enumeration/remote/test/aws_ec2_subnet_multiple/terraform.tf diff --git a/pkg/remote/test/aws_ecr_repository_multiple/aws_ecr_repository-bar.res.golden.json b/enumeration/remote/test/aws_ecr_repository_multiple/aws_ecr_repository-bar.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ecr_repository_multiple/aws_ecr_repository-bar.res.golden.json rename to enumeration/remote/test/aws_ecr_repository_multiple/aws_ecr_repository-bar.res.golden.json diff --git a/pkg/remote/test/aws_ecr_repository_multiple/aws_ecr_repository-test_ecr.res.golden.json b/enumeration/remote/test/aws_ecr_repository_multiple/aws_ecr_repository-test_ecr.res.golden.json similarity index 100% rename from pkg/remote/test/aws_ecr_repository_multiple/aws_ecr_repository-test_ecr.res.golden.json rename to enumeration/remote/test/aws_ecr_repository_multiple/aws_ecr_repository-test_ecr.res.golden.json diff --git a/pkg/remote/test/aws_ecr_repository_multiple/results.golden.json b/enumeration/remote/test/aws_ecr_repository_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_ecr_repository_multiple/results.golden.json rename to enumeration/remote/test/aws_ecr_repository_multiple/results.golden.json diff --git a/pkg/remote/test/aws_ecr_repository_multiple/terraform.tf b/enumeration/remote/test/aws_ecr_repository_multiple/terraform.tf similarity index 100% rename from pkg/remote/test/aws_ecr_repository_multiple/terraform.tf rename to enumeration/remote/test/aws_ecr_repository_multiple/terraform.tf diff --git a/pkg/remote/test/aws_iam_access_key_multiple/aws_iam_access_key-AKIA5QYBVVD223VWU32A-test-driftctl.res.golden.json b/enumeration/remote/test/aws_iam_access_key_multiple/aws_iam_access_key-AKIA5QYBVVD223VWU32A-test-driftctl.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_access_key_multiple/aws_iam_access_key-AKIA5QYBVVD223VWU32A-test-driftctl.res.golden.json rename to enumeration/remote/test/aws_iam_access_key_multiple/aws_iam_access_key-AKIA5QYBVVD223VWU32A-test-driftctl.res.golden.json diff --git a/pkg/remote/test/aws_iam_access_key_multiple/aws_iam_access_key-AKIA5QYBVVD26EJME25D-test-driftctl2.res.golden.json b/enumeration/remote/test/aws_iam_access_key_multiple/aws_iam_access_key-AKIA5QYBVVD26EJME25D-test-driftctl2.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_access_key_multiple/aws_iam_access_key-AKIA5QYBVVD26EJME25D-test-driftctl2.res.golden.json rename to enumeration/remote/test/aws_iam_access_key_multiple/aws_iam_access_key-AKIA5QYBVVD26EJME25D-test-driftctl2.res.golden.json diff --git a/pkg/remote/test/aws_iam_access_key_multiple/aws_iam_access_key-AKIA5QYBVVD2QYI36UZP-test-driftctl.res.golden.json b/enumeration/remote/test/aws_iam_access_key_multiple/aws_iam_access_key-AKIA5QYBVVD2QYI36UZP-test-driftctl.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_access_key_multiple/aws_iam_access_key-AKIA5QYBVVD2QYI36UZP-test-driftctl.res.golden.json rename to enumeration/remote/test/aws_iam_access_key_multiple/aws_iam_access_key-AKIA5QYBVVD2QYI36UZP-test-driftctl.res.golden.json diff --git a/pkg/remote/test/aws_iam_access_key_multiple/aws_iam_access_key-AKIA5QYBVVD2SWDFVVMG-test-driftctl2.res.golden.json b/enumeration/remote/test/aws_iam_access_key_multiple/aws_iam_access_key-AKIA5QYBVVD2SWDFVVMG-test-driftctl2.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_access_key_multiple/aws_iam_access_key-AKIA5QYBVVD2SWDFVVMG-test-driftctl2.res.golden.json rename to enumeration/remote/test/aws_iam_access_key_multiple/aws_iam_access_key-AKIA5QYBVVD2SWDFVVMG-test-driftctl2.res.golden.json diff --git a/pkg/remote/test/aws_iam_access_key_multiple/results.golden.json b/enumeration/remote/test/aws_iam_access_key_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_access_key_multiple/results.golden.json rename to enumeration/remote/test/aws_iam_access_key_multiple/results.golden.json diff --git a/pkg/remote/test/aws_iam_access_key_multiple/terraform.tf b/enumeration/remote/test/aws_iam_access_key_multiple/terraform.tf similarity index 100% rename from pkg/remote/test/aws_iam_access_key_multiple/terraform.tf rename to enumeration/remote/test/aws_iam_access_key_multiple/terraform.tf diff --git a/pkg/remote/test/aws_iam_policy_multiple/aws_iam_policy-arn_aws_iam__929327065333_policy_policy-0.res.golden.json b/enumeration/remote/test/aws_iam_policy_multiple/aws_iam_policy-arn_aws_iam__929327065333_policy_policy-0.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_policy_multiple/aws_iam_policy-arn_aws_iam__929327065333_policy_policy-0.res.golden.json rename to enumeration/remote/test/aws_iam_policy_multiple/aws_iam_policy-arn_aws_iam__929327065333_policy_policy-0.res.golden.json diff --git a/pkg/remote/test/aws_iam_policy_multiple/aws_iam_policy-arn_aws_iam__929327065333_policy_policy-1.res.golden.json b/enumeration/remote/test/aws_iam_policy_multiple/aws_iam_policy-arn_aws_iam__929327065333_policy_policy-1.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_policy_multiple/aws_iam_policy-arn_aws_iam__929327065333_policy_policy-1.res.golden.json rename to enumeration/remote/test/aws_iam_policy_multiple/aws_iam_policy-arn_aws_iam__929327065333_policy_policy-1.res.golden.json diff --git a/pkg/remote/test/aws_iam_policy_multiple/aws_iam_policy-arn_aws_iam__929327065333_policy_policy-2.res.golden.json b/enumeration/remote/test/aws_iam_policy_multiple/aws_iam_policy-arn_aws_iam__929327065333_policy_policy-2.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_policy_multiple/aws_iam_policy-arn_aws_iam__929327065333_policy_policy-2.res.golden.json rename to enumeration/remote/test/aws_iam_policy_multiple/aws_iam_policy-arn_aws_iam__929327065333_policy_policy-2.res.golden.json diff --git a/pkg/remote/test/aws_iam_policy_multiple/results.golden.json b/enumeration/remote/test/aws_iam_policy_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_policy_multiple/results.golden.json rename to enumeration/remote/test/aws_iam_policy_multiple/results.golden.json diff --git a/pkg/remote/test/aws_iam_role_multiple/aws_iam_role-test_role_0.res.golden.json b/enumeration/remote/test/aws_iam_role_multiple/aws_iam_role-test_role_0.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_role_multiple/aws_iam_role-test_role_0.res.golden.json rename to enumeration/remote/test/aws_iam_role_multiple/aws_iam_role-test_role_0.res.golden.json diff --git a/pkg/remote/test/aws_iam_role_multiple/aws_iam_role-test_role_1.res.golden.json b/enumeration/remote/test/aws_iam_role_multiple/aws_iam_role-test_role_1.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_role_multiple/aws_iam_role-test_role_1.res.golden.json rename to enumeration/remote/test/aws_iam_role_multiple/aws_iam_role-test_role_1.res.golden.json diff --git a/pkg/remote/test/aws_iam_role_multiple/aws_iam_role-test_role_2.res.golden.json b/enumeration/remote/test/aws_iam_role_multiple/aws_iam_role-test_role_2.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_role_multiple/aws_iam_role-test_role_2.res.golden.json rename to enumeration/remote/test/aws_iam_role_multiple/aws_iam_role-test_role_2.res.golden.json diff --git a/pkg/remote/test/aws_iam_role_multiple/results.golden.json b/enumeration/remote/test/aws_iam_role_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_role_multiple/results.golden.json rename to enumeration/remote/test/aws_iam_role_multiple/results.golden.json diff --git a/pkg/remote/test/aws_iam_role_multiple/terraform.tf b/enumeration/remote/test/aws_iam_role_multiple/terraform.tf similarity index 100% rename from pkg/remote/test/aws_iam_role_multiple/terraform.tf rename to enumeration/remote/test/aws_iam_role_multiple/terraform.tf diff --git a/pkg/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy-test-role-arn_aws_iam__929327065333_policy_test-policy-test-role.res.golden.json b/enumeration/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy-test-role-arn_aws_iam__929327065333_policy_test-policy-test-role.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy-test-role-arn_aws_iam__929327065333_policy_test-policy-test-role.res.golden.json rename to enumeration/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy-test-role-arn_aws_iam__929327065333_policy_test-policy-test-role.res.golden.json diff --git a/pkg/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy-test-role2-arn_aws_iam__929327065333_policy_test-policy-test-role2.res.golden.json b/enumeration/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy-test-role2-arn_aws_iam__929327065333_policy_test-policy-test-role2.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy-test-role2-arn_aws_iam__929327065333_policy_test-policy-test-role2.res.golden.json rename to enumeration/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy-test-role2-arn_aws_iam__929327065333_policy_test-policy-test-role2.res.golden.json diff --git a/pkg/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy2-test-role-arn_aws_iam__929327065333_policy_test-policy2-test-role.res.golden.json b/enumeration/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy2-test-role-arn_aws_iam__929327065333_policy_test-policy2-test-role.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy2-test-role-arn_aws_iam__929327065333_policy_test-policy2-test-role.res.golden.json rename to enumeration/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy2-test-role-arn_aws_iam__929327065333_policy_test-policy2-test-role.res.golden.json diff --git a/pkg/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy2-test-role2-arn_aws_iam__929327065333_policy_test-policy2-test-role2.res.golden.json b/enumeration/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy2-test-role2-arn_aws_iam__929327065333_policy_test-policy2-test-role2.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy2-test-role2-arn_aws_iam__929327065333_policy_test-policy2-test-role2.res.golden.json rename to enumeration/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy2-test-role2-arn_aws_iam__929327065333_policy_test-policy2-test-role2.res.golden.json diff --git a/pkg/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy3-test-role-arn_aws_iam__929327065333_policy_test-policy3-test-role.res.golden.json b/enumeration/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy3-test-role-arn_aws_iam__929327065333_policy_test-policy3-test-role.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy3-test-role-arn_aws_iam__929327065333_policy_test-policy3-test-role.res.golden.json rename to enumeration/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy3-test-role-arn_aws_iam__929327065333_policy_test-policy3-test-role.res.golden.json diff --git a/pkg/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy3-test-role2-arn_aws_iam__929327065333_policy_test-policy3-test-role2.res.golden.json b/enumeration/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy3-test-role2-arn_aws_iam__929327065333_policy_test-policy3-test-role2.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy3-test-role2-arn_aws_iam__929327065333_policy_test-policy3-test-role2.res.golden.json rename to enumeration/remote/test/aws_iam_role_policy_attachment_multiple/aws_iam_role_policy_attachment-test-policy3-test-role2-arn_aws_iam__929327065333_policy_test-policy3-test-role2.res.golden.json diff --git a/pkg/remote/test/aws_iam_role_policy_attachment_multiple/main.tf b/enumeration/remote/test/aws_iam_role_policy_attachment_multiple/main.tf similarity index 100% rename from pkg/remote/test/aws_iam_role_policy_attachment_multiple/main.tf rename to enumeration/remote/test/aws_iam_role_policy_attachment_multiple/main.tf diff --git a/pkg/remote/test/aws_iam_role_policy_attachment_multiple/results.golden.json b/enumeration/remote/test/aws_iam_role_policy_attachment_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_role_policy_attachment_multiple/results.golden.json rename to enumeration/remote/test/aws_iam_role_policy_attachment_multiple/results.golden.json diff --git a/pkg/remote/test/aws_iam_role_policy_empty/schema.golden.json b/enumeration/remote/test/aws_iam_role_policy_empty/schema.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_role_policy_empty/schema.golden.json rename to enumeration/remote/test/aws_iam_role_policy_empty/schema.golden.json diff --git a/pkg/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_0_policy-role0-0.res.golden.json b/enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_0_policy-role0-0.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_0_policy-role0-0.res.golden.json rename to enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_0_policy-role0-0.res.golden.json diff --git a/pkg/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_0_policy-role0-1.res.golden.json b/enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_0_policy-role0-1.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_0_policy-role0-1.res.golden.json rename to enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_0_policy-role0-1.res.golden.json diff --git a/pkg/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_0_policy-role0-2.res.golden.json b/enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_0_policy-role0-2.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_0_policy-role0-2.res.golden.json rename to enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_0_policy-role0-2.res.golden.json diff --git a/pkg/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_1_policy-role1-0.res.golden.json b/enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_1_policy-role1-0.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_1_policy-role1-0.res.golden.json rename to enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_1_policy-role1-0.res.golden.json diff --git a/pkg/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_1_policy-role1-1.res.golden.json b/enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_1_policy-role1-1.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_1_policy-role1-1.res.golden.json rename to enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_1_policy-role1-1.res.golden.json diff --git a/pkg/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_1_policy-role1-2.res.golden.json b/enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_1_policy-role1-2.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_1_policy-role1-2.res.golden.json rename to enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_1_policy-role1-2.res.golden.json diff --git a/pkg/remote/test/aws_iam_role_policy_multiple/results.golden.json b/enumeration/remote/test/aws_iam_role_policy_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_role_policy_multiple/results.golden.json rename to enumeration/remote/test/aws_iam_role_policy_multiple/results.golden.json diff --git a/pkg/remote/test/aws_iam_role_policy_multiple/schema.golden.json b/enumeration/remote/test/aws_iam_role_policy_multiple/schema.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_role_policy_multiple/schema.golden.json rename to enumeration/remote/test/aws_iam_role_policy_multiple/schema.golden.json diff --git a/pkg/remote/test/aws_iam_role_policy_multiple/terraform.tf b/enumeration/remote/test/aws_iam_role_policy_multiple/terraform.tf similarity index 100% rename from pkg/remote/test/aws_iam_role_policy_multiple/terraform.tf rename to enumeration/remote/test/aws_iam_role_policy_multiple/terraform.tf diff --git a/pkg/remote/test/aws_iam_user_multiple/aws_iam_user-test-driftctl-0.res.golden.json b/enumeration/remote/test/aws_iam_user_multiple/aws_iam_user-test-driftctl-0.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_multiple/aws_iam_user-test-driftctl-0.res.golden.json rename to enumeration/remote/test/aws_iam_user_multiple/aws_iam_user-test-driftctl-0.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_multiple/aws_iam_user-test-driftctl-1.res.golden.json b/enumeration/remote/test/aws_iam_user_multiple/aws_iam_user-test-driftctl-1.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_multiple/aws_iam_user-test-driftctl-1.res.golden.json rename to enumeration/remote/test/aws_iam_user_multiple/aws_iam_user-test-driftctl-1.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_multiple/aws_iam_user-test-driftctl-2.res.golden.json b/enumeration/remote/test/aws_iam_user_multiple/aws_iam_user-test-driftctl-2.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_multiple/aws_iam_user-test-driftctl-2.res.golden.json rename to enumeration/remote/test/aws_iam_user_multiple/aws_iam_user-test-driftctl-2.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_multiple/results.golden.json b/enumeration/remote/test/aws_iam_user_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_multiple/results.golden.json rename to enumeration/remote/test/aws_iam_user_multiple/results.golden.json diff --git a/pkg/remote/test/aws_iam_user_multiple/terraform.tf b/enumeration/remote/test/aws_iam_user_multiple/terraform.tf similarity index 100% rename from pkg/remote/test/aws_iam_user_multiple/terraform.tf rename to enumeration/remote/test/aws_iam_user_multiple/terraform.tf diff --git a/pkg/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test-loadbalancer-arn_aws_iam__726421854799_policy_test-loadbalancer.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test-loadbalancer-arn_aws_iam__726421854799_policy_test-loadbalancer.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test-loadbalancer-arn_aws_iam__726421854799_policy_test-loadbalancer.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test-loadbalancer-arn_aws_iam__726421854799_policy_test-loadbalancer.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test-loadbalancer2-arn_aws_iam__726421854799_policy_test-loadbalancer2.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test-loadbalancer2-arn_aws_iam__726421854799_policy_test-loadbalancer2.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test-loadbalancer2-arn_aws_iam__726421854799_policy_test-loadbalancer2.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test-loadbalancer2-arn_aws_iam__726421854799_policy_test-loadbalancer2.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test-loadbalancer3-arn_aws_iam__726421854799_policy_test-loadbalancer3.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test-loadbalancer3-arn_aws_iam__726421854799_policy_test-loadbalancer3.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test-loadbalancer3-arn_aws_iam__726421854799_policy_test-loadbalancer3.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test-loadbalancer3-arn_aws_iam__726421854799_policy_test-loadbalancer3.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test2-loadbalancer-arn_aws_iam__726421854799_policy_test2-loadbalancer.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test2-loadbalancer-arn_aws_iam__726421854799_policy_test2-loadbalancer.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test2-loadbalancer-arn_aws_iam__726421854799_policy_test2-loadbalancer.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test2-loadbalancer-arn_aws_iam__726421854799_policy_test2-loadbalancer.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test2-loadbalancer2-arn_aws_iam__726421854799_policy_test2-loadbalancer2.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test2-loadbalancer2-arn_aws_iam__726421854799_policy_test2-loadbalancer2.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test2-loadbalancer2-arn_aws_iam__726421854799_policy_test2-loadbalancer2.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test2-loadbalancer2-arn_aws_iam__726421854799_policy_test2-loadbalancer2.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test2-loadbalancer3-arn_aws_iam__726421854799_policy_test2-loadbalancer3.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test2-loadbalancer3-arn_aws_iam__726421854799_policy_test2-loadbalancer3.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test2-loadbalancer3-arn_aws_iam__726421854799_policy_test2-loadbalancer3.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test2-loadbalancer3-arn_aws_iam__726421854799_policy_test2-loadbalancer3.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test3-loadbalancer-arn_aws_iam__726421854799_policy_test3-loadbalancer.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test3-loadbalancer-arn_aws_iam__726421854799_policy_test3-loadbalancer.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test3-loadbalancer-arn_aws_iam__726421854799_policy_test3-loadbalancer.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test3-loadbalancer-arn_aws_iam__726421854799_policy_test3-loadbalancer.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test3-loadbalancer2-arn_aws_iam__726421854799_policy_test3-loadbalancer2.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test3-loadbalancer2-arn_aws_iam__726421854799_policy_test3-loadbalancer2.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test3-loadbalancer2-arn_aws_iam__726421854799_policy_test3-loadbalancer2.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test3-loadbalancer2-arn_aws_iam__726421854799_policy_test3-loadbalancer2.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test3-loadbalancer3-arn_aws_iam__726421854799_policy_test3-loadbalancer3.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test3-loadbalancer3-arn_aws_iam__726421854799_policy_test3-loadbalancer3.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test3-loadbalancer3-arn_aws_iam__726421854799_policy_test3-loadbalancer3.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test3-loadbalancer3-arn_aws_iam__726421854799_policy_test3-loadbalancer3.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test4-loadbalancer-arn_aws_iam__726421854799_policy_test4-loadbalancer.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test4-loadbalancer-arn_aws_iam__726421854799_policy_test4-loadbalancer.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test4-loadbalancer-arn_aws_iam__726421854799_policy_test4-loadbalancer.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test4-loadbalancer-arn_aws_iam__726421854799_policy_test4-loadbalancer.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test4-loadbalancer2-arn_aws_iam__726421854799_policy_test4-loadbalancer2.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test4-loadbalancer2-arn_aws_iam__726421854799_policy_test4-loadbalancer2.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test4-loadbalancer2-arn_aws_iam__726421854799_policy_test4-loadbalancer2.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test4-loadbalancer2-arn_aws_iam__726421854799_policy_test4-loadbalancer2.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test4-loadbalancer3-arn_aws_iam__726421854799_policy_test4-loadbalancer3.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test4-loadbalancer3-arn_aws_iam__726421854799_policy_test4-loadbalancer3.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test4-loadbalancer3-arn_aws_iam__726421854799_policy_test4-loadbalancer3.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_attachment_multiple/aws_iam_user_policy_attachment-test4-loadbalancer3-arn_aws_iam__726421854799_policy_test4-loadbalancer3.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_attachment_multiple/main.tf b/enumeration/remote/test/aws_iam_user_policy_attachment_multiple/main.tf similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_attachment_multiple/main.tf rename to enumeration/remote/test/aws_iam_user_policy_attachment_multiple/main.tf diff --git a/pkg/remote/test/aws_iam_user_policy_attachment_multiple/results.golden.json b/enumeration/remote/test/aws_iam_user_policy_attachment_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_attachment_multiple/results.golden.json rename to enumeration/remote/test/aws_iam_user_policy_attachment_multiple/results.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test2.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test2.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test2.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test2.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test22.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test22.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test22.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test22.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test23.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test23.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test23.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test23.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test24.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test24.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test24.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test24.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test3.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test3.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test3.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test3.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test4.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test4.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test4.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer2_test4.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test2.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test2.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test2.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test2.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test22.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test22.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test22.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test22.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test23.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test23.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test23.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test23.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test24.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test24.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test24.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test24.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test3.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test3.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test3.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test3.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test32.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test32.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test32.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test32.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test33.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test33.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test33.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test33.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test34.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test34.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test34.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test34.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test4.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test4.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test4.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer3_test4.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer_test.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer_test.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer_test.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer_test.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer_test2.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer_test2.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer_test2.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer_test2.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer_test3.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer_test3.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer_test3.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer_test3.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer_test4.res.golden.json b/enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer_test4.res.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer_test4.res.golden.json rename to enumeration/remote/test/aws_iam_user_policy_multiple/aws_iam_user_policy-loadbalancer_test4.res.golden.json diff --git a/pkg/remote/test/aws_iam_user_policy_multiple/main.tf b/enumeration/remote/test/aws_iam_user_policy_multiple/main.tf similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_multiple/main.tf rename to enumeration/remote/test/aws_iam_user_policy_multiple/main.tf diff --git a/pkg/remote/test/aws_iam_user_policy_multiple/results.golden.json b/enumeration/remote/test/aws_iam_user_policy_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_iam_user_policy_multiple/results.golden.json rename to enumeration/remote/test/aws_iam_user_policy_multiple/results.golden.json diff --git a/pkg/remote/test/aws_kms_alias_multiple/aws_kms_alias-alias_bar.res.golden.json b/enumeration/remote/test/aws_kms_alias_multiple/aws_kms_alias-alias_bar.res.golden.json similarity index 100% rename from pkg/remote/test/aws_kms_alias_multiple/aws_kms_alias-alias_bar.res.golden.json rename to enumeration/remote/test/aws_kms_alias_multiple/aws_kms_alias-alias_bar.res.golden.json diff --git a/pkg/remote/test/aws_kms_alias_multiple/aws_kms_alias-alias_baz20210225124429210500000001.res.golden.json b/enumeration/remote/test/aws_kms_alias_multiple/aws_kms_alias-alias_baz20210225124429210500000001.res.golden.json similarity index 100% rename from pkg/remote/test/aws_kms_alias_multiple/aws_kms_alias-alias_baz20210225124429210500000001.res.golden.json rename to enumeration/remote/test/aws_kms_alias_multiple/aws_kms_alias-alias_baz20210225124429210500000001.res.golden.json diff --git a/pkg/remote/test/aws_kms_alias_multiple/aws_kms_alias-alias_foo.res.golden.json b/enumeration/remote/test/aws_kms_alias_multiple/aws_kms_alias-alias_foo.res.golden.json similarity index 100% rename from pkg/remote/test/aws_kms_alias_multiple/aws_kms_alias-alias_foo.res.golden.json rename to enumeration/remote/test/aws_kms_alias_multiple/aws_kms_alias-alias_foo.res.golden.json diff --git a/pkg/remote/test/aws_kms_alias_multiple/results.golden.json b/enumeration/remote/test/aws_kms_alias_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_kms_alias_multiple/results.golden.json rename to enumeration/remote/test/aws_kms_alias_multiple/results.golden.json diff --git a/pkg/remote/test/aws_kms_alias_multiple/terraform.tf b/enumeration/remote/test/aws_kms_alias_multiple/terraform.tf similarity index 100% rename from pkg/remote/test/aws_kms_alias_multiple/terraform.tf rename to enumeration/remote/test/aws_kms_alias_multiple/terraform.tf diff --git a/pkg/remote/test/aws_kms_key_multiple/aws_kms_key-5d765f32-bfdc-4610-b6ab-f82db5d0601b.res.golden.json b/enumeration/remote/test/aws_kms_key_multiple/aws_kms_key-5d765f32-bfdc-4610-b6ab-f82db5d0601b.res.golden.json similarity index 100% rename from pkg/remote/test/aws_kms_key_multiple/aws_kms_key-5d765f32-bfdc-4610-b6ab-f82db5d0601b.res.golden.json rename to enumeration/remote/test/aws_kms_key_multiple/aws_kms_key-5d765f32-bfdc-4610-b6ab-f82db5d0601b.res.golden.json diff --git a/pkg/remote/test/aws_kms_key_multiple/aws_kms_key-89d2c023-ea53-40a5-b20a-d84905c622d7.res.golden.json b/enumeration/remote/test/aws_kms_key_multiple/aws_kms_key-89d2c023-ea53-40a5-b20a-d84905c622d7.res.golden.json similarity index 100% rename from pkg/remote/test/aws_kms_key_multiple/aws_kms_key-89d2c023-ea53-40a5-b20a-d84905c622d7.res.golden.json rename to enumeration/remote/test/aws_kms_key_multiple/aws_kms_key-89d2c023-ea53-40a5-b20a-d84905c622d7.res.golden.json diff --git a/pkg/remote/test/aws_kms_key_multiple/aws_kms_key-8ee21d91-c000-428c-8032-235aac55da36.res.golden.json b/enumeration/remote/test/aws_kms_key_multiple/aws_kms_key-8ee21d91-c000-428c-8032-235aac55da36.res.golden.json similarity index 100% rename from pkg/remote/test/aws_kms_key_multiple/aws_kms_key-8ee21d91-c000-428c-8032-235aac55da36.res.golden.json rename to enumeration/remote/test/aws_kms_key_multiple/aws_kms_key-8ee21d91-c000-428c-8032-235aac55da36.res.golden.json diff --git a/pkg/remote/test/aws_kms_key_multiple/results.golden.json b/enumeration/remote/test/aws_kms_key_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_kms_key_multiple/results.golden.json rename to enumeration/remote/test/aws_kms_key_multiple/results.golden.json diff --git a/pkg/remote/test/aws_kms_key_multiple/terraform.tf b/enumeration/remote/test/aws_kms_key_multiple/terraform.tf similarity index 100% rename from pkg/remote/test/aws_kms_key_multiple/terraform.tf rename to enumeration/remote/test/aws_kms_key_multiple/terraform.tf diff --git a/pkg/remote/test/aws_lambda_function_multiple/aws_lambda_function-bar-bar.res.golden.json b/enumeration/remote/test/aws_lambda_function_multiple/aws_lambda_function-bar-bar.res.golden.json similarity index 100% rename from pkg/remote/test/aws_lambda_function_multiple/aws_lambda_function-bar-bar.res.golden.json rename to enumeration/remote/test/aws_lambda_function_multiple/aws_lambda_function-bar-bar.res.golden.json diff --git a/pkg/remote/test/aws_lambda_function_multiple/aws_lambda_function-foo-foo.res.golden.json b/enumeration/remote/test/aws_lambda_function_multiple/aws_lambda_function-foo-foo.res.golden.json similarity index 100% rename from pkg/remote/test/aws_lambda_function_multiple/aws_lambda_function-foo-foo.res.golden.json rename to enumeration/remote/test/aws_lambda_function_multiple/aws_lambda_function-foo-foo.res.golden.json diff --git a/pkg/remote/test/aws_lambda_function_multiple/results.golden.json b/enumeration/remote/test/aws_lambda_function_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_lambda_function_multiple/results.golden.json rename to enumeration/remote/test/aws_lambda_function_multiple/results.golden.json diff --git a/pkg/remote/test/aws_lambda_function_signed/aws_lambda_function-foo-foo.res.golden.json b/enumeration/remote/test/aws_lambda_function_signed/aws_lambda_function-foo-foo.res.golden.json similarity index 100% rename from pkg/remote/test/aws_lambda_function_signed/aws_lambda_function-foo-foo.res.golden.json rename to enumeration/remote/test/aws_lambda_function_signed/aws_lambda_function-foo-foo.res.golden.json diff --git a/pkg/remote/test/aws_lambda_function_signed/lambda.zip b/enumeration/remote/test/aws_lambda_function_signed/lambda.zip similarity index 100% rename from pkg/remote/test/aws_lambda_function_signed/lambda.zip rename to enumeration/remote/test/aws_lambda_function_signed/lambda.zip diff --git a/pkg/remote/test/aws_lambda_function_signed/main.tf b/enumeration/remote/test/aws_lambda_function_signed/main.tf similarity index 100% rename from pkg/remote/test/aws_lambda_function_signed/main.tf rename to enumeration/remote/test/aws_lambda_function_signed/main.tf diff --git a/pkg/remote/test/aws_lambda_function_signed/results.golden.json b/enumeration/remote/test/aws_lambda_function_signed/results.golden.json similarity index 100% rename from pkg/remote/test/aws_lambda_function_signed/results.golden.json rename to enumeration/remote/test/aws_lambda_function_signed/results.golden.json diff --git a/pkg/remote/test/aws_lambda_source_mapping_dynamo_multiple/aws_lambda_event_source_mapping-1aa9c4a0-060b-41c1-a9ae-dc304ebcdb00.res.golden.json b/enumeration/remote/test/aws_lambda_source_mapping_dynamo_multiple/aws_lambda_event_source_mapping-1aa9c4a0-060b-41c1-a9ae-dc304ebcdb00.res.golden.json similarity index 100% rename from pkg/remote/test/aws_lambda_source_mapping_dynamo_multiple/aws_lambda_event_source_mapping-1aa9c4a0-060b-41c1-a9ae-dc304ebcdb00.res.golden.json rename to enumeration/remote/test/aws_lambda_source_mapping_dynamo_multiple/aws_lambda_event_source_mapping-1aa9c4a0-060b-41c1-a9ae-dc304ebcdb00.res.golden.json diff --git a/pkg/remote/test/aws_lambda_source_mapping_dynamo_multiple/results.golden.json b/enumeration/remote/test/aws_lambda_source_mapping_dynamo_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_lambda_source_mapping_dynamo_multiple/results.golden.json rename to enumeration/remote/test/aws_lambda_source_mapping_dynamo_multiple/results.golden.json diff --git a/pkg/remote/test/aws_lambda_source_mapping_sqs_multiple/aws_lambda_event_source_mapping-13ff66f8-37eb-4ad6-a0a8-594fea72df4f.res.golden.json b/enumeration/remote/test/aws_lambda_source_mapping_sqs_multiple/aws_lambda_event_source_mapping-13ff66f8-37eb-4ad6-a0a8-594fea72df4f.res.golden.json similarity index 100% rename from pkg/remote/test/aws_lambda_source_mapping_sqs_multiple/aws_lambda_event_source_mapping-13ff66f8-37eb-4ad6-a0a8-594fea72df4f.res.golden.json rename to enumeration/remote/test/aws_lambda_source_mapping_sqs_multiple/aws_lambda_event_source_mapping-13ff66f8-37eb-4ad6-a0a8-594fea72df4f.res.golden.json diff --git a/pkg/remote/test/aws_lambda_source_mapping_sqs_multiple/aws_lambda_event_source_mapping-4ad7e2b3-79e9-4713-9d9d-5af2c01d9058.res.golden.json b/enumeration/remote/test/aws_lambda_source_mapping_sqs_multiple/aws_lambda_event_source_mapping-4ad7e2b3-79e9-4713-9d9d-5af2c01d9058.res.golden.json similarity index 100% rename from pkg/remote/test/aws_lambda_source_mapping_sqs_multiple/aws_lambda_event_source_mapping-4ad7e2b3-79e9-4713-9d9d-5af2c01d9058.res.golden.json rename to enumeration/remote/test/aws_lambda_source_mapping_sqs_multiple/aws_lambda_event_source_mapping-4ad7e2b3-79e9-4713-9d9d-5af2c01d9058.res.golden.json diff --git a/pkg/remote/test/aws_lambda_source_mapping_sqs_multiple/results.golden.json b/enumeration/remote/test/aws_lambda_source_mapping_sqs_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_lambda_source_mapping_sqs_multiple/results.golden.json rename to enumeration/remote/test/aws_lambda_source_mapping_sqs_multiple/results.golden.json diff --git a/pkg/remote/test/aws_launch_template_multiple/aws_launch_template-lt-00b2d18c6cee7fe23.res.golden.json b/enumeration/remote/test/aws_launch_template_multiple/aws_launch_template-lt-00b2d18c6cee7fe23.res.golden.json similarity index 100% rename from pkg/remote/test/aws_launch_template_multiple/aws_launch_template-lt-00b2d18c6cee7fe23.res.golden.json rename to enumeration/remote/test/aws_launch_template_multiple/aws_launch_template-lt-00b2d18c6cee7fe23.res.golden.json diff --git a/pkg/remote/test/aws_launch_template_multiple/aws_launch_template-lt-0ed993d09ce6afc67.res.golden.json b/enumeration/remote/test/aws_launch_template_multiple/aws_launch_template-lt-0ed993d09ce6afc67.res.golden.json similarity index 100% rename from pkg/remote/test/aws_launch_template_multiple/aws_launch_template-lt-0ed993d09ce6afc67.res.golden.json rename to enumeration/remote/test/aws_launch_template_multiple/aws_launch_template-lt-0ed993d09ce6afc67.res.golden.json diff --git a/pkg/remote/test/aws_launch_template_multiple/results.golden.json b/enumeration/remote/test/aws_launch_template_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_launch_template_multiple/results.golden.json rename to enumeration/remote/test/aws_launch_template_multiple/results.golden.json diff --git a/pkg/remote/test/aws_rds_clusters_results/aws_rds_cluster-aurora-cluster-demo-2-aurora-cluster-demo-2-.res.golden.json b/enumeration/remote/test/aws_rds_clusters_results/aws_rds_cluster-aurora-cluster-demo-2-aurora-cluster-demo-2-.res.golden.json similarity index 100% rename from pkg/remote/test/aws_rds_clusters_results/aws_rds_cluster-aurora-cluster-demo-2-aurora-cluster-demo-2-.res.golden.json rename to enumeration/remote/test/aws_rds_clusters_results/aws_rds_cluster-aurora-cluster-demo-2-aurora-cluster-demo-2-.res.golden.json diff --git a/pkg/remote/test/aws_rds_clusters_results/aws_rds_cluster-aurora-cluster-demo-aurora-cluster-demo-mydb.res.golden.json b/enumeration/remote/test/aws_rds_clusters_results/aws_rds_cluster-aurora-cluster-demo-aurora-cluster-demo-mydb.res.golden.json similarity index 100% rename from pkg/remote/test/aws_rds_clusters_results/aws_rds_cluster-aurora-cluster-demo-aurora-cluster-demo-mydb.res.golden.json rename to enumeration/remote/test/aws_rds_clusters_results/aws_rds_cluster-aurora-cluster-demo-aurora-cluster-demo-mydb.res.golden.json diff --git a/pkg/remote/test/aws_rds_clusters_results/results.golden.json b/enumeration/remote/test/aws_rds_clusters_results/results.golden.json similarity index 97% rename from pkg/remote/test/aws_rds_clusters_results/results.golden.json rename to enumeration/remote/test/aws_rds_clusters_results/results.golden.json index af95979ee..a17efc9d7 100755 --- a/pkg/remote/test/aws_rds_clusters_results/results.golden.json +++ b/enumeration/remote/test/aws_rds_clusters_results/results.golden.json @@ -44,12 +44,12 @@ "restore_to_point_in_time": null, "s3_import": null, "scaling_configuration": null, - "skip_final_snapshot": false, + "skip_final_snapshot": null, "snapshot_identifier": null, "source_region": null, "storage_encrypted": false, "tags": null, - "timeouts": null, + "timeouts": {}, "vpc_security_group_ids": [ "sg-49e38646" ] @@ -99,12 +99,12 @@ "restore_to_point_in_time": null, "s3_import": null, "scaling_configuration": null, - "skip_final_snapshot": false, + "skip_final_snapshot": null, "snapshot_identifier": null, "source_region": null, "storage_encrypted": false, "tags": null, - "timeouts": null, + "timeouts": {}, "vpc_security_group_ids": [ "sg-49e38646" ] diff --git a/pkg/remote/test/aws_rds_db_instance_multiple/aws_db_instance-database-1.res.golden.json b/enumeration/remote/test/aws_rds_db_instance_multiple/aws_db_instance-database-1.res.golden.json similarity index 100% rename from pkg/remote/test/aws_rds_db_instance_multiple/aws_db_instance-database-1.res.golden.json rename to enumeration/remote/test/aws_rds_db_instance_multiple/aws_db_instance-database-1.res.golden.json diff --git a/pkg/remote/test/aws_rds_db_instance_multiple/aws_db_instance-terraform-20201015115018309600000001.res.golden.json b/enumeration/remote/test/aws_rds_db_instance_multiple/aws_db_instance-terraform-20201015115018309600000001.res.golden.json similarity index 100% rename from pkg/remote/test/aws_rds_db_instance_multiple/aws_db_instance-terraform-20201015115018309600000001.res.golden.json rename to enumeration/remote/test/aws_rds_db_instance_multiple/aws_db_instance-terraform-20201015115018309600000001.res.golden.json diff --git a/pkg/remote/test/aws_rds_db_instance_multiple/results.golden.json b/enumeration/remote/test/aws_rds_db_instance_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_rds_db_instance_multiple/results.golden.json rename to enumeration/remote/test/aws_rds_db_instance_multiple/results.golden.json diff --git a/pkg/remote/test/aws_rds_db_instance_single/aws_db_instance-terraform-20201015115018309600000001.res.golden.json b/enumeration/remote/test/aws_rds_db_instance_single/aws_db_instance-terraform-20201015115018309600000001.res.golden.json similarity index 100% rename from pkg/remote/test/aws_rds_db_instance_single/aws_db_instance-terraform-20201015115018309600000001.res.golden.json rename to enumeration/remote/test/aws_rds_db_instance_single/aws_db_instance-terraform-20201015115018309600000001.res.golden.json diff --git a/pkg/remote/test/aws_rds_db_instance_single/results.golden.json b/enumeration/remote/test/aws_rds_db_instance_single/results.golden.json similarity index 100% rename from pkg/remote/test/aws_rds_db_instance_single/results.golden.json rename to enumeration/remote/test/aws_rds_db_instance_single/results.golden.json diff --git a/pkg/remote/test/aws_rds_db_subnet_group_multiple/aws_db_subnet_group-bar.res.golden.json b/enumeration/remote/test/aws_rds_db_subnet_group_multiple/aws_db_subnet_group-bar.res.golden.json similarity index 100% rename from pkg/remote/test/aws_rds_db_subnet_group_multiple/aws_db_subnet_group-bar.res.golden.json rename to enumeration/remote/test/aws_rds_db_subnet_group_multiple/aws_db_subnet_group-bar.res.golden.json diff --git a/pkg/remote/test/aws_rds_db_subnet_group_multiple/aws_db_subnet_group-foo.res.golden.json b/enumeration/remote/test/aws_rds_db_subnet_group_multiple/aws_db_subnet_group-foo.res.golden.json similarity index 100% rename from pkg/remote/test/aws_rds_db_subnet_group_multiple/aws_db_subnet_group-foo.res.golden.json rename to enumeration/remote/test/aws_rds_db_subnet_group_multiple/aws_db_subnet_group-foo.res.golden.json diff --git a/pkg/remote/test/aws_rds_db_subnet_group_multiple/results.golden.json b/enumeration/remote/test/aws_rds_db_subnet_group_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_rds_db_subnet_group_multiple/results.golden.json rename to enumeration/remote/test/aws_rds_db_subnet_group_multiple/results.golden.json diff --git a/pkg/remote/test/aws_route53_health_check_empty/schema.golden.json b/enumeration/remote/test/aws_route53_health_check_empty/schema.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_health_check_empty/schema.golden.json rename to enumeration/remote/test/aws_route53_health_check_empty/schema.golden.json diff --git a/pkg/remote/test/aws_route53_health_check_multiple/aws_route53_health_check-7001a9df-ded4-4802-9909-668eb80b972b.res.golden.json b/enumeration/remote/test/aws_route53_health_check_multiple/aws_route53_health_check-7001a9df-ded4-4802-9909-668eb80b972b.res.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_health_check_multiple/aws_route53_health_check-7001a9df-ded4-4802-9909-668eb80b972b.res.golden.json rename to enumeration/remote/test/aws_route53_health_check_multiple/aws_route53_health_check-7001a9df-ded4-4802-9909-668eb80b972b.res.golden.json diff --git a/pkg/remote/test/aws_route53_health_check_multiple/aws_route53_health_check-84fc318a-2e0d-41d6-b638-280e2f0f4e26.res.golden.json b/enumeration/remote/test/aws_route53_health_check_multiple/aws_route53_health_check-84fc318a-2e0d-41d6-b638-280e2f0f4e26.res.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_health_check_multiple/aws_route53_health_check-84fc318a-2e0d-41d6-b638-280e2f0f4e26.res.golden.json rename to enumeration/remote/test/aws_route53_health_check_multiple/aws_route53_health_check-84fc318a-2e0d-41d6-b638-280e2f0f4e26.res.golden.json diff --git a/pkg/remote/test/aws_route53_health_check_multiple/results.golden.json b/enumeration/remote/test/aws_route53_health_check_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_health_check_multiple/results.golden.json rename to enumeration/remote/test/aws_route53_health_check_multiple/results.golden.json diff --git a/pkg/remote/test/aws_route53_health_check_multiple/terraform.tf b/enumeration/remote/test/aws_route53_health_check_multiple/terraform.tf similarity index 100% rename from pkg/remote/test/aws_route53_health_check_multiple/terraform.tf rename to enumeration/remote/test/aws_route53_health_check_multiple/terraform.tf diff --git a/pkg/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM__test2.foo-2.com_A.res.golden.json b/enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM__test2.foo-2.com_A.res.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM__test2.foo-2.com_A.res.golden.json rename to enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM__test2.foo-2.com_A.res.golden.json diff --git a/pkg/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM__test2.foo-2.com_TXT.res.golden.json b/enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM__test2.foo-2.com_TXT.res.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM__test2.foo-2.com_TXT.res.golden.json rename to enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM__test2.foo-2.com_TXT.res.golden.json diff --git a/pkg/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test0_A.res.golden.json b/enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test0_A.res.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test0_A.res.golden.json rename to enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test0_A.res.golden.json diff --git a/pkg/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test0_TXT.res.golden.json b/enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test0_TXT.res.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test0_TXT.res.golden.json rename to enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test0_TXT.res.golden.json diff --git a/pkg/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test1.foo-2.com_A.res.golden.json b/enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test1.foo-2.com_A.res.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test1.foo-2.com_A.res.golden.json rename to enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test1.foo-2.com_A.res.golden.json diff --git a/pkg/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test1.foo-2.com_TXT.res.golden.json b/enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test1.foo-2.com_TXT.res.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test1.foo-2.com_TXT.res.golden.json rename to enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test1.foo-2.com_TXT.res.golden.json diff --git a/pkg/remote/test/aws_route53_record_explicit_subdomain/main.tf b/enumeration/remote/test/aws_route53_record_explicit_subdomain/main.tf similarity index 100% rename from pkg/remote/test/aws_route53_record_explicit_subdomain/main.tf rename to enumeration/remote/test/aws_route53_record_explicit_subdomain/main.tf diff --git a/pkg/remote/test/aws_route53_record_explicit_subdomain/results.golden.json b/enumeration/remote/test/aws_route53_record_explicit_subdomain/results.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_record_explicit_subdomain/results.golden.json rename to enumeration/remote/test/aws_route53_record_explicit_subdomain/results.golden.json diff --git a/pkg/remote/test/aws_route53_record_explicit_subdomain/schema.golden.json b/enumeration/remote/test/aws_route53_record_explicit_subdomain/schema.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_record_explicit_subdomain/schema.golden.json rename to enumeration/remote/test/aws_route53_record_explicit_subdomain/schema.golden.json diff --git a/pkg/remote/test/aws_route53_record_multiples/aws_route53_record-Z10347383HV75H96J919W_test2_A.res.golden.json b/enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z10347383HV75H96J919W_test2_A.res.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_record_multiples/aws_route53_record-Z10347383HV75H96J919W_test2_A.res.golden.json rename to enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z10347383HV75H96J919W_test2_A.res.golden.json diff --git a/pkg/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G__.test4_A.res.golden.json b/enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G__.test4_A.res.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G__.test4_A.res.golden.json rename to enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G__.test4_A.res.golden.json diff --git a/pkg/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_foo-0.com_NS.res.golden.json b/enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_foo-0.com_NS.res.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_foo-0.com_NS.res.golden.json rename to enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_foo-0.com_NS.res.golden.json diff --git a/pkg/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_test0_A.res.golden.json b/enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_test0_A.res.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_test0_A.res.golden.json rename to enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_test0_A.res.golden.json diff --git a/pkg/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_test1_A.res.golden.json b/enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_test1_A.res.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_test1_A.res.golden.json rename to enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_test1_A.res.golden.json diff --git a/pkg/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_test2_A.res.golden.json b/enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_test2_A.res.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_test2_A.res.golden.json rename to enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_test2_A.res.golden.json diff --git a/pkg/remote/test/aws_route53_record_multiples/results.golden.json b/enumeration/remote/test/aws_route53_record_multiples/results.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_record_multiples/results.golden.json rename to enumeration/remote/test/aws_route53_record_multiples/results.golden.json diff --git a/pkg/remote/test/aws_route53_record_multiples/schema.golden.json b/enumeration/remote/test/aws_route53_record_multiples/schema.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_record_multiples/schema.golden.json rename to enumeration/remote/test/aws_route53_record_multiples/schema.golden.json diff --git a/pkg/remote/test/aws_route53_zone_empty/schema.golden.json b/enumeration/remote/test/aws_route53_zone_empty/schema.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_zone_empty/schema.golden.json rename to enumeration/remote/test/aws_route53_zone_empty/schema.golden.json diff --git a/pkg/remote/test/aws_route53_zone_multiples/aws_route53_zone-Z01804312AV8PHE3C43AD.res.golden.json b/enumeration/remote/test/aws_route53_zone_multiples/aws_route53_zone-Z01804312AV8PHE3C43AD.res.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_zone_multiples/aws_route53_zone-Z01804312AV8PHE3C43AD.res.golden.json rename to enumeration/remote/test/aws_route53_zone_multiples/aws_route53_zone-Z01804312AV8PHE3C43AD.res.golden.json diff --git a/pkg/remote/test/aws_route53_zone_multiples/aws_route53_zone-Z01809283VH9BBALZHO7B.res.golden.json b/enumeration/remote/test/aws_route53_zone_multiples/aws_route53_zone-Z01809283VH9BBALZHO7B.res.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_zone_multiples/aws_route53_zone-Z01809283VH9BBALZHO7B.res.golden.json rename to enumeration/remote/test/aws_route53_zone_multiples/aws_route53_zone-Z01809283VH9BBALZHO7B.res.golden.json diff --git a/pkg/remote/test/aws_route53_zone_multiples/aws_route53_zone-Z01874941AR1TCGV5K65C.res.golden.json b/enumeration/remote/test/aws_route53_zone_multiples/aws_route53_zone-Z01874941AR1TCGV5K65C.res.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_zone_multiples/aws_route53_zone-Z01874941AR1TCGV5K65C.res.golden.json rename to enumeration/remote/test/aws_route53_zone_multiples/aws_route53_zone-Z01874941AR1TCGV5K65C.res.golden.json diff --git a/pkg/remote/test/aws_route53_zone_multiples/results.golden.json b/enumeration/remote/test/aws_route53_zone_multiples/results.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_zone_multiples/results.golden.json rename to enumeration/remote/test/aws_route53_zone_multiples/results.golden.json diff --git a/pkg/remote/test/aws_route53_zone_multiples/schema.golden.json b/enumeration/remote/test/aws_route53_zone_multiples/schema.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_zone_multiples/schema.golden.json rename to enumeration/remote/test/aws_route53_zone_multiples/schema.golden.json diff --git a/pkg/remote/test/aws_route53_zone_multiples/terraform.tf b/enumeration/remote/test/aws_route53_zone_multiples/terraform.tf similarity index 100% rename from pkg/remote/test/aws_route53_zone_multiples/terraform.tf rename to enumeration/remote/test/aws_route53_zone_multiples/terraform.tf diff --git a/pkg/remote/test/aws_route53_zone_single/aws_route53_zone-Z08068311RGDXPHF8KE62.res.golden.json b/enumeration/remote/test/aws_route53_zone_single/aws_route53_zone-Z08068311RGDXPHF8KE62.res.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_zone_single/aws_route53_zone-Z08068311RGDXPHF8KE62.res.golden.json rename to enumeration/remote/test/aws_route53_zone_single/aws_route53_zone-Z08068311RGDXPHF8KE62.res.golden.json diff --git a/pkg/remote/test/aws_route53_zone_single/aws_route53_zone-Z093553112BLINKY4N57.res.golden.json b/enumeration/remote/test/aws_route53_zone_single/aws_route53_zone-Z093553112BLINKY4N57.res.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_zone_single/aws_route53_zone-Z093553112BLINKY4N57.res.golden.json rename to enumeration/remote/test/aws_route53_zone_single/aws_route53_zone-Z093553112BLINKY4N57.res.golden.json diff --git a/pkg/remote/test/aws_route53_zone_single/results.golden.json b/enumeration/remote/test/aws_route53_zone_single/results.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_zone_single/results.golden.json rename to enumeration/remote/test/aws_route53_zone_single/results.golden.json diff --git a/pkg/remote/test/aws_route53_zone_single/schema.golden.json b/enumeration/remote/test/aws_route53_zone_single/schema.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_zone_single/schema.golden.json rename to enumeration/remote/test/aws_route53_zone_single/schema.golden.json diff --git a/pkg/remote/test/aws_route53_zone_single/terraform.tf b/enumeration/remote/test/aws_route53_zone_single/terraform.tf similarity index 100% rename from pkg/remote/test/aws_route53_zone_single/terraform.tf rename to enumeration/remote/test/aws_route53_zone_single/terraform.tf diff --git a/pkg/remote/test/aws_route53_zone_with_no_record/schema.golden.json b/enumeration/remote/test/aws_route53_zone_with_no_record/schema.golden.json similarity index 100% rename from pkg/remote/test/aws_route53_zone_with_no_record/schema.golden.json rename to enumeration/remote/test/aws_route53_zone_with_no_record/schema.golden.json diff --git a/pkg/remote/test/aws_s3_bucket_analytics_multiple/aws_s3_bucket_analytics_configuration-bucket-martin-test-drift2_Analytics2_Bucket2-eu-west-3.res.golden.json b/enumeration/remote/test/aws_s3_bucket_analytics_multiple/aws_s3_bucket_analytics_configuration-bucket-martin-test-drift2_Analytics2_Bucket2-eu-west-3.res.golden.json similarity index 100% rename from pkg/remote/test/aws_s3_bucket_analytics_multiple/aws_s3_bucket_analytics_configuration-bucket-martin-test-drift2_Analytics2_Bucket2-eu-west-3.res.golden.json rename to enumeration/remote/test/aws_s3_bucket_analytics_multiple/aws_s3_bucket_analytics_configuration-bucket-martin-test-drift2_Analytics2_Bucket2-eu-west-3.res.golden.json diff --git a/pkg/remote/test/aws_s3_bucket_analytics_multiple/aws_s3_bucket_analytics_configuration-bucket-martin-test-drift2_Analytics_Bucket2-eu-west-3.res.golden.json b/enumeration/remote/test/aws_s3_bucket_analytics_multiple/aws_s3_bucket_analytics_configuration-bucket-martin-test-drift2_Analytics_Bucket2-eu-west-3.res.golden.json similarity index 100% rename from pkg/remote/test/aws_s3_bucket_analytics_multiple/aws_s3_bucket_analytics_configuration-bucket-martin-test-drift2_Analytics_Bucket2-eu-west-3.res.golden.json rename to enumeration/remote/test/aws_s3_bucket_analytics_multiple/aws_s3_bucket_analytics_configuration-bucket-martin-test-drift2_Analytics_Bucket2-eu-west-3.res.golden.json diff --git a/pkg/remote/test/aws_s3_bucket_analytics_multiple/results.golden.json b/enumeration/remote/test/aws_s3_bucket_analytics_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_s3_bucket_analytics_multiple/results.golden.json rename to enumeration/remote/test/aws_s3_bucket_analytics_multiple/results.golden.json diff --git a/pkg/remote/test/aws_s3_bucket_inventories_multiple/aws_s3_bucket_inventory-bucket-martin-test-drift2_Inventory2_Bucket2-eu-west-3.res.golden.json b/enumeration/remote/test/aws_s3_bucket_inventories_multiple/aws_s3_bucket_inventory-bucket-martin-test-drift2_Inventory2_Bucket2-eu-west-3.res.golden.json similarity index 100% rename from pkg/remote/test/aws_s3_bucket_inventories_multiple/aws_s3_bucket_inventory-bucket-martin-test-drift2_Inventory2_Bucket2-eu-west-3.res.golden.json rename to enumeration/remote/test/aws_s3_bucket_inventories_multiple/aws_s3_bucket_inventory-bucket-martin-test-drift2_Inventory2_Bucket2-eu-west-3.res.golden.json diff --git a/pkg/remote/test/aws_s3_bucket_inventories_multiple/aws_s3_bucket_inventory-bucket-martin-test-drift2_Inventory_Bucket2-eu-west-3.res.golden.json b/enumeration/remote/test/aws_s3_bucket_inventories_multiple/aws_s3_bucket_inventory-bucket-martin-test-drift2_Inventory_Bucket2-eu-west-3.res.golden.json similarity index 100% rename from pkg/remote/test/aws_s3_bucket_inventories_multiple/aws_s3_bucket_inventory-bucket-martin-test-drift2_Inventory_Bucket2-eu-west-3.res.golden.json rename to enumeration/remote/test/aws_s3_bucket_inventories_multiple/aws_s3_bucket_inventory-bucket-martin-test-drift2_Inventory_Bucket2-eu-west-3.res.golden.json diff --git a/pkg/remote/test/aws_s3_bucket_inventories_multiple/results.golden.json b/enumeration/remote/test/aws_s3_bucket_inventories_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_s3_bucket_inventories_multiple/results.golden.json rename to enumeration/remote/test/aws_s3_bucket_inventories_multiple/results.golden.json diff --git a/pkg/remote/test/aws_s3_bucket_metrics_multiple/aws_s3_bucket_metric-bucket-martin-test-drift2_Metric2_Bucket2-eu-west-3.res.golden.json b/enumeration/remote/test/aws_s3_bucket_metrics_multiple/aws_s3_bucket_metric-bucket-martin-test-drift2_Metric2_Bucket2-eu-west-3.res.golden.json similarity index 100% rename from pkg/remote/test/aws_s3_bucket_metrics_multiple/aws_s3_bucket_metric-bucket-martin-test-drift2_Metric2_Bucket2-eu-west-3.res.golden.json rename to enumeration/remote/test/aws_s3_bucket_metrics_multiple/aws_s3_bucket_metric-bucket-martin-test-drift2_Metric2_Bucket2-eu-west-3.res.golden.json diff --git a/pkg/remote/test/aws_s3_bucket_metrics_multiple/aws_s3_bucket_metric-bucket-martin-test-drift2_Metric_Bucket2-eu-west-3.res.golden.json b/enumeration/remote/test/aws_s3_bucket_metrics_multiple/aws_s3_bucket_metric-bucket-martin-test-drift2_Metric_Bucket2-eu-west-3.res.golden.json similarity index 100% rename from pkg/remote/test/aws_s3_bucket_metrics_multiple/aws_s3_bucket_metric-bucket-martin-test-drift2_Metric_Bucket2-eu-west-3.res.golden.json rename to enumeration/remote/test/aws_s3_bucket_metrics_multiple/aws_s3_bucket_metric-bucket-martin-test-drift2_Metric_Bucket2-eu-west-3.res.golden.json diff --git a/pkg/remote/test/aws_s3_bucket_metrics_multiple/aws_s3_bucket_metric-bucket-martin-test-drift2_Metrics2_Bucket2-eu-west-3.res.golden.json b/enumeration/remote/test/aws_s3_bucket_metrics_multiple/aws_s3_bucket_metric-bucket-martin-test-drift2_Metrics2_Bucket2-eu-west-3.res.golden.json similarity index 100% rename from pkg/remote/test/aws_s3_bucket_metrics_multiple/aws_s3_bucket_metric-bucket-martin-test-drift2_Metrics2_Bucket2-eu-west-3.res.golden.json rename to enumeration/remote/test/aws_s3_bucket_metrics_multiple/aws_s3_bucket_metric-bucket-martin-test-drift2_Metrics2_Bucket2-eu-west-3.res.golden.json diff --git a/pkg/remote/test/aws_s3_bucket_metrics_multiple/aws_s3_bucket_metric-bucket-martin-test-drift2_Metrics_Bucket2-eu-west-3.res.golden.json b/enumeration/remote/test/aws_s3_bucket_metrics_multiple/aws_s3_bucket_metric-bucket-martin-test-drift2_Metrics_Bucket2-eu-west-3.res.golden.json similarity index 100% rename from pkg/remote/test/aws_s3_bucket_metrics_multiple/aws_s3_bucket_metric-bucket-martin-test-drift2_Metrics_Bucket2-eu-west-3.res.golden.json rename to enumeration/remote/test/aws_s3_bucket_metrics_multiple/aws_s3_bucket_metric-bucket-martin-test-drift2_Metrics_Bucket2-eu-west-3.res.golden.json diff --git a/pkg/remote/test/aws_s3_bucket_metrics_multiple/results.golden.json b/enumeration/remote/test/aws_s3_bucket_metrics_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_s3_bucket_metrics_multiple/results.golden.json rename to enumeration/remote/test/aws_s3_bucket_metrics_multiple/results.golden.json diff --git a/pkg/remote/test/aws_s3_bucket_multiple/aws_s3_bucket-bucket-martin-test-drift2-eu-west-3.res.golden.json b/enumeration/remote/test/aws_s3_bucket_multiple/aws_s3_bucket-bucket-martin-test-drift2-eu-west-3.res.golden.json similarity index 100% rename from pkg/remote/test/aws_s3_bucket_multiple/aws_s3_bucket-bucket-martin-test-drift2-eu-west-3.res.golden.json rename to enumeration/remote/test/aws_s3_bucket_multiple/aws_s3_bucket-bucket-martin-test-drift2-eu-west-3.res.golden.json diff --git a/pkg/remote/test/aws_s3_bucket_multiple/main.tf b/enumeration/remote/test/aws_s3_bucket_multiple/main.tf similarity index 100% rename from pkg/remote/test/aws_s3_bucket_multiple/main.tf rename to enumeration/remote/test/aws_s3_bucket_multiple/main.tf diff --git a/pkg/remote/test/aws_s3_bucket_multiple/results.golden.json b/enumeration/remote/test/aws_s3_bucket_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_s3_bucket_multiple/results.golden.json rename to enumeration/remote/test/aws_s3_bucket_multiple/results.golden.json diff --git a/pkg/remote/test/aws_s3_bucket_notifications_multiple/aws_s3_bucket_notification-bucket-martin-test-drift2-eu-west-3.res.golden.json b/enumeration/remote/test/aws_s3_bucket_notifications_multiple/aws_s3_bucket_notification-bucket-martin-test-drift2-eu-west-3.res.golden.json similarity index 100% rename from pkg/remote/test/aws_s3_bucket_notifications_multiple/aws_s3_bucket_notification-bucket-martin-test-drift2-eu-west-3.res.golden.json rename to enumeration/remote/test/aws_s3_bucket_notifications_multiple/aws_s3_bucket_notification-bucket-martin-test-drift2-eu-west-3.res.golden.json diff --git a/pkg/remote/test/aws_s3_bucket_notifications_multiple/results.golden.json b/enumeration/remote/test/aws_s3_bucket_notifications_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_s3_bucket_notifications_multiple/results.golden.json rename to enumeration/remote/test/aws_s3_bucket_notifications_multiple/results.golden.json diff --git a/pkg/remote/test/aws_s3_bucket_notifications_no_notif/aws_s3_bucket_notification-dritftctl-test-no-notifications.res.golden.json b/enumeration/remote/test/aws_s3_bucket_notifications_no_notif/aws_s3_bucket_notification-dritftctl-test-no-notifications.res.golden.json similarity index 100% rename from pkg/remote/test/aws_s3_bucket_notifications_no_notif/aws_s3_bucket_notification-dritftctl-test-no-notifications.res.golden.json rename to enumeration/remote/test/aws_s3_bucket_notifications_no_notif/aws_s3_bucket_notification-dritftctl-test-no-notifications.res.golden.json diff --git a/pkg/remote/test/aws_s3_bucket_notifications_no_notif/terraform.tf b/enumeration/remote/test/aws_s3_bucket_notifications_no_notif/terraform.tf similarity index 100% rename from pkg/remote/test/aws_s3_bucket_notifications_no_notif/terraform.tf rename to enumeration/remote/test/aws_s3_bucket_notifications_no_notif/terraform.tf diff --git a/pkg/remote/test/aws_s3_bucket_policies_multiple/aws_s3_bucket_policy-bucket-martin-test-drift2-eu-west-3.res.golden.json b/enumeration/remote/test/aws_s3_bucket_policies_multiple/aws_s3_bucket_policy-bucket-martin-test-drift2-eu-west-3.res.golden.json similarity index 100% rename from pkg/remote/test/aws_s3_bucket_policies_multiple/aws_s3_bucket_policy-bucket-martin-test-drift2-eu-west-3.res.golden.json rename to enumeration/remote/test/aws_s3_bucket_policies_multiple/aws_s3_bucket_policy-bucket-martin-test-drift2-eu-west-3.res.golden.json diff --git a/pkg/remote/test/aws_s3_bucket_policies_multiple/results.golden.json b/enumeration/remote/test/aws_s3_bucket_policies_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_s3_bucket_policies_multiple/results.golden.json rename to enumeration/remote/test/aws_s3_bucket_policies_multiple/results.golden.json diff --git a/pkg/remote/test/aws_s3_bucket_policy_no_policy/terraform.tf b/enumeration/remote/test/aws_s3_bucket_policy_no_policy/terraform.tf similarity index 100% rename from pkg/remote/test/aws_s3_bucket_policy_no_policy/terraform.tf rename to enumeration/remote/test/aws_s3_bucket_policy_no_policy/terraform.tf diff --git a/pkg/remote/test/aws_sns_topic_multiple/aws_sns_topic-arn_aws_sns_eu-west-3_526954929923_user-updates-topic-arn_aws_sns_eu-west-3_526954929923_user-updates-topic.res.golden.json b/enumeration/remote/test/aws_sns_topic_multiple/aws_sns_topic-arn_aws_sns_eu-west-3_526954929923_user-updates-topic-arn_aws_sns_eu-west-3_526954929923_user-updates-topic.res.golden.json similarity index 100% rename from pkg/remote/test/aws_sns_topic_multiple/aws_sns_topic-arn_aws_sns_eu-west-3_526954929923_user-updates-topic-arn_aws_sns_eu-west-3_526954929923_user-updates-topic.res.golden.json rename to enumeration/remote/test/aws_sns_topic_multiple/aws_sns_topic-arn_aws_sns_eu-west-3_526954929923_user-updates-topic-arn_aws_sns_eu-west-3_526954929923_user-updates-topic.res.golden.json diff --git a/pkg/remote/test/aws_sns_topic_multiple/aws_sns_topic-arn_aws_sns_eu-west-3_526954929923_user-updates-topic2-arn_aws_sns_eu-west-3_526954929923_user-updates-topic2.res.golden.json b/enumeration/remote/test/aws_sns_topic_multiple/aws_sns_topic-arn_aws_sns_eu-west-3_526954929923_user-updates-topic2-arn_aws_sns_eu-west-3_526954929923_user-updates-topic2.res.golden.json similarity index 100% rename from pkg/remote/test/aws_sns_topic_multiple/aws_sns_topic-arn_aws_sns_eu-west-3_526954929923_user-updates-topic2-arn_aws_sns_eu-west-3_526954929923_user-updates-topic2.res.golden.json rename to enumeration/remote/test/aws_sns_topic_multiple/aws_sns_topic-arn_aws_sns_eu-west-3_526954929923_user-updates-topic2-arn_aws_sns_eu-west-3_526954929923_user-updates-topic2.res.golden.json diff --git a/pkg/remote/test/aws_sns_topic_multiple/aws_sns_topic-arn_aws_sns_eu-west-3_526954929923_user-updates-topic3-arn_aws_sns_eu-west-3_526954929923_user-updates-topic3.res.golden.json b/enumeration/remote/test/aws_sns_topic_multiple/aws_sns_topic-arn_aws_sns_eu-west-3_526954929923_user-updates-topic3-arn_aws_sns_eu-west-3_526954929923_user-updates-topic3.res.golden.json similarity index 100% rename from pkg/remote/test/aws_sns_topic_multiple/aws_sns_topic-arn_aws_sns_eu-west-3_526954929923_user-updates-topic3-arn_aws_sns_eu-west-3_526954929923_user-updates-topic3.res.golden.json rename to enumeration/remote/test/aws_sns_topic_multiple/aws_sns_topic-arn_aws_sns_eu-west-3_526954929923_user-updates-topic3-arn_aws_sns_eu-west-3_526954929923_user-updates-topic3.res.golden.json diff --git a/pkg/remote/test/aws_sns_topic_multiple/main.tf b/enumeration/remote/test/aws_sns_topic_multiple/main.tf similarity index 100% rename from pkg/remote/test/aws_sns_topic_multiple/main.tf rename to enumeration/remote/test/aws_sns_topic_multiple/main.tf diff --git a/pkg/remote/test/aws_sns_topic_multiple/results.golden.json b/enumeration/remote/test/aws_sns_topic_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_sns_topic_multiple/results.golden.json rename to enumeration/remote/test/aws_sns_topic_multiple/results.golden.json diff --git a/pkg/remote/test/aws_sns_topic_policy_multiple/aws_sns_topic_policy-arn_aws_sns_us-east-1_526954929923_my-topic-with-policy-arn_aws_sns_us-east-1_526954929923_my-topic-with-policy.res.golden.json b/enumeration/remote/test/aws_sns_topic_policy_multiple/aws_sns_topic_policy-arn_aws_sns_us-east-1_526954929923_my-topic-with-policy-arn_aws_sns_us-east-1_526954929923_my-topic-with-policy.res.golden.json similarity index 100% rename from pkg/remote/test/aws_sns_topic_policy_multiple/aws_sns_topic_policy-arn_aws_sns_us-east-1_526954929923_my-topic-with-policy-arn_aws_sns_us-east-1_526954929923_my-topic-with-policy.res.golden.json rename to enumeration/remote/test/aws_sns_topic_policy_multiple/aws_sns_topic_policy-arn_aws_sns_us-east-1_526954929923_my-topic-with-policy-arn_aws_sns_us-east-1_526954929923_my-topic-with-policy.res.golden.json diff --git a/pkg/remote/test/aws_sns_topic_policy_multiple/aws_sns_topic_policy-arn_aws_sns_us-east-1_526954929923_my-topic-with-policy2-arn_aws_sns_us-east-1_526954929923_my-topic-with-policy2.res.golden.json b/enumeration/remote/test/aws_sns_topic_policy_multiple/aws_sns_topic_policy-arn_aws_sns_us-east-1_526954929923_my-topic-with-policy2-arn_aws_sns_us-east-1_526954929923_my-topic-with-policy2.res.golden.json similarity index 100% rename from pkg/remote/test/aws_sns_topic_policy_multiple/aws_sns_topic_policy-arn_aws_sns_us-east-1_526954929923_my-topic-with-policy2-arn_aws_sns_us-east-1_526954929923_my-topic-with-policy2.res.golden.json rename to enumeration/remote/test/aws_sns_topic_policy_multiple/aws_sns_topic_policy-arn_aws_sns_us-east-1_526954929923_my-topic-with-policy2-arn_aws_sns_us-east-1_526954929923_my-topic-with-policy2.res.golden.json diff --git a/pkg/remote/test/aws_sns_topic_policy_multiple/results.golden.json b/enumeration/remote/test/aws_sns_topic_policy_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_sns_topic_policy_multiple/results.golden.json rename to enumeration/remote/test/aws_sns_topic_policy_multiple/results.golden.json diff --git a/pkg/remote/test/aws_sns_topic_subscription_multiple/aws_sns_topic_subscription-arn_aws_sns_us-east-1_526954929923_user-updates-topic2_c0f794c5-a009-4db4-9147-4c55959787fa-arn_aws_sns_us-east-1_526954929923_user-updates-topic2_c0f794c5-a009-4db4-9147-4c55959787fa.res.golden.json b/enumeration/remote/test/aws_sns_topic_subscription_multiple/aws_sns_topic_subscription-arn_aws_sns_us-east-1_526954929923_user-updates-topic2_c0f794c5-a009-4db4-9147-4c55959787fa-arn_aws_sns_us-east-1_526954929923_user-updates-topic2_c0f794c5-a009-4db4-9147-4c55959787fa.res.golden.json similarity index 100% rename from pkg/remote/test/aws_sns_topic_subscription_multiple/aws_sns_topic_subscription-arn_aws_sns_us-east-1_526954929923_user-updates-topic2_c0f794c5-a009-4db4-9147-4c55959787fa-arn_aws_sns_us-east-1_526954929923_user-updates-topic2_c0f794c5-a009-4db4-9147-4c55959787fa.res.golden.json rename to enumeration/remote/test/aws_sns_topic_subscription_multiple/aws_sns_topic_subscription-arn_aws_sns_us-east-1_526954929923_user-updates-topic2_c0f794c5-a009-4db4-9147-4c55959787fa-arn_aws_sns_us-east-1_526954929923_user-updates-topic2_c0f794c5-a009-4db4-9147-4c55959787fa.res.golden.json diff --git a/pkg/remote/test/aws_sns_topic_subscription_multiple/aws_sns_topic_subscription-arn_aws_sns_us-east-1_526954929923_user-updates-topic_b6e66147-2b31-4486-8d4b-2a2272264c8e-arn_aws_sns_us-east-1_526954929923_user-updates-topic_b6e66147-2b31-4486-8d4b-2a2272264c8e.res.golden.json b/enumeration/remote/test/aws_sns_topic_subscription_multiple/aws_sns_topic_subscription-arn_aws_sns_us-east-1_526954929923_user-updates-topic_b6e66147-2b31-4486-8d4b-2a2272264c8e-arn_aws_sns_us-east-1_526954929923_user-updates-topic_b6e66147-2b31-4486-8d4b-2a2272264c8e.res.golden.json similarity index 100% rename from pkg/remote/test/aws_sns_topic_subscription_multiple/aws_sns_topic_subscription-arn_aws_sns_us-east-1_526954929923_user-updates-topic_b6e66147-2b31-4486-8d4b-2a2272264c8e-arn_aws_sns_us-east-1_526954929923_user-updates-topic_b6e66147-2b31-4486-8d4b-2a2272264c8e.res.golden.json rename to enumeration/remote/test/aws_sns_topic_subscription_multiple/aws_sns_topic_subscription-arn_aws_sns_us-east-1_526954929923_user-updates-topic_b6e66147-2b31-4486-8d4b-2a2272264c8e-arn_aws_sns_us-east-1_526954929923_user-updates-topic_b6e66147-2b31-4486-8d4b-2a2272264c8e.res.golden.json diff --git a/pkg/remote/test/aws_sns_topic_subscription_multiple/main.tf b/enumeration/remote/test/aws_sns_topic_subscription_multiple/main.tf similarity index 100% rename from pkg/remote/test/aws_sns_topic_subscription_multiple/main.tf rename to enumeration/remote/test/aws_sns_topic_subscription_multiple/main.tf diff --git a/pkg/remote/test/aws_sns_topic_subscription_multiple/results.golden.json b/enumeration/remote/test/aws_sns_topic_subscription_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_sns_topic_subscription_multiple/results.golden.json rename to enumeration/remote/test/aws_sns_topic_subscription_multiple/results.golden.json diff --git a/pkg/remote/test/aws_sqs_queue_multiple/aws_sqs_queue-https___sqs.eu-west-3.amazonaws.com_047081014315_bar.fifo.res.golden.json b/enumeration/remote/test/aws_sqs_queue_multiple/aws_sqs_queue-https___sqs.eu-west-3.amazonaws.com_047081014315_bar.fifo.res.golden.json similarity index 100% rename from pkg/remote/test/aws_sqs_queue_multiple/aws_sqs_queue-https___sqs.eu-west-3.amazonaws.com_047081014315_bar.fifo.res.golden.json rename to enumeration/remote/test/aws_sqs_queue_multiple/aws_sqs_queue-https___sqs.eu-west-3.amazonaws.com_047081014315_bar.fifo.res.golden.json diff --git a/pkg/remote/test/aws_sqs_queue_multiple/aws_sqs_queue-https___sqs.eu-west-3.amazonaws.com_047081014315_foo.res.golden.json b/enumeration/remote/test/aws_sqs_queue_multiple/aws_sqs_queue-https___sqs.eu-west-3.amazonaws.com_047081014315_foo.res.golden.json similarity index 100% rename from pkg/remote/test/aws_sqs_queue_multiple/aws_sqs_queue-https___sqs.eu-west-3.amazonaws.com_047081014315_foo.res.golden.json rename to enumeration/remote/test/aws_sqs_queue_multiple/aws_sqs_queue-https___sqs.eu-west-3.amazonaws.com_047081014315_foo.res.golden.json diff --git a/pkg/remote/test/aws_sqs_queue_multiple/results.golden.json b/enumeration/remote/test/aws_sqs_queue_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_sqs_queue_multiple/results.golden.json rename to enumeration/remote/test/aws_sqs_queue_multiple/results.golden.json diff --git a/pkg/remote/test/aws_sqs_queue_multiple/terraform.tf b/enumeration/remote/test/aws_sqs_queue_multiple/terraform.tf similarity index 100% rename from pkg/remote/test/aws_sqs_queue_multiple/terraform.tf rename to enumeration/remote/test/aws_sqs_queue_multiple/terraform.tf diff --git a/pkg/remote/test/aws_sqs_queue_policy_multiple/aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_bar.fifo.res.golden.json b/enumeration/remote/test/aws_sqs_queue_policy_multiple/aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_bar.fifo.res.golden.json similarity index 100% rename from pkg/remote/test/aws_sqs_queue_policy_multiple/aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_bar.fifo.res.golden.json rename to enumeration/remote/test/aws_sqs_queue_policy_multiple/aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_bar.fifo.res.golden.json diff --git a/pkg/remote/test/aws_sqs_queue_policy_multiple/aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_baz.res.golden.json b/enumeration/remote/test/aws_sqs_queue_policy_multiple/aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_baz.res.golden.json similarity index 100% rename from pkg/remote/test/aws_sqs_queue_policy_multiple/aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_baz.res.golden.json rename to enumeration/remote/test/aws_sqs_queue_policy_multiple/aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_baz.res.golden.json diff --git a/pkg/remote/test/aws_sqs_queue_policy_multiple/aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_foo.res.golden.json b/enumeration/remote/test/aws_sqs_queue_policy_multiple/aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_foo.res.golden.json similarity index 100% rename from pkg/remote/test/aws_sqs_queue_policy_multiple/aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_foo.res.golden.json rename to enumeration/remote/test/aws_sqs_queue_policy_multiple/aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_foo.res.golden.json diff --git a/pkg/remote/test/aws_sqs_queue_policy_multiple/policy.json b/enumeration/remote/test/aws_sqs_queue_policy_multiple/policy.json similarity index 100% rename from pkg/remote/test/aws_sqs_queue_policy_multiple/policy.json rename to enumeration/remote/test/aws_sqs_queue_policy_multiple/policy.json diff --git a/pkg/remote/test/aws_sqs_queue_policy_multiple/results.golden.json b/enumeration/remote/test/aws_sqs_queue_policy_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_sqs_queue_policy_multiple/results.golden.json rename to enumeration/remote/test/aws_sqs_queue_policy_multiple/results.golden.json diff --git a/pkg/remote/test/aws_sqs_queue_policy_multiple/terraform.tf b/enumeration/remote/test/aws_sqs_queue_policy_multiple/terraform.tf similarity index 100% rename from pkg/remote/test/aws_sqs_queue_policy_multiple/terraform.tf rename to enumeration/remote/test/aws_sqs_queue_policy_multiple/terraform.tf diff --git a/pkg/remote/test/aws_vpc/aws_vpc-vpc-020b072316a95b97f.res.golden.json b/enumeration/remote/test/aws_vpc/aws_vpc-vpc-020b072316a95b97f.res.golden.json similarity index 100% rename from pkg/remote/test/aws_vpc/aws_vpc-vpc-020b072316a95b97f.res.golden.json rename to enumeration/remote/test/aws_vpc/aws_vpc-vpc-020b072316a95b97f.res.golden.json diff --git a/pkg/remote/test/aws_vpc/aws_vpc-vpc-02c50896b59598761.res.golden.json b/enumeration/remote/test/aws_vpc/aws_vpc-vpc-02c50896b59598761.res.golden.json similarity index 100% rename from pkg/remote/test/aws_vpc/aws_vpc-vpc-02c50896b59598761.res.golden.json rename to enumeration/remote/test/aws_vpc/aws_vpc-vpc-02c50896b59598761.res.golden.json diff --git a/pkg/remote/test/aws_vpc/aws_vpc-vpc-0768e1fd0029e3fc3.res.golden.json b/enumeration/remote/test/aws_vpc/aws_vpc-vpc-0768e1fd0029e3fc3.res.golden.json similarity index 100% rename from pkg/remote/test/aws_vpc/aws_vpc-vpc-0768e1fd0029e3fc3.res.golden.json rename to enumeration/remote/test/aws_vpc/aws_vpc-vpc-0768e1fd0029e3fc3.res.golden.json diff --git a/pkg/remote/test/aws_vpc/aws_vpc-vpc-a8c5d4c1.res.golden.json b/enumeration/remote/test/aws_vpc/aws_vpc-vpc-a8c5d4c1.res.golden.json similarity index 100% rename from pkg/remote/test/aws_vpc/aws_vpc-vpc-a8c5d4c1.res.golden.json rename to enumeration/remote/test/aws_vpc/aws_vpc-vpc-a8c5d4c1.res.golden.json diff --git a/pkg/remote/test/aws_vpc/results.golden.json b/enumeration/remote/test/aws_vpc/results.golden.json similarity index 100% rename from pkg/remote/test/aws_vpc/results.golden.json rename to enumeration/remote/test/aws_vpc/results.golden.json diff --git a/pkg/remote/test/aws_vpc/terraform.tf b/enumeration/remote/test/aws_vpc/terraform.tf similarity index 100% rename from pkg/remote/test/aws_vpc/terraform.tf rename to enumeration/remote/test/aws_vpc/terraform.tf diff --git a/pkg/remote/test/aws_vpc_default_security_group_multiple/aws_default_security_group-sg-9e0204ff.res.golden.json b/enumeration/remote/test/aws_vpc_default_security_group_multiple/aws_default_security_group-sg-9e0204ff.res.golden.json similarity index 100% rename from pkg/remote/test/aws_vpc_default_security_group_multiple/aws_default_security_group-sg-9e0204ff.res.golden.json rename to enumeration/remote/test/aws_vpc_default_security_group_multiple/aws_default_security_group-sg-9e0204ff.res.golden.json diff --git a/pkg/remote/test/aws_vpc_default_security_group_multiple/results.golden.json b/enumeration/remote/test/aws_vpc_default_security_group_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_vpc_default_security_group_multiple/results.golden.json rename to enumeration/remote/test/aws_vpc_default_security_group_multiple/results.golden.json diff --git a/pkg/remote/test/aws_vpc_default_security_group_multiple/terraform.tf b/enumeration/remote/test/aws_vpc_default_security_group_multiple/terraform.tf similarity index 100% rename from pkg/remote/test/aws_vpc_default_security_group_multiple/terraform.tf rename to enumeration/remote/test/aws_vpc_default_security_group_multiple/terraform.tf diff --git a/pkg/remote/test/aws_vpc_security_group_default_rules/aws_security_group_rule-sgrule-3820791514-1-1.2.0.0_16-0-0-0--1-sg-a74815c8-false--0-ingress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_default_rules/aws_security_group_rule-sgrule-3820791514-1-1.2.0.0_16-0-0-0--1-sg-a74815c8-false--0-ingress.res.golden.json similarity index 100% rename from pkg/remote/test/aws_vpc_security_group_default_rules/aws_security_group_rule-sgrule-3820791514-1-1.2.0.0_16-0-0-0--1-sg-a74815c8-false--0-ingress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_default_rules/aws_security_group_rule-sgrule-3820791514-1-1.2.0.0_16-0-0-0--1-sg-a74815c8-false--0-ingress.res.golden.json diff --git a/pkg/remote/test/aws_vpc_security_group_default_rules/aws_security_group_rule-sgrule-529352477-1-1.2.3.4_32-0-0-0--1-sg-a74815c8-false--0-egress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_default_rules/aws_security_group_rule-sgrule-529352477-1-1.2.3.4_32-0-0-0--1-sg-a74815c8-false--0-egress.res.golden.json similarity index 100% rename from pkg/remote/test/aws_vpc_security_group_default_rules/aws_security_group_rule-sgrule-529352477-1-1.2.3.4_32-0-0-0--1-sg-a74815c8-false--0-egress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_default_rules/aws_security_group_rule-sgrule-529352477-1-1.2.3.4_32-0-0-0--1-sg-a74815c8-false--0-egress.res.golden.json diff --git a/pkg/remote/test/aws_vpc_security_group_default_rules/results.golden.json b/enumeration/remote/test/aws_vpc_security_group_default_rules/results.golden.json similarity index 100% rename from pkg/remote/test/aws_vpc_security_group_default_rules/results.golden.json rename to enumeration/remote/test/aws_vpc_security_group_default_rules/results.golden.json diff --git a/pkg/remote/test/aws_vpc_security_group_multiple/aws_security_group-sg-0254c038e32f25530.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_multiple/aws_security_group-sg-0254c038e32f25530.res.golden.json similarity index 100% rename from pkg/remote/test/aws_vpc_security_group_multiple/aws_security_group-sg-0254c038e32f25530.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_multiple/aws_security_group-sg-0254c038e32f25530.res.golden.json diff --git a/pkg/remote/test/aws_vpc_security_group_multiple/results.golden.json b/enumeration/remote/test/aws_vpc_security_group_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_vpc_security_group_multiple/results.golden.json rename to enumeration/remote/test/aws_vpc_security_group_multiple/results.golden.json diff --git a/pkg/remote/test/aws_vpc_security_group_multiple/terraform.tf b/enumeration/remote/test/aws_vpc_security_group_multiple/terraform.tf similarity index 100% rename from pkg/remote/test/aws_vpc_security_group_multiple/terraform.tf rename to enumeration/remote/test/aws_vpc_security_group_multiple/terraform.tf diff --git a/pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-1175318309-1-0.0.0.0_0-0--1-sg-0cc8b3c3c2851705a-false-0-egress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-1175318309-1-0.0.0.0_0-0--1-sg-0cc8b3c3c2851705a-false--0-egress.res.golden.json similarity index 100% rename from pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-1175318309-1-0.0.0.0_0-0--1-sg-0cc8b3c3c2851705a-false-0-egress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-1175318309-1-0.0.0.0_0-0--1-sg-0cc8b3c3c2851705a-false--0-egress.res.golden.json diff --git a/pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-1707973622-1-0.0.0.0_0-0--1-sg-0254c038e32f25530-false-0-egress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-1707973622-1-0.0.0.0_0-0--1-sg-0254c038e32f25530-false--0-egress.res.golden.json similarity index 100% rename from pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-1707973622-1-0.0.0.0_0-0--1-sg-0254c038e32f25530-false-0-egress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-1707973622-1-0.0.0.0_0-0--1-sg-0254c038e32f25530-false--0-egress.res.golden.json diff --git a/pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2165103420-1-5.6.7.0_24-0--1-sg-0254c038e32f25530-false-0-ingress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2165103420-1-5.6.7.0_24-0--1-sg-0254c038e32f25530-false--0-ingress.res.golden.json similarity index 100% rename from pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2165103420-1-5.6.7.0_24-0--1-sg-0254c038e32f25530-false-0-ingress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2165103420-1-5.6.7.0_24-0--1-sg-0254c038e32f25530-false--0-ingress.res.golden.json diff --git a/pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2582518759-1-1.2.0.0_16-0--1-sg-0254c038e32f25530-false-0-ingress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2582518759-1-1.2.0.0_16-0--1-sg-0254c038e32f25530-false--0-ingress.res.golden.json similarity index 100% rename from pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2582518759-1-1.2.0.0_16-0--1-sg-0254c038e32f25530-false-0-ingress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2582518759-1-1.2.0.0_16-0--1-sg-0254c038e32f25530-false--0-ingress.res.golden.json diff --git a/pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2821752134-0-1-___0--1-sg-0254c038e32f25530-false-0-egress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2821752134-0-1-___0--1-sg-0254c038e32f25530-false--0-egress.res.golden.json similarity index 100% rename from pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2821752134-0-1-___0--1-sg-0254c038e32f25530-false-0-egress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2821752134-0-1-___0--1-sg-0254c038e32f25530-false--0-egress.res.golden.json diff --git a/pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-350400929-0-1-___0--1-sg-0cc8b3c3c2851705a-false-0-egress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-350400929-0-1-___0--1-sg-0cc8b3c3c2851705a-false--0-egress.res.golden.json similarity index 100% rename from pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-350400929-0-1-___0--1-sg-0cc8b3c3c2851705a-false-0-egress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-350400929-0-1-___0--1-sg-0cc8b3c3c2851705a-false--0-egress.res.golden.json diff --git a/pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-3587309474-0-tcp-sg-0254c038e32f25530-false-sg-9e0204ff-65535-ingress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-3587309474-0-tcp-sg-0254c038e32f25530-false-sg-9e0204ff-65535-ingress.res.golden.json similarity index 100% rename from pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-3587309474-0-tcp-sg-0254c038e32f25530-false-sg-9e0204ff-65535-ingress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-3587309474-0-tcp-sg-0254c038e32f25530-false-sg-9e0204ff-65535-ingress.res.golden.json diff --git a/pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-3970541193-0-tcp-sg-0254c038e32f25530-true-65535-ingress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-3970541193-0-tcp-sg-0254c038e32f25530-true--65535-ingress.res.golden.json similarity index 100% rename from pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-3970541193-0-tcp-sg-0254c038e32f25530-true-65535-ingress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-3970541193-0-tcp-sg-0254c038e32f25530-true--65535-ingress.res.golden.json diff --git a/pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-453320892-1-0.0.0.0_0-443-tcp-sg-0cc8b3c3c2851705a-false-443-ingress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-453320892-1-0.0.0.0_0-443-tcp-sg-0cc8b3c3c2851705a-false--443-ingress.res.golden.json similarity index 100% rename from pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-453320892-1-0.0.0.0_0-443-tcp-sg-0cc8b3c3c2851705a-false-443-ingress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-453320892-1-0.0.0.0_0-443-tcp-sg-0cc8b3c3c2851705a-false--443-ingress.res.golden.json diff --git a/pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-674800228-0-1-___0--1-sg-0254c038e32f25530-false-0-ingress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-674800228-0-1-___0--1-sg-0254c038e32f25530-false--0-ingress.res.golden.json similarity index 100% rename from pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-674800228-0-1-___0--1-sg-0254c038e32f25530-false-0-ingress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-674800228-0-1-___0--1-sg-0254c038e32f25530-false--0-ingress.res.golden.json diff --git a/pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-850043874-1-0.0.0.0_0-5-sg-0cc8b3c3c2851705a-false-egress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-850043874-1-0.0.0.0_0-0-5-sg-0cc8b3c3c2851705a-false--0-egress.res.golden.json similarity index 100% rename from pkg/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-850043874-1-0.0.0.0_0-5-sg-0cc8b3c3c2851705a-false-egress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-850043874-1-0.0.0.0_0-0-5-sg-0cc8b3c3c2851705a-false--0-egress.res.golden.json diff --git a/pkg/remote/test/aws_vpc_security_group_rule_multiple/results.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/aws_vpc_security_group_rule_multiple/results.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/results.golden.json diff --git a/pkg/remote/test/azurerm_lb_rule_multiple/17c4e2b7f4cc466670ccbd8dd1d506289fd818c0.res.golden.json b/enumeration/remote/test/azurerm_lb_rule_multiple/17c4e2b7f4cc466670ccbd8dd1d506289fd818c0.res.golden.json similarity index 100% rename from pkg/remote/test/azurerm_lb_rule_multiple/17c4e2b7f4cc466670ccbd8dd1d506289fd818c0.res.golden.json rename to enumeration/remote/test/azurerm_lb_rule_multiple/17c4e2b7f4cc466670ccbd8dd1d506289fd818c0.res.golden.json diff --git a/pkg/remote/test/azurerm_lb_rule_multiple/2f725aa2c71898229fcfa091837deaa387bee9d8.res.golden.json b/enumeration/remote/test/azurerm_lb_rule_multiple/2f725aa2c71898229fcfa091837deaa387bee9d8.res.golden.json similarity index 100% rename from pkg/remote/test/azurerm_lb_rule_multiple/2f725aa2c71898229fcfa091837deaa387bee9d8.res.golden.json rename to enumeration/remote/test/azurerm_lb_rule_multiple/2f725aa2c71898229fcfa091837deaa387bee9d8.res.golden.json diff --git a/pkg/remote/test/azurerm_lb_rule_multiple/results.golden.json b/enumeration/remote/test/azurerm_lb_rule_multiple/results.golden.json similarity index 98% rename from pkg/remote/test/azurerm_lb_rule_multiple/results.golden.json rename to enumeration/remote/test/azurerm_lb_rule_multiple/results.golden.json index 132a1c166..6266d781d 100755 --- a/pkg/remote/test/azurerm_lb_rule_multiple/results.golden.json +++ b/enumeration/remote/test/azurerm_lb_rule_multiple/results.golden.json @@ -16,7 +16,7 @@ "probe_id": "", "protocol": "Tcp", "resource_group_name": "raphael-dev", - "timeouts": null + "timeouts": {} }, { "backend_address_pool_id": "", @@ -35,6 +35,6 @@ "probe_id": "", "protocol": "Tcp", "resource_group_name": "raphael-dev", - "timeouts": null + "timeouts": {} } ] \ No newline at end of file diff --git a/pkg/remote/test/azurerm_network_security_group_multiple/azurerm_network_security_group-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_example-resources_providers_Microsoft.Network_networkSecurityGroups_acceptanceTestSecurityGroup1.res.golden.json b/enumeration/remote/test/azurerm_network_security_group_multiple/azurerm_network_security_group-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_example-resources_providers_Microsoft.Network_networkSecurityGroups_acceptanceTestSecurityGroup1.res.golden.json similarity index 100% rename from pkg/remote/test/azurerm_network_security_group_multiple/azurerm_network_security_group-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_example-resources_providers_Microsoft.Network_networkSecurityGroups_acceptanceTestSecurityGroup1.res.golden.json rename to enumeration/remote/test/azurerm_network_security_group_multiple/azurerm_network_security_group-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_example-resources_providers_Microsoft.Network_networkSecurityGroups_acceptanceTestSecurityGroup1.res.golden.json diff --git a/pkg/remote/test/azurerm_network_security_group_multiple/azurerm_network_security_group-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_example-resources_providers_Microsoft.Network_networkSecurityGroups_acceptanceTestSecurityGroup2.res.golden.json b/enumeration/remote/test/azurerm_network_security_group_multiple/azurerm_network_security_group-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_example-resources_providers_Microsoft.Network_networkSecurityGroups_acceptanceTestSecurityGroup2.res.golden.json similarity index 100% rename from pkg/remote/test/azurerm_network_security_group_multiple/azurerm_network_security_group-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_example-resources_providers_Microsoft.Network_networkSecurityGroups_acceptanceTestSecurityGroup2.res.golden.json rename to enumeration/remote/test/azurerm_network_security_group_multiple/azurerm_network_security_group-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_example-resources_providers_Microsoft.Network_networkSecurityGroups_acceptanceTestSecurityGroup2.res.golden.json diff --git a/pkg/remote/test/azurerm_network_security_group_multiple/results.golden.json b/enumeration/remote/test/azurerm_network_security_group_multiple/results.golden.json similarity index 97% rename from pkg/remote/test/azurerm_network_security_group_multiple/results.golden.json rename to enumeration/remote/test/azurerm_network_security_group_multiple/results.golden.json index 5a57c3a10..3daa87adc 100755 --- a/pkg/remote/test/azurerm_network_security_group_multiple/results.golden.json +++ b/enumeration/remote/test/azurerm_network_security_group_multiple/results.golden.json @@ -6,7 +6,7 @@ "resource_group_name": "example-resources", "security_rule": null, "tags": null, - "timeouts": null + "timeouts": {} }, { "id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/example-resources/providers/Microsoft.Network/networkSecurityGroups/acceptanceTestSecurityGroup1", @@ -36,6 +36,6 @@ "tags": { "environment": "Production" }, - "timeouts": null + "timeouts": {} } ] \ No newline at end of file diff --git a/pkg/remote/test/azurerm_private_dns_a_record_multiple/azurerm_private_dns_a_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_A_othertest.res.golden.json b/enumeration/remote/test/azurerm_private_dns_a_record_multiple/azurerm_private_dns_a_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_A_othertest.res.golden.json similarity index 100% rename from pkg/remote/test/azurerm_private_dns_a_record_multiple/azurerm_private_dns_a_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_A_othertest.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_a_record_multiple/azurerm_private_dns_a_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_A_othertest.res.golden.json diff --git a/pkg/remote/test/azurerm_private_dns_a_record_multiple/azurerm_private_dns_a_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_A_test.res.golden.json b/enumeration/remote/test/azurerm_private_dns_a_record_multiple/azurerm_private_dns_a_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_A_test.res.golden.json similarity index 100% rename from pkg/remote/test/azurerm_private_dns_a_record_multiple/azurerm_private_dns_a_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_A_test.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_a_record_multiple/azurerm_private_dns_a_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_A_test.res.golden.json diff --git a/pkg/remote/test/azurerm_private_dns_a_record_multiple/results.golden.json b/enumeration/remote/test/azurerm_private_dns_a_record_multiple/results.golden.json similarity index 95% rename from pkg/remote/test/azurerm_private_dns_a_record_multiple/results.golden.json rename to enumeration/remote/test/azurerm_private_dns_a_record_multiple/results.golden.json index d6aeff7ab..f0b58fc98 100755 --- a/pkg/remote/test/azurerm_private_dns_a_record_multiple/results.golden.json +++ b/enumeration/remote/test/azurerm_private_dns_a_record_multiple/results.golden.json @@ -9,7 +9,7 @@ ], "resource_group_name": "martin-dev", "tags": null, - "timeouts": null, + "timeouts": {}, "ttl": 300, "zone_name": "thisisatestusingtf.com" }, @@ -22,7 +22,7 @@ ], "resource_group_name": "martin-dev", "tags": null, - "timeouts": null, + "timeouts": {}, "ttl": 300, "zone_name": "thisisatestusingtf.com" } diff --git a/pkg/remote/test/azurerm_private_dns_aaaaa_record_multiple/azurerm_private_dns_aaaa_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_AAAA_othertest.res.golden.json b/enumeration/remote/test/azurerm_private_dns_aaaaa_record_multiple/azurerm_private_dns_aaaa_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_AAAA_othertest.res.golden.json similarity index 100% rename from pkg/remote/test/azurerm_private_dns_aaaaa_record_multiple/azurerm_private_dns_aaaa_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_AAAA_othertest.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_aaaaa_record_multiple/azurerm_private_dns_aaaa_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_AAAA_othertest.res.golden.json diff --git a/pkg/remote/test/azurerm_private_dns_aaaaa_record_multiple/azurerm_private_dns_aaaa_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_AAAA_test.res.golden.json b/enumeration/remote/test/azurerm_private_dns_aaaaa_record_multiple/azurerm_private_dns_aaaa_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_AAAA_test.res.golden.json similarity index 100% rename from pkg/remote/test/azurerm_private_dns_aaaaa_record_multiple/azurerm_private_dns_aaaa_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_AAAA_test.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_aaaaa_record_multiple/azurerm_private_dns_aaaa_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_AAAA_test.res.golden.json diff --git a/pkg/remote/test/azurerm_private_dns_aaaaa_record_multiple/results.golden.json b/enumeration/remote/test/azurerm_private_dns_aaaaa_record_multiple/results.golden.json similarity index 95% rename from pkg/remote/test/azurerm_private_dns_aaaaa_record_multiple/results.golden.json rename to enumeration/remote/test/azurerm_private_dns_aaaaa_record_multiple/results.golden.json index 6af371616..cc30ef5a6 100755 --- a/pkg/remote/test/azurerm_private_dns_aaaaa_record_multiple/results.golden.json +++ b/enumeration/remote/test/azurerm_private_dns_aaaaa_record_multiple/results.golden.json @@ -9,7 +9,7 @@ ], "resource_group_name": "martin-dev", "tags": null, - "timeouts": null, + "timeouts": {}, "ttl": 300, "zone_name": "thisisatestusingtf.com" }, @@ -23,7 +23,7 @@ ], "resource_group_name": "martin-dev", "tags": null, - "timeouts": null, + "timeouts": {}, "ttl": 300, "zone_name": "thisisatestusingtf.com" } diff --git a/pkg/remote/test/azurerm_private_dns_cname_record_multiple/azurerm_private_dns_cname_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_CNAME_othertest.res.golden.json b/enumeration/remote/test/azurerm_private_dns_cname_record_multiple/azurerm_private_dns_cname_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_CNAME_othertest.res.golden.json similarity index 100% rename from pkg/remote/test/azurerm_private_dns_cname_record_multiple/azurerm_private_dns_cname_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_CNAME_othertest.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_cname_record_multiple/azurerm_private_dns_cname_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_CNAME_othertest.res.golden.json diff --git a/pkg/remote/test/azurerm_private_dns_cname_record_multiple/azurerm_private_dns_cname_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_CNAME_test.res.golden.json b/enumeration/remote/test/azurerm_private_dns_cname_record_multiple/azurerm_private_dns_cname_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_CNAME_test.res.golden.json similarity index 100% rename from pkg/remote/test/azurerm_private_dns_cname_record_multiple/azurerm_private_dns_cname_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_CNAME_test.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_cname_record_multiple/azurerm_private_dns_cname_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_CNAME_test.res.golden.json diff --git a/pkg/remote/test/azurerm_private_dns_cname_record_multiple/results.golden.json b/enumeration/remote/test/azurerm_private_dns_cname_record_multiple/results.golden.json similarity index 94% rename from pkg/remote/test/azurerm_private_dns_cname_record_multiple/results.golden.json rename to enumeration/remote/test/azurerm_private_dns_cname_record_multiple/results.golden.json index 91a68e860..db9064a6e 100755 --- a/pkg/remote/test/azurerm_private_dns_cname_record_multiple/results.golden.json +++ b/enumeration/remote/test/azurerm_private_dns_cname_record_multiple/results.golden.json @@ -6,7 +6,7 @@ "record": "test.com", "resource_group_name": "martin-dev", "tags": null, - "timeouts": null, + "timeouts": {}, "ttl": 300, "zone_name": "thisisatestusingtf.com" }, @@ -17,7 +17,7 @@ "record": "othertest.com", "resource_group_name": "martin-dev", "tags": null, - "timeouts": null, + "timeouts": {}, "ttl": 300, "zone_name": "thisisatestusingtf.com" } diff --git a/pkg/remote/test/azurerm_private_dns_mx_record_multiple/azurerm_private_dns_mx_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_MX_othertestmx.res.golden.json b/enumeration/remote/test/azurerm_private_dns_mx_record_multiple/azurerm_private_dns_mx_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_MX_othertestmx.res.golden.json similarity index 100% rename from pkg/remote/test/azurerm_private_dns_mx_record_multiple/azurerm_private_dns_mx_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_MX_othertestmx.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_mx_record_multiple/azurerm_private_dns_mx_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_MX_othertestmx.res.golden.json diff --git a/pkg/remote/test/azurerm_private_dns_mx_record_multiple/azurerm_private_dns_mx_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_MX_testmx.res.golden.json b/enumeration/remote/test/azurerm_private_dns_mx_record_multiple/azurerm_private_dns_mx_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_MX_testmx.res.golden.json similarity index 100% rename from pkg/remote/test/azurerm_private_dns_mx_record_multiple/azurerm_private_dns_mx_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_MX_testmx.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_mx_record_multiple/azurerm_private_dns_mx_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_MX_testmx.res.golden.json diff --git a/pkg/remote/test/azurerm_private_dns_mx_record_multiple/results.golden.json b/enumeration/remote/test/azurerm_private_dns_mx_record_multiple/results.golden.json similarity index 96% rename from pkg/remote/test/azurerm_private_dns_mx_record_multiple/results.golden.json rename to enumeration/remote/test/azurerm_private_dns_mx_record_multiple/results.golden.json index 36dd442e4..c0f56139d 100755 --- a/pkg/remote/test/azurerm_private_dns_mx_record_multiple/results.golden.json +++ b/enumeration/remote/test/azurerm_private_dns_mx_record_multiple/results.golden.json @@ -11,7 +11,7 @@ ], "resource_group_name": "martin-dev", "tags": null, - "timeouts": null, + "timeouts": {}, "ttl": 300, "zone_name": "thisisatestusingtf.com" }, @@ -31,7 +31,7 @@ ], "resource_group_name": "martin-dev", "tags": null, - "timeouts": null, + "timeouts": {}, "ttl": 300, "zone_name": "thisisatestusingtf.com" } diff --git a/pkg/remote/test/azurerm_private_dns_private_zone_multiple/azurerm_private_dns_zone-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_testmartin.com.res.golden.json b/enumeration/remote/test/azurerm_private_dns_private_zone_multiple/azurerm_private_dns_zone-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_testmartin.com.res.golden.json similarity index 100% rename from pkg/remote/test/azurerm_private_dns_private_zone_multiple/azurerm_private_dns_zone-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_testmartin.com.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_private_zone_multiple/azurerm_private_dns_zone-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_testmartin.com.res.golden.json diff --git a/pkg/remote/test/azurerm_private_dns_private_zone_multiple/azurerm_private_dns_zone-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com.res.golden.json b/enumeration/remote/test/azurerm_private_dns_private_zone_multiple/azurerm_private_dns_zone-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com.res.golden.json similarity index 100% rename from pkg/remote/test/azurerm_private_dns_private_zone_multiple/azurerm_private_dns_zone-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_private_zone_multiple/azurerm_private_dns_zone-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com.res.golden.json diff --git a/pkg/remote/test/azurerm_private_dns_private_zone_multiple/azurerm_private_dns_zone-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf2.com.res.golden.json b/enumeration/remote/test/azurerm_private_dns_private_zone_multiple/azurerm_private_dns_zone-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf2.com.res.golden.json similarity index 100% rename from pkg/remote/test/azurerm_private_dns_private_zone_multiple/azurerm_private_dns_zone-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf2.com.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_private_zone_multiple/azurerm_private_dns_zone-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf2.com.res.golden.json diff --git a/pkg/remote/test/azurerm_private_dns_private_zone_multiple/results.golden.json b/enumeration/remote/test/azurerm_private_dns_private_zone_multiple/results.golden.json similarity index 93% rename from pkg/remote/test/azurerm_private_dns_private_zone_multiple/results.golden.json rename to enumeration/remote/test/azurerm_private_dns_private_zone_multiple/results.golden.json index 96fbf2088..a10659653 100755 --- a/pkg/remote/test/azurerm_private_dns_private_zone_multiple/results.golden.json +++ b/enumeration/remote/test/azurerm_private_dns_private_zone_multiple/results.golden.json @@ -5,7 +5,7 @@ "max_number_of_virtual_network_links": 1000, "max_number_of_virtual_network_links_with_registration": 100, "name": "thisisatestusingtf2.com", - "number_of_record_sets": null, + "number_of_record_sets": 1, "resource_group_name": "martin-dev", "soa_record": [ { @@ -22,7 +22,7 @@ } ], "tags": null, - "timeouts": null + "timeouts": {} }, { "id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/testmartin.com", @@ -30,7 +30,7 @@ "max_number_of_virtual_network_links": 1000, "max_number_of_virtual_network_links_with_registration": 100, "name": "testmartin.com", - "number_of_record_sets": null, + "number_of_record_sets": 2, "resource_group_name": "martin-dev", "soa_record": [ { @@ -49,7 +49,7 @@ "tags": { "test": "test" }, - "timeouts": null + "timeouts": {} }, { "id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com", @@ -57,7 +57,7 @@ "max_number_of_virtual_network_links": 1000, "max_number_of_virtual_network_links_with_registration": 100, "name": "thisisatestusingtf.com", - "number_of_record_sets": null, + "number_of_record_sets": 5, "resource_group_name": "martin-dev", "soa_record": [ { @@ -74,6 +74,6 @@ } ], "tags": null, - "timeouts": null + "timeouts": {} } ] \ No newline at end of file diff --git a/pkg/remote/test/azurerm_private_dns_ptr_record_multiple/azurerm_private_dns_ptr_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_PTR_othertestptr.res.golden.json b/enumeration/remote/test/azurerm_private_dns_ptr_record_multiple/azurerm_private_dns_ptr_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_PTR_othertestptr.res.golden.json similarity index 100% rename from pkg/remote/test/azurerm_private_dns_ptr_record_multiple/azurerm_private_dns_ptr_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_PTR_othertestptr.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_ptr_record_multiple/azurerm_private_dns_ptr_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_PTR_othertestptr.res.golden.json diff --git a/pkg/remote/test/azurerm_private_dns_ptr_record_multiple/azurerm_private_dns_ptr_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_PTR_testptr.res.golden.json b/enumeration/remote/test/azurerm_private_dns_ptr_record_multiple/azurerm_private_dns_ptr_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_PTR_testptr.res.golden.json similarity index 100% rename from pkg/remote/test/azurerm_private_dns_ptr_record_multiple/azurerm_private_dns_ptr_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_PTR_testptr.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_ptr_record_multiple/azurerm_private_dns_ptr_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_PTR_testptr.res.golden.json diff --git a/pkg/remote/test/azurerm_private_dns_ptr_record_multiple/results.golden.json b/enumeration/remote/test/azurerm_private_dns_ptr_record_multiple/results.golden.json similarity index 95% rename from pkg/remote/test/azurerm_private_dns_ptr_record_multiple/results.golden.json rename to enumeration/remote/test/azurerm_private_dns_ptr_record_multiple/results.golden.json index afa5d613d..3a42c39bb 100755 --- a/pkg/remote/test/azurerm_private_dns_ptr_record_multiple/results.golden.json +++ b/enumeration/remote/test/azurerm_private_dns_ptr_record_multiple/results.golden.json @@ -8,7 +8,7 @@ ], "resource_group_name": "martin-dev", "tags": null, - "timeouts": null, + "timeouts": {}, "ttl": 300, "zone_name": "thisisatestusingtf.com" }, @@ -22,7 +22,7 @@ ], "resource_group_name": "martin-dev", "tags": null, - "timeouts": null, + "timeouts": {}, "ttl": 300, "zone_name": "thisisatestusingtf.com" } diff --git a/pkg/remote/test/azurerm_private_dns_srv_record_multiple/azurerm_private_dns_srv_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_SRV_othertestptr.res.golden.json b/enumeration/remote/test/azurerm_private_dns_srv_record_multiple/azurerm_private_dns_srv_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_SRV_othertestptr.res.golden.json similarity index 100% rename from pkg/remote/test/azurerm_private_dns_srv_record_multiple/azurerm_private_dns_srv_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_SRV_othertestptr.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_srv_record_multiple/azurerm_private_dns_srv_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_SRV_othertestptr.res.golden.json diff --git a/pkg/remote/test/azurerm_private_dns_srv_record_multiple/azurerm_private_dns_srv_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_SRV_testptr.res.golden.json b/enumeration/remote/test/azurerm_private_dns_srv_record_multiple/azurerm_private_dns_srv_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_SRV_testptr.res.golden.json similarity index 100% rename from pkg/remote/test/azurerm_private_dns_srv_record_multiple/azurerm_private_dns_srv_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_SRV_testptr.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_srv_record_multiple/azurerm_private_dns_srv_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_SRV_testptr.res.golden.json diff --git a/pkg/remote/test/azurerm_private_dns_srv_record_multiple/results.golden.json b/enumeration/remote/test/azurerm_private_dns_srv_record_multiple/results.golden.json similarity index 96% rename from pkg/remote/test/azurerm_private_dns_srv_record_multiple/results.golden.json rename to enumeration/remote/test/azurerm_private_dns_srv_record_multiple/results.golden.json index d5f0b6709..08ca167d6 100755 --- a/pkg/remote/test/azurerm_private_dns_srv_record_multiple/results.golden.json +++ b/enumeration/remote/test/azurerm_private_dns_srv_record_multiple/results.golden.json @@ -19,7 +19,7 @@ ], "resource_group_name": "martin-dev", "tags": null, - "timeouts": null, + "timeouts": {}, "ttl": 300, "zone_name": "thisisatestusingtf.com" }, @@ -37,7 +37,7 @@ ], "resource_group_name": "martin-dev", "tags": null, - "timeouts": null, + "timeouts": {}, "ttl": 300, "zone_name": "thisisatestusingtf.com" } diff --git a/pkg/remote/test/azurerm_private_dns_txt_record_multiple/azurerm_private_dns_txt_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_TXT_othertesttxt.res.golden.json b/enumeration/remote/test/azurerm_private_dns_txt_record_multiple/azurerm_private_dns_txt_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_TXT_othertesttxt.res.golden.json similarity index 100% rename from pkg/remote/test/azurerm_private_dns_txt_record_multiple/azurerm_private_dns_txt_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_TXT_othertesttxt.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_txt_record_multiple/azurerm_private_dns_txt_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_TXT_othertesttxt.res.golden.json diff --git a/pkg/remote/test/azurerm_private_dns_txt_record_multiple/azurerm_private_dns_txt_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_TXT_testtxt.res.golden.json b/enumeration/remote/test/azurerm_private_dns_txt_record_multiple/azurerm_private_dns_txt_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_TXT_testtxt.res.golden.json similarity index 100% rename from pkg/remote/test/azurerm_private_dns_txt_record_multiple/azurerm_private_dns_txt_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_TXT_testtxt.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_txt_record_multiple/azurerm_private_dns_txt_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_TXT_testtxt.res.golden.json diff --git a/pkg/remote/test/azurerm_private_dns_txt_record_multiple/results.golden.json b/enumeration/remote/test/azurerm_private_dns_txt_record_multiple/results.golden.json similarity index 95% rename from pkg/remote/test/azurerm_private_dns_txt_record_multiple/results.golden.json rename to enumeration/remote/test/azurerm_private_dns_txt_record_multiple/results.golden.json index a52f6bf17..7dfe177fa 100755 --- a/pkg/remote/test/azurerm_private_dns_txt_record_multiple/results.golden.json +++ b/enumeration/remote/test/azurerm_private_dns_txt_record_multiple/results.golden.json @@ -10,7 +10,7 @@ ], "resource_group_name": "martin-dev", "tags": null, - "timeouts": null, + "timeouts": {}, "ttl": 300, "zone_name": "thisisatestusingtf.com" }, @@ -28,7 +28,7 @@ ], "resource_group_name": "martin-dev", "tags": null, - "timeouts": null, + "timeouts": {}, "ttl": 300, "zone_name": "thisisatestusingtf.com" } diff --git a/pkg/remote/test/azurerm_ssh_public_key_multiple/azurerm_ssh_public_key-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_TESTRESGROUP_providers_Microsoft.Compute_sshPublicKeys_example-key.res.golden.json b/enumeration/remote/test/azurerm_ssh_public_key_multiple/azurerm_ssh_public_key-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_TESTRESGROUP_providers_Microsoft.Compute_sshPublicKeys_example-key.res.golden.json similarity index 100% rename from pkg/remote/test/azurerm_ssh_public_key_multiple/azurerm_ssh_public_key-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_TESTRESGROUP_providers_Microsoft.Compute_sshPublicKeys_example-key.res.golden.json rename to enumeration/remote/test/azurerm_ssh_public_key_multiple/azurerm_ssh_public_key-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_TESTRESGROUP_providers_Microsoft.Compute_sshPublicKeys_example-key.res.golden.json diff --git a/pkg/remote/test/azurerm_ssh_public_key_multiple/azurerm_ssh_public_key-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_TESTRESGROUP_providers_Microsoft.Compute_sshPublicKeys_example-key2.res.golden.json b/enumeration/remote/test/azurerm_ssh_public_key_multiple/azurerm_ssh_public_key-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_TESTRESGROUP_providers_Microsoft.Compute_sshPublicKeys_example-key2.res.golden.json similarity index 100% rename from pkg/remote/test/azurerm_ssh_public_key_multiple/azurerm_ssh_public_key-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_TESTRESGROUP_providers_Microsoft.Compute_sshPublicKeys_example-key2.res.golden.json rename to enumeration/remote/test/azurerm_ssh_public_key_multiple/azurerm_ssh_public_key-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_TESTRESGROUP_providers_Microsoft.Compute_sshPublicKeys_example-key2.res.golden.json diff --git a/pkg/remote/test/azurerm_ssh_public_key_multiple/results.golden.json b/enumeration/remote/test/azurerm_ssh_public_key_multiple/results.golden.json similarity index 98% rename from pkg/remote/test/azurerm_ssh_public_key_multiple/results.golden.json rename to enumeration/remote/test/azurerm_ssh_public_key_multiple/results.golden.json index 5ff4d335e..4cef8a321 100755 --- a/pkg/remote/test/azurerm_ssh_public_key_multiple/results.golden.json +++ b/enumeration/remote/test/azurerm_ssh_public_key_multiple/results.golden.json @@ -6,7 +6,7 @@ "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCjeC5sO1EdEfZOrdVCpuOgXcXsKZg9zgfJbHgQgX1R2Nd8mNQrUjpsB4XLHNZ3T6UYrsSh7oxYC3UFu6peO4LmA2WTe2wCWVFn9WW/Lo99WcA/G/fGj6s5HK5CHFVPXnNxM47QJMNm5BWOM55+EWP839SHLH9Fk63H575x7jxZvBvaV0uL84XuVpiEBKhnpQfT4cJGoGLOGgjM+TpHyosbKldu5q2UTF9nOGpmLuku41oihqiPPSJnJRv3TDKFi4mIl9Iz5HJINWvLl1kdCfyjPcHcH5GO0tuA9rP5AbsmG5EAGOKtuFipYA4MyY9SYriZ2V1vpgefUS9lilg9hIPEj/8ZPTxf62XeyC1dQ3cOz6yPWR2sODyVECVf6mrmhZPTjVX+DorByX2uBzLDzF9jGMFMJRhxi0yVpXsqBrP+ps9G+s7oNUDp771d1Bix+gm5EyebEbdiQuf0/8wDlhY5jYAFJW1xkPKXcjJdM1FuVVS1B8zhvRVEJZUngruVfh/7jJUOWNS44F7rVz5a4r/vs84ObFIMeYdFn+uxgUqOlNMAvXLvJ2GzlPXInXW90Uv+JJ5msny/5ygGfHr2D6xOf6P7r7oSalXwjd9BcRS6/4GQAY6LVfPwrpnrpyJBiK/FhEbR+ctfDo81eKhmp0EyxvSJGW46/26/kqHvchf+rQ== ?\n", "resource_group_name": "TESTRESGROUP", "tags": null, - "timeouts": null + "timeouts": {} }, { "id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/TESTRESGROUP/providers/Microsoft.Compute/sshPublicKeys/example-key", @@ -15,6 +15,6 @@ "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCjeC5sO1EdEfZOrdVCpuOgXcXsKZg9zgfJbHgQgX1R2Nd8mNQrUjpsB4XLHNZ3T6UYrsSh7oxYC3UFu6peO4LmA2WTe2wCWVFn9WW/Lo99WcA/G/fGj6s5HK5CHFVPXnNxM47QJMNm5BWOM55+EWP839SHLH9Fk63H575x7jxZvBvaV0uL84XuVpiEBKhnpQfT4cJGoGLOGgjM+TpHyosbKldu5q2UTF9nOGpmLuku41oihqiPPSJnJRv3TDKFi4mIl9Iz5HJINWvLl1kdCfyjPcHcH5GO0tuA9rP5AbsmG5EAGOKtuFipYA4MyY9SYriZ2V1vpgefUS9lilg9hIPEj/8ZPTxf62XeyC1dQ3cOz6yPWR2sODyVECVf6mrmhZPTjVX+DorByX2uBzLDzF9jGMFMJRhxi0yVpXsqBrP+ps9G+s7oNUDp771d1Bix+gm5EyebEbdiQuf0/8wDlhY5jYAFJW1xkPKXcjJdM1FuVVS1B8zhvRVEJZUngruVfh/7jJUOWNS44F7rVz5a4r/vs84ObFIMeYdFn+uxgUqOlNMAvXLvJ2GzlPXInXW90Uv+JJ5msny/5ygGfHr2D6xOf6P7r7oSalXwjd9BcRS6/4GQAY6LVfPwrpnrpyJBiK/FhEbR+ctfDo81eKhmp0EyxvSJGW46/26/kqHvchf+rQ== ?\n", "resource_group_name": "TESTRESGROUP", "tags": null, - "timeouts": null + "timeouts": {} } ] \ No newline at end of file diff --git a/pkg/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzE=.res.golden.json b/enumeration/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzE=.res.golden.json similarity index 100% rename from pkg/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzE=.res.golden.json rename to enumeration/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzE=.res.golden.json diff --git a/pkg/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzI=.res.golden.json b/enumeration/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzI=.res.golden.json similarity index 100% rename from pkg/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzI=.res.golden.json rename to enumeration/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzI=.res.golden.json diff --git a/pkg/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzQ=.res.golden.json b/enumeration/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzQ=.res.golden.json similarity index 100% rename from pkg/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzQ=.res.golden.json rename to enumeration/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzQ=.res.golden.json diff --git a/pkg/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0Nzc=.res.golden.json b/enumeration/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0Nzc=.res.golden.json similarity index 100% rename from pkg/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0Nzc=.res.golden.json rename to enumeration/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0Nzc=.res.golden.json diff --git a/pkg/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0Nzg=.res.golden.json b/enumeration/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0Nzg=.res.golden.json similarity index 100% rename from pkg/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0Nzg=.res.golden.json rename to enumeration/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0Nzg=.res.golden.json diff --git a/pkg/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0ODA=.res.golden.json b/enumeration/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0ODA=.res.golden.json similarity index 100% rename from pkg/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0ODA=.res.golden.json rename to enumeration/remote/test/github_branch_protection_multiples/github_branch_protection-MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0ODA=.res.golden.json diff --git a/pkg/remote/test/github_branch_protection_multiples/results.golden.json b/enumeration/remote/test/github_branch_protection_multiples/results.golden.json similarity index 100% rename from pkg/remote/test/github_branch_protection_multiples/results.golden.json rename to enumeration/remote/test/github_branch_protection_multiples/results.golden.json diff --git a/pkg/remote/test/github_branch_protection_multiples/terraform.tf b/enumeration/remote/test/github_branch_protection_multiples/terraform.tf similarity index 100% rename from pkg/remote/test/github_branch_protection_multiples/terraform.tf rename to enumeration/remote/test/github_branch_protection_multiples/terraform.tf diff --git a/pkg/remote/test/github_membership_multiple/github_membership-driftctl-test_driftctl-acceptance-tester.res.golden.json b/enumeration/remote/test/github_membership_multiple/github_membership-driftctl-test_driftctl-acceptance-tester.res.golden.json similarity index 100% rename from pkg/remote/test/github_membership_multiple/github_membership-driftctl-test_driftctl-acceptance-tester.res.golden.json rename to enumeration/remote/test/github_membership_multiple/github_membership-driftctl-test_driftctl-acceptance-tester.res.golden.json diff --git a/pkg/remote/test/github_membership_multiple/github_membership-driftctl-test_eliecharra.res.golden.json b/enumeration/remote/test/github_membership_multiple/github_membership-driftctl-test_eliecharra.res.golden.json similarity index 100% rename from pkg/remote/test/github_membership_multiple/github_membership-driftctl-test_eliecharra.res.golden.json rename to enumeration/remote/test/github_membership_multiple/github_membership-driftctl-test_eliecharra.res.golden.json diff --git a/pkg/remote/test/github_membership_multiple/results.golden.json b/enumeration/remote/test/github_membership_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/github_membership_multiple/results.golden.json rename to enumeration/remote/test/github_membership_multiple/results.golden.json diff --git a/pkg/remote/test/github_repository_multiple/github_repository-driftctl-demos.res.golden.json b/enumeration/remote/test/github_repository_multiple/github_repository-driftctl-demos.res.golden.json similarity index 100% rename from pkg/remote/test/github_repository_multiple/github_repository-driftctl-demos.res.golden.json rename to enumeration/remote/test/github_repository_multiple/github_repository-driftctl-demos.res.golden.json diff --git a/pkg/remote/test/github_repository_multiple/github_repository-driftctl.res.golden.json b/enumeration/remote/test/github_repository_multiple/github_repository-driftctl.res.golden.json similarity index 100% rename from pkg/remote/test/github_repository_multiple/github_repository-driftctl.res.golden.json rename to enumeration/remote/test/github_repository_multiple/github_repository-driftctl.res.golden.json diff --git a/pkg/remote/test/github_repository_multiple/results.golden.json b/enumeration/remote/test/github_repository_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/github_repository_multiple/results.golden.json rename to enumeration/remote/test/github_repository_multiple/results.golden.json diff --git a/pkg/remote/test/github_team_membership_multiple/github_team_membership-4570529_driftctl-acceptance-tester.res.golden.json b/enumeration/remote/test/github_team_membership_multiple/github_team_membership-4570529_driftctl-acceptance-tester.res.golden.json similarity index 100% rename from pkg/remote/test/github_team_membership_multiple/github_team_membership-4570529_driftctl-acceptance-tester.res.golden.json rename to enumeration/remote/test/github_team_membership_multiple/github_team_membership-4570529_driftctl-acceptance-tester.res.golden.json diff --git a/pkg/remote/test/github_team_membership_multiple/github_team_membership-4570529_wbeuil.res.golden.json b/enumeration/remote/test/github_team_membership_multiple/github_team_membership-4570529_wbeuil.res.golden.json similarity index 100% rename from pkg/remote/test/github_team_membership_multiple/github_team_membership-4570529_wbeuil.res.golden.json rename to enumeration/remote/test/github_team_membership_multiple/github_team_membership-4570529_wbeuil.res.golden.json diff --git a/pkg/remote/test/github_team_membership_multiple/results.golden.json b/enumeration/remote/test/github_team_membership_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/github_team_membership_multiple/results.golden.json rename to enumeration/remote/test/github_team_membership_multiple/results.golden.json diff --git a/pkg/remote/test/github_team_membership_multiple/terraform.tf b/enumeration/remote/test/github_team_membership_multiple/terraform.tf similarity index 100% rename from pkg/remote/test/github_team_membership_multiple/terraform.tf rename to enumeration/remote/test/github_team_membership_multiple/terraform.tf diff --git a/pkg/remote/test/github_teams_multiple/github_team-4556811.res.golden.json b/enumeration/remote/test/github_teams_multiple/github_team-4556811.res.golden.json similarity index 100% rename from pkg/remote/test/github_teams_multiple/github_team-4556811.res.golden.json rename to enumeration/remote/test/github_teams_multiple/github_team-4556811.res.golden.json diff --git a/pkg/remote/test/github_teams_multiple/github_team-4556812.res.golden.json b/enumeration/remote/test/github_teams_multiple/github_team-4556812.res.golden.json similarity index 100% rename from pkg/remote/test/github_teams_multiple/github_team-4556812.res.golden.json rename to enumeration/remote/test/github_teams_multiple/github_team-4556812.res.golden.json diff --git a/pkg/remote/test/github_teams_multiple/github_team-4556814.res.golden.json b/enumeration/remote/test/github_teams_multiple/github_team-4556814.res.golden.json similarity index 100% rename from pkg/remote/test/github_teams_multiple/github_team-4556814.res.golden.json rename to enumeration/remote/test/github_teams_multiple/github_team-4556814.res.golden.json diff --git a/pkg/remote/test/github_teams_multiple/results.golden.json b/enumeration/remote/test/github_teams_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/github_teams_multiple/results.golden.json rename to enumeration/remote/test/github_teams_multiple/results.golden.json diff --git a/pkg/remote/test/google_compute_firewall/google_compute_firewall-projects_cloudskiff-dev-elie_global_firewalls_test-firewall-0-test-firewall-0-cloudskiff-dev-elie.res.golden.json b/enumeration/remote/test/google_compute_firewall/google_compute_firewall-projects_cloudskiff-dev-elie_global_firewalls_test-firewall-0-test-firewall-0-cloudskiff-dev-elie.res.golden.json similarity index 100% rename from pkg/remote/test/google_compute_firewall/google_compute_firewall-projects_cloudskiff-dev-elie_global_firewalls_test-firewall-0-test-firewall-0-cloudskiff-dev-elie.res.golden.json rename to enumeration/remote/test/google_compute_firewall/google_compute_firewall-projects_cloudskiff-dev-elie_global_firewalls_test-firewall-0-test-firewall-0-cloudskiff-dev-elie.res.golden.json diff --git a/pkg/remote/test/google_compute_firewall/google_compute_firewall-projects_cloudskiff-dev-elie_global_firewalls_test-firewall-1-test-firewall-1-cloudskiff-dev-elie.res.golden.json b/enumeration/remote/test/google_compute_firewall/google_compute_firewall-projects_cloudskiff-dev-elie_global_firewalls_test-firewall-1-test-firewall-1-cloudskiff-dev-elie.res.golden.json similarity index 100% rename from pkg/remote/test/google_compute_firewall/google_compute_firewall-projects_cloudskiff-dev-elie_global_firewalls_test-firewall-1-test-firewall-1-cloudskiff-dev-elie.res.golden.json rename to enumeration/remote/test/google_compute_firewall/google_compute_firewall-projects_cloudskiff-dev-elie_global_firewalls_test-firewall-1-test-firewall-1-cloudskiff-dev-elie.res.golden.json diff --git a/pkg/remote/test/google_compute_firewall/google_compute_firewall-projects_cloudskiff-dev-elie_global_firewalls_test-firewall-2-test-firewall-2-cloudskiff-dev-elie.res.golden.json b/enumeration/remote/test/google_compute_firewall/google_compute_firewall-projects_cloudskiff-dev-elie_global_firewalls_test-firewall-2-test-firewall-2-cloudskiff-dev-elie.res.golden.json similarity index 100% rename from pkg/remote/test/google_compute_firewall/google_compute_firewall-projects_cloudskiff-dev-elie_global_firewalls_test-firewall-2-test-firewall-2-cloudskiff-dev-elie.res.golden.json rename to enumeration/remote/test/google_compute_firewall/google_compute_firewall-projects_cloudskiff-dev-elie_global_firewalls_test-firewall-2-test-firewall-2-cloudskiff-dev-elie.res.golden.json diff --git a/pkg/remote/test/google_compute_firewall/results.golden.json b/enumeration/remote/test/google_compute_firewall/results.golden.json similarity index 98% rename from pkg/remote/test/google_compute_firewall/results.golden.json rename to enumeration/remote/test/google_compute_firewall/results.golden.json index f82df3cde..b6948683b 100755 --- a/pkg/remote/test/google_compute_firewall/results.golden.json +++ b/enumeration/remote/test/google_compute_firewall/results.golden.json @@ -35,7 +35,7 @@ ], "target_service_accounts": null, "target_tags": null, - "timeouts": null + "timeouts": {} }, { "allow": [ @@ -73,7 +73,7 @@ ], "target_service_accounts": null, "target_tags": null, - "timeouts": null + "timeouts": {} }, { "allow": [ @@ -111,6 +111,6 @@ ], "target_service_accounts": null, "target_tags": null, - "timeouts": null + "timeouts": {} } ] \ No newline at end of file diff --git a/pkg/remote/test/google_compute_firewall/terraform.tf b/enumeration/remote/test/google_compute_firewall/terraform.tf similarity index 100% rename from pkg/remote/test/google_compute_firewall/terraform.tf rename to enumeration/remote/test/google_compute_firewall/terraform.tf diff --git a/pkg/remote/test/google_compute_instance_group/google_compute_instance_group-projects_cloudskiff-dev-raphael_zones_us-central1-a_instanceGroups_driftctl-test-1-driftctl-test-1-cloudskiff-dev-raphael-us-central1-a.res.golden.json b/enumeration/remote/test/google_compute_instance_group/google_compute_instance_group-projects_cloudskiff-dev-raphael_zones_us-central1-a_instanceGroups_driftctl-test-1-driftctl-test-1-cloudskiff-dev-raphael-us-central1-a.res.golden.json similarity index 100% rename from pkg/remote/test/google_compute_instance_group/google_compute_instance_group-projects_cloudskiff-dev-raphael_zones_us-central1-a_instanceGroups_driftctl-test-1-driftctl-test-1-cloudskiff-dev-raphael-us-central1-a.res.golden.json rename to enumeration/remote/test/google_compute_instance_group/google_compute_instance_group-projects_cloudskiff-dev-raphael_zones_us-central1-a_instanceGroups_driftctl-test-1-driftctl-test-1-cloudskiff-dev-raphael-us-central1-a.res.golden.json diff --git a/pkg/remote/test/google_compute_instance_group/google_compute_instance_group-projects_cloudskiff-dev-raphael_zones_us-central1-a_instanceGroups_driftctl-test-2-driftctl-test-2-cloudskiff-dev-raphael-us-central1-a.res.golden.json b/enumeration/remote/test/google_compute_instance_group/google_compute_instance_group-projects_cloudskiff-dev-raphael_zones_us-central1-a_instanceGroups_driftctl-test-2-driftctl-test-2-cloudskiff-dev-raphael-us-central1-a.res.golden.json similarity index 100% rename from pkg/remote/test/google_compute_instance_group/google_compute_instance_group-projects_cloudskiff-dev-raphael_zones_us-central1-a_instanceGroups_driftctl-test-2-driftctl-test-2-cloudskiff-dev-raphael-us-central1-a.res.golden.json rename to enumeration/remote/test/google_compute_instance_group/google_compute_instance_group-projects_cloudskiff-dev-raphael_zones_us-central1-a_instanceGroups_driftctl-test-2-driftctl-test-2-cloudskiff-dev-raphael-us-central1-a.res.golden.json diff --git a/pkg/remote/test/google_compute_instance_group/results.golden.json b/enumeration/remote/test/google_compute_instance_group/results.golden.json similarity index 96% rename from pkg/remote/test/google_compute_instance_group/results.golden.json rename to enumeration/remote/test/google_compute_instance_group/results.golden.json index cc28d15ff..b1bfeceb7 100755 --- a/pkg/remote/test/google_compute_instance_group/results.golden.json +++ b/enumeration/remote/test/google_compute_instance_group/results.golden.json @@ -9,7 +9,7 @@ "project": "cloudskiff-dev-raphael", "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-2", "size": 0, - "timeouts": null, + "timeouts": {}, "zone": "us-central1-a" }, { @@ -22,7 +22,7 @@ "project": "cloudskiff-dev-raphael", "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-1", "size": 0, - "timeouts": null, + "timeouts": {}, "zone": "us-central1-a" } ] \ No newline at end of file diff --git a/pkg/remote/test/google_compute_instance_group/terraform.tf b/enumeration/remote/test/google_compute_instance_group/terraform.tf similarity index 100% rename from pkg/remote/test/google_compute_instance_group/terraform.tf rename to enumeration/remote/test/google_compute_instance_group/terraform.tf diff --git a/pkg/remote/test/google_compute_network/google_compute_network-projects_driftctl-qa-1_global_networks_driftctl-unittest-1-driftctl-unittest-1.res.golden.json b/enumeration/remote/test/google_compute_network/google_compute_network-projects_driftctl-qa-1_global_networks_driftctl-unittest-1-driftctl-unittest-1.res.golden.json similarity index 100% rename from pkg/remote/test/google_compute_network/google_compute_network-projects_driftctl-qa-1_global_networks_driftctl-unittest-1-driftctl-unittest-1.res.golden.json rename to enumeration/remote/test/google_compute_network/google_compute_network-projects_driftctl-qa-1_global_networks_driftctl-unittest-1-driftctl-unittest-1.res.golden.json diff --git a/pkg/remote/test/google_compute_network/google_compute_network-projects_driftctl-qa-1_global_networks_driftctl-unittest-2-driftctl-unittest-2.res.golden.json b/enumeration/remote/test/google_compute_network/google_compute_network-projects_driftctl-qa-1_global_networks_driftctl-unittest-2-driftctl-unittest-2.res.golden.json similarity index 100% rename from pkg/remote/test/google_compute_network/google_compute_network-projects_driftctl-qa-1_global_networks_driftctl-unittest-2-driftctl-unittest-2.res.golden.json rename to enumeration/remote/test/google_compute_network/google_compute_network-projects_driftctl-qa-1_global_networks_driftctl-unittest-2-driftctl-unittest-2.res.golden.json diff --git a/pkg/remote/test/google_compute_network/google_compute_network-projects_driftctl-qa-1_global_networks_driftctl-unittest-3-driftctl-unittest-3.res.golden.json b/enumeration/remote/test/google_compute_network/google_compute_network-projects_driftctl-qa-1_global_networks_driftctl-unittest-3-driftctl-unittest-3.res.golden.json similarity index 100% rename from pkg/remote/test/google_compute_network/google_compute_network-projects_driftctl-qa-1_global_networks_driftctl-unittest-3-driftctl-unittest-3.res.golden.json rename to enumeration/remote/test/google_compute_network/google_compute_network-projects_driftctl-qa-1_global_networks_driftctl-unittest-3-driftctl-unittest-3.res.golden.json diff --git a/pkg/remote/test/google_compute_network/results.golden.json b/enumeration/remote/test/google_compute_network/results.golden.json similarity index 65% rename from pkg/remote/test/google_compute_network/results.golden.json rename to enumeration/remote/test/google_compute_network/results.golden.json index e6e2f8f61..c160ca26f 100755 --- a/pkg/remote/test/google_compute_network/results.golden.json +++ b/enumeration/remote/test/google_compute_network/results.golden.json @@ -3,39 +3,39 @@ "auto_create_subnetworks": false, "delete_default_routes_on_create": false, "description": "", - "gateway_ipv4": null, + "gateway_ipv4": "", "id": "projects/driftctl-qa-1/global/networks/driftctl-unittest-3", "mtu": 1460, "name": "driftctl-unittest-3", "project": "driftctl-qa-1", "routing_mode": "REGIONAL", - "self_link": null, - "timeouts": null + "self_link": "https://www.googleapis.com/compute/v1/projects/driftctl-qa-1/global/networks/driftctl-unittest-3", + "timeouts": {} }, { "auto_create_subnetworks": true, "delete_default_routes_on_create": false, "description": "", - "gateway_ipv4": null, + "gateway_ipv4": "", "id": "projects/driftctl-qa-1/global/networks/driftctl-unittest-2", "mtu": 1460, "name": "driftctl-unittest-2", "project": "driftctl-qa-1", "routing_mode": "REGIONAL", - "self_link": null, - "timeouts": null + "self_link": "https://www.googleapis.com/compute/v1/projects/driftctl-qa-1/global/networks/driftctl-unittest-2", + "timeouts": {} }, { "auto_create_subnetworks": false, "delete_default_routes_on_create": false, "description": "", - "gateway_ipv4": null, + "gateway_ipv4": "", "id": "projects/driftctl-qa-1/global/networks/driftctl-unittest-1", "mtu": 1460, "name": "driftctl-unittest-1", "project": "driftctl-qa-1", "routing_mode": "REGIONAL", - "self_link": null, - "timeouts": null + "self_link": "https://www.googleapis.com/compute/v1/projects/driftctl-qa-1/global/networks/driftctl-unittest-1", + "timeouts": {} } ] \ No newline at end of file diff --git a/pkg/remote/test/google_compute_subnetwork_multiple/google_compute_subnetwork-projects_cloudskiff-dev-raphael_regions_us-central1_subnetworks_driftctl-unittest-1-driftctl-unittest-1-.res.golden.json b/enumeration/remote/test/google_compute_subnetwork_multiple/google_compute_subnetwork-projects_cloudskiff-dev-raphael_regions_us-central1_subnetworks_driftctl-unittest-1-driftctl-unittest-1-.res.golden.json similarity index 100% rename from pkg/remote/test/google_compute_subnetwork_multiple/google_compute_subnetwork-projects_cloudskiff-dev-raphael_regions_us-central1_subnetworks_driftctl-unittest-1-driftctl-unittest-1-.res.golden.json rename to enumeration/remote/test/google_compute_subnetwork_multiple/google_compute_subnetwork-projects_cloudskiff-dev-raphael_regions_us-central1_subnetworks_driftctl-unittest-1-driftctl-unittest-1-.res.golden.json diff --git a/pkg/remote/test/google_compute_subnetwork_multiple/google_compute_subnetwork-projects_cloudskiff-dev-raphael_regions_us-central1_subnetworks_driftctl-unittest-2-driftctl-unittest-2-.res.golden.json b/enumeration/remote/test/google_compute_subnetwork_multiple/google_compute_subnetwork-projects_cloudskiff-dev-raphael_regions_us-central1_subnetworks_driftctl-unittest-2-driftctl-unittest-2-.res.golden.json similarity index 100% rename from pkg/remote/test/google_compute_subnetwork_multiple/google_compute_subnetwork-projects_cloudskiff-dev-raphael_regions_us-central1_subnetworks_driftctl-unittest-2-driftctl-unittest-2-.res.golden.json rename to enumeration/remote/test/google_compute_subnetwork_multiple/google_compute_subnetwork-projects_cloudskiff-dev-raphael_regions_us-central1_subnetworks_driftctl-unittest-2-driftctl-unittest-2-.res.golden.json diff --git a/pkg/remote/test/google_compute_subnetwork_multiple/google_compute_subnetwork-projects_cloudskiff-dev-raphael_regions_us-central1_subnetworks_driftctl-unittest-3-driftctl-unittest-3-.res.golden.json b/enumeration/remote/test/google_compute_subnetwork_multiple/google_compute_subnetwork-projects_cloudskiff-dev-raphael_regions_us-central1_subnetworks_driftctl-unittest-3-driftctl-unittest-3-.res.golden.json similarity index 100% rename from pkg/remote/test/google_compute_subnetwork_multiple/google_compute_subnetwork-projects_cloudskiff-dev-raphael_regions_us-central1_subnetworks_driftctl-unittest-3-driftctl-unittest-3-.res.golden.json rename to enumeration/remote/test/google_compute_subnetwork_multiple/google_compute_subnetwork-projects_cloudskiff-dev-raphael_regions_us-central1_subnetworks_driftctl-unittest-3-driftctl-unittest-3-.res.golden.json diff --git a/pkg/remote/test/google_compute_subnetwork_multiple/results.golden.json b/enumeration/remote/test/google_compute_subnetwork_multiple/results.golden.json similarity index 82% rename from pkg/remote/test/google_compute_subnetwork_multiple/results.golden.json rename to enumeration/remote/test/google_compute_subnetwork_multiple/results.golden.json index 8a6a07c4c..074a306ef 100755 --- a/pkg/remote/test/google_compute_subnetwork_multiple/results.golden.json +++ b/enumeration/remote/test/google_compute_subnetwork_multiple/results.golden.json @@ -19,8 +19,8 @@ "range_name": "tf-test-secondary-range-update1" } ], - "self_link": null, - "timeouts": null + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/regions/us-central1/subnetworks/driftctl-unittest-1", + "timeouts": {} }, { "creation_timestamp": "2021-10-20T07:39:45.114-07:00", @@ -42,8 +42,8 @@ "range_name": "tf-test-secondary-range-update1" } ], - "self_link": null, - "timeouts": null + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/regions/us-central1/subnetworks/driftctl-unittest-2", + "timeouts": {} }, { "creation_timestamp": "2021-10-20T07:39:34.650-07:00", @@ -65,7 +65,7 @@ "range_name": "tf-test-secondary-range-update1" } ], - "self_link": null, - "timeouts": null + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/regions/us-central1/subnetworks/driftctl-unittest-3", + "timeouts": {} } ] \ No newline at end of file diff --git a/pkg/remote/test/google_project_member_listing_multiple/results.golden.json b/enumeration/remote/test/google_project_member_listing_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/google_project_member_listing_multiple/results.golden.json rename to enumeration/remote/test/google_project_member_listing_multiple/results.golden.json diff --git a/pkg/remote/test/google_storage_bucket/google_storage_bucket-driftctl-unittest-1-driftctl-unittest-1.res.golden.json b/enumeration/remote/test/google_storage_bucket/google_storage_bucket-driftctl-unittest-1-driftctl-unittest-1.res.golden.json similarity index 100% rename from pkg/remote/test/google_storage_bucket/google_storage_bucket-driftctl-unittest-1-driftctl-unittest-1.res.golden.json rename to enumeration/remote/test/google_storage_bucket/google_storage_bucket-driftctl-unittest-1-driftctl-unittest-1.res.golden.json diff --git a/pkg/remote/test/google_storage_bucket/google_storage_bucket-driftctl-unittest-2-driftctl-unittest-2.res.golden.json b/enumeration/remote/test/google_storage_bucket/google_storage_bucket-driftctl-unittest-2-driftctl-unittest-2.res.golden.json similarity index 100% rename from pkg/remote/test/google_storage_bucket/google_storage_bucket-driftctl-unittest-2-driftctl-unittest-2.res.golden.json rename to enumeration/remote/test/google_storage_bucket/google_storage_bucket-driftctl-unittest-2-driftctl-unittest-2.res.golden.json diff --git a/pkg/remote/test/google_storage_bucket/google_storage_bucket-driftctl-unittest-3-driftctl-unittest-3.res.golden.json b/enumeration/remote/test/google_storage_bucket/google_storage_bucket-driftctl-unittest-3-driftctl-unittest-3.res.golden.json similarity index 100% rename from pkg/remote/test/google_storage_bucket/google_storage_bucket-driftctl-unittest-3-driftctl-unittest-3.res.golden.json rename to enumeration/remote/test/google_storage_bucket/google_storage_bucket-driftctl-unittest-3-driftctl-unittest-3.res.golden.json diff --git a/pkg/remote/test/google_storage_bucket/results.golden.json b/enumeration/remote/test/google_storage_bucket/results.golden.json similarity index 100% rename from pkg/remote/test/google_storage_bucket/results.golden.json rename to enumeration/remote/test/google_storage_bucket/results.golden.json diff --git a/pkg/remote/test/google_storage_bucket_member_listing_multiple/results.golden.json b/enumeration/remote/test/google_storage_bucket_member_listing_multiple/results.golden.json similarity index 100% rename from pkg/remote/test/google_storage_bucket_member_listing_multiple/results.golden.json rename to enumeration/remote/test/google_storage_bucket_member_listing_multiple/results.golden.json diff --git a/pkg/resource/aws/aws_alb.go b/enumeration/resource/aws/aws_alb.go similarity index 100% rename from pkg/resource/aws/aws_alb.go rename to enumeration/resource/aws/aws_alb.go diff --git a/pkg/resource/aws/aws_alb_listener.go b/enumeration/resource/aws/aws_alb_listener.go similarity index 100% rename from pkg/resource/aws/aws_alb_listener.go rename to enumeration/resource/aws/aws_alb_listener.go diff --git a/enumeration/resource/aws/aws_ami.go b/enumeration/resource/aws/aws_ami.go new file mode 100644 index 000000000..ac8fec7db --- /dev/null +++ b/enumeration/resource/aws/aws_ami.go @@ -0,0 +1,11 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsAmiResourceType = "aws_ami" + +func initAwsAmiMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsAmiResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_api_gateway_account.go b/enumeration/resource/aws/aws_api_gateway_account.go similarity index 100% rename from pkg/resource/aws/aws_api_gateway_account.go rename to enumeration/resource/aws/aws_api_gateway_account.go diff --git a/pkg/resource/aws/aws_api_gateway_api_key.go b/enumeration/resource/aws/aws_api_gateway_api_key.go similarity index 100% rename from pkg/resource/aws/aws_api_gateway_api_key.go rename to enumeration/resource/aws/aws_api_gateway_api_key.go diff --git a/pkg/resource/aws/aws_api_gateway_authorizer.go b/enumeration/resource/aws/aws_api_gateway_authorizer.go similarity index 100% rename from pkg/resource/aws/aws_api_gateway_authorizer.go rename to enumeration/resource/aws/aws_api_gateway_authorizer.go diff --git a/pkg/resource/aws/aws_api_gateway_base_path_mapping.go b/enumeration/resource/aws/aws_api_gateway_base_path_mapping.go similarity index 100% rename from pkg/resource/aws/aws_api_gateway_base_path_mapping.go rename to enumeration/resource/aws/aws_api_gateway_base_path_mapping.go diff --git a/pkg/resource/aws/aws_api_gateway_deployment.go b/enumeration/resource/aws/aws_api_gateway_deployment.go similarity index 100% rename from pkg/resource/aws/aws_api_gateway_deployment.go rename to enumeration/resource/aws/aws_api_gateway_deployment.go diff --git a/pkg/resource/aws/aws_api_gateway_domain_name.go b/enumeration/resource/aws/aws_api_gateway_domain_name.go similarity index 100% rename from pkg/resource/aws/aws_api_gateway_domain_name.go rename to enumeration/resource/aws/aws_api_gateway_domain_name.go diff --git a/pkg/resource/aws/aws_api_gateway_gateway_response.go b/enumeration/resource/aws/aws_api_gateway_gateway_response.go similarity index 100% rename from pkg/resource/aws/aws_api_gateway_gateway_response.go rename to enumeration/resource/aws/aws_api_gateway_gateway_response.go diff --git a/pkg/resource/aws/aws_api_gateway_integration.go b/enumeration/resource/aws/aws_api_gateway_integration.go similarity index 100% rename from pkg/resource/aws/aws_api_gateway_integration.go rename to enumeration/resource/aws/aws_api_gateway_integration.go diff --git a/pkg/resource/aws/aws_api_gateway_integration_response.go b/enumeration/resource/aws/aws_api_gateway_integration_response.go similarity index 100% rename from pkg/resource/aws/aws_api_gateway_integration_response.go rename to enumeration/resource/aws/aws_api_gateway_integration_response.go diff --git a/pkg/resource/aws/aws_api_gateway_method.go b/enumeration/resource/aws/aws_api_gateway_method.go similarity index 100% rename from pkg/resource/aws/aws_api_gateway_method.go rename to enumeration/resource/aws/aws_api_gateway_method.go diff --git a/pkg/resource/aws/aws_api_gateway_method_response.go b/enumeration/resource/aws/aws_api_gateway_method_response.go similarity index 100% rename from pkg/resource/aws/aws_api_gateway_method_response.go rename to enumeration/resource/aws/aws_api_gateway_method_response.go diff --git a/pkg/resource/aws/aws_api_gateway_method_settings.go b/enumeration/resource/aws/aws_api_gateway_method_settings.go similarity index 100% rename from pkg/resource/aws/aws_api_gateway_method_settings.go rename to enumeration/resource/aws/aws_api_gateway_method_settings.go diff --git a/pkg/resource/aws/aws_api_gateway_model.go b/enumeration/resource/aws/aws_api_gateway_model.go similarity index 100% rename from pkg/resource/aws/aws_api_gateway_model.go rename to enumeration/resource/aws/aws_api_gateway_model.go diff --git a/pkg/resource/aws/aws_api_gateway_request_validator.go b/enumeration/resource/aws/aws_api_gateway_request_validator.go similarity index 100% rename from pkg/resource/aws/aws_api_gateway_request_validator.go rename to enumeration/resource/aws/aws_api_gateway_request_validator.go diff --git a/pkg/resource/aws/aws_api_gateway_resource.go b/enumeration/resource/aws/aws_api_gateway_resource.go similarity index 100% rename from pkg/resource/aws/aws_api_gateway_resource.go rename to enumeration/resource/aws/aws_api_gateway_resource.go diff --git a/pkg/resource/aws/aws_api_gateway_rest_api.go b/enumeration/resource/aws/aws_api_gateway_rest_api.go similarity index 100% rename from pkg/resource/aws/aws_api_gateway_rest_api.go rename to enumeration/resource/aws/aws_api_gateway_rest_api.go diff --git a/pkg/resource/aws/aws_api_gateway_rest_api_policy.go b/enumeration/resource/aws/aws_api_gateway_rest_api_policy.go similarity index 100% rename from pkg/resource/aws/aws_api_gateway_rest_api_policy.go rename to enumeration/resource/aws/aws_api_gateway_rest_api_policy.go diff --git a/pkg/resource/aws/aws_api_gateway_stage.go b/enumeration/resource/aws/aws_api_gateway_stage.go similarity index 100% rename from pkg/resource/aws/aws_api_gateway_stage.go rename to enumeration/resource/aws/aws_api_gateway_stage.go diff --git a/pkg/resource/aws/aws_api_gateway_vpc_link.go b/enumeration/resource/aws/aws_api_gateway_vpc_link.go similarity index 100% rename from pkg/resource/aws/aws_api_gateway_vpc_link.go rename to enumeration/resource/aws/aws_api_gateway_vpc_link.go diff --git a/pkg/resource/aws/aws_apigatewayv2_api.go b/enumeration/resource/aws/aws_apigatewayv2_api.go similarity index 100% rename from pkg/resource/aws/aws_apigatewayv2_api.go rename to enumeration/resource/aws/aws_apigatewayv2_api.go diff --git a/pkg/resource/aws/aws_apigatewayv2_authorizer.go b/enumeration/resource/aws/aws_apigatewayv2_authorizer.go similarity index 100% rename from pkg/resource/aws/aws_apigatewayv2_authorizer.go rename to enumeration/resource/aws/aws_apigatewayv2_authorizer.go diff --git a/pkg/resource/aws/aws_apigatewayv2_deployment.go b/enumeration/resource/aws/aws_apigatewayv2_deployment.go similarity index 100% rename from pkg/resource/aws/aws_apigatewayv2_deployment.go rename to enumeration/resource/aws/aws_apigatewayv2_deployment.go diff --git a/pkg/resource/aws/aws_apigatewayv2_domain_name.go b/enumeration/resource/aws/aws_apigatewayv2_domain_name.go similarity index 100% rename from pkg/resource/aws/aws_apigatewayv2_domain_name.go rename to enumeration/resource/aws/aws_apigatewayv2_domain_name.go diff --git a/pkg/resource/aws/aws_apigatewayv2_integration.go b/enumeration/resource/aws/aws_apigatewayv2_integration.go similarity index 100% rename from pkg/resource/aws/aws_apigatewayv2_integration.go rename to enumeration/resource/aws/aws_apigatewayv2_integration.go diff --git a/pkg/resource/aws/aws_apigatewayv2_integration_response.go b/enumeration/resource/aws/aws_apigatewayv2_integration_response.go similarity index 100% rename from pkg/resource/aws/aws_apigatewayv2_integration_response.go rename to enumeration/resource/aws/aws_apigatewayv2_integration_response.go diff --git a/pkg/resource/aws/aws_apigatewayv2_mapping.go b/enumeration/resource/aws/aws_apigatewayv2_mapping.go similarity index 91% rename from pkg/resource/aws/aws_apigatewayv2_mapping.go rename to enumeration/resource/aws/aws_apigatewayv2_mapping.go index 7bd053071..dd563a9a2 100644 --- a/pkg/resource/aws/aws_apigatewayv2_mapping.go +++ b/enumeration/resource/aws/aws_apigatewayv2_mapping.go @@ -1,6 +1,6 @@ package aws -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const AwsApiGatewayV2MappingResourceType = "aws_apigatewayv2_api_mapping" diff --git a/pkg/resource/aws/aws_apigatewayv2_model.go b/enumeration/resource/aws/aws_apigatewayv2_model.go similarity index 88% rename from pkg/resource/aws/aws_apigatewayv2_model.go rename to enumeration/resource/aws/aws_apigatewayv2_model.go index 3919784fe..471ae4937 100644 --- a/pkg/resource/aws/aws_apigatewayv2_model.go +++ b/enumeration/resource/aws/aws_apigatewayv2_model.go @@ -1,6 +1,6 @@ package aws -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const AwsApiGatewayV2ModelResourceType = "aws_apigatewayv2_model" diff --git a/pkg/resource/aws/aws_apigatewayv2_route.go b/enumeration/resource/aws/aws_apigatewayv2_route.go similarity index 100% rename from pkg/resource/aws/aws_apigatewayv2_route.go rename to enumeration/resource/aws/aws_apigatewayv2_route.go diff --git a/pkg/resource/aws/aws_apigatewayv2_route_response.go b/enumeration/resource/aws/aws_apigatewayv2_route_response.go similarity index 100% rename from pkg/resource/aws/aws_apigatewayv2_route_response.go rename to enumeration/resource/aws/aws_apigatewayv2_route_response.go diff --git a/pkg/resource/aws/aws_apigatewayv2_stage.go b/enumeration/resource/aws/aws_apigatewayv2_stage.go similarity index 100% rename from pkg/resource/aws/aws_apigatewayv2_stage.go rename to enumeration/resource/aws/aws_apigatewayv2_stage.go diff --git a/pkg/resource/aws/aws_apigatewayv2_vpc_link.go b/enumeration/resource/aws/aws_apigatewayv2_vpc_link.go similarity index 100% rename from pkg/resource/aws/aws_apigatewayv2_vpc_link.go rename to enumeration/resource/aws/aws_apigatewayv2_vpc_link.go diff --git a/pkg/resource/aws/aws_appautoscaling_policy.go b/enumeration/resource/aws/aws_appautoscaling_policy.go similarity index 95% rename from pkg/resource/aws/aws_appautoscaling_policy.go rename to enumeration/resource/aws/aws_appautoscaling_policy.go index 1bd7ce6c5..b212828a1 100644 --- a/pkg/resource/aws/aws_appautoscaling_policy.go +++ b/enumeration/resource/aws/aws_appautoscaling_policy.go @@ -1,6 +1,6 @@ package aws -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const AwsAppAutoscalingPolicyResourceType = "aws_appautoscaling_policy" diff --git a/pkg/resource/aws/aws_appautoscaling_scheduled_action.go b/enumeration/resource/aws/aws_appautoscaling_scheduled_action.go similarity index 100% rename from pkg/resource/aws/aws_appautoscaling_scheduled_action.go rename to enumeration/resource/aws/aws_appautoscaling_scheduled_action.go diff --git a/enumeration/resource/aws/aws_appautoscaling_target.go b/enumeration/resource/aws/aws_appautoscaling_target.go new file mode 100644 index 000000000..bd01002ad --- /dev/null +++ b/enumeration/resource/aws/aws_appautoscaling_target.go @@ -0,0 +1,22 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsAppAutoscalingTargetResourceType = "aws_appautoscaling_target" + +func initAwsAppAutoscalingTargetMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetResolveReadAttributesFunc(AwsAppAutoscalingTargetResourceType, func(res *resource.Resource) map[string]string { + return map[string]string{ + "service_namespace": *res.Attributes().GetString("service_namespace"), + "scalable_dimension": *res.Attributes().GetString("scalable_dimension"), + } + }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsAppAutoscalingTargetResourceType, func(res *resource.Resource) map[string]string { + attrs := make(map[string]string) + if v := res.Attributes().GetString("scalable_dimension"); v != nil && *v != "" { + attrs["Scalable dimension"] = *v + } + return attrs + }) + resourceSchemaRepository.SetFlags(AwsAppAutoscalingTargetResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/aws/aws_cloudformation_stack.go b/enumeration/resource/aws/aws_cloudformation_stack.go new file mode 100644 index 000000000..27531968b --- /dev/null +++ b/enumeration/resource/aws/aws_cloudformation_stack.go @@ -0,0 +1,22 @@ +package aws + +import ( + "strconv" + + "github.com/hashicorp/terraform/flatmap" + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsCloudformationStackResourceType = "aws_cloudformation_stack" + +func initAwsCloudformationStackMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetResolveReadAttributesFunc(AwsCloudformationStackResourceType, func(res *resource.Resource) map[string]string { + attrs := make(map[string]interface{}) + if v := res.Attributes().GetMap("parameters"); v != nil { + attrs["parameters.%"] = strconv.FormatInt(int64(len(v)), 10) + attrs["parameters"] = v + } + return flatmap.Flatten(attrs) + }) + resourceSchemaRepository.SetFlags(AwsCloudformationStackResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/aws/aws_cloudfront_distribution.go b/enumeration/resource/aws/aws_cloudfront_distribution.go new file mode 100644 index 000000000..8d51bbe63 --- /dev/null +++ b/enumeration/resource/aws/aws_cloudfront_distribution.go @@ -0,0 +1,11 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsCloudfrontDistributionResourceType = "aws_cloudfront_distribution" + +func initAwsCloudfrontDistributionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsCloudfrontDistributionResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/aws/aws_db_instance.go b/enumeration/resource/aws/aws_db_instance.go new file mode 100644 index 000000000..2632e5543 --- /dev/null +++ b/enumeration/resource/aws/aws_db_instance.go @@ -0,0 +1,11 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsDbInstanceResourceType = "aws_db_instance" + +func initAwsDbInstanceMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsDbInstanceResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/aws/aws_db_subnet_group.go b/enumeration/resource/aws/aws_db_subnet_group.go new file mode 100644 index 000000000..faa474c7c --- /dev/null +++ b/enumeration/resource/aws/aws_db_subnet_group.go @@ -0,0 +1,11 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsDbSubnetGroupResourceType = "aws_db_subnet_group" + +func initAwsDbSubnetGroupMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsDbSubnetGroupResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/aws/aws_default_network_acl.go b/enumeration/resource/aws/aws_default_network_acl.go new file mode 100644 index 000000000..f15deb288 --- /dev/null +++ b/enumeration/resource/aws/aws_default_network_acl.go @@ -0,0 +1,11 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsDefaultNetworkACLResourceType = "aws_default_network_acl" + +func initAwsDefaultNetworkACLMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsDefaultNetworkACLResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_default_route_table.go b/enumeration/resource/aws/aws_default_route_table.go similarity index 92% rename from pkg/resource/aws/aws_default_route_table.go rename to enumeration/resource/aws/aws_default_route_table.go index 0f18d2e89..2386d3460 100644 --- a/pkg/resource/aws/aws_default_route_table.go +++ b/enumeration/resource/aws/aws_default_route_table.go @@ -1,6 +1,6 @@ package aws -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const AwsDefaultRouteTableResourceType = "aws_default_route_table" diff --git a/enumeration/resource/aws/aws_default_security_group.go b/enumeration/resource/aws/aws_default_security_group.go new file mode 100644 index 000000000..000b24e13 --- /dev/null +++ b/enumeration/resource/aws/aws_default_security_group.go @@ -0,0 +1,11 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsDefaultSecurityGroupResourceType = "aws_default_security_group" + +func initAwsDefaultSecurityGroupMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsDefaultSecurityGroupResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/aws/aws_default_subnet.go b/enumeration/resource/aws/aws_default_subnet.go new file mode 100644 index 000000000..74702a1e7 --- /dev/null +++ b/enumeration/resource/aws/aws_default_subnet.go @@ -0,0 +1,11 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsDefaultSubnetResourceType = "aws_default_subnet" + +func initAwsDefaultSubnetMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsDefaultSubnetResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_default_vpc.go b/enumeration/resource/aws/aws_default_vpc.go similarity index 81% rename from pkg/resource/aws/aws_default_vpc.go rename to enumeration/resource/aws/aws_default_vpc.go index c9319158b..62a02a122 100644 --- a/pkg/resource/aws/aws_default_vpc.go +++ b/enumeration/resource/aws/aws_default_vpc.go @@ -1,6 +1,6 @@ package aws -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const AwsDefaultVpcResourceType = "aws_default_vpc" diff --git a/enumeration/resource/aws/aws_dynamodb_table.go b/enumeration/resource/aws/aws_dynamodb_table.go new file mode 100644 index 000000000..11bad21ea --- /dev/null +++ b/enumeration/resource/aws/aws_dynamodb_table.go @@ -0,0 +1,17 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsDynamodbTableResourceType = "aws_dynamodb_table" + +func initAwsDynamodbTableMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetResolveReadAttributesFunc(AwsDynamodbTableResourceType, func(res *resource.Resource) map[string]string { + return map[string]string{ + "table_name": res.ResourceId(), + } + }) + resourceSchemaRepository.SetFlags(AwsDynamodbTableResourceType, resource.FlagDeepMode) + +} diff --git a/pkg/resource/aws/aws_ebs_encryption_by_default.go b/enumeration/resource/aws/aws_ebs_encryption_by_default.go similarity index 84% rename from pkg/resource/aws/aws_ebs_encryption_by_default.go rename to enumeration/resource/aws/aws_ebs_encryption_by_default.go index 7676628a5..502b99f38 100644 --- a/pkg/resource/aws/aws_ebs_encryption_by_default.go +++ b/enumeration/resource/aws/aws_ebs_encryption_by_default.go @@ -1,6 +1,6 @@ package aws -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const AwsEbsEncryptionByDefaultResourceType = "aws_ebs_encryption_by_default" diff --git a/enumeration/resource/aws/aws_ebs_snapshot.go b/enumeration/resource/aws/aws_ebs_snapshot.go new file mode 100644 index 000000000..e18e2cb68 --- /dev/null +++ b/enumeration/resource/aws/aws_ebs_snapshot.go @@ -0,0 +1,11 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsEbsSnapshotResourceType = "aws_ebs_snapshot" + +func initAwsEbsSnapshotMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsEbsSnapshotResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/aws/aws_ebs_volume.go b/enumeration/resource/aws/aws_ebs_volume.go new file mode 100644 index 000000000..d362ba4ee --- /dev/null +++ b/enumeration/resource/aws/aws_ebs_volume.go @@ -0,0 +1,11 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsEbsVolumeResourceType = "aws_ebs_volume" + +func initAwsEbsVolumeMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsEbsVolumeResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/aws/aws_ecr_repository.go b/enumeration/resource/aws/aws_ecr_repository.go new file mode 100644 index 000000000..4f1d1ccd8 --- /dev/null +++ b/enumeration/resource/aws/aws_ecr_repository.go @@ -0,0 +1,10 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsEcrRepositoryResourceType = "aws_ecr_repository" + +func initAwsEcrRepositoryMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + + resourceSchemaRepository.SetFlags(AwsEcrRepositoryResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_ecr_repository_policy.go b/enumeration/resource/aws/aws_ecr_repository_policy.go similarity index 100% rename from pkg/resource/aws/aws_ecr_repository_policy.go rename to enumeration/resource/aws/aws_ecr_repository_policy.go diff --git a/enumeration/resource/aws/aws_eip.go b/enumeration/resource/aws/aws_eip.go new file mode 100644 index 000000000..e1d914c4d --- /dev/null +++ b/enumeration/resource/aws/aws_eip.go @@ -0,0 +1,11 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsEipResourceType = "aws_eip" + +func initAwsEipMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsEipResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_eip_association.go b/enumeration/resource/aws/aws_eip_association.go similarity index 82% rename from pkg/resource/aws/aws_eip_association.go rename to enumeration/resource/aws/aws_eip_association.go index 2ad675709..60248114b 100644 --- a/pkg/resource/aws/aws_eip_association.go +++ b/enumeration/resource/aws/aws_eip_association.go @@ -1,6 +1,6 @@ package aws -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const AwsEipAssociationResourceType = "aws_eip_association" diff --git a/pkg/resource/aws/aws_elasticache_cluster.go b/enumeration/resource/aws/aws_elasticache_cluster.go similarity index 100% rename from pkg/resource/aws/aws_elasticache_cluster.go rename to enumeration/resource/aws/aws_elasticache_cluster.go diff --git a/pkg/resource/aws/aws_elb.go b/enumeration/resource/aws/aws_elb.go similarity index 100% rename from pkg/resource/aws/aws_elb.go rename to enumeration/resource/aws/aws_elb.go diff --git a/enumeration/resource/aws/aws_iam_access_key.go b/enumeration/resource/aws/aws_iam_access_key.go new file mode 100644 index 000000000..3706284e3 --- /dev/null +++ b/enumeration/resource/aws/aws_iam_access_key.go @@ -0,0 +1,26 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsIamAccessKeyResourceType = "aws_iam_access_key" + +func initAwsIAMAccessKeyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + + resourceSchemaRepository.SetResolveReadAttributesFunc(AwsIamAccessKeyResourceType, func(res *resource.Resource) map[string]string { + return map[string]string{ + "user": *res.Attributes().GetString("user"), + } + }) + + resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsIamAccessKeyResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if user := val.GetString("user"); user != nil && *user != "" { + attrs["User"] = *user + } + return attrs + }) + resourceSchemaRepository.SetFlags(AwsIamAccessKeyResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_iam_group.go b/enumeration/resource/aws/aws_iam_group.go similarity index 100% rename from pkg/resource/aws/aws_iam_group.go rename to enumeration/resource/aws/aws_iam_group.go diff --git a/pkg/resource/aws/aws_iam_group_policy.go b/enumeration/resource/aws/aws_iam_group_policy.go similarity index 100% rename from pkg/resource/aws/aws_iam_group_policy.go rename to enumeration/resource/aws/aws_iam_group_policy.go diff --git a/pkg/resource/aws/aws_iam_group_policy_attachment.go b/enumeration/resource/aws/aws_iam_group_policy_attachment.go similarity index 100% rename from pkg/resource/aws/aws_iam_group_policy_attachment.go rename to enumeration/resource/aws/aws_iam_group_policy_attachment.go diff --git a/enumeration/resource/aws/aws_iam_policy.go b/enumeration/resource/aws/aws_iam_policy.go new file mode 100644 index 000000000..538411ac1 --- /dev/null +++ b/enumeration/resource/aws/aws_iam_policy.go @@ -0,0 +1,16 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsIamPolicyResourceType = "aws_iam_policy" + +func initAwsIAMPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.UpdateSchema(AwsIamPolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ + "policy": func(attributeSchema *resource.AttributeSchema) { + attributeSchema.JsonString = true + }, + }) + resourceSchemaRepository.SetFlags(AwsIamPolicyResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/aws/aws_iam_policy_attachment.go b/enumeration/resource/aws/aws_iam_policy_attachment.go new file mode 100644 index 000000000..088f0b14d --- /dev/null +++ b/enumeration/resource/aws/aws_iam_policy_attachment.go @@ -0,0 +1,11 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsIamPolicyAttachmentResourceType = "aws_iam_policy_attachment" + +func initAwsIAMPolicyAttachmentMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsIamPolicyAttachmentResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/aws/aws_iam_role.go b/enumeration/resource/aws/aws_iam_role.go new file mode 100644 index 000000000..e736f29c3 --- /dev/null +++ b/enumeration/resource/aws/aws_iam_role.go @@ -0,0 +1,16 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsIamRoleResourceType = "aws_iam_role" + +func initAwsIAMRoleMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.UpdateSchema(AwsIamRoleResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ + "assume_role_policy": func(attributeSchema *resource.AttributeSchema) { + attributeSchema.JsonString = true + }, + }) + resourceSchemaRepository.SetFlags(AwsIamRoleResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_iam_role_policy.go b/enumeration/resource/aws/aws_iam_role_policy.go similarity index 91% rename from pkg/resource/aws/aws_iam_role_policy.go rename to enumeration/resource/aws/aws_iam_role_policy.go index 255cdaaeb..d5ed4580e 100644 --- a/pkg/resource/aws/aws_iam_role_policy.go +++ b/enumeration/resource/aws/aws_iam_role_policy.go @@ -1,7 +1,7 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) const AwsIamRolePolicyResourceType = "aws_iam_role_policy" diff --git a/pkg/resource/aws/aws_iam_role_policy_attachment.go b/enumeration/resource/aws/aws_iam_role_policy_attachment.go similarity index 91% rename from pkg/resource/aws/aws_iam_role_policy_attachment.go rename to enumeration/resource/aws/aws_iam_role_policy_attachment.go index c8b7396a5..763e1664e 100644 --- a/pkg/resource/aws/aws_iam_role_policy_attachment.go +++ b/enumeration/resource/aws/aws_iam_role_policy_attachment.go @@ -1,6 +1,6 @@ package aws -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const AwsIamRolePolicyAttachmentResourceType = "aws_iam_role_policy_attachment" diff --git a/enumeration/resource/aws/aws_iam_user.go b/enumeration/resource/aws/aws_iam_user.go new file mode 100644 index 000000000..e79413be5 --- /dev/null +++ b/enumeration/resource/aws/aws_iam_user.go @@ -0,0 +1,11 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsIamUserResourceType = "aws_iam_user" + +func initAwsIAMUserMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsIamUserResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_iam_user_policy.go b/enumeration/resource/aws/aws_iam_user_policy.go similarity index 91% rename from pkg/resource/aws/aws_iam_user_policy.go rename to enumeration/resource/aws/aws_iam_user_policy.go index 19cfc22df..3de42a38c 100644 --- a/pkg/resource/aws/aws_iam_user_policy.go +++ b/enumeration/resource/aws/aws_iam_user_policy.go @@ -1,7 +1,7 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) const AwsIamUserPolicyResourceType = "aws_iam_user_policy" diff --git a/pkg/resource/aws/aws_iam_user_policy_attachment.go b/enumeration/resource/aws/aws_iam_user_policy_attachment.go similarity index 91% rename from pkg/resource/aws/aws_iam_user_policy_attachment.go rename to enumeration/resource/aws/aws_iam_user_policy_attachment.go index 5f1aa8057..06f1bef30 100644 --- a/pkg/resource/aws/aws_iam_user_policy_attachment.go +++ b/enumeration/resource/aws/aws_iam_user_policy_attachment.go @@ -1,6 +1,6 @@ package aws -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const AwsIamUserPolicyAttachmentResourceType = "aws_iam_user_policy_attachment" diff --git a/enumeration/resource/aws/aws_instance.go b/enumeration/resource/aws/aws_instance.go new file mode 100644 index 000000000..98f12250a --- /dev/null +++ b/enumeration/resource/aws/aws_instance.go @@ -0,0 +1,21 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsInstanceResourceType = "aws_instance" + +func initAwsInstanceMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsInstanceResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if tags := val.GetMap("tags"); tags != nil { + if name, ok := tags["Name"]; ok { + attrs["Name"] = name.(string) + } + } + return attrs + }) + resourceSchemaRepository.SetFlags(AwsInstanceResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_internet_gateway.go b/enumeration/resource/aws/aws_internet_gateway.go similarity index 85% rename from pkg/resource/aws/aws_internet_gateway.go rename to enumeration/resource/aws/aws_internet_gateway.go index 8a2589091..4c6c69664 100644 --- a/pkg/resource/aws/aws_internet_gateway.go +++ b/enumeration/resource/aws/aws_internet_gateway.go @@ -1,7 +1,7 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) const AwsInternetGatewayResourceType = "aws_internet_gateway" diff --git a/enumeration/resource/aws/aws_key_pair.go b/enumeration/resource/aws/aws_key_pair.go new file mode 100644 index 000000000..35514570d --- /dev/null +++ b/enumeration/resource/aws/aws_key_pair.go @@ -0,0 +1,11 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsKeyPairResourceType = "aws_key_pair" + +func initAwsKeyPairMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsKeyPairResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/aws/aws_kms_alias.go b/enumeration/resource/aws/aws_kms_alias.go new file mode 100644 index 000000000..ff6750f19 --- /dev/null +++ b/enumeration/resource/aws/aws_kms_alias.go @@ -0,0 +1,11 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsKmsAliasResourceType = "aws_kms_alias" + +func initAwsKmsAliasMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsKmsAliasResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/aws/aws_kms_key.go b/enumeration/resource/aws/aws_kms_key.go new file mode 100644 index 000000000..9e2658ae8 --- /dev/null +++ b/enumeration/resource/aws/aws_kms_key.go @@ -0,0 +1,16 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsKmsKeyResourceType = "aws_kms_key" + +func initAwsKmsKeyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.UpdateSchema(AwsKmsKeyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ + "policy": func(attributeSchema *resource.AttributeSchema) { + attributeSchema.JsonString = true + }, + }) + resourceSchemaRepository.SetFlags(AwsKmsKeyResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/aws/aws_lambda_event_source_mapping.go b/enumeration/resource/aws/aws_lambda_event_source_mapping.go new file mode 100644 index 000000000..25e66a7b3 --- /dev/null +++ b/enumeration/resource/aws/aws_lambda_event_source_mapping.go @@ -0,0 +1,22 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsLambdaEventSourceMappingResourceType = "aws_lambda_event_source_mapping" + +func initAwsLambdaEventSourceMappingMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsLambdaEventSourceMappingResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + source := val.GetString("event_source_arn") + dest := val.GetString("function_name") + if source != nil && *source != "" && dest != nil && *dest != "" { + attrs["Source"] = *source + attrs["Dest"] = *dest + } + return attrs + }) + resourceSchemaRepository.SetFlags(AwsLambdaEventSourceMappingResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/aws/aws_lambda_function.go b/enumeration/resource/aws/aws_lambda_function.go new file mode 100644 index 000000000..1a16b4f47 --- /dev/null +++ b/enumeration/resource/aws/aws_lambda_function.go @@ -0,0 +1,17 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsLambdaFunctionResourceType = "aws_lambda_function" + +func initAwsLambdaFunctionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + + resourceSchemaRepository.SetResolveReadAttributesFunc(AwsLambdaFunctionResourceType, func(res *resource.Resource) map[string]string { + return map[string]string{ + "function_name": res.ResourceId(), + } + }) + resourceSchemaRepository.SetFlags(AwsLambdaFunctionResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_launch_configuration.go b/enumeration/resource/aws/aws_launch_configuration.go similarity index 100% rename from pkg/resource/aws/aws_launch_configuration.go rename to enumeration/resource/aws/aws_launch_configuration.go diff --git a/pkg/resource/aws/aws_launch_template.go b/enumeration/resource/aws/aws_launch_template.go similarity index 82% rename from pkg/resource/aws/aws_launch_template.go rename to enumeration/resource/aws/aws_launch_template.go index 83189500e..ce931e208 100644 --- a/pkg/resource/aws/aws_launch_template.go +++ b/enumeration/resource/aws/aws_launch_template.go @@ -1,6 +1,6 @@ package aws -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const AwsLaunchTemplateResourceType = "aws_launch_template" diff --git a/pkg/resource/aws/aws_lb.go b/enumeration/resource/aws/aws_lb.go similarity index 87% rename from pkg/resource/aws/aws_lb.go rename to enumeration/resource/aws/aws_lb.go index 33c350ab2..791f8068f 100644 --- a/pkg/resource/aws/aws_lb.go +++ b/enumeration/resource/aws/aws_lb.go @@ -1,6 +1,6 @@ package aws -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const AwsLoadBalancerResourceType = "aws_lb" diff --git a/pkg/resource/aws/aws_lb_listener.go b/enumeration/resource/aws/aws_lb_listener.go similarity index 100% rename from pkg/resource/aws/aws_lb_listener.go rename to enumeration/resource/aws/aws_lb_listener.go diff --git a/pkg/resource/aws/aws_nat_gateway.go b/enumeration/resource/aws/aws_nat_gateway.go similarity index 81% rename from pkg/resource/aws/aws_nat_gateway.go rename to enumeration/resource/aws/aws_nat_gateway.go index c8eddae2b..c51f3a98b 100644 --- a/pkg/resource/aws/aws_nat_gateway.go +++ b/enumeration/resource/aws/aws_nat_gateway.go @@ -1,6 +1,6 @@ package aws -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const AwsNatGatewayResourceType = "aws_nat_gateway" diff --git a/pkg/resource/aws/aws_network_acl.go b/enumeration/resource/aws/aws_network_acl.go similarity index 84% rename from pkg/resource/aws/aws_network_acl.go rename to enumeration/resource/aws/aws_network_acl.go index 1897a09f6..46973ef15 100644 --- a/pkg/resource/aws/aws_network_acl.go +++ b/enumeration/resource/aws/aws_network_acl.go @@ -1,7 +1,7 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) const AwsNetworkACLResourceType = "aws_network_acl" diff --git a/enumeration/resource/aws/aws_network_acl_rule.go b/enumeration/resource/aws/aws_network_acl_rule.go new file mode 100644 index 000000000..d646937be --- /dev/null +++ b/enumeration/resource/aws/aws_network_acl_rule.go @@ -0,0 +1,69 @@ +package aws + +import ( + "bytes" + "fmt" + "strconv" + + "github.com/hashicorp/terraform/helper/hashcode" + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsNetworkACLRuleResourceType = "aws_network_acl_rule" + +func initAwsNetworkACLRuleMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsNetworkACLRuleResourceType, resource.FlagDeepMode) + resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsNetworkACLRuleResourceType, func(res *resource.Resource) map[string]string { + + ruleNumber := strconv.FormatInt(int64(*res.Attrs.GetFloat64("rule_number")), 10) + if ruleNumber == "32767" { + ruleNumber = "*" + } + + attrs := map[string]string{ + "Network": *res.Attrs.GetString("network_acl_id"), + "Egress": strconv.FormatBool(*res.Attrs.GetBool("egress")), + "Rule number": ruleNumber, + } + + if proto := res.Attrs.GetString("protocol"); proto != nil { + if *proto == "-1" { + *proto = "All" + } + attrs["Protocol"] = *proto + } + + if res.Attrs.GetFloat64("from_port") != nil && res.Attrs.GetFloat64("to_port") != nil { + attrs["Port range"] = fmt.Sprintf("%d - %d", + int64(*res.Attrs.GetFloat64("from_port")), + int64(*res.Attrs.GetFloat64("to_port")), + ) + } + + if cidr := res.Attrs.GetString("cidr_block"); cidr != nil && *cidr != "" { + attrs["CIDR"] = *cidr + } + + if cidr := res.Attrs.GetString("ipv6_cidr_block"); cidr != nil && *cidr != "" { + attrs["CIDR"] = *cidr + } + + return attrs + }) + resourceSchemaRepository.SetResolveReadAttributesFunc(AwsNetworkACLRuleResourceType, func(res *resource.Resource) map[string]string { + return map[string]string{ + "network_acl_id": *res.Attrs.GetString("network_acl_id"), + "rule_number": strconv.FormatInt(int64(*res.Attrs.GetFloat64("rule_number")), 10), + "egress": strconv.FormatBool(*res.Attrs.GetBool("egress")), + } + }) +} + +func CreateNetworkACLRuleID(networkAclId string, ruleNumber int, egress bool, protocol string) string { + var buf bytes.Buffer + buf.WriteString(fmt.Sprintf("%s-", networkAclId)) + buf.WriteString(fmt.Sprintf("%d-", ruleNumber)) + buf.WriteString(fmt.Sprintf("%t-", egress)) + buf.WriteString(fmt.Sprintf("%s-", protocol)) + return fmt.Sprintf("nacl-%d", hashcode.String(buf.String())) +} diff --git a/enumeration/resource/aws/aws_rds_cluster.go b/enumeration/resource/aws/aws_rds_cluster.go new file mode 100644 index 000000000..563783516 --- /dev/null +++ b/enumeration/resource/aws/aws_rds_cluster.go @@ -0,0 +1,17 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsRDSClusterResourceType = "aws_rds_cluster" + +func initAwsRDSClusterMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetResolveReadAttributesFunc(AwsRDSClusterResourceType, func(res *resource.Resource) map[string]string { + return map[string]string{ + "cluster_identifier": *res.Attributes().GetString("cluster_identifier"), + "database_name": *res.Attributes().GetString("database_name"), + } + }) + resourceSchemaRepository.SetFlags(AwsRDSClusterResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_rds_cluster_instance.go b/enumeration/resource/aws/aws_rds_cluster_instance.go similarity index 100% rename from pkg/resource/aws/aws_rds_cluster_instance.go rename to enumeration/resource/aws/aws_rds_cluster_instance.go diff --git a/enumeration/resource/aws/aws_route.go b/enumeration/resource/aws/aws_route.go new file mode 100644 index 000000000..65b045661 --- /dev/null +++ b/enumeration/resource/aws/aws_route.go @@ -0,0 +1,62 @@ +package aws + +import ( + "fmt" + + "github.com/hashicorp/terraform/helper/hashcode" + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsRouteResourceType = "aws_route" + +func initAwsRouteMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetResolveReadAttributesFunc(AwsRouteResourceType, func(res *resource.Resource) map[string]string { + attributes := map[string]string{ + "route_table_id": *res.Attributes().GetString("route_table_id"), + } + if ipv4 := res.Attributes().GetString("destination_cidr_block"); ipv4 != nil && *ipv4 != "" { + attributes["destination_cidr_block"] = *ipv4 + } + if ipv6 := res.Attributes().GetString("destination_ipv6_cidr_block"); ipv6 != nil && *ipv6 != "" { + attributes["destination_ipv6_cidr_block"] = *ipv6 + } + if prefixes := res.Attributes().GetString("destination_prefix_list_id"); prefixes != nil && *prefixes != "" { + attributes["destination_prefix_list_id"] = *prefixes + } + return attributes + }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsRouteResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if rtID := val.GetString("route_table_id"); rtID != nil && *rtID != "" { + attrs["Table"] = *rtID + } + if ipv4 := val.GetString("destination_cidr_block"); ipv4 != nil && *ipv4 != "" { + attrs["Destination"] = *ipv4 + } + if ipv6 := val.GetString("destination_ipv6_cidr_block"); ipv6 != nil && *ipv6 != "" { + attrs["Destination"] = *ipv6 + } + if prefix := val.GetString("destination_prefix_list_id"); prefix != nil && *prefix != "" { + attrs["Destination"] = *prefix + } + return attrs + }) + resourceSchemaRepository.SetFlags(AwsRouteResourceType, resource.FlagDeepMode) +} + +func CalculateRouteID(tableId, CidrBlock, Ipv6CidrBlock, PrefixListId *string) string { + if CidrBlock != nil && *CidrBlock != "" { + return fmt.Sprintf("r-%s%d", *tableId, hashcode.String(*CidrBlock)) + } + + if Ipv6CidrBlock != nil && *Ipv6CidrBlock != "" { + return fmt.Sprintf("r-%s%d", *tableId, hashcode.String(*Ipv6CidrBlock)) + } + + if PrefixListId != nil && *PrefixListId != "" { + return fmt.Sprintf("r-%s%d", *tableId, hashcode.String(*PrefixListId)) + } + + return "" +} diff --git a/pkg/resource/aws/aws_route53_health_check.go b/enumeration/resource/aws/aws_route53_health_check.go similarity index 96% rename from pkg/resource/aws/aws_route53_health_check.go rename to enumeration/resource/aws/aws_route53_health_check.go index ad5e5effe..e87e5b376 100644 --- a/pkg/resource/aws/aws_route53_health_check.go +++ b/enumeration/resource/aws/aws_route53_health_check.go @@ -3,7 +3,7 @@ package aws import ( "fmt" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) const AwsRoute53HealthCheckResourceType = "aws_route53_health_check" diff --git a/enumeration/resource/aws/aws_route53_record.go b/enumeration/resource/aws/aws_route53_record.go new file mode 100644 index 000000000..de67f8c4e --- /dev/null +++ b/enumeration/resource/aws/aws_route53_record.go @@ -0,0 +1,25 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsRoute53RecordResourceType = "aws_route53_record" + +func initAwsRoute53RecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsRoute53RecordResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if fqdn := val.GetString("fqdn"); fqdn != nil && *fqdn != "" { + attrs["Fqdn"] = *fqdn + } + if ty := val.GetString("type"); ty != nil && *ty != "" { + attrs["Type"] = *ty + } + if zoneID := val.GetString("zone_id"); zoneID != nil && *zoneID != "" { + attrs["ZoneId"] = *zoneID + } + return attrs + }) + resourceSchemaRepository.SetFlags(AwsRoute53RecordResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/aws/aws_route53_zone.go b/enumeration/resource/aws/aws_route53_zone.go new file mode 100644 index 000000000..4d188b05f --- /dev/null +++ b/enumeration/resource/aws/aws_route53_zone.go @@ -0,0 +1,19 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsRoute53ZoneResourceType = "aws_route53_zone" + +func initAwsRoute53ZoneMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsRoute53ZoneResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + return attrs + }) + resourceSchemaRepository.SetFlags(AwsRoute53ZoneResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_route_table.go b/enumeration/resource/aws/aws_route_table.go similarity index 88% rename from pkg/resource/aws/aws_route_table.go rename to enumeration/resource/aws/aws_route_table.go index 95a1af5ce..edef38567 100644 --- a/pkg/resource/aws/aws_route_table.go +++ b/enumeration/resource/aws/aws_route_table.go @@ -1,6 +1,6 @@ package aws -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const AwsRouteTableResourceType = "aws_route_table" diff --git a/pkg/resource/aws/aws_route_table_association.go b/enumeration/resource/aws/aws_route_table_association.go similarity index 95% rename from pkg/resource/aws/aws_route_table_association.go rename to enumeration/resource/aws/aws_route_table_association.go index 6c48ffcc5..75ae4c5c8 100644 --- a/pkg/resource/aws/aws_route_table_association.go +++ b/enumeration/resource/aws/aws_route_table_association.go @@ -1,6 +1,6 @@ package aws -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const AwsRouteTableAssociationResourceType = "aws_route_table_association" diff --git a/enumeration/resource/aws/aws_s3_bucket.go b/enumeration/resource/aws/aws_s3_bucket.go new file mode 100644 index 000000000..81c12b04e --- /dev/null +++ b/enumeration/resource/aws/aws_s3_bucket.go @@ -0,0 +1,21 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsS3BucketResourceType = "aws_s3_bucket" + +func initAwsS3BucketMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetResolveReadAttributesFunc(AwsS3BucketResourceType, func(res *resource.Resource) map[string]string { + return map[string]string{ + "alias": *res.Attributes().GetString("region"), + } + }) + resourceSchemaRepository.UpdateSchema(AwsS3BucketResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ + "policy": func(attributeSchema *resource.AttributeSchema) { + attributeSchema.JsonString = true + }, + }) + resourceSchemaRepository.SetFlags(AwsS3BucketResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_s3_bucket_analytics_configuration.go b/enumeration/resource/aws/aws_s3_bucket_analytics_configuration.go similarity index 91% rename from pkg/resource/aws/aws_s3_bucket_analytics_configuration.go rename to enumeration/resource/aws/aws_s3_bucket_analytics_configuration.go index f0660dca3..5f894cf42 100644 --- a/pkg/resource/aws/aws_s3_bucket_analytics_configuration.go +++ b/enumeration/resource/aws/aws_s3_bucket_analytics_configuration.go @@ -1,6 +1,6 @@ package aws -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const AwsS3BucketAnalyticsConfigurationResourceType = "aws_s3_bucket_analytics_configuration" diff --git a/pkg/resource/aws/aws_s3_bucket_inventory.go b/enumeration/resource/aws/aws_s3_bucket_inventory.go similarity index 90% rename from pkg/resource/aws/aws_s3_bucket_inventory.go rename to enumeration/resource/aws/aws_s3_bucket_inventory.go index 79e78fd24..6e07eaad6 100644 --- a/pkg/resource/aws/aws_s3_bucket_inventory.go +++ b/enumeration/resource/aws/aws_s3_bucket_inventory.go @@ -1,6 +1,6 @@ package aws -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const AwsS3BucketInventoryResourceType = "aws_s3_bucket_inventory" diff --git a/pkg/resource/aws/aws_s3_bucket_metric.go b/enumeration/resource/aws/aws_s3_bucket_metric.go similarity index 89% rename from pkg/resource/aws/aws_s3_bucket_metric.go rename to enumeration/resource/aws/aws_s3_bucket_metric.go index 2c6cd0afe..29b238d60 100644 --- a/pkg/resource/aws/aws_s3_bucket_metric.go +++ b/enumeration/resource/aws/aws_s3_bucket_metric.go @@ -1,6 +1,6 @@ package aws -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const AwsS3BucketMetricResourceType = "aws_s3_bucket_metric" diff --git a/pkg/resource/aws/aws_s3_bucket_notification.go b/enumeration/resource/aws/aws_s3_bucket_notification.go similarity index 90% rename from pkg/resource/aws/aws_s3_bucket_notification.go rename to enumeration/resource/aws/aws_s3_bucket_notification.go index 37e3cb291..1f425e1fe 100644 --- a/pkg/resource/aws/aws_s3_bucket_notification.go +++ b/enumeration/resource/aws/aws_s3_bucket_notification.go @@ -1,6 +1,6 @@ package aws -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const AwsS3BucketNotificationResourceType = "aws_s3_bucket_notification" diff --git a/enumeration/resource/aws/aws_s3_bucket_policy.go b/enumeration/resource/aws/aws_s3_bucket_policy.go new file mode 100644 index 000000000..35ec77546 --- /dev/null +++ b/enumeration/resource/aws/aws_s3_bucket_policy.go @@ -0,0 +1,21 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsS3BucketPolicyResourceType = "aws_s3_bucket_policy" + +func initAwsS3BucketPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetResolveReadAttributesFunc(AwsS3BucketPolicyResourceType, func(res *resource.Resource) map[string]string { + return map[string]string{ + "alias": *res.Attributes().GetString("region"), + } + }) + resourceSchemaRepository.UpdateSchema(AwsS3BucketPolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ + "policy": func(attributeSchema *resource.AttributeSchema) { + attributeSchema.JsonString = true + }, + }) + resourceSchemaRepository.SetFlags(AwsS3BucketPolicyResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_s3_bucket_public_access_block.go b/enumeration/resource/aws/aws_s3_bucket_public_access_block.go similarity index 100% rename from pkg/resource/aws/aws_s3_bucket_public_access_block.go rename to enumeration/resource/aws/aws_s3_bucket_public_access_block.go diff --git a/enumeration/resource/aws/aws_security_group.go b/enumeration/resource/aws/aws_security_group.go new file mode 100644 index 000000000..55510c70d --- /dev/null +++ b/enumeration/resource/aws/aws_security_group.go @@ -0,0 +1,9 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsSecurityGroupResourceType = "aws_security_group" + +func initAwsSecurityGroupMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsSecurityGroupResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/aws/aws_security_group_rule.go b/enumeration/resource/aws/aws_security_group_rule.go new file mode 100644 index 000000000..48436ac6e --- /dev/null +++ b/enumeration/resource/aws/aws_security_group_rule.go @@ -0,0 +1,174 @@ +package aws + +import ( + "bytes" + "fmt" + "strings" + + "github.com/hashicorp/terraform/flatmap" + "github.com/hashicorp/terraform/helper/hashcode" + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsSecurityGroupRuleResourceType = "aws_security_group_rule" + +func CreateSecurityGroupRuleIdHash(attrs *resource.Attributes) string { + var buf bytes.Buffer + buf.WriteString(fmt.Sprintf("%s-", *attrs.GetString("security_group_id"))) + if attrs.GetInt("from_port") != nil && *attrs.GetInt("from_port") > 0 { + buf.WriteString(fmt.Sprintf("%d-", *attrs.GetInt("from_port"))) + } + if attrs.GetInt("to_port") != nil && *attrs.GetInt("to_port") > 0 { + buf.WriteString(fmt.Sprintf("%d-", *attrs.GetInt("to_port"))) + } + buf.WriteString(fmt.Sprintf("%s-", *attrs.GetString("protocol"))) + buf.WriteString(fmt.Sprintf("%s-", *attrs.GetString("type"))) + + if attrs.GetSlice("cidr_blocks") != nil { + for _, v := range attrs.GetSlice("cidr_blocks") { + buf.WriteString(fmt.Sprintf("%s-", v)) + } + } + + if attrs.GetSlice("ipv6_cidr_blocks") != nil { + for _, v := range attrs.GetSlice("ipv6_cidr_blocks") { + buf.WriteString(fmt.Sprintf("%s-", v)) + } + } + + if attrs.GetSlice("prefix_list_ids") != nil { + for _, v := range attrs.GetSlice("prefix_list_ids") { + buf.WriteString(fmt.Sprintf("%s-", v)) + } + } + + if (attrs.GetBool("self") != nil && *attrs.GetBool("self")) || + (attrs.GetString("source_security_group_id") != nil && *attrs.GetString("source_security_group_id") != "") { + if attrs.GetBool("self") != nil && *attrs.GetBool("self") { + buf.WriteString(fmt.Sprintf("%s-", *attrs.GetString("security_group_id"))) + } else { + buf.WriteString(fmt.Sprintf("%s-", *attrs.GetString("source_security_group_id"))) + } + buf.WriteString("-") + } + + return fmt.Sprintf("sgrule-%d", hashcode.String(buf.String())) +} + +func initAwsSecurityGroupRuleMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetResolveReadAttributesFunc(AwsSecurityGroupRuleResourceType, func(res *resource.Resource) map[string]string { + attrs := make(map[string]interface{}) + if v, ok := res.Attributes().Get("type"); ok { + attrs["type"] = v + } + if v, ok := res.Attributes().Get("protocol"); ok { + attrs["protocol"] = v + } + if v := res.Attributes().GetInt("from_port"); v != nil { + attrs["from_port"] = *v + } + if v := res.Attributes().GetInt("to_port"); v != nil { + attrs["to_port"] = *v + } + if v, ok := res.Attributes().Get("security_group_id"); ok { + attrs["security_group_id"] = v + } + if v, ok := res.Attributes().Get("self"); ok { + attrs["self"] = v + } + if v, ok := res.Attributes().Get("cidr_blocks"); ok { + attrs["cidr_blocks"] = v + } + if v, ok := res.Attributes().Get("ipv6_cidr_blocks"); ok { + attrs["ipv6_cidr_blocks"] = v + } + if v, ok := res.Attributes().Get("prefix_list_ids"); ok { + attrs["prefix_list_ids"] = v + } + if v, ok := res.Attributes().Get("source_security_group_id"); ok { + attrs["source_security_group_id"] = v + } + return flatmap.Flatten(attrs) + }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsSecurityGroupRuleResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if sgID := val.GetString("security_group_id"); sgID != nil && *sgID != "" { + attrs["SecurityGroup"] = *sgID + } + if protocol := val.GetString("protocol"); protocol != nil && *protocol != "" { + if *protocol == "-1" { + *protocol = "All" + } + attrs["Protocol"] = *protocol + } + fromPort := val.GetInt("from_port") + toPort := val.GetInt("to_port") + if fromPort != nil && toPort != nil { + portRange := "All" + if *fromPort != 0 && *fromPort == *toPort { + portRange = fmt.Sprintf("%d", *fromPort) + } + if *fromPort != 0 && *toPort != 0 && *fromPort != *toPort { + portRange = fmt.Sprintf("%d-%d", *fromPort, *toPort) + } + attrs["Ports"] = portRange + } + ty := val.GetString("type") + if ty != nil && *ty != "" { + attrs["Type"] = *ty + var sourceOrDestination string + switch *ty { + case "egress": + sourceOrDestination = "Destination" + case "ingress": + sourceOrDestination = "Source" + } + if ipv4 := val.GetSlice("cidr_blocks"); len(ipv4) > 0 { + attrs[sourceOrDestination] = join(ipv4, ", ") + } + if ipv6 := val.GetSlice("ipv6_cidr_blocks"); len(ipv6) > 0 { + attrs[sourceOrDestination] = join(ipv6, ", ") + } + if prefixList := val.GetSlice("prefix_list_ids"); len(prefixList) > 0 { + attrs[sourceOrDestination] = join(prefixList, ", ") + } + if sourceSgID := val.GetString("source_security_group_id"); sourceSgID != nil && *sourceSgID != "" { + attrs[sourceOrDestination] = *sourceSgID + } + } + return attrs + }) + resourceSchemaRepository.SetFlags(AwsSecurityGroupRuleResourceType, resource.FlagDeepMode) +} + +func join(elems []interface{}, sep string) string { + firstElemt, ok := elems[0].(string) + if !ok { + panic("cannot join a slice that contains something else than strings") + } + switch len(elems) { + case 0: + return "" + case 1: + + return firstElemt + } + n := len(sep) * (len(elems) - 1) + for i := 0; i < len(elems); i++ { + n += len(elems[i].(string)) + } + + var b strings.Builder + b.Grow(n) + b.WriteString(firstElemt) + for _, s := range elems[1:] { + b.WriteString(sep) + elem, ok := s.(string) + if !ok { + panic("cannot join a slice that contains something else than strings") + } + b.WriteString(elem) + } + return b.String() +} diff --git a/enumeration/resource/aws/aws_sns_topic.go b/enumeration/resource/aws/aws_sns_topic.go new file mode 100644 index 000000000..c60da86e6 --- /dev/null +++ b/enumeration/resource/aws/aws_sns_topic.go @@ -0,0 +1,33 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsSnsTopicResourceType = "aws_sns_topic" + +func initSnsTopicMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetResolveReadAttributesFunc(AwsSnsTopicResourceType, func(res *resource.Resource) map[string]string { + return map[string]string{ + "topic_arn": res.ResourceId(), + } + }) + resourceSchemaRepository.UpdateSchema(AwsSnsTopicResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ + "delivery_policy": func(attributeSchema *resource.AttributeSchema) { + attributeSchema.JsonString = true + }, + "policy": func(attributeSchema *resource.AttributeSchema) { + attributeSchema.JsonString = true + }, + }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsSnsTopicResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + if displayName := val.GetString("display_name"); displayName != nil && *displayName != "" { + attrs["DisplayName"] = *displayName + } + } + return attrs + }) + resourceSchemaRepository.SetFlags(AwsSnsTopicResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/aws/aws_sns_topic_policy.go b/enumeration/resource/aws/aws_sns_topic_policy.go new file mode 100644 index 000000000..25869100f --- /dev/null +++ b/enumeration/resource/aws/aws_sns_topic_policy.go @@ -0,0 +1,22 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsSnsTopicPolicyResourceType = "aws_sns_topic_policy" + +func initSnsTopicPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetResolveReadAttributesFunc(AwsSnsTopicPolicyResourceType, func(res *resource.Resource) map[string]string { + return map[string]string{ + "topic_arn": res.ResourceId(), + } + }) + + resourceSchemaRepository.UpdateSchema(AwsSnsTopicPolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ + "policy": func(attributeSchema *resource.AttributeSchema) { + attributeSchema.JsonString = true + }, + }) + resourceSchemaRepository.SetFlags(AwsSnsTopicPolicyResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/aws/aws_sns_topic_subscription.go b/enumeration/resource/aws/aws_sns_topic_subscription.go new file mode 100644 index 000000000..0cde9ec5a --- /dev/null +++ b/enumeration/resource/aws/aws_sns_topic_subscription.go @@ -0,0 +1,26 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsSnsTopicSubscriptionResourceType = "aws_sns_topic_subscription" + +func initSnsTopicSubscriptionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetResolveReadAttributesFunc(AwsSnsTopicSubscriptionResourceType, func(res *resource.Resource) map[string]string { + return map[string]string{ + "SubscriptionId": res.ResourceId(), + } + }) + + resourceSchemaRepository.UpdateSchema(AwsSnsTopicSubscriptionResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ + "delivery_policy": func(attributeSchema *resource.AttributeSchema) { + attributeSchema.JsonString = true + }, + "filter_policy": func(attributeSchema *resource.AttributeSchema) { + attributeSchema.JsonString = true + }, + }) + + resourceSchemaRepository.SetFlags(AwsSnsTopicSubscriptionResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_sqs_queue.go b/enumeration/resource/aws/aws_sqs_queue.go similarity index 83% rename from pkg/resource/aws/aws_sqs_queue.go rename to enumeration/resource/aws/aws_sqs_queue.go index 6415c3e73..b6ee1dcf5 100644 --- a/pkg/resource/aws/aws_sqs_queue.go +++ b/enumeration/resource/aws/aws_sqs_queue.go @@ -1,7 +1,7 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) const AwsSqsQueueResourceType = "aws_sqs_queue" diff --git a/enumeration/resource/aws/aws_sqs_queue_policy.go b/enumeration/resource/aws/aws_sqs_queue_policy.go new file mode 100644 index 000000000..422e2d03b --- /dev/null +++ b/enumeration/resource/aws/aws_sqs_queue_policy.go @@ -0,0 +1,16 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsSqsQueuePolicyResourceType = "aws_sqs_queue_policy" + +func initAwsSQSQueuePolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.UpdateSchema(AwsSqsQueuePolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ + "policy": func(attributeSchema *resource.AttributeSchema) { + attributeSchema.JsonString = true + }, + }) + resourceSchemaRepository.SetFlags(AwsSqsQueuePolicyResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/aws/aws_subnet.go b/enumeration/resource/aws/aws_subnet.go new file mode 100644 index 000000000..e25361a18 --- /dev/null +++ b/enumeration/resource/aws/aws_subnet.go @@ -0,0 +1,11 @@ +package aws + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsSubnetResourceType = "aws_subnet" + +func initAwsSubnetMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsSubnetResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_vpc.go b/enumeration/resource/aws/aws_vpc.go similarity index 79% rename from pkg/resource/aws/aws_vpc.go rename to enumeration/resource/aws/aws_vpc.go index 848763b98..8d7ae9acb 100644 --- a/pkg/resource/aws/aws_vpc.go +++ b/enumeration/resource/aws/aws_vpc.go @@ -1,6 +1,6 @@ package aws -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const AwsVpcResourceType = "aws_vpc" diff --git a/pkg/resource/aws/metadata_test.go b/enumeration/resource/aws/metadata_test.go similarity index 98% rename from pkg/resource/aws/metadata_test.go rename to enumeration/resource/aws/metadata_test.go index 0f1d1f297..3dafb3268 100644 --- a/pkg/resource/aws/metadata_test.go +++ b/enumeration/resource/aws/metadata_test.go @@ -1,10 +1,11 @@ package aws import ( + tf "github.com/snyk/driftctl/enumeration/terraform" + "testing" - "github.com/snyk/driftctl/pkg/resource" - tf "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration/resource" testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" ) diff --git a/enumeration/resource/aws/metadatas.go b/enumeration/resource/aws/metadatas.go new file mode 100644 index 000000000..c6aac2b9b --- /dev/null +++ b/enumeration/resource/aws/metadatas.go @@ -0,0 +1,70 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + initAwsAmiMetaData(resourceSchemaRepository) + initAwsCloudfrontDistributionMetaData(resourceSchemaRepository) + initAwsDbInstanceMetaData(resourceSchemaRepository) + initAwsDbSubnetGroupMetaData(resourceSchemaRepository) + initAwsDefaultSecurityGroupMetaData(resourceSchemaRepository) + initAwsDefaultSubnetMetaData(resourceSchemaRepository) + initAwsDefaultVpcMetaData(resourceSchemaRepository) + initAwsDefaultRouteTableMetadata(resourceSchemaRepository) + initAwsDynamodbTableMetaData(resourceSchemaRepository) + initAwsEbsSnapshotMetaData(resourceSchemaRepository) + initAwsInstanceMetaData(resourceSchemaRepository) + initAwsInternetGatewayMetaData(resourceSchemaRepository) + initAwsEbsVolumeMetaData(resourceSchemaRepository) + initAwsEipMetaData(resourceSchemaRepository) + initAwsEipAssociationMetaData(resourceSchemaRepository) + initAwsS3BucketMetaData(resourceSchemaRepository) + initAwsS3BucketPolicyMetaData(resourceSchemaRepository) + initAwsS3BucketInventoryMetadata(resourceSchemaRepository) + initAwsS3BucketMetricMetadata(resourceSchemaRepository) + initAwsS3BucketNotificationMetadata(resourceSchemaRepository) + initAwsS3BucketAnalyticsConfigurationMetaData(resourceSchemaRepository) + initAwsEcrRepositoryMetaData(resourceSchemaRepository) + initAwsRouteMetaData(resourceSchemaRepository) + initAwsRouteTableAssociationMetaData(resourceSchemaRepository) + initAwsRoute53RecordMetaData(resourceSchemaRepository) + initAwsRoute53ZoneMetaData(resourceSchemaRepository) + initAwsRoute53HealthCheckMetaData(resourceSchemaRepository) + initAwsRouteTableMetaData(resourceSchemaRepository) + initSnsTopicSubscriptionMetaData(resourceSchemaRepository) + initSnsTopicPolicyMetaData(resourceSchemaRepository) + initSnsTopicMetaData(resourceSchemaRepository) + initSqsQueueMetaData(resourceSchemaRepository) + initAwsIAMAccessKeyMetaData(resourceSchemaRepository) + initAwsIAMPolicyMetaData(resourceSchemaRepository) + initAwsIAMPolicyAttachmentMetaData(resourceSchemaRepository) + initAwsIAMRoleMetaData(resourceSchemaRepository) + initAwsIAMRolePolicyMetaData(resourceSchemaRepository) + initAwsIamRolePolicyAttachmentMetaData(resourceSchemaRepository) + initAwsIamUserPolicyAttachmentMetaData(resourceSchemaRepository) + initAwsIAMUserMetaData(resourceSchemaRepository) + initAwsIAMUserPolicyMetaData(resourceSchemaRepository) + initAwsKeyPairMetaData(resourceSchemaRepository) + initAwsKmsKeyMetaData(resourceSchemaRepository) + initAwsKmsAliasMetaData(resourceSchemaRepository) + initAwsLambdaFunctionMetaData(resourceSchemaRepository) + initAwsLambdaEventSourceMappingMetaData(resourceSchemaRepository) + initNatGatewayMetaData(resourceSchemaRepository) + initAwsNetworkACLMetaData(resourceSchemaRepository) + initAwsNetworkACLRuleMetaData(resourceSchemaRepository) + initAwsDefaultNetworkACLMetaData(resourceSchemaRepository) + initAwsSubnetMetaData(resourceSchemaRepository) + initAwsSQSQueuePolicyMetaData(resourceSchemaRepository) + initAwsSecurityGroupRuleMetaData(resourceSchemaRepository) + initAwsSecurityGroupMetaData(resourceSchemaRepository) + initAwsRDSClusterMetaData(resourceSchemaRepository) + initAwsCloudformationStackMetaData(resourceSchemaRepository) + initAwsVpcMetaData(resourceSchemaRepository) + initAwsAppAutoscalingTargetMetaData(resourceSchemaRepository) + initAwsAppAutoscalingPolicyMetaData(resourceSchemaRepository) + initAwsLaunchTemplateMetaData(resourceSchemaRepository) + initAwsApiGatewayV2ModelMetaData(resourceSchemaRepository) + initAwsApiGatewayV2MappingMetaData(resourceSchemaRepository) + initAwsEbsEncryptionByDefaultMetaData(resourceSchemaRepository) + initAwsLoadBalancerMetaData(resourceSchemaRepository) +} diff --git a/pkg/resource/azurerm/azurerm_container_registry.go b/enumeration/resource/azurerm/azurerm_container_registry.go similarity index 90% rename from pkg/resource/azurerm/azurerm_container_registry.go rename to enumeration/resource/azurerm/azurerm_container_registry.go index 915930015..4a6d52b65 100644 --- a/pkg/resource/azurerm/azurerm_container_registry.go +++ b/enumeration/resource/azurerm/azurerm_container_registry.go @@ -1,6 +1,6 @@ package azurerm -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const AzureContainerRegistryResourceType = "azurerm_container_registry" diff --git a/pkg/resource/azurerm/azurerm_firewall.go b/enumeration/resource/azurerm/azurerm_firewall.go similarity index 89% rename from pkg/resource/azurerm/azurerm_firewall.go rename to enumeration/resource/azurerm/azurerm_firewall.go index b28c23943..ded79fe2a 100644 --- a/pkg/resource/azurerm/azurerm_firewall.go +++ b/enumeration/resource/azurerm/azurerm_firewall.go @@ -1,6 +1,6 @@ package azurerm -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const AzureFirewallResourceType = "azurerm_firewall" diff --git a/pkg/resource/azurerm/azurerm_image.go b/enumeration/resource/azurerm/azurerm_image.go similarity index 90% rename from pkg/resource/azurerm/azurerm_image.go rename to enumeration/resource/azurerm/azurerm_image.go index 79f320d2e..a86e8d2e4 100644 --- a/pkg/resource/azurerm/azurerm_image.go +++ b/enumeration/resource/azurerm/azurerm_image.go @@ -1,7 +1,7 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) const AzureImageResourceType = "azurerm_image" diff --git a/pkg/resource/azurerm/azurerm_lb.go b/enumeration/resource/azurerm/azurerm_lb.go similarity index 89% rename from pkg/resource/azurerm/azurerm_lb.go rename to enumeration/resource/azurerm/azurerm_lb.go index 59b22f261..04a7cc0d5 100644 --- a/pkg/resource/azurerm/azurerm_lb.go +++ b/enumeration/resource/azurerm/azurerm_lb.go @@ -1,6 +1,6 @@ package azurerm -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const AzureLoadBalancerResourceType = "azurerm_lb" diff --git a/enumeration/resource/azurerm/azurerm_lb_rule.go b/enumeration/resource/azurerm/azurerm_lb_rule.go new file mode 100644 index 000000000..ea5a5fcd1 --- /dev/null +++ b/enumeration/resource/azurerm/azurerm_lb_rule.go @@ -0,0 +1,21 @@ +package azurerm + +import "github.com/snyk/driftctl/enumeration/resource" + +const AzureLoadBalancerRuleResourceType = "azurerm_lb_rule" + +func initAzureLoadBalancerRuleMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetResolveReadAttributesFunc(AzureLoadBalancerRuleResourceType, func(res *resource.Resource) map[string]string { + return map[string]string{ + "loadbalancer_id": *res.Attributes().GetString("loadbalancer_id"), + } + }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureLoadBalancerRuleResourceType, func(res *resource.Resource) map[string]string { + attrs := make(map[string]string) + if name := res.Attributes().GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + return attrs + }) + resourceSchemaRepository.SetFlags(AzureLoadBalancerRuleResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/azurerm/azurerm_network_security_group.go b/enumeration/resource/azurerm/azurerm_network_security_group.go new file mode 100644 index 000000000..29303ba1c --- /dev/null +++ b/enumeration/resource/azurerm/azurerm_network_security_group.go @@ -0,0 +1,17 @@ +package azurerm + +import "github.com/snyk/driftctl/enumeration/resource" + +const AzureNetworkSecurityGroupResourceType = "azurerm_network_security_group" + +func initAzureNetworkSecurityGroupMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureNetworkSecurityGroupResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + return attrs + }) + resourceSchemaRepository.SetFlags(AzureNetworkSecurityGroupResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/azurerm/azurerm_postgresql_database.go b/enumeration/resource/azurerm/azurerm_postgresql_database.go similarity index 90% rename from pkg/resource/azurerm/azurerm_postgresql_database.go rename to enumeration/resource/azurerm/azurerm_postgresql_database.go index caa41b162..7a5784f95 100644 --- a/pkg/resource/azurerm/azurerm_postgresql_database.go +++ b/enumeration/resource/azurerm/azurerm_postgresql_database.go @@ -1,6 +1,6 @@ package azurerm -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const AzurePostgresqlDatabaseResourceType = "azurerm_postgresql_database" diff --git a/pkg/resource/azurerm/azurerm_postgresql_server.go b/enumeration/resource/azurerm/azurerm_postgresql_server.go similarity index 90% rename from pkg/resource/azurerm/azurerm_postgresql_server.go rename to enumeration/resource/azurerm/azurerm_postgresql_server.go index 380f152b2..167e68c3e 100644 --- a/pkg/resource/azurerm/azurerm_postgresql_server.go +++ b/enumeration/resource/azurerm/azurerm_postgresql_server.go @@ -1,6 +1,6 @@ package azurerm -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const AzurePostgresqlServerResourceType = "azurerm_postgresql_server" diff --git a/enumeration/resource/azurerm/azurerm_private_dns_a_record.go b/enumeration/resource/azurerm/azurerm_private_dns_a_record.go new file mode 100644 index 000000000..014ebb7f6 --- /dev/null +++ b/enumeration/resource/azurerm/azurerm_private_dns_a_record.go @@ -0,0 +1,22 @@ +package azurerm + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AzurePrivateDNSARecordResourceType = "azurerm_private_dns_a_record" + +func initAzurePrivateDNSARecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePrivateDNSARecordResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + if zone := val.GetString("zone_name"); zone != nil && *zone != "" { + attrs["Zone"] = *zone + } + return attrs + }) + resourceSchemaRepository.SetFlags(AzurePrivateDNSARecordResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/azurerm/azurerm_private_dns_aaaa_record.go b/enumeration/resource/azurerm/azurerm_private_dns_aaaa_record.go new file mode 100644 index 000000000..ad3582928 --- /dev/null +++ b/enumeration/resource/azurerm/azurerm_private_dns_aaaa_record.go @@ -0,0 +1,22 @@ +package azurerm + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AzurePrivateDNSAAAARecordResourceType = "azurerm_private_dns_aaaa_record" + +func initAzurePrivateDNSAAAARecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePrivateDNSAAAARecordResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + if zone := val.GetString("zone_name"); zone != nil && *zone != "" { + attrs["Zone"] = *zone + } + return attrs + }) + resourceSchemaRepository.SetFlags(AzurePrivateDNSAAAARecordResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/azurerm/azurerm_private_dns_cname_record.go b/enumeration/resource/azurerm/azurerm_private_dns_cname_record.go new file mode 100644 index 000000000..5673ddff1 --- /dev/null +++ b/enumeration/resource/azurerm/azurerm_private_dns_cname_record.go @@ -0,0 +1,21 @@ +package azurerm + +import "github.com/snyk/driftctl/enumeration/resource" + +const AzurePrivateDNSCNameRecordResourceType = "azurerm_private_dns_cname_record" + +func initAzurePrivateDNSCNameRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AzurePrivateDNSCNameRecordResourceType, resource.FlagDeepMode) + + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePrivateDNSCNameRecordResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + if zone := val.GetString("zone_name"); zone != nil && *zone != "" { + attrs["Zone"] = *zone + } + return attrs + }) +} diff --git a/enumeration/resource/azurerm/azurerm_private_dns_mx_record.go b/enumeration/resource/azurerm/azurerm_private_dns_mx_record.go new file mode 100644 index 000000000..478a721cc --- /dev/null +++ b/enumeration/resource/azurerm/azurerm_private_dns_mx_record.go @@ -0,0 +1,25 @@ +package azurerm + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AzurePrivateDNSMXRecordResourceType = "azurerm_private_dns_mx_record" + +func initAzurePrivateDNSMXRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSMXRecordResourceType, func(res *resource.Resource) { + res.Attributes().SafeDelete([]string{"timeouts"}) + }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePrivateDNSMXRecordResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + if zone := val.GetString("zone_name"); zone != nil && *zone != "" { + attrs["Zone"] = *zone + } + return attrs + }) + resourceSchemaRepository.SetFlags(AzurePrivateDNSMXRecordResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/azurerm/azurerm_private_dns_ptr_record.go b/enumeration/resource/azurerm/azurerm_private_dns_ptr_record.go new file mode 100644 index 000000000..59ea61355 --- /dev/null +++ b/enumeration/resource/azurerm/azurerm_private_dns_ptr_record.go @@ -0,0 +1,22 @@ +package azurerm + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AzurePrivateDNSPTRRecordResourceType = "azurerm_private_dns_ptr_record" + +func initAzurePrivateDNSPTRRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePrivateDNSPTRRecordResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + if zone := val.GetString("zone_name"); zone != nil && *zone != "" { + attrs["Zone"] = *zone + } + return attrs + }) + resourceSchemaRepository.SetFlags(AzurePrivateDNSPTRRecordResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/azurerm/azurerm_private_dns_srv_record.go b/enumeration/resource/azurerm/azurerm_private_dns_srv_record.go new file mode 100644 index 000000000..91942d1cd --- /dev/null +++ b/enumeration/resource/azurerm/azurerm_private_dns_srv_record.go @@ -0,0 +1,22 @@ +package azurerm + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AzurePrivateDNSSRVRecordResourceType = "azurerm_private_dns_srv_record" + +func initAzurePrivateDNSSRVRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePrivateDNSSRVRecordResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + if zone := val.GetString("zone_name"); zone != nil && *zone != "" { + attrs["Zone"] = *zone + } + return attrs + }) + resourceSchemaRepository.SetFlags(AzurePrivateDNSSRVRecordResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/azurerm/azurerm_private_dns_txt_record.go b/enumeration/resource/azurerm/azurerm_private_dns_txt_record.go new file mode 100644 index 000000000..173675421 --- /dev/null +++ b/enumeration/resource/azurerm/azurerm_private_dns_txt_record.go @@ -0,0 +1,22 @@ +package azurerm + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AzurePrivateDNSTXTRecordResourceType = "azurerm_private_dns_txt_record" + +func initAzurePrivateDNSTXTRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePrivateDNSTXTRecordResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + if zone := val.GetString("zone_name"); zone != nil && *zone != "" { + attrs["Zone"] = *zone + } + return attrs + }) + resourceSchemaRepository.SetFlags(AzurePrivateDNSTXTRecordResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/azurerm/azurerm_private_dns_zone.go b/enumeration/resource/azurerm/azurerm_private_dns_zone.go new file mode 100644 index 000000000..19075ea3a --- /dev/null +++ b/enumeration/resource/azurerm/azurerm_private_dns_zone.go @@ -0,0 +1,11 @@ +package azurerm + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AzurePrivateDNSZoneResourceType = "azurerm_private_dns_zone" + +func initAzurePrivateDNSZoneMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AzurePrivateDNSZoneResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/azurerm/azurerm_public_ip.go b/enumeration/resource/azurerm/azurerm_public_ip.go similarity index 89% rename from pkg/resource/azurerm/azurerm_public_ip.go rename to enumeration/resource/azurerm/azurerm_public_ip.go index ce2b03743..ac3d07102 100644 --- a/pkg/resource/azurerm/azurerm_public_ip.go +++ b/enumeration/resource/azurerm/azurerm_public_ip.go @@ -1,6 +1,6 @@ package azurerm -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const AzurePublicIPResourceType = "azurerm_public_ip" diff --git a/pkg/resource/azurerm/azurerm_resource_group.go b/enumeration/resource/azurerm/azurerm_resource_group.go similarity index 89% rename from pkg/resource/azurerm/azurerm_resource_group.go rename to enumeration/resource/azurerm/azurerm_resource_group.go index 88f5daf89..f30885cb7 100644 --- a/pkg/resource/azurerm/azurerm_resource_group.go +++ b/enumeration/resource/azurerm/azurerm_resource_group.go @@ -1,6 +1,6 @@ package azurerm -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const AzureResourceGroupResourceType = "azurerm_resource_group" diff --git a/pkg/resource/azurerm/azurerm_route.go b/enumeration/resource/azurerm/azurerm_route.go similarity index 91% rename from pkg/resource/azurerm/azurerm_route.go rename to enumeration/resource/azurerm/azurerm_route.go index 082184f0e..79789fc1f 100644 --- a/pkg/resource/azurerm/azurerm_route.go +++ b/enumeration/resource/azurerm/azurerm_route.go @@ -1,7 +1,7 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) const AzureRouteResourceType = "azurerm_route" diff --git a/pkg/resource/azurerm/azurerm_route_table.go b/enumeration/resource/azurerm/azurerm_route_table.go similarity index 90% rename from pkg/resource/azurerm/azurerm_route_table.go rename to enumeration/resource/azurerm/azurerm_route_table.go index fb2065d89..d0056f6aa 100644 --- a/pkg/resource/azurerm/azurerm_route_table.go +++ b/enumeration/resource/azurerm/azurerm_route_table.go @@ -1,7 +1,7 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) const AzureRouteTableResourceType = "azurerm_route_table" diff --git a/enumeration/resource/azurerm/azurerm_ssh_public_key.go b/enumeration/resource/azurerm/azurerm_ssh_public_key.go new file mode 100644 index 000000000..1d648ba28 --- /dev/null +++ b/enumeration/resource/azurerm/azurerm_ssh_public_key.go @@ -0,0 +1,20 @@ +package azurerm + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const AzureSSHPublicKeyResourceType = "azurerm_ssh_public_key" + +func initAzureSSHPublicKeyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureSSHPublicKeyResourceType, func(res *resource.Resource) map[string]string { + attrs := make(map[string]string) + + if v := res.Attributes().GetString("name"); v != nil && *v != "" { + attrs["Name"] = *v + } + + return attrs + }) + resourceSchemaRepository.SetFlags(AzureSSHPublicKeyResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/azurerm/azurerm_storage_account.go b/enumeration/resource/azurerm/azurerm_storage_account.go similarity index 100% rename from pkg/resource/azurerm/azurerm_storage_account.go rename to enumeration/resource/azurerm/azurerm_storage_account.go diff --git a/pkg/resource/azurerm/azurerm_storage_container.go b/enumeration/resource/azurerm/azurerm_storage_container.go similarity index 100% rename from pkg/resource/azurerm/azurerm_storage_container.go rename to enumeration/resource/azurerm/azurerm_storage_container.go diff --git a/pkg/resource/azurerm/azurerm_subnet.go b/enumeration/resource/azurerm/azurerm_subnet.go similarity index 100% rename from pkg/resource/azurerm/azurerm_subnet.go rename to enumeration/resource/azurerm/azurerm_subnet.go diff --git a/pkg/resource/azurerm/azurerm_virtual_network.go b/enumeration/resource/azurerm/azurerm_virtual_network.go similarity index 90% rename from pkg/resource/azurerm/azurerm_virtual_network.go rename to enumeration/resource/azurerm/azurerm_virtual_network.go index 470492521..790413f15 100644 --- a/pkg/resource/azurerm/azurerm_virtual_network.go +++ b/enumeration/resource/azurerm/azurerm_virtual_network.go @@ -1,7 +1,7 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) const AzureVirtualNetworkResourceType = "azurerm_virtual_network" diff --git a/enumeration/resource/azurerm/metadata.go b/enumeration/resource/azurerm/metadata.go new file mode 100644 index 000000000..5051e2267 --- /dev/null +++ b/enumeration/resource/azurerm/metadata.go @@ -0,0 +1,28 @@ +package azurerm + +import "github.com/snyk/driftctl/enumeration/resource" + +func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + initAzureVirtualNetworkMetaData(resourceSchemaRepository) + initAzureRouteTableMetaData(resourceSchemaRepository) + initAzureRouteMetaData(resourceSchemaRepository) + initAzureResourceGroupMetadata(resourceSchemaRepository) + initAzureContainerRegistryMetadata(resourceSchemaRepository) + initAzureFirewallMetadata(resourceSchemaRepository) + initAzurePostgresqlServerMetadata(resourceSchemaRepository) + initAzurePublicIPMetadata(resourceSchemaRepository) + initAzurePostgresqlDatabaseMetadata(resourceSchemaRepository) + initAzureNetworkSecurityGroupMetadata(resourceSchemaRepository) + initAzureLoadBalancerMetadata(resourceSchemaRepository) + initAzurePrivateDNSZoneMetaData(resourceSchemaRepository) + initAzurePrivateDNSARecordMetaData(resourceSchemaRepository) + initAzurePrivateDNSAAAARecordMetaData(resourceSchemaRepository) + initAzurePrivateDNSPTRRecordMetaData(resourceSchemaRepository) + initAzurePrivateDNSSRVRecordMetaData(resourceSchemaRepository) + initAzurePrivateDNSMXRecordMetaData(resourceSchemaRepository) + initAzurePrivateDNSTXTRecordMetaData(resourceSchemaRepository) + initAzureImageMetaData(resourceSchemaRepository) + initAzureSSHPublicKeyMetaData(resourceSchemaRepository) + initAzurePrivateDNSCNameRecordMetaData(resourceSchemaRepository) + initAzureLoadBalancerRuleMetadata(resourceSchemaRepository) +} diff --git a/pkg/resource/azurerm/metadata_test.go b/enumeration/resource/azurerm/metadata_test.go similarity index 95% rename from pkg/resource/azurerm/metadata_test.go rename to enumeration/resource/azurerm/metadata_test.go index 8e1dce50f..6dff89a1e 100644 --- a/pkg/resource/azurerm/metadata_test.go +++ b/enumeration/resource/azurerm/metadata_test.go @@ -1,10 +1,11 @@ package azurerm import ( + tf "github.com/snyk/driftctl/enumeration/terraform" + "testing" - "github.com/snyk/driftctl/pkg/resource" - tf "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration/resource" testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" ) diff --git a/enumeration/resource/deserializer.go b/enumeration/resource/deserializer.go new file mode 100644 index 000000000..aa71080a0 --- /dev/null +++ b/enumeration/resource/deserializer.go @@ -0,0 +1,48 @@ +package resource + +import ( + "encoding/json" + + "github.com/zclconf/go-cty/cty" + ctyjson "github.com/zclconf/go-cty/cty/json" +) + +type Deserializer struct { + factory ResourceFactory +} + +func NewDeserializer(factory ResourceFactory) *Deserializer { + return &Deserializer{factory} +} + +func (s *Deserializer) Deserialize(ty string, rawList []cty.Value) ([]*Resource, error) { + resources := make([]*Resource, 0) + for _, rawResource := range rawList { + rawResource := rawResource + res, err := s.DeserializeOne(ty, rawResource) + if err != nil { + return nil, err + } + resources = append(resources, res) + } + return resources, nil +} + +func (s *Deserializer) DeserializeOne(ty string, value cty.Value) (*Resource, error) { + if value.IsNull() { + return nil, nil + } + + // Marked values cannot be deserialized to JSON. + // For example, this ensures we can deserialize sensitive values too. + unmarkedVal, _ := value.UnmarkDeep() + + var attrs Attributes + bytes, _ := ctyjson.Marshal(unmarkedVal, unmarkedVal.Type()) + err := json.Unmarshal(bytes, &attrs) + if err != nil { + return nil, err + } + + return s.factory.CreateAbstractResource(ty, value.GetAttr("id").AsString(), attrs), nil +} diff --git a/enumeration/resource/github/github_branch_protection.go b/enumeration/resource/github/github_branch_protection.go new file mode 100644 index 000000000..03c5b22d0 --- /dev/null +++ b/enumeration/resource/github/github_branch_protection.go @@ -0,0 +1,39 @@ +// GENERATED, DO NOT EDIT THIS FILE +package github + +import ( + "encoding/base64" + + "github.com/snyk/driftctl/enumeration/resource" +) + +const GithubBranchProtectionResourceType = "github_branch_protection" + +func initGithubBranchProtectionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(GithubBranchProtectionResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + pattern := val.GetString("pattern") + repoID := val.GetString("repository_id") + if pattern != nil && *pattern != "" { + id := "" + if repoID != nil && *repoID != "" { + decodedID, err := base64.StdEncoding.DecodeString(*repoID) + if err == nil { + id = string(decodedID) + } + } + if id == "" { + attrs["Branch"] = *pattern + attrs["Id"] = res.ResourceId() + return attrs + } + attrs["Branch"] = *pattern + attrs["RepoId"] = id + return attrs + } + attrs["Id"] = res.ResourceId() + return attrs + }) + resourceSchemaRepository.SetFlags(GithubBranchProtectionResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/github/github_membership.go b/enumeration/resource/github/github_membership.go new file mode 100644 index 000000000..2a5dbd67a --- /dev/null +++ b/enumeration/resource/github/github_membership.go @@ -0,0 +1,10 @@ +// GENERATED, DO NOT EDIT THIS FILE +package github + +import "github.com/snyk/driftctl/enumeration/resource" + +const GithubMembershipResourceType = "github_membership" + +func initGithubMembershipMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(GithubMembershipResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/github/github_repository.go b/enumeration/resource/github/github_repository.go new file mode 100644 index 000000000..80f0e31cc --- /dev/null +++ b/enumeration/resource/github/github_repository.go @@ -0,0 +1,9 @@ +package github + +import "github.com/snyk/driftctl/enumeration/resource" + +const GithubRepositoryResourceType = "github_repository" + +func initGithubRepositoryMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(GithubRepositoryResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/github/github_team.go b/enumeration/resource/github/github_team.go new file mode 100644 index 000000000..6d679b396 --- /dev/null +++ b/enumeration/resource/github/github_team.go @@ -0,0 +1,19 @@ +// GENERATED, DO NOT EDIT THIS FILE +package github + +import "github.com/snyk/driftctl/enumeration/resource" + +const GithubTeamResourceType = "github_team" + +func initGithubTeamMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(GithubTeamResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + attrs["Id"] = res.ResourceId() + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + return attrs + }) + resourceSchemaRepository.SetFlags(GithubTeamResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/github/github_team_membership.go b/enumeration/resource/github/github_team_membership.go new file mode 100644 index 000000000..b2056879e --- /dev/null +++ b/enumeration/resource/github/github_team_membership.go @@ -0,0 +1,10 @@ +// GENERATED, DO NOT EDIT THIS FILE +package github + +import "github.com/snyk/driftctl/enumeration/resource" + +const GithubTeamMembershipResourceType = "github_team_membership" + +func initGithubTeamMembershipMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(GithubTeamMembershipResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/github/metadata_test.go b/enumeration/resource/github/metadata_test.go similarity index 91% rename from pkg/resource/github/metadata_test.go rename to enumeration/resource/github/metadata_test.go index c5064fe83..7f0902582 100644 --- a/pkg/resource/github/metadata_test.go +++ b/enumeration/resource/github/metadata_test.go @@ -1,10 +1,11 @@ package github import ( + tf "github.com/snyk/driftctl/enumeration/terraform" + "testing" - "github.com/snyk/driftctl/pkg/resource" - tf "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration/resource" testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" ) diff --git a/enumeration/resource/github/metadatas.go b/enumeration/resource/github/metadatas.go new file mode 100644 index 000000000..246227851 --- /dev/null +++ b/enumeration/resource/github/metadatas.go @@ -0,0 +1,11 @@ +package github + +import "github.com/snyk/driftctl/enumeration/resource" + +func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + initGithubBranchProtectionMetaData(resourceSchemaRepository) + initGithubMembershipMetaData(resourceSchemaRepository) + initGithubRepositoryMetaData(resourceSchemaRepository) + initGithubTeamMetaData(resourceSchemaRepository) + initGithubTeamMembershipMetaData(resourceSchemaRepository) +} diff --git a/pkg/resource/google/google_bigquery_dataset.go b/enumeration/resource/google/google_bigquery_dataset.go similarity index 88% rename from pkg/resource/google/google_bigquery_dataset.go rename to enumeration/resource/google/google_bigquery_dataset.go index 86eda5867..db663d490 100644 --- a/pkg/resource/google/google_bigquery_dataset.go +++ b/enumeration/resource/google/google_bigquery_dataset.go @@ -1,6 +1,6 @@ package google -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const GoogleBigqueryDatasetResourceType = "google_bigquery_dataset" diff --git a/pkg/resource/google/google_bigquery_table.go b/enumeration/resource/google/google_bigquery_table.go similarity index 88% rename from pkg/resource/google/google_bigquery_table.go rename to enumeration/resource/google/google_bigquery_table.go index f6aa8d7a3..9c39658d1 100644 --- a/pkg/resource/google/google_bigquery_table.go +++ b/enumeration/resource/google/google_bigquery_table.go @@ -1,6 +1,6 @@ package google -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const GoogleBigqueryTableResourceType = "google_bigquery_table" diff --git a/pkg/resource/google/google_bigtable_instance.go b/enumeration/resource/google/google_bigtable_instance.go similarity index 100% rename from pkg/resource/google/google_bigtable_instance.go rename to enumeration/resource/google/google_bigtable_instance.go diff --git a/pkg/resource/google/google_bigtable_table.go b/enumeration/resource/google/google_bigtable_table.go similarity index 100% rename from pkg/resource/google/google_bigtable_table.go rename to enumeration/resource/google/google_bigtable_table.go diff --git a/pkg/resource/google/google_cloudfunctions_function.go b/enumeration/resource/google/google_cloudfunctions_function.go similarity index 100% rename from pkg/resource/google/google_cloudfunctions_function.go rename to enumeration/resource/google/google_cloudfunctions_function.go diff --git a/pkg/resource/google/google_cloudrun_service.go b/enumeration/resource/google/google_cloudrun_service.go similarity index 100% rename from pkg/resource/google/google_cloudrun_service.go rename to enumeration/resource/google/google_cloudrun_service.go diff --git a/pkg/resource/google/google_compute_address.go b/enumeration/resource/google/google_compute_address.go similarity index 89% rename from pkg/resource/google/google_compute_address.go rename to enumeration/resource/google/google_compute_address.go index 61897161f..a37732855 100644 --- a/pkg/resource/google/google_compute_address.go +++ b/enumeration/resource/google/google_compute_address.go @@ -1,6 +1,6 @@ package google -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const GoogleComputeAddressResourceType = "google_compute_address" diff --git a/pkg/resource/google/google_compute_disk.go b/enumeration/resource/google/google_compute_disk.go similarity index 87% rename from pkg/resource/google/google_compute_disk.go rename to enumeration/resource/google/google_compute_disk.go index 37e020093..ed40a222e 100644 --- a/pkg/resource/google/google_compute_disk.go +++ b/enumeration/resource/google/google_compute_disk.go @@ -1,6 +1,6 @@ package google -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const GoogleComputeDiskResourceType = "google_compute_disk" diff --git a/enumeration/resource/google/google_compute_firewall.go b/enumeration/resource/google/google_compute_firewall.go new file mode 100644 index 000000000..4b836b5f7 --- /dev/null +++ b/enumeration/resource/google/google_compute_firewall.go @@ -0,0 +1,15 @@ +package google + +import "github.com/snyk/driftctl/enumeration/resource" + +const GoogleComputeFirewallResourceType = "google_compute_firewall" + +func initGoogleComputeFirewallMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetResolveReadAttributesFunc(GoogleComputeFirewallResourceType, func(res *resource.Resource) map[string]string { + return map[string]string{ + "name": *res.Attrs.GetString("name"), + "project": *res.Attrs.GetString("project"), + } + }) + resourceSchemaRepository.SetFlags(GoogleComputeFirewallResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/google/google_compute_forwarding_rule.go b/enumeration/resource/google/google_compute_forwarding_rule.go similarity index 100% rename from pkg/resource/google/google_compute_forwarding_rule.go rename to enumeration/resource/google/google_compute_forwarding_rule.go diff --git a/pkg/resource/google/google_compute_global_address.go b/enumeration/resource/google/google_compute_global_address.go similarity index 89% rename from pkg/resource/google/google_compute_global_address.go rename to enumeration/resource/google/google_compute_global_address.go index 00a141406..1c3af037c 100644 --- a/pkg/resource/google/google_compute_global_address.go +++ b/enumeration/resource/google/google_compute_global_address.go @@ -1,6 +1,6 @@ package google -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const GoogleComputeGlobalAddressResourceType = "google_compute_global_address" diff --git a/pkg/resource/google/google_compute_global_forwarding_rule.go b/enumeration/resource/google/google_compute_global_forwarding_rule.go similarity index 100% rename from pkg/resource/google/google_compute_global_forwarding_rule.go rename to enumeration/resource/google/google_compute_global_forwarding_rule.go diff --git a/pkg/resource/google/google_compute_health_check.go b/enumeration/resource/google/google_compute_health_check.go similarity index 88% rename from pkg/resource/google/google_compute_health_check.go rename to enumeration/resource/google/google_compute_health_check.go index 033e91639..c33b81731 100644 --- a/pkg/resource/google/google_compute_health_check.go +++ b/enumeration/resource/google/google_compute_health_check.go @@ -1,6 +1,6 @@ package google -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const GoogleComputeHealthCheckResourceType = "google_compute_health_check" diff --git a/pkg/resource/google/google_compute_image.go b/enumeration/resource/google/google_compute_image.go similarity index 87% rename from pkg/resource/google/google_compute_image.go rename to enumeration/resource/google/google_compute_image.go index 7b30ae044..f52788da5 100644 --- a/pkg/resource/google/google_compute_image.go +++ b/enumeration/resource/google/google_compute_image.go @@ -1,6 +1,6 @@ package google -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const GoogleComputeImageResourceType = "google_compute_image" diff --git a/pkg/resource/google/google_compute_instance.go b/enumeration/resource/google/google_compute_instance.go similarity index 100% rename from pkg/resource/google/google_compute_instance.go rename to enumeration/resource/google/google_compute_instance.go diff --git a/enumeration/resource/google/google_compute_instance_group.go b/enumeration/resource/google/google_compute_instance_group.go new file mode 100644 index 000000000..e2cd6c4f2 --- /dev/null +++ b/enumeration/resource/google/google_compute_instance_group.go @@ -0,0 +1,23 @@ +package google + +import "github.com/snyk/driftctl/enumeration/resource" + +const GoogleComputeInstanceGroupResourceType = "google_compute_instance_group" + +func initGoogleComputeInstanceGroupMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetResolveReadAttributesFunc(GoogleComputeInstanceGroupResourceType, func(res *resource.Resource) map[string]string { + return map[string]string{ + "name": *res.Attributes().GetString("name"), + "project": *res.Attributes().GetString("project"), + "zone": *res.Attributes().GetString("location"), + } + }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleComputeInstanceGroupResourceType, func(res *resource.Resource) map[string]string { + attrs := make(map[string]string) + if v := res.Attributes().GetString("name"); v != nil && *v != "" { + attrs["Name"] = *v + } + return attrs + }) + resourceSchemaRepository.SetFlags(GoogleComputeInstanceGroupResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/google/google_compute_instance_group_manager.go b/enumeration/resource/google/google_compute_instance_group_manager.go similarity index 90% rename from pkg/resource/google/google_compute_instance_group_manager.go rename to enumeration/resource/google/google_compute_instance_group_manager.go index 9afe13194..35ab1fbbc 100644 --- a/pkg/resource/google/google_compute_instance_group_manager.go +++ b/enumeration/resource/google/google_compute_instance_group_manager.go @@ -1,6 +1,6 @@ package google -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const GoogleComputeInstanceGroupManagerResourceType = "google_compute_instance_group_manager" diff --git a/enumeration/resource/google/google_compute_network.go b/enumeration/resource/google/google_compute_network.go new file mode 100644 index 000000000..850fc61ab --- /dev/null +++ b/enumeration/resource/google/google_compute_network.go @@ -0,0 +1,14 @@ +package google + +import "github.com/snyk/driftctl/enumeration/resource" + +const GoogleComputeNetworkResourceType = "google_compute_network" + +func initGoogleComputeNetworkMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetResolveReadAttributesFunc(GoogleComputeNetworkResourceType, func(res *resource.Resource) map[string]string { + return map[string]string{ + "name": *res.Attributes().GetString("name"), + } + }) + resourceSchemaRepository.SetFlags(GoogleComputeNetworkResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/google/google_compute_node_group.go b/enumeration/resource/google/google_compute_node_group.go similarity index 100% rename from pkg/resource/google/google_compute_node_group.go rename to enumeration/resource/google/google_compute_node_group.go diff --git a/pkg/resource/google/google_compute_router.go b/enumeration/resource/google/google_compute_router.go similarity index 89% rename from pkg/resource/google/google_compute_router.go rename to enumeration/resource/google/google_compute_router.go index ea428a594..43ae2b129 100644 --- a/pkg/resource/google/google_compute_router.go +++ b/enumeration/resource/google/google_compute_router.go @@ -1,6 +1,6 @@ package google -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" const GoogleComputeRouterResourceType = "google_compute_router" diff --git a/enumeration/resource/google/google_compute_subnetwork.go b/enumeration/resource/google/google_compute_subnetwork.go new file mode 100644 index 000000000..c88670d90 --- /dev/null +++ b/enumeration/resource/google/google_compute_subnetwork.go @@ -0,0 +1,23 @@ +package google + +import "github.com/snyk/driftctl/enumeration/resource" + +const GoogleComputeSubnetworkResourceType = "google_compute_subnetwork" + +func initGoogleComputeSubnetworkMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetResolveReadAttributesFunc(GoogleComputeSubnetworkResourceType, func(res *resource.Resource) map[string]string { + return map[string]string{ + "name": *res.Attributes().GetString("name"), + "region": *res.Attributes().GetString("region"), + } + }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleComputeSubnetworkResourceType, func(res *resource.Resource) map[string]string { + attrs := make(map[string]string) + + if v := res.Attributes().GetString("name"); v != nil && *v != "" { + attrs["Name"] = *v + } + return attrs + }) + resourceSchemaRepository.SetFlags(GoogleComputeSubnetworkResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/google/google_dns_managed_zone.go b/enumeration/resource/google/google_dns_managed_zone.go similarity index 100% rename from pkg/resource/google/google_dns_managed_zone.go rename to enumeration/resource/google/google_dns_managed_zone.go diff --git a/pkg/resource/google/google_project_iam_binding.go b/enumeration/resource/google/google_project_iam_binding.go similarity index 100% rename from pkg/resource/google/google_project_iam_binding.go rename to enumeration/resource/google/google_project_iam_binding.go diff --git a/enumeration/resource/google/google_project_iam_member.go b/enumeration/resource/google/google_project_iam_member.go new file mode 100644 index 000000000..1d29be10d --- /dev/null +++ b/enumeration/resource/google/google_project_iam_member.go @@ -0,0 +1,17 @@ +package google + +import "github.com/snyk/driftctl/enumeration/resource" + +const GoogleProjectIamMemberResourceType = "google_project_iam_member" + +func initGoogleProjectIAMMemberMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetResolveReadAttributesFunc(GoogleProjectIamMemberResourceType, func(res *resource.Resource) map[string]string { + return map[string]string{ + "project": *res.Attrs.GetString("project"), + "role": *res.Attrs.GetString("role"), + "member": *res.Attrs.GetString("member"), + } + }) + resourceSchemaRepository.SetFlags(GoogleProjectIamMemberResourceType, resource.FlagDeepMode) + +} diff --git a/pkg/resource/google/google_project_iam_policy.go b/enumeration/resource/google/google_project_iam_policy.go similarity index 100% rename from pkg/resource/google/google_project_iam_policy.go rename to enumeration/resource/google/google_project_iam_policy.go diff --git a/pkg/resource/google/google_sql_database_instance.go b/enumeration/resource/google/google_sql_database_instance.go similarity index 100% rename from pkg/resource/google/google_sql_database_instance.go rename to enumeration/resource/google/google_sql_database_instance.go diff --git a/enumeration/resource/google/google_storage_bucket.go b/enumeration/resource/google/google_storage_bucket.go new file mode 100644 index 000000000..42ecc5f52 --- /dev/null +++ b/enumeration/resource/google/google_storage_bucket.go @@ -0,0 +1,14 @@ +package google + +import "github.com/snyk/driftctl/enumeration/resource" + +const GoogleStorageBucketResourceType = "google_storage_bucket" + +func initGoogleStorageBucketMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetResolveReadAttributesFunc(GoogleStorageBucketResourceType, func(res *resource.Resource) map[string]string { + return map[string]string{ + "name": res.ResourceId(), + } + }) + resourceSchemaRepository.SetFlags(GoogleStorageBucketResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/google/google_storage_bucket_iam_binding.go b/enumeration/resource/google/google_storage_bucket_iam_binding.go similarity index 100% rename from pkg/resource/google/google_storage_bucket_iam_binding.go rename to enumeration/resource/google/google_storage_bucket_iam_binding.go diff --git a/enumeration/resource/google/google_storage_bucket_iam_member.go b/enumeration/resource/google/google_storage_bucket_iam_member.go new file mode 100644 index 000000000..3be214014 --- /dev/null +++ b/enumeration/resource/google/google_storage_bucket_iam_member.go @@ -0,0 +1,25 @@ +package google + +import "github.com/snyk/driftctl/enumeration/resource" + +const GoogleStorageBucketIamMemberResourceType = "google_storage_bucket_iam_member" + +func initGoogleStorageBucketIamBMemberMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetResolveReadAttributesFunc(GoogleStorageBucketIamMemberResourceType, func(res *resource.Resource) map[string]string { + return map[string]string{ + "bucket": *res.Attrs.GetString("bucket"), + "role": *res.Attrs.GetString("role"), + "member": *res.Attrs.GetString("member"), + } + }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleStorageBucketIamMemberResourceType, func(res *resource.Resource) map[string]string { + attrs := map[string]string{ + "bucket": *res.Attrs.GetString("bucket"), + "role": *res.Attrs.GetString("role"), + "member": *res.Attrs.GetString("member"), + } + return attrs + }) + resourceSchemaRepository.SetFlags(GoogleStorageBucketIamMemberResourceType, resource.FlagDeepMode) + +} diff --git a/pkg/resource/google/google_storage_bucket_iam_policy.go b/enumeration/resource/google/google_storage_bucket_iam_policy.go similarity index 100% rename from pkg/resource/google/google_storage_bucket_iam_policy.go rename to enumeration/resource/google/google_storage_bucket_iam_policy.go diff --git a/pkg/resource/google/metadata_test.go b/enumeration/resource/google/metadata_test.go similarity index 95% rename from pkg/resource/google/metadata_test.go rename to enumeration/resource/google/metadata_test.go index 2d1ebd6a1..7ff82e995 100644 --- a/pkg/resource/google/metadata_test.go +++ b/enumeration/resource/google/metadata_test.go @@ -3,8 +3,9 @@ package google import ( "testing" - "github.com/snyk/driftctl/pkg/resource" - tf "github.com/snyk/driftctl/pkg/terraform" + tf "github.com/snyk/driftctl/enumeration/terraform" + + "github.com/snyk/driftctl/enumeration/resource" testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" ) diff --git a/enumeration/resource/google/metadatas.go b/enumeration/resource/google/metadatas.go new file mode 100644 index 000000000..9cb8c8763 --- /dev/null +++ b/enumeration/resource/google/metadatas.go @@ -0,0 +1,22 @@ +package google + +import "github.com/snyk/driftctl/enumeration/resource" + +func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + initGoogleStorageBucketMetadata(resourceSchemaRepository) + initGoogleComputeFirewallMetadata(resourceSchemaRepository) + initGoogleComputeRouterMetadata(resourceSchemaRepository) + initGoogleComputeNetworkMetadata(resourceSchemaRepository) + initGoogleStorageBucketIamBMemberMetadata(resourceSchemaRepository) + initGoogleComputeInstanceGroupMetadata(resourceSchemaRepository) + initGoogleBigqueryDatasetMetadata(resourceSchemaRepository) + initGoogleBigqueryTableMetadata(resourceSchemaRepository) + initGoogleProjectIAMMemberMetadata(resourceSchemaRepository) + initGoogleComputeAddressMetadata(resourceSchemaRepository) + initGoogleComputeGlobalAddressMetadata(resourceSchemaRepository) + initGoogleComputeSubnetworkMetadata(resourceSchemaRepository) + initGoogleComputeDiskMetadata(resourceSchemaRepository) + initGoogleComputeImageMetadata(resourceSchemaRepository) + initGoogleComputeHealthCheckMetadata(resourceSchemaRepository) + initComputeInstanceGroupManagerMetadata(resourceSchemaRepository) +} diff --git a/enumeration/resource/mock_Supplier.go b/enumeration/resource/mock_Supplier.go new file mode 100644 index 000000000..981d4f489 --- /dev/null +++ b/enumeration/resource/mock_Supplier.go @@ -0,0 +1,33 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package resource + +import mock "github.com/stretchr/testify/mock" + +// MockSupplier is an autogenerated mock type for the Supplier type +type MockSupplier struct { + mock.Mock +} + +// Resources provides a mock function with given fields: +func (_m *MockSupplier) Resources() ([]*Resource, error) { + ret := _m.Called() + + var r0 []*Resource + if rf, ok := ret.Get(0).(func() []*Resource); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*Resource) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} diff --git a/pkg/resource/resource.go b/enumeration/resource/resource.go similarity index 100% rename from pkg/resource/resource.go rename to enumeration/resource/resource.go diff --git a/pkg/resource/resource_test.go b/enumeration/resource/resource_test.go similarity index 100% rename from pkg/resource/resource_test.go rename to enumeration/resource/resource_test.go diff --git a/pkg/resource/resource_types.go b/enumeration/resource/resource_types.go similarity index 100% rename from pkg/resource/resource_types.go rename to enumeration/resource/resource_types.go diff --git a/pkg/resource/schemas.go b/enumeration/resource/schemas.go similarity index 100% rename from pkg/resource/schemas.go rename to enumeration/resource/schemas.go diff --git a/enumeration/resource/supplier.go b/enumeration/resource/supplier.go new file mode 100644 index 000000000..054b64d00 --- /dev/null +++ b/enumeration/resource/supplier.go @@ -0,0 +1,11 @@ +package resource + +// Supplier supply the list of resource.Resource, it's the main interface to retrieve remote resources +type Supplier interface { + Resources() ([]*Resource, error) +} + +type StoppableSupplier interface { + Supplier + Stop() +} diff --git a/pkg/terraform/error/provider_download_error.go b/enumeration/terraform/error/provider_download_error.go similarity index 100% rename from pkg/terraform/error/provider_download_error.go rename to enumeration/terraform/error/provider_download_error.go diff --git a/pkg/terraform/lock/lockfile.go b/enumeration/terraform/lock/lockfile.go similarity index 100% rename from pkg/terraform/lock/lockfile.go rename to enumeration/terraform/lock/lockfile.go diff --git a/pkg/terraform/lock/lockfile_test.go b/enumeration/terraform/lock/lockfile_test.go similarity index 100% rename from pkg/terraform/lock/lockfile_test.go rename to enumeration/terraform/lock/lockfile_test.go diff --git a/pkg/terraform/lock/testdata/lockfile_empty.hcl b/enumeration/terraform/lock/testdata/lockfile_empty.hcl similarity index 100% rename from pkg/terraform/lock/testdata/lockfile_empty.hcl rename to enumeration/terraform/lock/testdata/lockfile_empty.hcl diff --git a/pkg/terraform/lock/testdata/lockfile_invalid.hcl b/enumeration/terraform/lock/testdata/lockfile_invalid.hcl similarity index 100% rename from pkg/terraform/lock/testdata/lockfile_invalid.hcl rename to enumeration/terraform/lock/testdata/lockfile_invalid.hcl diff --git a/pkg/terraform/lock/testdata/lockfile_invalid_type-1.hcl b/enumeration/terraform/lock/testdata/lockfile_invalid_type-1.hcl similarity index 100% rename from pkg/terraform/lock/testdata/lockfile_invalid_type-1.hcl rename to enumeration/terraform/lock/testdata/lockfile_invalid_type-1.hcl diff --git a/pkg/terraform/lock/testdata/lockfile_invalid_type-3.hcl b/enumeration/terraform/lock/testdata/lockfile_invalid_type-3.hcl similarity index 100% rename from pkg/terraform/lock/testdata/lockfile_invalid_type-3.hcl rename to enumeration/terraform/lock/testdata/lockfile_invalid_type-3.hcl diff --git a/pkg/terraform/lock/testdata/lockfile_valid.hcl b/enumeration/terraform/lock/testdata/lockfile_valid.hcl similarity index 100% rename from pkg/terraform/lock/testdata/lockfile_valid.hcl rename to enumeration/terraform/lock/testdata/lockfile_valid.hcl diff --git a/pkg/terraform/mock_ResourceFactory.go b/enumeration/terraform/mock_ResourceFactory.go similarity index 96% rename from pkg/terraform/mock_ResourceFactory.go rename to enumeration/terraform/mock_ResourceFactory.go index b3e0d0f92..fb58c47af 100644 --- a/pkg/terraform/mock_ResourceFactory.go +++ b/enumeration/terraform/mock_ResourceFactory.go @@ -3,7 +3,7 @@ package terraform import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" mock "github.com/stretchr/testify/mock" cty "github.com/zclconf/go-cty/cty" ) diff --git a/pkg/terraform/parallel_resource_reader.go b/enumeration/terraform/parallel_resource_reader.go similarity index 94% rename from pkg/terraform/parallel_resource_reader.go rename to enumeration/terraform/parallel_resource_reader.go index 4ee1cc17b..ab0f22862 100644 --- a/pkg/terraform/parallel_resource_reader.go +++ b/enumeration/terraform/parallel_resource_reader.go @@ -1,8 +1,7 @@ package terraform import ( - "github.com/snyk/driftctl/pkg/parallel" - + "github.com/snyk/driftctl/enumeration/parallel" "github.com/zclconf/go-cty/cty" ) diff --git a/pkg/terraform/parallel_resource_reader_test.go b/enumeration/terraform/parallel_resource_reader_test.go similarity index 97% rename from pkg/terraform/parallel_resource_reader_test.go rename to enumeration/terraform/parallel_resource_reader_test.go index 134b78468..4dd891759 100644 --- a/pkg/terraform/parallel_resource_reader_test.go +++ b/enumeration/terraform/parallel_resource_reader_test.go @@ -6,9 +6,9 @@ import ( "strings" "testing" - "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/parallel" + "github.com/snyk/driftctl/enumeration/parallel" + "github.com/r3labs/diff/v2" "github.com/stretchr/testify/assert" "github.com/zclconf/go-cty/cty" diff --git a/pkg/terraform/plugin_client.go b/enumeration/terraform/plugin_client.go similarity index 100% rename from pkg/terraform/plugin_client.go rename to enumeration/terraform/plugin_client.go diff --git a/pkg/terraform/provider_config.go b/enumeration/terraform/provider_config.go similarity index 100% rename from pkg/terraform/provider_config.go rename to enumeration/terraform/provider_config.go diff --git a/pkg/terraform/provider_config_test.go b/enumeration/terraform/provider_config_test.go similarity index 100% rename from pkg/terraform/provider_config_test.go rename to enumeration/terraform/provider_config_test.go diff --git a/pkg/terraform/provider_downloader.go b/enumeration/terraform/provider_downloader.go similarity index 94% rename from pkg/terraform/provider_downloader.go rename to enumeration/terraform/provider_downloader.go index d9463ad4a..dafdec642 100644 --- a/pkg/terraform/provider_downloader.go +++ b/enumeration/terraform/provider_downloader.go @@ -6,10 +6,12 @@ import ( "net/http" "os" + tferror "github.com/snyk/driftctl/enumeration/terraform/error" + "github.com/hashicorp/go-getter" + "github.com/pkg/errors" "github.com/sirupsen/logrus" - error2 "github.com/snyk/driftctl/pkg/terraform/error" ) type ProviderDownloaderInterface interface { @@ -46,7 +48,7 @@ func (p *ProviderDownloader) Download(url, path string) error { } defer resp.Body.Close() if resp.StatusCode == http.StatusForbidden { - return error2.ProviderNotFoundError{} + return tferror.ProviderNotFoundError{} } if resp.StatusCode != http.StatusOK { return errors.Errorf("unsuccessful request to %s: %s", url, resp.Status) diff --git a/pkg/terraform/provider_downloader_test.go b/enumeration/terraform/provider_downloader_test.go similarity index 97% rename from pkg/terraform/provider_downloader_test.go rename to enumeration/terraform/provider_downloader_test.go index a77734f31..6c6503d28 100644 --- a/pkg/terraform/provider_downloader_test.go +++ b/enumeration/terraform/provider_downloader_test.go @@ -2,14 +2,13 @@ package terraform import ( "fmt" + terraformError "github.com/snyk/driftctl/enumeration/terraform/error" "io/ioutil" "net/http" "path" "testing" "github.com/aws/aws-sdk-go/aws" - terraformError "github.com/snyk/driftctl/pkg/terraform/error" - "github.com/stretchr/testify/assert" "github.com/jarcoal/httpmock" diff --git a/pkg/terraform/provider_factory.go b/enumeration/terraform/provider_factory.go similarity index 100% rename from pkg/terraform/provider_factory.go rename to enumeration/terraform/provider_factory.go diff --git a/pkg/terraform/provider_installer.go b/enumeration/terraform/provider_installer.go similarity index 92% rename from pkg/terraform/provider_installer.go rename to enumeration/terraform/provider_installer.go index bbe6daa50..f40b8c165 100644 --- a/pkg/terraform/provider_installer.go +++ b/enumeration/terraform/provider_installer.go @@ -9,11 +9,10 @@ import ( "runtime" "strings" + error2 "github.com/snyk/driftctl/enumeration/terraform/error" + "github.com/pkg/errors" "github.com/sirupsen/logrus" - error2 "github.com/snyk/driftctl/pkg/terraform/error" - - "github.com/snyk/driftctl/pkg/output" ) type HomeDirInterface interface { @@ -44,7 +43,6 @@ func (p *ProviderInstaller) Install() (string, error) { logrus.WithFields(logrus.Fields{ "path": providerPath, }).Debug("provider not found, downloading ...") - output.Printf("Downloading terraform provider: %s\n", p.config.Key) err := p.downloader.Download( p.config.GetDownloadUrl(), providerDir, diff --git a/pkg/terraform/provider_installer_test.go b/enumeration/terraform/provider_installer_test.go similarity index 98% rename from pkg/terraform/provider_installer_test.go rename to enumeration/terraform/provider_installer_test.go index d861b32b9..43814e844 100644 --- a/pkg/terraform/provider_installer_test.go +++ b/enumeration/terraform/provider_installer_test.go @@ -2,13 +2,13 @@ package terraform import ( "fmt" + terraformError "github.com/snyk/driftctl/enumeration/terraform/error" "os" "path" "runtime" "testing" "github.com/snyk/driftctl/mocks" - terraformError "github.com/snyk/driftctl/pkg/terraform/error" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/assert" diff --git a/pkg/terraform/providers.go b/enumeration/terraform/providers.go similarity index 100% rename from pkg/terraform/providers.go rename to enumeration/terraform/providers.go diff --git a/pkg/terraform/resource_factory.go b/enumeration/terraform/resource_factory.go similarity index 94% rename from pkg/terraform/resource_factory.go rename to enumeration/terraform/resource_factory.go index 33670989b..e80d3097c 100644 --- a/pkg/terraform/resource_factory.go +++ b/enumeration/terraform/resource_factory.go @@ -1,7 +1,7 @@ package terraform import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) type TerraformResourceFactory struct { diff --git a/pkg/terraform/resource_reader.go b/enumeration/terraform/resource_reader.go similarity index 84% rename from pkg/terraform/resource_reader.go rename to enumeration/terraform/resource_reader.go index 8600848c9..1f7a6e369 100644 --- a/pkg/terraform/resource_reader.go +++ b/enumeration/terraform/resource_reader.go @@ -1,7 +1,7 @@ package terraform import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" "github.com/zclconf/go-cty/cty" ) diff --git a/pkg/terraform/schema_supplier.go b/enumeration/terraform/schema_supplier.go similarity index 100% rename from pkg/terraform/schema_supplier.go rename to enumeration/terraform/schema_supplier.go diff --git a/pkg/terraform/terraform_provider.go b/enumeration/terraform/terraform_provider.go similarity index 100% rename from pkg/terraform/terraform_provider.go rename to enumeration/terraform/terraform_provider.go diff --git a/pkg/terraform/testdata/invalid.zip b/enumeration/terraform/testdata/invalid.zip similarity index 100% rename from pkg/terraform/testdata/invalid.zip rename to enumeration/terraform/testdata/invalid.zip diff --git a/pkg/terraform/testdata/terraform-provider-aws_3.5.0_linux_amd64.zip b/enumeration/terraform/testdata/terraform-provider-aws_3.5.0_linux_amd64.zip similarity index 100% rename from pkg/terraform/testdata/terraform-provider-aws_3.5.0_linux_amd64.zip rename to enumeration/terraform/testdata/terraform-provider-aws_3.5.0_linux_amd64.zip diff --git a/mocks/AlerterInterface.go b/mocks/AlerterInterface.go index bfd52a2e3..4903a713a 100644 --- a/mocks/AlerterInterface.go +++ b/mocks/AlerterInterface.go @@ -3,7 +3,7 @@ package mocks import ( - alerter "github.com/snyk/driftctl/pkg/alerter" + "github.com/snyk/driftctl/enumeration/alerter" mock "github.com/stretchr/testify/mock" ) diff --git a/pkg/analyser/analysis.go b/pkg/analyser/analysis.go index 90b80beed..9de62ef32 100644 --- a/pkg/analyser/analysis.go +++ b/pkg/analyser/analysis.go @@ -7,9 +7,10 @@ import ( "strings" "time" + "github.com/snyk/driftctl/enumeration/alerter" + "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/alerter" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) type Change struct { diff --git a/pkg/analyser/analyzer.go b/pkg/analyser/analyzer.go index 83e297e66..d26f45763 100644 --- a/pkg/analyser/analyzer.go +++ b/pkg/analyser/analyzer.go @@ -2,11 +2,11 @@ package analyser import ( "github.com/r3labs/diff/v2" + "github.com/snyk/driftctl/enumeration/alerter" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/pkg/filter" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/alerter" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) type UnmanagedSecurityGroupRulesAlert struct{} diff --git a/pkg/analyser/analyzer_test.go b/pkg/analyser/analyzer_test.go index 984ef0d98..16bdca891 100644 --- a/pkg/analyser/analyzer_test.go +++ b/pkg/analyser/analyzer_test.go @@ -6,6 +6,9 @@ import ( "testing" "time" + alerter2 "github.com/snyk/driftctl/enumeration/alerter" + aws2 "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/pkg/filter" "github.com/stretchr/testify/mock" @@ -15,9 +18,8 @@ import ( "github.com/snyk/driftctl/test/goldenfile" - "github.com/snyk/driftctl/pkg/alerter" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/r3labs/diff/v2" ) @@ -32,7 +34,7 @@ func TestAnalyze(t *testing.T) { res *resource.Resource path []string } - alerts alerter.Alerts + alerts alerter2.Alerts expected Analysis hasDrifted bool options *AnalyzerOptions @@ -292,7 +294,7 @@ func TestAnalyze(t *testing.T) { }, }, }, - alerts: alerter.Alerts{ + alerts: alerter2.Alerts{ "": { NewComputedDiffAlert(), }, @@ -379,7 +381,7 @@ func TestAnalyze(t *testing.T) { }, }, }, - alerts: alerter.Alerts{ + alerts: alerter2.Alerts{ "": { NewComputedDiffAlert(), }, @@ -574,15 +576,15 @@ func TestAnalyze(t *testing.T) { }, }, }, - alerts: alerter.Alerts{ + alerts: alerter2.Alerts{ "fakeres": { - &alerter.FakeAlert{Msg: "Should be ignored", IgnoreResource: true}, + &alerter2.FakeAlert{Msg: "Should be ignored", IgnoreResource: true}, }, "other.foobaz": { - &alerter.FakeAlert{Msg: "Should be ignored", IgnoreResource: true}, + &alerter2.FakeAlert{Msg: "Should be ignored", IgnoreResource: true}, }, "other.resource": { - &alerter.FakeAlert{Msg: "Should not be ignored"}, + &alerter2.FakeAlert{Msg: "Should not be ignored"}, }, }, expected: Analysis{ @@ -702,15 +704,15 @@ func TestAnalyze(t *testing.T) { }, }, }, - alerts: alerter.Alerts{ + alerts: alerter2.Alerts{ "fakeres": { - &alerter.FakeAlert{Msg: "Should be ignored", IgnoreResource: true}, + &alerter2.FakeAlert{Msg: "Should be ignored", IgnoreResource: true}, }, "other.foobaz": { - &alerter.FakeAlert{Msg: "Should be ignored", IgnoreResource: true}, + &alerter2.FakeAlert{Msg: "Should be ignored", IgnoreResource: true}, }, "other.resource": { - &alerter.FakeAlert{Msg: "Should not be ignored"}, + &alerter2.FakeAlert{Msg: "Should not be ignored"}, }, }, }, @@ -738,7 +740,7 @@ func TestAnalyze(t *testing.T) { }, }, }, - alerts: alerter.Alerts{}, + alerts: alerter2.Alerts{}, expected: Analysis{ managed: []*resource.Resource{ { @@ -791,7 +793,7 @@ func TestAnalyze(t *testing.T) { }, }, }, - alerts: alerter.Alerts{ + alerts: alerter2.Alerts{ "": { NewComputedDiffAlert(), }, @@ -850,7 +852,7 @@ func TestAnalyze(t *testing.T) { TotalManaged: 1, TotalUnmanaged: 1, }, - alerts: alerter.Alerts{ + alerts: alerter2.Alerts{ "": { newUnmanagedSecurityGroupRulesAlert(), }, @@ -924,7 +926,7 @@ func TestAnalyze(t *testing.T) { TotalUnmanaged: 3, TotalDeleted: 3, }, - alerts: alerter.Alerts{}, + alerts: alerter2.Alerts{}, }, hasDrifted: true, }, @@ -1158,13 +1160,14 @@ func TestAnalyze(t *testing.T) { } testFilter.On("IsFieldIgnored", mock.Anything, mock.Anything).Return(false) - al := alerter.NewAlerter() + al := alerter2.NewAlerter() if c.alerts != nil { al.SetAlerts(c.alerts) } repo := testresource.InitFakeSchemaRepository("aws", "3.19.0") aws.InitResourcesMetadata(repo) + aws2.InitResourcesMetadata(repo) options := AnalyzerOptions{Deep: true} if c.options != nil { @@ -1327,9 +1330,9 @@ func TestAnalysis_MarshalJSON(t *testing.T) { }, }, }) - analysis.SetAlerts(alerter.Alerts{ + analysis.SetAlerts(alerter2.Alerts{ "aws_iam_access_key": { - &alerter.FakeAlert{Msg: "This is an alert"}, + &alerter2.FakeAlert{Msg: "This is an alert"}, }, }) analysis.ProviderName = "AWS" @@ -1413,9 +1416,9 @@ func TestAnalysis_UnmarshalJSON(t *testing.T) { }, }, }, - alerts: alerter.Alerts{ + alerts: alerter2.Alerts{ "aws_iam_access_key": { - &alerter.SerializedAlert{ + &alerter2.SerializedAlert{ Msg: "This is an alert", }, }, diff --git a/pkg/cmd/scan.go b/pkg/cmd/scan.go index 28c51035d..b5476e994 100644 --- a/pkg/cmd/scan.go +++ b/pkg/cmd/scan.go @@ -16,27 +16,28 @@ import ( "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/snyk/driftctl/build" + "github.com/snyk/driftctl/enumeration/alerter" + "github.com/snyk/driftctl/enumeration/remote" + "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform/lock" "github.com/snyk/driftctl/pkg/analyser" "github.com/snyk/driftctl/pkg/iac/config" "github.com/snyk/driftctl/pkg/iac/terraform/state" "github.com/snyk/driftctl/pkg/memstore" - "github.com/snyk/driftctl/pkg/remote/common" "github.com/snyk/driftctl/pkg/telemetry" "github.com/snyk/driftctl/pkg/terraform/hcl" - "github.com/snyk/driftctl/pkg/terraform/lock" "github.com/spf13/cobra" + "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/pkg" - "github.com/snyk/driftctl/pkg/alerter" cmderrors "github.com/snyk/driftctl/pkg/cmd/errors" "github.com/snyk/driftctl/pkg/cmd/scan/output" "github.com/snyk/driftctl/pkg/filter" "github.com/snyk/driftctl/pkg/iac/supplier" "github.com/snyk/driftctl/pkg/iac/terraform/state/backend" globaloutput "github.com/snyk/driftctl/pkg/output" - "github.com/snyk/driftctl/pkg/remote" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/terraform" + dctlresource "github.com/snyk/driftctl/pkg/resource" ) func NewScanCmd(opts *pkg.ScanOptions) *cobra.Command { @@ -295,6 +296,10 @@ func scanRun(opts *pkg.ScanOptions) error { return err } + err = dctlresource.InitMetadatas(opts.To, resourceSchemaRepository) + if err != nil { + return err + } // Teardown defer func() { logrus.Trace("Exiting scan cmd") diff --git a/pkg/cmd/scan/output/console.go b/pkg/cmd/scan/output/console.go index 23c2e0cb4..2f8a70a8d 100644 --- a/pkg/cmd/scan/output/console.go +++ b/pkg/cmd/scan/output/console.go @@ -3,6 +3,7 @@ package output import ( "encoding/json" "fmt" + "github.com/snyk/driftctl/enumeration/remote/alerts" "os" "reflect" "sort" @@ -12,12 +13,11 @@ import ( "github.com/fatih/color" "github.com/mattn/go-isatty" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/remote/alerts" "github.com/yudai/gojsondiff" "github.com/yudai/gojsondiff/formatter" + "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/pkg/analyser" - "github.com/snyk/driftctl/pkg/resource" ) const ConsoleOutputType = "console" diff --git a/pkg/cmd/scan/output/console_test.go b/pkg/cmd/scan/output/console_test.go index 87751b186..abdbc2d4a 100644 --- a/pkg/cmd/scan/output/console_test.go +++ b/pkg/cmd/scan/output/console_test.go @@ -8,8 +8,8 @@ import ( "path" "testing" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/test/goldenfile" testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" diff --git a/pkg/cmd/scan/output/html.go b/pkg/cmd/scan/output/html.go index f7adb2d02..571869638 100644 --- a/pkg/cmd/scan/output/html.go +++ b/pkg/cmd/scan/output/html.go @@ -5,6 +5,7 @@ import ( "embed" "encoding/base64" "fmt" + "github.com/snyk/driftctl/enumeration/alerter" "html/template" "math" "os" @@ -16,9 +17,8 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/alerter" + "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/pkg/analyser" - "github.com/snyk/driftctl/pkg/resource" ) const HTMLOutputType = "html" diff --git a/pkg/cmd/scan/output/html_test.go b/pkg/cmd/scan/output/html_test.go index 9490a9a73..7542de9ab 100644 --- a/pkg/cmd/scan/output/html_test.go +++ b/pkg/cmd/scan/output/html_test.go @@ -7,7 +7,7 @@ import ( "time" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" "github.com/stretchr/testify/assert" "github.com/snyk/driftctl/pkg/analyser" diff --git a/pkg/cmd/scan/output/output_test.go b/pkg/cmd/scan/output/output_test.go index 7ff6c11d7..70b2c3fd0 100644 --- a/pkg/cmd/scan/output/output_test.go +++ b/pkg/cmd/scan/output/output_test.go @@ -6,16 +6,17 @@ import ( "testing" "time" + "github.com/snyk/driftctl/enumeration/alerter" + "github.com/snyk/driftctl/enumeration/remote/alerts" + "github.com/snyk/driftctl/enumeration/remote/common" + remoteerr "github.com/snyk/driftctl/enumeration/remote/error" + "github.com/pkg/errors" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/alerter" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/pkg/analyser" "github.com/snyk/driftctl/pkg/output" - "github.com/snyk/driftctl/pkg/remote/alerts" - "github.com/snyk/driftctl/pkg/remote/common" - remoteerr "github.com/snyk/driftctl/pkg/remote/error" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" ) func fakeAnalysis(opts analyser.AnalyzerOptions) *analyser.Analysis { diff --git a/pkg/cmd/scan/output/plan.go b/pkg/cmd/scan/output/plan.go index 48ab75dcc..ceed70aae 100644 --- a/pkg/cmd/scan/output/plan.go +++ b/pkg/cmd/scan/output/plan.go @@ -5,8 +5,8 @@ import ( "fmt" "os" + "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/pkg/analyser" - "github.com/snyk/driftctl/pkg/resource" ) const FormatVersion = "0.1" diff --git a/pkg/driftctl.go b/pkg/driftctl.go index f9130d4a8..953f4cf42 100644 --- a/pkg/driftctl.go +++ b/pkg/driftctl.go @@ -4,19 +4,21 @@ import ( "fmt" "time" + "github.com/snyk/driftctl/enumeration/alerter" + resource2 "github.com/snyk/driftctl/pkg/resource" + "github.com/jmespath/go-jmespath" "github.com/sirupsen/logrus" "github.com/snyk/driftctl/pkg/memstore" globaloutput "github.com/snyk/driftctl/pkg/output" - "github.com/snyk/driftctl/pkg/alerter" + "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/pkg/analyser" "github.com/snyk/driftctl/pkg/cmd/scan/output" "github.com/snyk/driftctl/pkg/filter" "github.com/snyk/driftctl/pkg/iac/config" "github.com/snyk/driftctl/pkg/iac/terraform/state/backend" "github.com/snyk/driftctl/pkg/middlewares" - "github.com/snyk/driftctl/pkg/resource" ) type FmtOptions struct { @@ -45,7 +47,7 @@ type ScanOptions struct { type DriftCTL struct { remoteSupplier resource.Supplier - iacSupplier resource.IaCSupplier + iacSupplier resource2.IaCSupplier alerter alerter.AlerterInterface analyzer *analyser.Analyzer resourceFactory resource.ResourceFactory @@ -57,7 +59,7 @@ type DriftCTL struct { } func NewDriftCTL(remoteSupplier resource.Supplier, - iacSupplier resource.IaCSupplier, + iacSupplier resource2.IaCSupplier, alerter *alerter.Alerter, analyzer *analyser.Analyzer, resFactory resource.ResourceFactory, diff --git a/pkg/driftctl_test.go b/pkg/driftctl_test.go index 1d8a99f14..6a8576511 100644 --- a/pkg/driftctl_test.go +++ b/pkg/driftctl_test.go @@ -1,20 +1,22 @@ package pkg_test import ( + terraform2 "github.com/snyk/driftctl/enumeration/terraform" + resource2 "github.com/snyk/driftctl/pkg/resource" + "reflect" "testing" "github.com/r3labs/diff/v2" + "github.com/snyk/driftctl/enumeration/alerter" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/enumeration/resource/github" "github.com/snyk/driftctl/pkg" - "github.com/snyk/driftctl/pkg/alerter" "github.com/snyk/driftctl/pkg/analyser" "github.com/snyk/driftctl/pkg/filter" "github.com/snyk/driftctl/pkg/memstore" "github.com/snyk/driftctl/pkg/output" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/resource/github" - "github.com/snyk/driftctl/pkg/terraform" "github.com/snyk/driftctl/test" testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" @@ -62,7 +64,7 @@ func runTest(t *testing.T, cases TestCases) { res.Sch = schema } - stateSupplier := &resource.MockIaCSupplier{} + stateSupplier := &resource2.MockIaCSupplier{} stateSupplier.On("Resources").Return(c.stateResources, nil) stateSupplier.On("SourceCount").Return(uint(2)) @@ -77,10 +79,10 @@ func runTest(t *testing.T, cases TestCases) { remoteSupplier := &resource.MockSupplier{} remoteSupplier.On("Resources").Return(c.remoteResources, nil) - var resourceFactory resource.ResourceFactory = terraform.NewTerraformResourceFactory(repo) + var resourceFactory resource.ResourceFactory = terraform2.NewTerraformResourceFactory(repo) if c.mocks != nil { - resourceFactory = &terraform.MockResourceFactory{} + resourceFactory = &terraform2.MockResourceFactory{} c.mocks(resourceFactory, repo) } @@ -364,7 +366,7 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) { { name: "we should ignore default AWS IAM role when strict mode is disabled", mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { - factory.(*terraform.MockResourceFactory).On( + factory.(*terraform2.MockResourceFactory).On( "CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "role-test-1-policy-test-1", @@ -462,7 +464,7 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) { { name: "we should not ignore default AWS IAM role when strict mode is enabled", mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { - factory.(*terraform.MockResourceFactory).On( + factory.(*terraform2.MockResourceFactory).On( "CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "role-test-1-policy-test-1", @@ -560,7 +562,7 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) { { name: "we should not ignore default AWS IAM role when strict mode is enabled and a filter is specified", mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { - factory.(*terraform.MockResourceFactory).On( + factory.(*terraform2.MockResourceFactory).On( "CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "role-test-1-policy-test-1", @@ -791,7 +793,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, }, mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { - factory.(*terraform.MockResourceFactory).On( + factory.(*terraform2.MockResourceFactory).On( "CreateAbstractResource", aws.AwsS3BucketPolicyResourceType, "foo", @@ -888,7 +890,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, Sch: getSchema(repo, "aws_ebs_volume"), } - factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_ebs_volume", mock.Anything, mock.MatchedBy(func(input map[string]interface{}) bool { + factory.(*terraform2.MockResourceFactory).On("CreateAbstractResource", "aws_ebs_volume", mock.Anything, mock.MatchedBy(func(input map[string]interface{}) bool { return matchByAttributes(input, map[string]interface{}{ "id": "vol-018c5ae89895aca4c", "availability_zone": "us-east-1", @@ -907,7 +909,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, Sch: getSchema(repo, "aws_ebs_volume"), } - factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_ebs_volume", mock.Anything, mock.MatchedBy(func(input map[string]interface{}) bool { + factory.(*terraform2.MockResourceFactory).On("CreateAbstractResource", "aws_ebs_volume", mock.Anything, mock.MatchedBy(func(input map[string]interface{}) bool { return matchByAttributes(input, map[string]interface{}{ "id": "vol-02862d9b39045a3a4", "availability_zone": "us-east-1", @@ -993,7 +995,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, }, mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { - factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_route", "r-table1080289494", mock.MatchedBy(func(input map[string]interface{}) bool { + factory.(*terraform2.MockResourceFactory).On("CreateAbstractResource", "aws_route", "r-table1080289494", mock.MatchedBy(func(input map[string]interface{}) bool { return matchByAttributes(input, map[string]interface{}{ "destination_cidr_block": "0.0.0.0/0", "gateway_id": "igw-07b7844a8fd17a638", @@ -1012,7 +1014,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "state": "active", }, }, nil) - factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_route", "r-table2750132062", mock.MatchedBy(func(input map[string]interface{}) bool { + factory.(*terraform2.MockResourceFactory).On("CreateAbstractResource", "aws_route", "r-table2750132062", mock.MatchedBy(func(input map[string]interface{}) bool { return matchByAttributes(input, map[string]interface{}{ "destination_ipv6_cidr_block": "::/0", "gateway_id": "igw-07b7844a8fd17a638", @@ -1071,7 +1073,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, }, mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { - factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_sns_topic_policy", "foo", map[string]interface{}{ + factory.(*terraform2.MockResourceFactory).On("CreateAbstractResource", "aws_sns_topic_policy", "foo", map[string]interface{}{ "id": "foo", "arn": "arn", "policy": "{\"policy\":\"bar\"}", @@ -1133,7 +1135,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, }, mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { - factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_sqs_queue_policy", "foo", map[string]interface{}{ + factory.(*terraform2.MockResourceFactory).On("CreateAbstractResource", "aws_sqs_queue_policy", "foo", map[string]interface{}{ "id": "foo", "queue_url": "foo", "policy": "{\"policy\":\"bar\"}", @@ -1362,7 +1364,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "prefix_list_ids": []interface{}{}, }, } - factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_security_group_rule", rule1.Id, + factory.(*terraform2.MockResourceFactory).On("CreateAbstractResource", "aws_security_group_rule", rule1.Id, mock.MatchedBy(func(input map[string]interface{}) bool { return matchByAttributes(input, map[string]interface{}{ "id": "sgrule-1707973622", @@ -1394,7 +1396,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "prefix_list_ids": []interface{}{}, }, } - factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_security_group_rule", rule2.Id, + factory.(*terraform2.MockResourceFactory).On("CreateAbstractResource", "aws_security_group_rule", rule2.Id, mock.MatchedBy(func(input map[string]interface{}) bool { return matchByAttributes(input, map[string]interface{}{ "id": "sgrule-2821752134", @@ -1426,7 +1428,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "prefix_list_ids": []interface{}{}, }, } - factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_security_group_rule", rule3.Id, + factory.(*terraform2.MockResourceFactory).On("CreateAbstractResource", "aws_security_group_rule", rule3.Id, mock.MatchedBy(func(input map[string]interface{}) bool { return matchByAttributes(input, map[string]interface{}{ "id": "sgrule-2165103420", @@ -1458,7 +1460,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "prefix_list_ids": []interface{}{}, }, } - factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_security_group_rule", rule4.Id, + factory.(*terraform2.MockResourceFactory).On("CreateAbstractResource", "aws_security_group_rule", rule4.Id, mock.MatchedBy(func(input map[string]interface{}) bool { return matchByAttributes(input, map[string]interface{}{ "id": "sgrule-2582518759", @@ -1554,7 +1556,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, }, mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { - factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "iduser1", map[string]interface{}{ + factory.(*terraform2.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "iduser1", map[string]interface{}{ "id": "iduser1", "policy_arn": "policy_arn1", "users": []interface{}{"user1"}, @@ -1571,7 +1573,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "roles": []interface{}{}, }, }, nil) - factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "user1-policy_arn1", map[string]interface{}{ + factory.(*terraform2.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "user1-policy_arn1", map[string]interface{}{ "policy_arn": "policy_arn1", "users": []interface{}{"user1"}, }).Twice().Return(&resource.Resource{ @@ -1582,7 +1584,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "users": []interface{}{"user1"}, }, }, nil) - factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "idrole1", map[string]interface{}{ + factory.(*terraform2.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "idrole1", map[string]interface{}{ "id": "idrole1", "policy_arn": "policy_arn1", "users": []interface{}{}, @@ -1599,7 +1601,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "roles": []interface{}{"role1"}, }, }, nil) - factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "role1-policy_arn1", map[string]interface{}{ + factory.(*terraform2.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "role1-policy_arn1", map[string]interface{}{ "policy_arn": "policy_arn1", "roles": []interface{}{"role1"}, }).Twice().Return(&resource.Resource{ diff --git a/pkg/filter/driftignore.go b/pkg/filter/driftignore.go index ac9033f2e..762a12453 100644 --- a/pkg/filter/driftignore.go +++ b/pkg/filter/driftignore.go @@ -8,7 +8,7 @@ import ( "github.com/go-git/go-git/v5/plumbing/format/gitignore" "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) const separator = "_-_" diff --git a/pkg/filter/driftignore_test.go b/pkg/filter/driftignore_test.go index 575ea7b27..0695a874d 100644 --- a/pkg/filter/driftignore_test.go +++ b/pkg/filter/driftignore_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/assert" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) func TestDriftIgnore_IsResourceIgnored(t *testing.T) { diff --git a/pkg/filter/filter.go b/pkg/filter/filter.go index 479501b67..5a08a1ae6 100644 --- a/pkg/filter/filter.go +++ b/pkg/filter/filter.go @@ -1,6 +1,6 @@ package filter -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" type Filter interface { IsTypeIgnored(ty resource.ResourceType) bool diff --git a/pkg/filter/filter_engine.go b/pkg/filter/filter_engine.go index 699dc7024..8bcacdea9 100644 --- a/pkg/filter/filter_engine.go +++ b/pkg/filter/filter_engine.go @@ -4,7 +4,7 @@ import ( "errors" "github.com/jmespath/go-jmespath" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) type FilterEngine struct { diff --git a/pkg/filter/filter_engine_test.go b/pkg/filter/filter_engine_test.go index 4a487a6cd..8eee8a2f7 100644 --- a/pkg/filter/filter_engine_test.go +++ b/pkg/filter/filter_engine_test.go @@ -5,7 +5,7 @@ import ( "reflect" "testing" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) func TestFilterEngine_Run(t *testing.T) { diff --git a/pkg/filter/mock_Filter.go b/pkg/filter/mock_Filter.go index f10df6016..92be8af5e 100644 --- a/pkg/filter/mock_Filter.go +++ b/pkg/filter/mock_Filter.go @@ -3,7 +3,7 @@ package filter import ( - resource "github.com/snyk/driftctl/pkg/resource" + resource "github.com/snyk/driftctl/enumeration/resource" mock "github.com/stretchr/testify/mock" ) diff --git a/pkg/helpers/interface.go b/pkg/helpers/interface.go deleted file mode 100644 index e3f3088fe..000000000 --- a/pkg/helpers/interface.go +++ /dev/null @@ -1,34 +0,0 @@ -package helpers - -import "strings" - -func Join(elems []interface{}, sep string) string { - firstElemt, ok := elems[0].(string) - if !ok { - panic("cannot join a slice that contains something else than strings") - } - switch len(elems) { - case 0: - return "" - case 1: - - return firstElemt - } - n := len(sep) * (len(elems) - 1) - for i := 0; i < len(elems); i++ { - n += len(elems[i].(string)) - } - - var b strings.Builder - b.Grow(n) - b.WriteString(firstElemt) - for _, s := range elems[1:] { - b.WriteString(sep) - elem, ok := s.(string) - if !ok { - panic("cannot join a slice that contains something else than strings") - } - b.WriteString(elem) - } - return b.String() -} diff --git a/pkg/iac/supplier/IacChainSupplier.go b/pkg/iac/supplier/IacChainSupplier.go index d63d5461f..d2ca27a88 100644 --- a/pkg/iac/supplier/IacChainSupplier.go +++ b/pkg/iac/supplier/IacChainSupplier.go @@ -4,13 +4,15 @@ import ( "context" "runtime" + "github.com/snyk/driftctl/enumeration/parallel" + resource2 "github.com/snyk/driftctl/pkg/resource" + + "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/pkg/iac" - "github.com/snyk/driftctl/pkg/parallel" - "github.com/snyk/driftctl/pkg/resource" ) type IacChainSupplier struct { - suppliers []resource.IaCSupplier + suppliers []resource2.IaCSupplier runner *parallel.ParallelRunner } @@ -28,7 +30,7 @@ func (r *IacChainSupplier) SourceCount() uint { return count } -func (r *IacChainSupplier) AddSupplier(supplier resource.IaCSupplier) { +func (r *IacChainSupplier) AddSupplier(supplier resource2.IaCSupplier) { r.suppliers = append(r.suppliers, supplier) } diff --git a/pkg/iac/supplier/IacChainSupplier_test.go b/pkg/iac/supplier/IacChainSupplier_test.go index 9c7d7885b..c2071c728 100644 --- a/pkg/iac/supplier/IacChainSupplier_test.go +++ b/pkg/iac/supplier/IacChainSupplier_test.go @@ -5,28 +5,29 @@ import ( "testing" "github.com/pkg/errors" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + resource2 "github.com/snyk/driftctl/pkg/resource" ) func TestIacChainSupplier_Resources(t *testing.T) { tests := []struct { name string - initSuppliers func(suppliers *[]resource.IaCSupplier) + initSuppliers func(suppliers *[]resource2.IaCSupplier) want []*resource.Resource wantErr bool }{ { name: "All failed", - initSuppliers: func(suppliers *[]resource.IaCSupplier) { - sup := &resource.MockIaCSupplier{} + initSuppliers: func(suppliers *[]resource2.IaCSupplier) { + sup := &resource2.MockIaCSupplier{} sup.On("Resources").Return(nil, errors.New("1")) *suppliers = append(*suppliers, sup) - sup = &resource.MockIaCSupplier{} + sup = &resource2.MockIaCSupplier{} sup.On("Resources").Return(nil, errors.New("2")) *suppliers = append(*suppliers, sup) - sup = &resource.MockIaCSupplier{} + sup = &resource2.MockIaCSupplier{} sup.On("Resources").Return(nil, errors.New("3")) *suppliers = append(*suppliers, sup) }, @@ -35,16 +36,16 @@ func TestIacChainSupplier_Resources(t *testing.T) { }, { name: "Partial failed", - initSuppliers: func(suppliers *[]resource.IaCSupplier) { - sup := &resource.MockIaCSupplier{} + initSuppliers: func(suppliers *[]resource2.IaCSupplier) { + sup := &resource2.MockIaCSupplier{} sup.On("Resources").Return(nil, errors.New("1")) *suppliers = append(*suppliers, sup) - sup = &resource.MockIaCSupplier{} + sup = &resource2.MockIaCSupplier{} sup.On("Resources").Return(nil, errors.New("2")) *suppliers = append(*suppliers, sup) - sup = &resource.MockIaCSupplier{} + sup = &resource2.MockIaCSupplier{} sup.On("Resources").Return([]*resource.Resource{ &resource.Resource{ Id: "ID", @@ -67,7 +68,7 @@ func TestIacChainSupplier_Resources(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { r := NewIacChainSupplier() - suppliers := make([]resource.IaCSupplier, 0) + suppliers := make([]resource2.IaCSupplier, 0) tt.initSuppliers(&suppliers) for _, supplier := range suppliers { diff --git a/pkg/iac/supplier/supplier.go b/pkg/iac/supplier/supplier.go index 184f794d4..8840afb1f 100644 --- a/pkg/iac/supplier/supplier.go +++ b/pkg/iac/supplier/supplier.go @@ -3,19 +3,20 @@ package supplier import ( "fmt" + "github.com/snyk/driftctl/enumeration/alerter" + "github.com/snyk/driftctl/enumeration/terraform" + resource2 "github.com/snyk/driftctl/pkg/resource" + "github.com/pkg/errors" "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/alerter" "github.com/snyk/driftctl/pkg/filter" + "github.com/snyk/driftctl/pkg/iac/config" "github.com/snyk/driftctl/pkg/iac/terraform/state/backend" "github.com/snyk/driftctl/pkg/output" - "github.com/snyk/driftctl/pkg/terraform" - - "github.com/snyk/driftctl/pkg/iac/config" "github.com/snyk/driftctl/pkg/iac/terraform/state" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) var supportedSuppliers = []string{ @@ -37,7 +38,7 @@ func GetIACSupplier(configs []config.SupplierConfig, progress output.Progress, alerter *alerter.Alerter, factory resource.ResourceFactory, - filter filter.Filter) (resource.IaCSupplier, error) { + filter filter.Filter) (resource2.IaCSupplier, error) { chainSupplier := NewIacChainSupplier() for _, config := range configs { @@ -47,7 +48,7 @@ func GetIACSupplier(configs []config.SupplierConfig, deserializer := resource.NewDeserializer(factory) - var supplier resource.IaCSupplier + var supplier resource2.IaCSupplier var err error switch config.Key { case state.TerraformStateReaderSupplier: diff --git a/pkg/iac/supplier/supplier_test.go b/pkg/iac/supplier/supplier_test.go index 2b0b6072f..615e77b1b 100644 --- a/pkg/iac/supplier/supplier_test.go +++ b/pkg/iac/supplier/supplier_test.go @@ -5,12 +5,13 @@ import ( "reflect" "testing" - "github.com/snyk/driftctl/pkg/alerter" + "github.com/snyk/driftctl/enumeration/alerter" + terraform2 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/pkg/filter" "github.com/snyk/driftctl/pkg/iac/config" "github.com/snyk/driftctl/pkg/iac/terraform/state/backend" "github.com/snyk/driftctl/pkg/output" - "github.com/snyk/driftctl/pkg/terraform" "github.com/snyk/driftctl/test/resource" ) @@ -90,12 +91,12 @@ func TestGetIACSupplier(t *testing.T) { progress.On("Start").Return().Times(1) repo := resource.InitFakeSchemaRepository("aws", "3.19.0") - factory := terraform.NewTerraformResourceFactory(repo) + factory := terraform2.NewTerraformResourceFactory(repo) alerter := alerter.NewAlerter() testFilter := &filter.MockFilter{} - _, err := GetIACSupplier(tt.args.config, terraform.NewProviderLibrary(), tt.args.options, progress, alerter, factory, testFilter) + _, err := GetIACSupplier(tt.args.config, terraform2.NewProviderLibrary(), tt.args.options, progress, alerter, factory, testFilter) if tt.wantErr != nil && err.Error() != tt.wantErr.Error() { t.Errorf("GetIACSupplier() error = %v, wantErr %v", err, tt.wantErr) diff --git a/pkg/iac/terraform/state/terraform_state_reader.go b/pkg/iac/terraform/state/terraform_state_reader.go index d94a2db64..16d081ad8 100644 --- a/pkg/iac/terraform/state/terraform_state_reader.go +++ b/pkg/iac/terraform/state/terraform_state_reader.go @@ -4,12 +4,14 @@ import ( "fmt" "strings" + "github.com/snyk/driftctl/enumeration/alerter" + "github.com/snyk/driftctl/enumeration/terraform" + "github.com/hashicorp/terraform/addrs" "github.com/hashicorp/terraform/states" "github.com/hashicorp/terraform/states/statefile" "github.com/pkg/errors" "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/alerter" "github.com/snyk/driftctl/pkg/filter" "github.com/snyk/driftctl/pkg/iac" "github.com/snyk/driftctl/pkg/output" @@ -17,11 +19,10 @@ import ( ctyconvert "github.com/zclconf/go-cty/cty/convert" ctyjson "github.com/zclconf/go-cty/cty/json" + "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/pkg/iac/config" "github.com/snyk/driftctl/pkg/iac/terraform/state/backend" "github.com/snyk/driftctl/pkg/iac/terraform/state/enumerator" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/terraform" ) const TerraformStateReaderSupplier = "tfstate" diff --git a/pkg/iac/terraform/state/terraform_state_reader_test.go b/pkg/iac/terraform/state/terraform_state_reader_test.go index 830775e05..dd15c00e2 100644 --- a/pkg/iac/terraform/state/terraform_state_reader_test.go +++ b/pkg/iac/terraform/state/terraform_state_reader_test.go @@ -7,24 +7,29 @@ import ( "strings" "testing" + "github.com/snyk/driftctl/enumeration/remote/aws" + "github.com/snyk/driftctl/enumeration/remote/azurerm" + "github.com/snyk/driftctl/enumeration/remote/github" + "github.com/snyk/driftctl/enumeration/remote/google" + "github.com/snyk/driftctl/enumeration/terraform" + aws2 "github.com/snyk/driftctl/pkg/resource/aws" + azurerm2 "github.com/snyk/driftctl/pkg/resource/azurerm" + github2 "github.com/snyk/driftctl/pkg/resource/github" + google2 "github.com/snyk/driftctl/pkg/resource/google" + "github.com/pkg/errors" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" + resourceazure "github.com/snyk/driftctl/enumeration/resource/azurerm" + resourcegithub "github.com/snyk/driftctl/enumeration/resource/github" + resourcegoogle "github.com/snyk/driftctl/enumeration/resource/google" "github.com/snyk/driftctl/pkg/filter" "github.com/snyk/driftctl/pkg/output" - "github.com/snyk/driftctl/pkg/remote/azurerm" - "github.com/snyk/driftctl/pkg/remote/google" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" - resourceazure "github.com/snyk/driftctl/pkg/resource/azurerm" - resourcegithub "github.com/snyk/driftctl/pkg/resource/github" - resourcegoogle "github.com/snyk/driftctl/pkg/resource/google" testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/assert" + "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/pkg/iac/config" - "github.com/snyk/driftctl/pkg/remote/aws" - "github.com/snyk/driftctl/pkg/remote/github" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/terraform" "github.com/snyk/driftctl/test/goldenfile" "github.com/snyk/driftctl/test/mocks" @@ -236,6 +241,7 @@ func TestTerraformStateReader_AWS_Resources(t *testing.T) { repo := testresource.InitFakeSchemaRepository(terraform.AWS, tt.providerVersion) resourceaws.InitResourcesMetadata(repo) + aws2.InitResourcesMetadata(repo) factory := terraform.NewTerraformResourceFactory(repo) @@ -268,7 +274,8 @@ func TestTerraformStateReader_AWS_Resources(t *testing.T) { t.Errorf("Resources() error = %v, wantErr %v", err, tt.wantErr) return } - changelog, err := diff.Diff(convert(got), want) + gotc := convert(got) + changelog, err := diff.Diff(gotc, want) if err != nil { panic(err) } @@ -321,6 +328,7 @@ func TestTerraformStateReader_Github_Resources(t *testing.T) { repo := testresource.InitFakeSchemaRepository(terraform.GITHUB, "4.4.0") resourcegithub.InitResourcesMetadata(repo) + github2.InitResourcesMetadata(repo) factory := terraform.NewTerraformResourceFactory(repo) r := &TerraformStateReader{ @@ -426,6 +434,7 @@ func TestTerraformStateReader_Google_Resources(t *testing.T) { repo := testresource.InitFakeSchemaRepository(terraform.GOOGLE, providerVersion) resourcegoogle.InitResourcesMetadata(repo) + google2.InitResourcesMetadata(repo) factory := terraform.NewTerraformResourceFactory(repo) r := &TerraformStateReader{ @@ -520,6 +529,7 @@ func TestTerraformStateReader_Azure_Resources(t *testing.T) { repo := testresource.InitFakeSchemaRepository(terraform.AZURE, providerVersion) resourceazure.InitResourcesMetadata(repo) + azurerm2.InitResourcesMetadata(repo) factory := terraform.NewTerraformResourceFactory(repo) r := &TerraformStateReader{ diff --git a/pkg/iac/terraform/state/testdata/acc/multiple_states_local/route53/.terraform.lock.hcl b/pkg/iac/terraform/state/testdata/acc/multiple_states_local/route53/.terraform.lock.hcl old mode 100755 new mode 100644 index 1045bc9c5..5230555a7 --- a/pkg/iac/terraform/state/testdata/acc/multiple_states_local/route53/.terraform.lock.hcl +++ b/pkg/iac/terraform/state/testdata/acc/multiple_states_local/route53/.terraform.lock.hcl @@ -3,9 +3,10 @@ provider "registry.terraform.io/hashicorp/aws" { version = "3.19.0" - constraints = "~> 3.19.0" + constraints = "3.19.0" hashes = [ "h1:+7Vi7p13+cnrxjXbfJiTimGSFR97xCaQwkkvWcreLns=", + "h1:xur9tF49NgsovNnmwmBR8RdpN8Fcg1TD4CKQPJD6n1A=", "zh:185a5259153eb9ee4699d4be43b3d509386b473683392034319beee97d470c3b", "zh:2d9a0a01f93e8d16539d835c02b8b6e1927b7685f4076e96cb07f7dd6944bc6c", "zh:703f6da36b1b5f3497baa38fccaa7765fb8a2b6440344e4c97172516b49437dd", @@ -23,6 +24,7 @@ provider "registry.terraform.io/hashicorp/random" { version = "3.1.0" hashes = [ "h1:BZMEPucF+pbu9gsPk0G0BHx7YP04+tKdq2MrRDF1EDM=", + "h1:rKYu5ZUbXwrLG1w81k7H3nce/Ys6yAxXhWcbtk36HjY=", "zh:2bbb3339f0643b5daa07480ef4397bd23a79963cc364cdfbb4e86354cb7725bc", "zh:3cd456047805bf639fbf2c761b1848880ea703a054f76db51852008b11008626", "zh:4f251b0eda5bb5e3dc26ea4400dba200018213654b69b4a5f96abee815b4f5ff", diff --git a/pkg/iac/terraform/state/testdata/acc/multiple_states_local/s3/.terraform.lock.hcl b/pkg/iac/terraform/state/testdata/acc/multiple_states_local/s3/.terraform.lock.hcl old mode 100755 new mode 100644 index 1045bc9c5..5230555a7 --- a/pkg/iac/terraform/state/testdata/acc/multiple_states_local/s3/.terraform.lock.hcl +++ b/pkg/iac/terraform/state/testdata/acc/multiple_states_local/s3/.terraform.lock.hcl @@ -3,9 +3,10 @@ provider "registry.terraform.io/hashicorp/aws" { version = "3.19.0" - constraints = "~> 3.19.0" + constraints = "3.19.0" hashes = [ "h1:+7Vi7p13+cnrxjXbfJiTimGSFR97xCaQwkkvWcreLns=", + "h1:xur9tF49NgsovNnmwmBR8RdpN8Fcg1TD4CKQPJD6n1A=", "zh:185a5259153eb9ee4699d4be43b3d509386b473683392034319beee97d470c3b", "zh:2d9a0a01f93e8d16539d835c02b8b6e1927b7685f4076e96cb07f7dd6944bc6c", "zh:703f6da36b1b5f3497baa38fccaa7765fb8a2b6440344e4c97172516b49437dd", @@ -23,6 +24,7 @@ provider "registry.terraform.io/hashicorp/random" { version = "3.1.0" hashes = [ "h1:BZMEPucF+pbu9gsPk0G0BHx7YP04+tKdq2MrRDF1EDM=", + "h1:rKYu5ZUbXwrLG1w81k7H3nce/Ys6yAxXhWcbtk36HjY=", "zh:2bbb3339f0643b5daa07480ef4397bd23a79963cc364cdfbb4e86354cb7725bc", "zh:3cd456047805bf639fbf2c761b1848880ea703a054f76db51852008b11008626", "zh:4f251b0eda5bb5e3dc26ea4400dba200018213654b69b4a5f96abee815b4f5ff", diff --git a/pkg/memstore/store_test.go b/pkg/memstore/store_test.go index 1bc98ddca..6a0ee73e2 100644 --- a/pkg/memstore/store_test.go +++ b/pkg/memstore/store_test.go @@ -5,7 +5,7 @@ import ( "sync" "testing" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" "github.com/stretchr/testify/assert" ) diff --git a/pkg/middlewares/aws_alb_listener_transformer.go b/pkg/middlewares/aws_alb_listener_transformer.go index f1bcb91be..b2be01736 100644 --- a/pkg/middlewares/aws_alb_listener_transformer.go +++ b/pkg/middlewares/aws_alb_listener_transformer.go @@ -1,8 +1,8 @@ package middlewares import ( - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // AwsALBListenerTransformer is a simple middleware to turn all aws_alb_listener resources into aws_lb_listener ones diff --git a/pkg/middlewares/aws_alb_listener_transformer_test.go b/pkg/middlewares/aws_alb_listener_transformer_test.go index abcb0ea4e..4064a4f86 100644 --- a/pkg/middlewares/aws_alb_listener_transformer_test.go +++ b/pkg/middlewares/aws_alb_listener_transformer_test.go @@ -1,14 +1,14 @@ package middlewares import ( + "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) func TestAwsALBListenerTransformer_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_alb_transformer.go b/pkg/middlewares/aws_alb_transformer.go index 1b643e38f..ae9bd54e4 100644 --- a/pkg/middlewares/aws_alb_transformer.go +++ b/pkg/middlewares/aws_alb_transformer.go @@ -1,8 +1,8 @@ package middlewares import ( - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // AwsALBTransformer is a simple middleware to turn all aws_alb resources into aws_lb ones diff --git a/pkg/middlewares/aws_alb_transformer_test.go b/pkg/middlewares/aws_alb_transformer_test.go index 82cc7bb05..b5bec4aac 100644 --- a/pkg/middlewares/aws_alb_transformer_test.go +++ b/pkg/middlewares/aws_alb_transformer_test.go @@ -1,14 +1,14 @@ package middlewares import ( + "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) func TestAwsALBTransformer_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_api_gateway_api_expander.go b/pkg/middlewares/aws_api_gateway_api_expander.go index 1073d4333..d05f0f3a4 100644 --- a/pkg/middlewares/aws_api_gateway_api_expander.go +++ b/pkg/middlewares/aws_api_gateway_api_expander.go @@ -10,8 +10,8 @@ import ( "github.com/getkin/kin-openapi/openapi3" "github.com/ghodss/yaml" "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // Explodes the body attribute of api gateway apis v1|v2 to dedicated resources as per Terraform documentations diff --git a/pkg/middlewares/aws_api_gateway_api_expander_test.go b/pkg/middlewares/aws_api_gateway_api_expander_test.go index ec8f484af..e02ae0c7a 100644 --- a/pkg/middlewares/aws_api_gateway_api_expander_test.go +++ b/pkg/middlewares/aws_api_gateway_api_expander_test.go @@ -1,15 +1,15 @@ package middlewares import ( + "github.com/snyk/driftctl/enumeration/terraform" "path/filepath" "strings" "testing" "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) func TestAwsApiGatewayApiExpander_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_api_gateway_base_path_mapping_reconciler.go b/pkg/middlewares/aws_api_gateway_base_path_mapping_reconciler.go index a27ed13dd..a1286aafd 100644 --- a/pkg/middlewares/aws_api_gateway_base_path_mapping_reconciler.go +++ b/pkg/middlewares/aws_api_gateway_base_path_mapping_reconciler.go @@ -1,8 +1,8 @@ package middlewares import ( - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // AwsApiGatewayBasePathMappingReconciler is used to reconcile API Gateway base path mapping (v1 and v2) diff --git a/pkg/middlewares/aws_api_gateway_base_path_mapping_reconciler_test.go b/pkg/middlewares/aws_api_gateway_base_path_mapping_reconciler_test.go index 80e67fbf7..be9d8e3a6 100644 --- a/pkg/middlewares/aws_api_gateway_base_path_mapping_reconciler_test.go +++ b/pkg/middlewares/aws_api_gateway_base_path_mapping_reconciler_test.go @@ -6,8 +6,8 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) func TestAwsApiGatewayBasePathMappingReconciler_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_api_gateway_deployment_expander.go b/pkg/middlewares/aws_api_gateway_deployment_expander.go index b88c6358f..eb707dcaa 100644 --- a/pkg/middlewares/aws_api_gateway_deployment_expander.go +++ b/pkg/middlewares/aws_api_gateway_deployment_expander.go @@ -3,8 +3,8 @@ package middlewares import ( "strings" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // Create a aws_api_gateway_stage resource from a aws_api_gateway_deployment resource and ignore the latter resource diff --git a/pkg/middlewares/aws_api_gateway_deployment_expander_test.go b/pkg/middlewares/aws_api_gateway_deployment_expander_test.go index 353921198..33bd74139 100644 --- a/pkg/middlewares/aws_api_gateway_deployment_expander_test.go +++ b/pkg/middlewares/aws_api_gateway_deployment_expander_test.go @@ -1,15 +1,14 @@ package middlewares import ( + "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" "github.com/aws/aws-sdk-go/aws/awsutil" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" - "github.com/r3labs/diff/v2" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) func TestAwsApiGatewayDeploymentExpander_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_api_gateway_domain_names_reconciler.go b/pkg/middlewares/aws_api_gateway_domain_names_reconciler.go index cb65cd7ba..f56ef52d8 100644 --- a/pkg/middlewares/aws_api_gateway_domain_names_reconciler.go +++ b/pkg/middlewares/aws_api_gateway_domain_names_reconciler.go @@ -1,8 +1,8 @@ package middlewares import ( - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // Used to reconcile API Gateway domain names (v1 and v2) from both remote diff --git a/pkg/middlewares/aws_api_gateway_domain_names_reconciler_test.go b/pkg/middlewares/aws_api_gateway_domain_names_reconciler_test.go index 1aee8ff9e..4d81325d5 100644 --- a/pkg/middlewares/aws_api_gateway_domain_names_reconciler_test.go +++ b/pkg/middlewares/aws_api_gateway_domain_names_reconciler_test.go @@ -6,8 +6,8 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) func TestAwsApiGatewayDomainNamesReconciler_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_api_gateway_resource_expander.go b/pkg/middlewares/aws_api_gateway_resource_expander.go index 2aaf54ec5..593ae85b5 100644 --- a/pkg/middlewares/aws_api_gateway_resource_expander.go +++ b/pkg/middlewares/aws_api_gateway_resource_expander.go @@ -3,8 +3,8 @@ package middlewares import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // Explodes api gateway default resource found in aws_api_gateway_rest_api.root_resource_id from state resources to dedicated resources diff --git a/pkg/middlewares/aws_api_gateway_resource_expander_test.go b/pkg/middlewares/aws_api_gateway_resource_expander_test.go index ffaac6e42..e29ac560c 100644 --- a/pkg/middlewares/aws_api_gateway_resource_expander_test.go +++ b/pkg/middlewares/aws_api_gateway_resource_expander_test.go @@ -1,15 +1,14 @@ package middlewares import ( + "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" "github.com/aws/aws-sdk-go/aws/awsutil" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" - "github.com/r3labs/diff/v2" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) func TestAwsApiGatewayResourceExpander_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_api_gateway_rest_api_policy_expander.go b/pkg/middlewares/aws_api_gateway_rest_api_policy_expander.go index c6ae37dda..d6f69080b 100644 --- a/pkg/middlewares/aws_api_gateway_rest_api_policy_expander.go +++ b/pkg/middlewares/aws_api_gateway_rest_api_policy_expander.go @@ -2,8 +2,8 @@ package middlewares import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // Explodes policy found in aws_api_gateway_rest_api.policy from state resources to dedicated resources diff --git a/pkg/middlewares/aws_api_gateway_rest_api_policy_expander_test.go b/pkg/middlewares/aws_api_gateway_rest_api_policy_expander_test.go index 45cefd9b8..fc60c6506 100644 --- a/pkg/middlewares/aws_api_gateway_rest_api_policy_expander_test.go +++ b/pkg/middlewares/aws_api_gateway_rest_api_policy_expander_test.go @@ -1,15 +1,14 @@ package middlewares import ( + "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" "github.com/aws/aws-sdk-go/aws/awsutil" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" - "github.com/r3labs/diff/v2" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) func TestAwsApiGatewayRestApiPolicyPolicyExpander_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_bucket_policy_expander.go b/pkg/middlewares/aws_bucket_policy_expander.go index 4c3631ac8..d7d27822e 100644 --- a/pkg/middlewares/aws_bucket_policy_expander.go +++ b/pkg/middlewares/aws_bucket_policy_expander.go @@ -3,8 +3,8 @@ package middlewares import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // Explodes policy found in aws_s3_bucket.policy from state resources to dedicated resources diff --git a/pkg/middlewares/aws_bucket_policy_expander_test.go b/pkg/middlewares/aws_bucket_policy_expander_test.go index 7f393730b..941ef244d 100644 --- a/pkg/middlewares/aws_bucket_policy_expander_test.go +++ b/pkg/middlewares/aws_bucket_policy_expander_test.go @@ -1,16 +1,15 @@ package middlewares import ( + "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awsutil" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" - "github.com/r3labs/diff/v2" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) func TestAwsBucketPolicyExpander_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_console_api_gateway_gateway_response.go b/pkg/middlewares/aws_console_api_gateway_gateway_response.go index b2310b9aa..15ab216b8 100644 --- a/pkg/middlewares/aws_console_api_gateway_gateway_response.go +++ b/pkg/middlewares/aws_console_api_gateway_gateway_response.go @@ -2,8 +2,8 @@ package middlewares import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // Each API Gateway rest API has by design all the gateway responses available to edit in the console diff --git a/pkg/middlewares/aws_console_api_gateway_gateway_response_test.go b/pkg/middlewares/aws_console_api_gateway_gateway_response_test.go index 28bdea280..1092e1b0d 100644 --- a/pkg/middlewares/aws_console_api_gateway_gateway_response_test.go +++ b/pkg/middlewares/aws_console_api_gateway_gateway_response_test.go @@ -6,8 +6,8 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) func TestAwsConsoleApiGatewayGatewayResponse_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_default_api_gateway_account.go b/pkg/middlewares/aws_default_api_gateway_account.go index 0d1d79b14..43653d3f4 100644 --- a/pkg/middlewares/aws_default_api_gateway_account.go +++ b/pkg/middlewares/aws_default_api_gateway_account.go @@ -2,8 +2,8 @@ package middlewares import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // AwsDefaultApiGatewayAccount is a middleware that ignores the default API Gateway account resource in the current region. diff --git a/pkg/middlewares/aws_default_api_gateway_account_test.go b/pkg/middlewares/aws_default_api_gateway_account_test.go index a391e868a..680955854 100644 --- a/pkg/middlewares/aws_default_api_gateway_account_test.go +++ b/pkg/middlewares/aws_default_api_gateway_account_test.go @@ -6,8 +6,8 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) func TestAwsDefaultApiGatewayAccount_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_default_igw_route.go b/pkg/middlewares/aws_default_igw_route.go index b727dff14..df38d7568 100644 --- a/pkg/middlewares/aws_default_igw_route.go +++ b/pkg/middlewares/aws_default_igw_route.go @@ -2,8 +2,8 @@ package middlewares import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // Each region has a default vpc which has an internet gateway attached and thus the route table of this diff --git a/pkg/middlewares/aws_default_igw_route_test.go b/pkg/middlewares/aws_default_igw_route_test.go index 10a004fac..8d1918f2c 100644 --- a/pkg/middlewares/aws_default_igw_route_test.go +++ b/pkg/middlewares/aws_default_igw_route_test.go @@ -6,8 +6,8 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) func TestAwsDefaultInternetGatewayRoute_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_default_internet_gateway.go b/pkg/middlewares/aws_default_internet_gateway.go index a64241113..675d97e59 100644 --- a/pkg/middlewares/aws_default_internet_gateway.go +++ b/pkg/middlewares/aws_default_internet_gateway.go @@ -2,8 +2,8 @@ package middlewares import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // Each default vpc has an internet gateway attached that should not be seen as unmanaged if not managed by IaC diff --git a/pkg/middlewares/aws_default_internet_gateway_test.go b/pkg/middlewares/aws_default_internet_gateway_test.go index 4e324afa9..757e5af1c 100644 --- a/pkg/middlewares/aws_default_internet_gateway_test.go +++ b/pkg/middlewares/aws_default_internet_gateway_test.go @@ -6,8 +6,8 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) func TestAwsDefaultInternetGateway_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_default_network_acl.go b/pkg/middlewares/aws_default_network_acl.go index 8429caea7..f1a15f150 100644 --- a/pkg/middlewares/aws_default_network_acl.go +++ b/pkg/middlewares/aws_default_network_acl.go @@ -2,8 +2,8 @@ package middlewares import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // Default network ACL should not be shown as unmanaged as they are present by default diff --git a/pkg/middlewares/aws_default_network_acl_rule.go b/pkg/middlewares/aws_default_network_acl_rule.go index 1ef85e9a0..776b53736 100644 --- a/pkg/middlewares/aws_default_network_acl_rule.go +++ b/pkg/middlewares/aws_default_network_acl_rule.go @@ -2,8 +2,8 @@ package middlewares import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // Default network acl rules should not be shown as unmanaged as they are present by default diff --git a/pkg/middlewares/aws_default_network_acl_rule_test.go b/pkg/middlewares/aws_default_network_acl_rule_test.go index f27ec11b5..bce59ad23 100644 --- a/pkg/middlewares/aws_default_network_acl_rule_test.go +++ b/pkg/middlewares/aws_default_network_acl_rule_test.go @@ -6,8 +6,8 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) func TestAwsDefaultNetworkACLRule_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_default_network_acl_test.go b/pkg/middlewares/aws_default_network_acl_test.go index db40f18cd..d8dd82d76 100644 --- a/pkg/middlewares/aws_default_network_acl_test.go +++ b/pkg/middlewares/aws_default_network_acl_test.go @@ -6,8 +6,8 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) func TestAwsDefaultNetworkACL_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_default_route.go b/pkg/middlewares/aws_default_route.go index bcdbea62a..cf603f64e 100644 --- a/pkg/middlewares/aws_default_route.go +++ b/pkg/middlewares/aws_default_route.go @@ -2,8 +2,8 @@ package middlewares import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // Default routes should not be shown as unmanaged as they are present by default diff --git a/pkg/middlewares/aws_default_route_table.go b/pkg/middlewares/aws_default_route_table.go index 657bf27fb..e2bb738a5 100644 --- a/pkg/middlewares/aws_default_route_table.go +++ b/pkg/middlewares/aws_default_route_table.go @@ -2,8 +2,8 @@ package middlewares import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // Default route table should not be shown as unmanaged as they are present by default diff --git a/pkg/middlewares/aws_default_route_table_test.go b/pkg/middlewares/aws_default_route_table_test.go index 4cc7b729d..26fdc3e89 100644 --- a/pkg/middlewares/aws_default_route_table_test.go +++ b/pkg/middlewares/aws_default_route_table_test.go @@ -6,8 +6,8 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) func TestAwsDefaultRouteTable_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_default_route_test.go b/pkg/middlewares/aws_default_route_test.go index 37b5c95ad..3ca2eb0a2 100644 --- a/pkg/middlewares/aws_default_route_test.go +++ b/pkg/middlewares/aws_default_route_test.go @@ -6,8 +6,8 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) func TestAwsDefaultRoute_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_default_security_group_rule.go b/pkg/middlewares/aws_default_security_group_rule.go index ebc68f68d..a939cb091 100644 --- a/pkg/middlewares/aws_default_security_group_rule.go +++ b/pkg/middlewares/aws_default_security_group_rule.go @@ -2,8 +2,8 @@ package middlewares import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // Remove default security group rules of the default security group from remote resources diff --git a/pkg/middlewares/aws_default_security_group_rule_test.go b/pkg/middlewares/aws_default_security_group_rule_test.go index c09db7d0b..775dbc54d 100644 --- a/pkg/middlewares/aws_default_security_group_rule_test.go +++ b/pkg/middlewares/aws_default_security_group_rule_test.go @@ -4,8 +4,8 @@ import ( "reflect" "testing" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) func TestAwsDefaultSecurityGroupRule_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_default_sqs_queue_policy.go b/pkg/middlewares/aws_default_sqs_queue_policy.go index 9e6921ffc..e18a21f32 100644 --- a/pkg/middlewares/aws_default_sqs_queue_policy.go +++ b/pkg/middlewares/aws_default_sqs_queue_policy.go @@ -2,8 +2,8 @@ package middlewares import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // SQS queues from AWS have a weird behaviour when we fetch them. diff --git a/pkg/middlewares/aws_default_sqs_queue_policy_test.go b/pkg/middlewares/aws_default_sqs_queue_policy_test.go index 7e1200e68..0c6aa5133 100644 --- a/pkg/middlewares/aws_default_sqs_queue_policy_test.go +++ b/pkg/middlewares/aws_default_sqs_queue_policy_test.go @@ -7,8 +7,8 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) func TestAwsDefaultSQSQueuePolicy_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_default_subnet.go b/pkg/middlewares/aws_default_subnet.go index 85d4f8a8d..adc6091cc 100644 --- a/pkg/middlewares/aws_default_subnet.go +++ b/pkg/middlewares/aws_default_subnet.go @@ -2,8 +2,8 @@ package middlewares import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // Default subnet should not be shown as unmanaged as they are present by default diff --git a/pkg/middlewares/aws_default_vpc.go b/pkg/middlewares/aws_default_vpc.go index ddfac18ca..a12ffccc9 100644 --- a/pkg/middlewares/aws_default_vpc.go +++ b/pkg/middlewares/aws_default_vpc.go @@ -2,8 +2,8 @@ package middlewares import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // Default VPC should not be shown as unmanaged as they are present by default diff --git a/pkg/middlewares/aws_defaults.go b/pkg/middlewares/aws_defaults.go index 18456a611..7b9b1c877 100644 --- a/pkg/middlewares/aws_defaults.go +++ b/pkg/middlewares/aws_defaults.go @@ -4,8 +4,8 @@ import ( "strings" "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) const defaultIamRolePathPrefix = "/aws-service-role/" diff --git a/pkg/middlewares/aws_defaults_test.go b/pkg/middlewares/aws_defaults_test.go index 0c3e5bdf9..9810a8195 100644 --- a/pkg/middlewares/aws_defaults_test.go +++ b/pkg/middlewares/aws_defaults_test.go @@ -5,8 +5,8 @@ import ( "github.com/stretchr/testify/assert" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) func TestAwsDefaults_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_ebs_encryption_by_default_reconciler.go b/pkg/middlewares/aws_ebs_encryption_by_default_reconciler.go index ef6840481..648427bd2 100644 --- a/pkg/middlewares/aws_ebs_encryption_by_default_reconciler.go +++ b/pkg/middlewares/aws_ebs_encryption_by_default_reconciler.go @@ -1,8 +1,8 @@ package middlewares import ( - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // AwsEbsEncryptionByDefaultReconciler is a middleware that either creates an 'aws_ebs_encryption_by_default' resource diff --git a/pkg/middlewares/aws_ebs_encryption_by_default_reconciler_test.go b/pkg/middlewares/aws_ebs_encryption_by_default_reconciler_test.go index 5bbbd71dd..7a60d3c25 100644 --- a/pkg/middlewares/aws_ebs_encryption_by_default_reconciler_test.go +++ b/pkg/middlewares/aws_ebs_encryption_by_default_reconciler_test.go @@ -1,15 +1,14 @@ package middlewares import ( + "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/terraform" - - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) func TestAwsEbsEncryptionByDefaultReconciler_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_eip_association_expander.go b/pkg/middlewares/aws_eip_association_expander.go index 33d663a55..759815140 100644 --- a/pkg/middlewares/aws_eip_association_expander.go +++ b/pkg/middlewares/aws_eip_association_expander.go @@ -1,8 +1,8 @@ package middlewares import ( - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) /** diff --git a/pkg/middlewares/aws_iam_policy_attachement_transformer.go b/pkg/middlewares/aws_iam_policy_attachement_transformer.go index 76ad5d423..84074f620 100644 --- a/pkg/middlewares/aws_iam_policy_attachement_transformer.go +++ b/pkg/middlewares/aws_iam_policy_attachement_transformer.go @@ -1,8 +1,8 @@ package middlewares import ( - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) /** diff --git a/pkg/middlewares/aws_iam_policy_attachement_transformer_test.go b/pkg/middlewares/aws_iam_policy_attachement_transformer_test.go index 1690dea6e..ae9e3bcdb 100644 --- a/pkg/middlewares/aws_iam_policy_attachement_transformer_test.go +++ b/pkg/middlewares/aws_iam_policy_attachement_transformer_test.go @@ -1,14 +1,14 @@ package middlewares import ( + "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" testresource "github.com/snyk/driftctl/test/resource" ) diff --git a/pkg/middlewares/aws_instance_block_device.go b/pkg/middlewares/aws_instance_block_device.go index b086d80d1..926faf5d5 100644 --- a/pkg/middlewares/aws_instance_block_device.go +++ b/pkg/middlewares/aws_instance_block_device.go @@ -3,8 +3,8 @@ package middlewares import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // Remove root_block_device from aws_instance resources and create dedicated aws_ebs_volume resources diff --git a/pkg/middlewares/aws_instance_block_device_test.go b/pkg/middlewares/aws_instance_block_device_test.go index 9e374ac43..2429f90a1 100644 --- a/pkg/middlewares/aws_instance_block_device_test.go +++ b/pkg/middlewares/aws_instance_block_device_test.go @@ -1,13 +1,13 @@ package middlewares import ( + "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration/resource" "github.com/stretchr/testify/mock" ) diff --git a/pkg/middlewares/aws_instance_eip.go b/pkg/middlewares/aws_instance_eip.go index 07b6dc0d0..e3a5c95b1 100644 --- a/pkg/middlewares/aws_instance_eip.go +++ b/pkg/middlewares/aws_instance_eip.go @@ -2,8 +2,8 @@ package middlewares import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type AwsInstanceEIP struct{} diff --git a/pkg/middlewares/aws_instance_eip_test.go b/pkg/middlewares/aws_instance_eip_test.go index a149f9c8d..c671dc0d2 100644 --- a/pkg/middlewares/aws_instance_eip_test.go +++ b/pkg/middlewares/aws_instance_eip_test.go @@ -4,8 +4,8 @@ import ( "reflect" "testing" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) func TestAwsInstanceEIP_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_nat_gateway_eip_assoc.go b/pkg/middlewares/aws_nat_gateway_eip_assoc.go index 8914b88ae..5dc96ede3 100644 --- a/pkg/middlewares/aws_nat_gateway_eip_assoc.go +++ b/pkg/middlewares/aws_nat_gateway_eip_assoc.go @@ -2,8 +2,8 @@ package middlewares import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) type AwsNatGatewayEipAssoc struct{} diff --git a/pkg/middlewares/aws_nat_gateway_eip_assoc_test.go b/pkg/middlewares/aws_nat_gateway_eip_assoc_test.go index 995ef7118..abbb3f648 100644 --- a/pkg/middlewares/aws_nat_gateway_eip_assoc_test.go +++ b/pkg/middlewares/aws_nat_gateway_eip_assoc_test.go @@ -6,8 +6,8 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) func TestAwsNatGatewayEipAssoc_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_network_acl_expander.go b/pkg/middlewares/aws_network_acl_expander.go index 8bdd48ac2..3f09d6ea9 100644 --- a/pkg/middlewares/aws_network_acl_expander.go +++ b/pkg/middlewares/aws_network_acl_expander.go @@ -1,8 +1,8 @@ package middlewares import ( - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // This middelware goal is to explode aws_network_acl ingress and egress block into a set of aws_network_acl_rule diff --git a/pkg/middlewares/aws_network_acl_expander_test.go b/pkg/middlewares/aws_network_acl_expander_test.go index f80c7f40c..9b9bf7949 100644 --- a/pkg/middlewares/aws_network_acl_expander_test.go +++ b/pkg/middlewares/aws_network_acl_expander_test.go @@ -1,14 +1,14 @@ package middlewares import ( + "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) func TestAwsNetworkACLExpander_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_rds_cluster_instance_expander.go b/pkg/middlewares/aws_rds_cluster_instance_expander.go index 36d358bae..50d391c0f 100644 --- a/pkg/middlewares/aws_rds_cluster_instance_expander.go +++ b/pkg/middlewares/aws_rds_cluster_instance_expander.go @@ -2,8 +2,8 @@ package middlewares import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // AwsRDSClusterInstanceExpander search for cluster instances from state to import corresponding remote db instances. diff --git a/pkg/middlewares/aws_rds_cluster_instance_expander_test.go b/pkg/middlewares/aws_rds_cluster_instance_expander_test.go index 8e4adcd37..ce62dba82 100644 --- a/pkg/middlewares/aws_rds_cluster_instance_expander_test.go +++ b/pkg/middlewares/aws_rds_cluster_instance_expander_test.go @@ -1,11 +1,11 @@ package middlewares import ( + "github.com/snyk/driftctl/enumeration/terraform" "testing" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/stretchr/testify/assert" ) diff --git a/pkg/middlewares/aws_role_managed_policy_expander.go b/pkg/middlewares/aws_role_managed_policy_expander.go index ded2f5f1a..30d301ebf 100644 --- a/pkg/middlewares/aws_role_managed_policy_expander.go +++ b/pkg/middlewares/aws_role_managed_policy_expander.go @@ -4,8 +4,8 @@ import ( "fmt" "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // The role of this middleware is to expand policy contained in `managed_policy_arns` to dedicated `aws_iam_policy_attachment` diff --git a/pkg/middlewares/aws_route_table_expander.go b/pkg/middlewares/aws_route_table_expander.go index 8c0ddf04f..e4dcbd63f 100644 --- a/pkg/middlewares/aws_route_table_expander.go +++ b/pkg/middlewares/aws_route_table_expander.go @@ -2,10 +2,10 @@ package middlewares import ( "github.com/sirupsen/logrus" + "github.com/snyk/driftctl/enumeration/alerter" - "github.com/snyk/driftctl/pkg/alerter" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // Explodes routes found in aws_default_route_table.route and aws_route_table.route to dedicated resources diff --git a/pkg/middlewares/aws_route_table_expander_test.go b/pkg/middlewares/aws_route_table_expander_test.go index 4d27adb7a..cebc6825c 100644 --- a/pkg/middlewares/aws_route_table_expander_test.go +++ b/pkg/middlewares/aws_route_table_expander_test.go @@ -1,6 +1,7 @@ package middlewares import ( + "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" @@ -8,10 +9,9 @@ import ( "github.com/r3labs/diff/v2" "github.com/stretchr/testify/mock" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/mocks" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" ) func TestAwsRouteTableExpander_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_s3_bucket_public_access_block_reconcilier.go b/pkg/middlewares/aws_s3_bucket_public_access_block_reconcilier.go index 92143a6d3..b040c4e3d 100644 --- a/pkg/middlewares/aws_s3_bucket_public_access_block_reconcilier.go +++ b/pkg/middlewares/aws_s3_bucket_public_access_block_reconcilier.go @@ -3,8 +3,8 @@ package middlewares import ( awssdk "github.com/aws/aws-sdk-go/aws" "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // AwsS3BucketPublicAccessBlockReconciler middleware ignores every s3 bucket public block that is set to the default values (every option set to false) diff --git a/pkg/middlewares/aws_s3_bucket_public_access_block_reconcilier_test.go b/pkg/middlewares/aws_s3_bucket_public_access_block_reconcilier_test.go index c129e0863..56c009436 100644 --- a/pkg/middlewares/aws_s3_bucket_public_access_block_reconcilier_test.go +++ b/pkg/middlewares/aws_s3_bucket_public_access_block_reconcilier_test.go @@ -3,8 +3,8 @@ package middlewares import ( "testing" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/stretchr/testify/assert" ) diff --git a/pkg/middlewares/aws_sns_topic_policy_expander.go b/pkg/middlewares/aws_sns_topic_policy_expander.go index bbe4e4e50..224c88527 100644 --- a/pkg/middlewares/aws_sns_topic_policy_expander.go +++ b/pkg/middlewares/aws_sns_topic_policy_expander.go @@ -4,8 +4,8 @@ import ( "github.com/pkg/errors" "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // Explodes policy found in aws_sns_topic from state resources to aws_sns_topic_policy resources diff --git a/pkg/middlewares/aws_sns_topic_policy_expander_test.go b/pkg/middlewares/aws_sns_topic_policy_expander_test.go index 55e8badac..f443a1899 100644 --- a/pkg/middlewares/aws_sns_topic_policy_expander_test.go +++ b/pkg/middlewares/aws_sns_topic_policy_expander_test.go @@ -1,19 +1,19 @@ package middlewares import ( + "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" "github.com/stretchr/testify/mock" - awsresource "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" + awsresource "github.com/snyk/driftctl/enumeration/resource/aws" testresource "github.com/snyk/driftctl/test/resource" "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) func TestAwsSNSTopicPolicyExpander_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_sqs_queue_policy_expander.go b/pkg/middlewares/aws_sqs_queue_policy_expander.go index 3e532aaa2..0d4c414eb 100644 --- a/pkg/middlewares/aws_sqs_queue_policy_expander.go +++ b/pkg/middlewares/aws_sqs_queue_policy_expander.go @@ -3,8 +3,8 @@ package middlewares import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // Explodes policy found in aws_sqs_queue.policy from state resources to dedicated resources diff --git a/pkg/middlewares/aws_sqs_queue_policy_expander_test.go b/pkg/middlewares/aws_sqs_queue_policy_expander_test.go index 60738c287..9db97997d 100644 --- a/pkg/middlewares/aws_sqs_queue_policy_expander_test.go +++ b/pkg/middlewares/aws_sqs_queue_policy_expander_test.go @@ -1,15 +1,15 @@ package middlewares import ( + "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/stretchr/testify/mock" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" testresource "github.com/snyk/driftctl/test/resource" "github.com/r3labs/diff/v2" diff --git a/pkg/middlewares/azurerm_route_expander.go b/pkg/middlewares/azurerm_route_expander.go index 11f59b56b..c402e4978 100644 --- a/pkg/middlewares/azurerm_route_expander.go +++ b/pkg/middlewares/azurerm_route_expander.go @@ -3,8 +3,8 @@ package middlewares import ( "strings" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) // Explodes routes found in azurerm_route_table.route from state resources to dedicated resources diff --git a/pkg/middlewares/azurerm_route_expander_test.go b/pkg/middlewares/azurerm_route_expander_test.go index ba8dc7e88..7a24b7a82 100644 --- a/pkg/middlewares/azurerm_route_expander_test.go +++ b/pkg/middlewares/azurerm_route_expander_test.go @@ -1,14 +1,14 @@ package middlewares import ( + "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) func TestAzurermRouteExpander_Execute(t *testing.T) { diff --git a/pkg/middlewares/azurerm_subnet_expander.go b/pkg/middlewares/azurerm_subnet_expander.go index 4e5049009..4a0a82b46 100644 --- a/pkg/middlewares/azurerm_subnet_expander.go +++ b/pkg/middlewares/azurerm_subnet_expander.go @@ -1,8 +1,8 @@ package middlewares import ( - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) // Explodes subnet found in azurerm_virtual_network.subnet from state resources to dedicated resources diff --git a/pkg/middlewares/azurerm_subnet_expander_test.go b/pkg/middlewares/azurerm_subnet_expander_test.go index 82b244b33..95af5fe52 100644 --- a/pkg/middlewares/azurerm_subnet_expander_test.go +++ b/pkg/middlewares/azurerm_subnet_expander_test.go @@ -1,14 +1,14 @@ package middlewares import ( + "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/azurerm" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) func TestAzurermSubnetExpander_Execute(t *testing.T) { diff --git a/pkg/middlewares/chain_middleware.go b/pkg/middlewares/chain_middleware.go index c4ab01091..62fa5c6dd 100644 --- a/pkg/middlewares/chain_middleware.go +++ b/pkg/middlewares/chain_middleware.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) type Chain []Middleware diff --git a/pkg/middlewares/chain_middleware_test.go b/pkg/middlewares/chain_middleware_test.go index e16a48b4e..abe234049 100644 --- a/pkg/middlewares/chain_middleware_test.go +++ b/pkg/middlewares/chain_middleware_test.go @@ -4,7 +4,7 @@ import ( "errors" "testing" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) var callCounters map[string]int diff --git a/pkg/middlewares/default_vpc_test.go b/pkg/middlewares/default_vpc_test.go index 7f86f6ecc..acc1dc30c 100644 --- a/pkg/middlewares/default_vpc_test.go +++ b/pkg/middlewares/default_vpc_test.go @@ -3,9 +3,9 @@ package middlewares import ( "testing" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource/aws" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) func TestAwsDefaultVPCShouldBeIgnored(t *testing.T) { diff --git a/pkg/middlewares/google_compute_instance_group_manager_reconciler.go b/pkg/middlewares/google_compute_instance_group_manager_reconciler.go index 24dade78f..471845de3 100644 --- a/pkg/middlewares/google_compute_instance_group_manager_reconciler.go +++ b/pkg/middlewares/google_compute_instance_group_manager_reconciler.go @@ -1,8 +1,8 @@ package middlewares import ( - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) type GoogleComputeInstanceGroupManagerReconciler struct{} diff --git a/pkg/middlewares/google_compute_instance_group_manager_reconciler_test.go b/pkg/middlewares/google_compute_instance_group_manager_reconciler_test.go index ac0e28b32..16d8aa1cb 100644 --- a/pkg/middlewares/google_compute_instance_group_manager_reconciler_test.go +++ b/pkg/middlewares/google_compute_instance_group_manager_reconciler_test.go @@ -6,8 +6,8 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) func TestGoogleComputeInstanceGroupManagerExpander_Execute(t *testing.T) { diff --git a/pkg/middlewares/google_default_iam_member.go b/pkg/middlewares/google_default_iam_member.go index 93a18e595..a50c4c05f 100644 --- a/pkg/middlewares/google_default_iam_member.go +++ b/pkg/middlewares/google_default_iam_member.go @@ -5,8 +5,8 @@ import ( "strings" "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) // Some service accounts are created by default when activating APIs, this middleware will filter them unless they are managed. diff --git a/pkg/middlewares/google_default_iam_member_test.go b/pkg/middlewares/google_default_iam_member_test.go index 38b906431..130477db3 100644 --- a/pkg/middlewares/google_default_iam_member_test.go +++ b/pkg/middlewares/google_default_iam_member_test.go @@ -6,8 +6,8 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) func TestGoogleDefaultIAMMember_Execute(t *testing.T) { diff --git a/pkg/middlewares/google_iam_binding_tranformer_test.go b/pkg/middlewares/google_iam_binding_tranformer_test.go index 5c43eec93..57df0cb7b 100644 --- a/pkg/middlewares/google_iam_binding_tranformer_test.go +++ b/pkg/middlewares/google_iam_binding_tranformer_test.go @@ -1,14 +1,14 @@ package middlewares import ( + "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) func TestGoogleProjectIAMBindingTransformer_Execute(t *testing.T) { diff --git a/pkg/middlewares/google_iam_binding_transformer.go b/pkg/middlewares/google_iam_binding_transformer.go index 820f33ea4..789654f7b 100644 --- a/pkg/middlewares/google_iam_binding_transformer.go +++ b/pkg/middlewares/google_iam_binding_transformer.go @@ -4,8 +4,8 @@ import ( "fmt" "strings" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) // GoogleIAMBindingTransformer Transforms Bucket IAM binding in bucket iam member to ease comparison. diff --git a/pkg/middlewares/google_iam_policy_tranformer_test.go b/pkg/middlewares/google_iam_policy_tranformer_test.go index d4c3de952..7d96c6a61 100644 --- a/pkg/middlewares/google_iam_policy_tranformer_test.go +++ b/pkg/middlewares/google_iam_policy_tranformer_test.go @@ -1,14 +1,14 @@ package middlewares import ( + "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) func TestGoogleProjectIAMPolicyTransformer_Execute(t *testing.T) { diff --git a/pkg/middlewares/google_iam_policy_transformer.go b/pkg/middlewares/google_iam_policy_transformer.go index 2b9b8a469..70f3aa065 100644 --- a/pkg/middlewares/google_iam_policy_transformer.go +++ b/pkg/middlewares/google_iam_policy_transformer.go @@ -5,8 +5,8 @@ import ( "fmt" "strings" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) // GoogleStorageBucketIAMPolicyTransformer Transforms Bucket IAM policy in bucket iam binding to ease comparison. diff --git a/pkg/middlewares/google_legacy_bucket_iam_member.go b/pkg/middlewares/google_legacy_bucket_iam_member.go index 1328ad47a..184162ab0 100644 --- a/pkg/middlewares/google_legacy_bucket_iam_member.go +++ b/pkg/middlewares/google_legacy_bucket_iam_member.go @@ -4,8 +4,8 @@ import ( "strings" "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) // Creating buckets add legacy role bindings, this middleware will filter them unless they are managed. diff --git a/pkg/middlewares/google_legacy_bucket_iam_member_test.go b/pkg/middlewares/google_legacy_bucket_iam_member_test.go index 63bb92d23..4e1ee7f72 100644 --- a/pkg/middlewares/google_legacy_bucket_iam_member_test.go +++ b/pkg/middlewares/google_legacy_bucket_iam_member_test.go @@ -6,8 +6,8 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" ) func TestGoogleLegacyBucketIAMMember_Execute(t *testing.T) { diff --git a/pkg/middlewares/iam_policy_attachment_expander.go b/pkg/middlewares/iam_policy_attachment_expander.go index 787e1cfc2..fd87bfc4e 100644 --- a/pkg/middlewares/iam_policy_attachment_expander.go +++ b/pkg/middlewares/iam_policy_attachment_expander.go @@ -3,8 +3,8 @@ package middlewares import ( "fmt" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" ) // Split Policy attachment when there is multiple user and groups and generate a repeatable id diff --git a/pkg/middlewares/iam_policy_attachment_expander_test.go b/pkg/middlewares/iam_policy_attachment_expander_test.go index 964a33f6b..29cdac28d 100644 --- a/pkg/middlewares/iam_policy_attachment_expander_test.go +++ b/pkg/middlewares/iam_policy_attachment_expander_test.go @@ -1,16 +1,15 @@ package middlewares import ( + "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" - "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" - "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" + "github.com/snyk/driftctl/enumeration/resource/aws" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) func TestIamPolicyAttachmentExpander_Execute(t *testing.T) { diff --git a/pkg/middlewares/middlewares.go b/pkg/middlewares/middlewares.go index 09d20327a..6789f3266 100644 --- a/pkg/middlewares/middlewares.go +++ b/pkg/middlewares/middlewares.go @@ -1,6 +1,6 @@ package middlewares -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" type Middleware interface { Execute(remoteResources, resourcesFromState *[]*resource.Resource) error diff --git a/pkg/middlewares/route53_records.go b/pkg/middlewares/route53_records.go index 7df12e35c..4959a0892 100644 --- a/pkg/middlewares/route53_records.go +++ b/pkg/middlewares/route53_records.go @@ -2,8 +2,8 @@ package middlewares import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // Remote NS and SAO records from remote state if not managed by IAC diff --git a/pkg/middlewares/route53_records_id_reconcilier.go b/pkg/middlewares/route53_records_id_reconcilier.go index 06db9f25a..29b237218 100644 --- a/pkg/middlewares/route53_records_id_reconcilier.go +++ b/pkg/middlewares/route53_records_id_reconcilier.go @@ -4,8 +4,8 @@ import ( "strings" "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // Since AWS returns the FQDN as the name of the remote record, we must change the Id of the diff --git a/pkg/middlewares/route53_records_id_reconcilier_test.go b/pkg/middlewares/route53_records_id_reconcilier_test.go index 74a9bd8a8..c30b75c01 100644 --- a/pkg/middlewares/route53_records_id_reconcilier_test.go +++ b/pkg/middlewares/route53_records_id_reconcilier_test.go @@ -3,8 +3,8 @@ package middlewares import ( "testing" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/stretchr/testify/assert" ) diff --git a/pkg/middlewares/route53_records_test.go b/pkg/middlewares/route53_records_test.go index 7e9bc9770..a74fe2ef4 100644 --- a/pkg/middlewares/route53_records_test.go +++ b/pkg/middlewares/route53_records_test.go @@ -3,9 +3,9 @@ package middlewares import ( "testing" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource/aws" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) func TestDefaultRoute53RecordShouldBeIgnored(t *testing.T) { diff --git a/pkg/middlewares/s3_bucket_acl.go b/pkg/middlewares/s3_bucket_acl.go index 4764978f4..11ea3ecbe 100644 --- a/pkg/middlewares/s3_bucket_acl.go +++ b/pkg/middlewares/s3_bucket_acl.go @@ -3,8 +3,8 @@ package middlewares import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // Remove grant field on remote resources when acl field != private in state diff --git a/pkg/middlewares/s3_bucket_acl_test.go b/pkg/middlewares/s3_bucket_acl_test.go index e353afb70..9a13a8f6a 100644 --- a/pkg/middlewares/s3_bucket_acl_test.go +++ b/pkg/middlewares/s3_bucket_acl_test.go @@ -5,9 +5,9 @@ import ( "github.com/stretchr/testify/assert" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource/aws" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) func TestS3BucketAcl_Execute(t *testing.T) { diff --git a/pkg/middlewares/tags_all_manager.go b/pkg/middlewares/tags_all_manager.go index 1e293f7ba..a84b76cec 100644 --- a/pkg/middlewares/tags_all_manager.go +++ b/pkg/middlewares/tags_all_manager.go @@ -1,7 +1,7 @@ package middlewares import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) // Manage tags_all attribute on each compatible resources diff --git a/pkg/middlewares/tags_all_manager_test.go b/pkg/middlewares/tags_all_manager_test.go index 9cc05b5d9..a89a9a489 100644 --- a/pkg/middlewares/tags_all_manager_test.go +++ b/pkg/middlewares/tags_all_manager_test.go @@ -6,7 +6,7 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) func TestTagsAllManager_Execute(t *testing.T) { diff --git a/pkg/middlewares/vpc_security_group_default.go b/pkg/middlewares/vpc_security_group_default.go index bfc76a0a0..68ab7c9c4 100644 --- a/pkg/middlewares/vpc_security_group_default.go +++ b/pkg/middlewares/vpc_security_group_default.go @@ -2,8 +2,8 @@ package middlewares import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) // Remove default security group from remote resources diff --git a/pkg/middlewares/vpc_security_group_default_test.go b/pkg/middlewares/vpc_security_group_default_test.go index 38d6f2d18..3700727aa 100644 --- a/pkg/middlewares/vpc_security_group_default_test.go +++ b/pkg/middlewares/vpc_security_group_default_test.go @@ -3,8 +3,8 @@ package middlewares import ( "testing" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) func TestDefaultVPCSecurityGroupShouldBeIgnored(t *testing.T) { diff --git a/pkg/middlewares/vpc_security_group_rules.go b/pkg/middlewares/vpc_security_group_rules.go index 75973e95a..278a28e4c 100644 --- a/pkg/middlewares/vpc_security_group_rules.go +++ b/pkg/middlewares/vpc_security_group_rules.go @@ -3,8 +3,8 @@ package middlewares import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/resource" - resourceaws "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/enumeration/resource" + resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" ) // Split security group rule if it needs to given its attributes diff --git a/pkg/middlewares/vpc_security_group_rules_test.go b/pkg/middlewares/vpc_security_group_rules_test.go index 2f70c7354..cee0351dd 100644 --- a/pkg/middlewares/vpc_security_group_rules_test.go +++ b/pkg/middlewares/vpc_security_group_rules_test.go @@ -1,13 +1,13 @@ package middlewares import ( + "github.com/snyk/driftctl/enumeration/terraform" "testing" "github.com/stretchr/testify/mock" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) func TestVPCSecurityGroupRuleSanitizer(t *testing.T) { diff --git a/pkg/resource/aws/aws_ami.go b/pkg/resource/aws/aws_ami.go index b5fd80d39..95d52108f 100644 --- a/pkg/resource/aws/aws_ami.go +++ b/pkg/resource/aws/aws_ami.go @@ -1,15 +1,14 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsAmiResourceType = "aws_ami" - func initAwsAmiMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AwsAmiResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsAmiResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) }) - resourceSchemaRepository.SetFlags(AwsAmiResourceType, resource.FlagDeepMode) + resourceSchemaRepository.SetFlags(aws.AwsAmiResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_appautoscaling_target.go b/pkg/resource/aws/aws_appautoscaling_target.go index 8c2d6dbf9..110037a8e 100644 --- a/pkg/resource/aws/aws_appautoscaling_target.go +++ b/pkg/resource/aws/aws_appautoscaling_target.go @@ -1,25 +1,12 @@ package aws -import "github.com/snyk/driftctl/pkg/resource" - -const AwsAppAutoscalingTargetResourceType = "aws_appautoscaling_target" +import ( + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" +) func initAwsAppAutoscalingTargetMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsAppAutoscalingTargetResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "service_namespace": *res.Attributes().GetString("service_namespace"), - "scalable_dimension": *res.Attributes().GetString("scalable_dimension"), - } - }) - resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsAppAutoscalingTargetResourceType, func(res *resource.Resource) map[string]string { - attrs := make(map[string]string) - if v := res.Attributes().GetString("scalable_dimension"); v != nil && *v != "" { - attrs["Scalable dimension"] = *v - } - return attrs - }) - resourceSchemaRepository.SetFlags(AwsAppAutoscalingTargetResourceType, resource.FlagDeepMode) - resourceSchemaRepository.SetDiscriminantFunc(AwsAppAutoscalingTargetResourceType, func(self, target *resource.Resource) bool { + resourceSchemaRepository.SetDiscriminantFunc(aws.AwsAppAutoscalingTargetResourceType, func(self, target *resource.Resource) bool { return *self.Attributes().GetString("scalable_dimension") == *target.Attributes().GetString("scalable_dimension") }) } diff --git a/pkg/resource/aws/aws_cloudformation_stack.go b/pkg/resource/aws/aws_cloudformation_stack.go index e092bd8f5..b3a53dfbc 100644 --- a/pkg/resource/aws/aws_cloudformation_stack.go +++ b/pkg/resource/aws/aws_cloudformation_stack.go @@ -1,26 +1,13 @@ package aws import ( - "strconv" - - "github.com/hashicorp/terraform/flatmap" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsCloudformationStackResourceType = "aws_cloudformation_stack" - func initAwsCloudformationStackMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsCloudformationStackResourceType, func(res *resource.Resource) map[string]string { - attrs := make(map[string]interface{}) - if v := res.Attributes().GetMap("parameters"); v != nil { - attrs["parameters.%"] = strconv.FormatInt(int64(len(v)), 10) - attrs["parameters"] = v - } - return flatmap.Flatten(attrs) - }) - resourceSchemaRepository.SetNormalizeFunc(AwsCloudformationStackResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsCloudformationStackResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) }) - resourceSchemaRepository.SetFlags(AwsCloudformationStackResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_cloudfront_distribution.go b/pkg/resource/aws/aws_cloudfront_distribution.go index 0ac48a9d5..714506028 100644 --- a/pkg/resource/aws/aws_cloudfront_distribution.go +++ b/pkg/resource/aws/aws_cloudfront_distribution.go @@ -1,13 +1,12 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsCloudfrontDistributionResourceType = "aws_cloudfront_distribution" - func initAwsCloudfrontDistributionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AwsCloudfrontDistributionResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsCloudfrontDistributionResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"etag"}) val.SafeDelete([]string{"last_modified_time"}) @@ -15,5 +14,4 @@ func initAwsCloudfrontDistributionMetaData(resourceSchemaRepository resource.Sch val.SafeDelete([]string{"status"}) val.SafeDelete([]string{"wait_for_deployment"}) }) - resourceSchemaRepository.SetFlags(AwsCloudfrontDistributionResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_cloudfront_distribution_test.go b/pkg/resource/aws/aws_cloudfront_distribution_test.go index c03dffb60..84d0106c2 100644 --- a/pkg/resource/aws/aws_cloudfront_distribution_test.go +++ b/pkg/resource/aws/aws_cloudfront_distribution_test.go @@ -5,8 +5,8 @@ import ( "github.com/aws/aws-sdk-go/service/cloudfront" + awsresources "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/pkg/analyser" - awsresources "github.com/snyk/driftctl/pkg/resource/aws" "github.com/snyk/driftctl/test" "github.com/r3labs/diff/v2" diff --git a/pkg/resource/aws/aws_db_instance.go b/pkg/resource/aws/aws_db_instance.go index 8290326ad..291e4722a 100644 --- a/pkg/resource/aws/aws_db_instance.go +++ b/pkg/resource/aws/aws_db_instance.go @@ -1,13 +1,12 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsDbInstanceResourceType = "aws_db_instance" - func initAwsDbInstanceMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AwsDbInstanceResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsDbInstanceResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"delete_automated_backups"}) val.SafeDelete([]string{"final_snapshot_identifier"}) @@ -20,5 +19,4 @@ func initAwsDbInstanceMetaData(resourceSchemaRepository resource.SchemaRepositor val.SafeDelete([]string{"apply_immediately"}) val.DeleteIfDefault("CharacterSetName") }) - resourceSchemaRepository.SetFlags(AwsDbInstanceResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_db_subnet_group.go b/pkg/resource/aws/aws_db_subnet_group.go index c87ba216c..f02e554f3 100644 --- a/pkg/resource/aws/aws_db_subnet_group.go +++ b/pkg/resource/aws/aws_db_subnet_group.go @@ -1,15 +1,13 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsDbSubnetGroupResourceType = "aws_db_subnet_group" - func initAwsDbSubnetGroupMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AwsDbSubnetGroupResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsDbSubnetGroupResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"name_prefix"}) }) - resourceSchemaRepository.SetFlags(AwsDbSubnetGroupResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_default_network_acl.go b/pkg/resource/aws/aws_default_network_acl.go index bfbc8ec92..0279b62e4 100644 --- a/pkg/resource/aws/aws_default_network_acl.go +++ b/pkg/resource/aws/aws_default_network_acl.go @@ -1,14 +1,12 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsDefaultNetworkACLResourceType = "aws_default_network_acl" - func initAwsDefaultNetworkACLMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsDefaultNetworkACLResourceType, resource.FlagDeepMode) - resourceSchemaRepository.SetNormalizeFunc(AwsDefaultNetworkACLResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsDefaultNetworkACLResourceType, func(res *resource.Resource) { res.Attrs.SafeDelete([]string{"default_network_acl_id"}) // https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/default_network_acl#managing-subnets-in-a-default-network-acl diff --git a/pkg/resource/aws/aws_default_security_group.go b/pkg/resource/aws/aws_default_security_group.go index a59ba3fc1..a85a9b10c 100644 --- a/pkg/resource/aws/aws_default_security_group.go +++ b/pkg/resource/aws/aws_default_security_group.go @@ -1,17 +1,15 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsDefaultSecurityGroupResourceType = "aws_default_security_group" - func initAwsDefaultSecurityGroupMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AwsDefaultSecurityGroupResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsDefaultSecurityGroupResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"revoke_rules_on_delete"}) val.SafeDelete([]string{"ingress"}) val.SafeDelete([]string{"egress"}) }) - resourceSchemaRepository.SetFlags(AwsDefaultSecurityGroupResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_default_subnet.go b/pkg/resource/aws/aws_default_subnet.go index 622fad33f..fd1663906 100644 --- a/pkg/resource/aws/aws_default_subnet.go +++ b/pkg/resource/aws/aws_default_subnet.go @@ -1,15 +1,13 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsDefaultSubnetResourceType = "aws_default_subnet" - func initAwsDefaultSubnetMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AwsDefaultSubnetResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsDefaultSubnetResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) }) - resourceSchemaRepository.SetFlags(AwsDefaultSubnetResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_dynamodb_table.go b/pkg/resource/aws/aws_dynamodb_table.go index 74bdefa69..d6d24a5f2 100644 --- a/pkg/resource/aws/aws_dynamodb_table.go +++ b/pkg/resource/aws/aws_dynamodb_table.go @@ -1,21 +1,13 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsDynamodbTableResourceType = "aws_dynamodb_table" - func initAwsDynamodbTableMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsDynamodbTableResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "table_name": res.ResourceId(), - } - }) - resourceSchemaRepository.SetNormalizeFunc(AwsDynamodbTableResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsDynamodbTableResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) }) - resourceSchemaRepository.SetFlags(AwsDynamodbTableResourceType, resource.FlagDeepMode) - } diff --git a/pkg/resource/aws/aws_ebs_snapshot.go b/pkg/resource/aws/aws_ebs_snapshot.go index c9d11e138..9bce422a6 100644 --- a/pkg/resource/aws/aws_ebs_snapshot.go +++ b/pkg/resource/aws/aws_ebs_snapshot.go @@ -1,15 +1,13 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsEbsSnapshotResourceType = "aws_ebs_snapshot" - func initAwsEbsSnapshotMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AwsEbsSnapshotResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsEbsSnapshotResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) }) - resourceSchemaRepository.SetFlags(AwsEbsSnapshotResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_ebs_volume.go b/pkg/resource/aws/aws_ebs_volume.go index 0a8a299df..d69f59a0e 100644 --- a/pkg/resource/aws/aws_ebs_volume.go +++ b/pkg/resource/aws/aws_ebs_volume.go @@ -1,18 +1,16 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsEbsVolumeResourceType = "aws_ebs_volume" - func initAwsEbsVolumeMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AwsEbsVolumeResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsEbsVolumeResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"arn"}) val.SafeDelete([]string{"outpost_arn"}) val.SafeDelete([]string{"snapshot_id"}) val.DeleteIfDefault("throughput") }) - resourceSchemaRepository.SetFlags(AwsEbsVolumeResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_ecr_repository.go b/pkg/resource/aws/aws_ecr_repository.go index b9723d148..431c3d89b 100644 --- a/pkg/resource/aws/aws_ecr_repository.go +++ b/pkg/resource/aws/aws_ecr_repository.go @@ -1,13 +1,13 @@ package aws -import "github.com/snyk/driftctl/pkg/resource" - -const AwsEcrRepositoryResourceType = "aws_ecr_repository" +import ( + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" +) func initAwsEcrRepositoryMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AwsEcrRepositoryResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsEcrRepositoryResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) }) - resourceSchemaRepository.SetFlags(AwsEcrRepositoryResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_ecr_repository_test.go b/pkg/resource/aws/aws_ecr_repository_test.go index d2afd53be..c8082ba8e 100644 --- a/pkg/resource/aws/aws_ecr_repository_test.go +++ b/pkg/resource/aws/aws_ecr_repository_test.go @@ -8,8 +8,8 @@ import ( "github.com/aws/aws-sdk-go/service/ecr" "github.com/r3labs/diff/v2" + awsresources "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/pkg/analyser" - awsresources "github.com/snyk/driftctl/pkg/resource/aws" "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/acceptance" "github.com/snyk/driftctl/test/acceptance/awsutils" diff --git a/pkg/resource/aws/aws_eip.go b/pkg/resource/aws/aws_eip.go index c4f95998e..d25e820e1 100644 --- a/pkg/resource/aws/aws_eip.go +++ b/pkg/resource/aws/aws_eip.go @@ -1,15 +1,13 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsEipResourceType = "aws_eip" - func initAwsEipMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AwsEipResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsEipResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) }) - resourceSchemaRepository.SetFlags(AwsEipResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_iam_access_key.go b/pkg/resource/aws/aws_iam_access_key.go index cce99bc9f..dc506d8b7 100644 --- a/pkg/resource/aws/aws_iam_access_key.go +++ b/pkg/resource/aws/aws_iam_access_key.go @@ -1,20 +1,13 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsIamAccessKeyResourceType = "aws_iam_access_key" - func initAwsIAMAccessKeyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsIamAccessKeyResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "user": *res.Attributes().GetString("user"), - } - }) - - resourceSchemaRepository.SetNormalizeFunc(AwsIamAccessKeyResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsIamAccessKeyResourceType, func(res *resource.Resource) { val := res.Attrs // As we can't read secrets from aws API once access_key created we need to set // fields retrieved from state to nil to avoid drift @@ -26,13 +19,4 @@ func initAwsIAMAccessKeyMetaData(resourceSchemaRepository resource.SchemaReposit val.SafeDelete([]string{"key_fingerprint"}) val.SafeDelete([]string{"pgp_key"}) }) - resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsIamAccessKeyResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if user := val.GetString("user"); user != nil && *user != "" { - attrs["User"] = *user - } - return attrs - }) - resourceSchemaRepository.SetFlags(AwsIamAccessKeyResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_iam_policy.go b/pkg/resource/aws/aws_iam_policy.go index 7f5492e4c..e6adfbe66 100644 --- a/pkg/resource/aws/aws_iam_policy.go +++ b/pkg/resource/aws/aws_iam_policy.go @@ -1,19 +1,13 @@ package aws import ( + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/pkg/helpers" - "github.com/snyk/driftctl/pkg/resource" ) -const AwsIamPolicyResourceType = "aws_iam_policy" - func initAwsIAMPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.UpdateSchema(AwsIamPolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ - "policy": func(attributeSchema *resource.AttributeSchema) { - attributeSchema.JsonString = true - }, - }) - resourceSchemaRepository.SetNormalizeFunc(AwsIamPolicyResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsIamPolicyResourceType, func(res *resource.Resource) { val := res.Attrs jsonString, err := helpers.NormalizeJsonString((*val)["policy"]) if err == nil { @@ -22,5 +16,4 @@ func initAwsIAMPolicyMetaData(resourceSchemaRepository resource.SchemaRepository val.SafeDelete([]string{"name_prefix"}) }) - resourceSchemaRepository.SetFlags(AwsIamPolicyResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_iam_policy_attachment.go b/pkg/resource/aws/aws_iam_policy_attachment.go index e50feb306..dcfca92d5 100644 --- a/pkg/resource/aws/aws_iam_policy_attachment.go +++ b/pkg/resource/aws/aws_iam_policy_attachment.go @@ -1,15 +1,13 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsIamPolicyAttachmentResourceType = "aws_iam_policy_attachment" - func initAwsIAMPolicyAttachmentMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AwsIamPolicyAttachmentResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsIamPolicyAttachmentResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"name"}) }) - resourceSchemaRepository.SetFlags(AwsIamPolicyAttachmentResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_iam_role.go b/pkg/resource/aws/aws_iam_role.go index ebd099615..abc9e9876 100644 --- a/pkg/resource/aws/aws_iam_role.go +++ b/pkg/resource/aws/aws_iam_role.go @@ -1,20 +1,13 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsIamRoleResourceType = "aws_iam_role" - func initAwsIAMRoleMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.UpdateSchema(AwsIamRoleResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ - "assume_role_policy": func(attributeSchema *resource.AttributeSchema) { - attributeSchema.JsonString = true - }, - }) - resourceSchemaRepository.SetNormalizeFunc(AwsIamRoleResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsIamRoleResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"force_detach_policies"}) }) - resourceSchemaRepository.SetFlags(AwsIamRoleResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_iam_user.go b/pkg/resource/aws/aws_iam_user.go index c7a6ce541..12b1cd938 100644 --- a/pkg/resource/aws/aws_iam_user.go +++ b/pkg/resource/aws/aws_iam_user.go @@ -1,13 +1,12 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsIamUserResourceType = "aws_iam_user" - func initAwsIAMUserMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AwsIamUserResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsIamUserResourceType, func(res *resource.Resource) { val := res.Attrs permissionsBoundary, exist := val.Get("permissions_boundary") if exist && permissionsBoundary == "" { @@ -15,5 +14,4 @@ func initAwsIAMUserMetaData(resourceSchemaRepository resource.SchemaRepositoryIn } val.SafeDelete([]string{"force_destroy"}) }) - resourceSchemaRepository.SetFlags(AwsIamUserResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_instance.go b/pkg/resource/aws/aws_instance.go index 4d7460926..41760ae5b 100644 --- a/pkg/resource/aws/aws_instance.go +++ b/pkg/resource/aws/aws_instance.go @@ -2,13 +2,12 @@ package aws import ( "github.com/hashicorp/go-version" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsInstanceResourceType = "aws_instance" - func initAwsInstanceMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AwsInstanceResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsInstanceResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) @@ -16,15 +15,4 @@ func initAwsInstanceMetaData(resourceSchemaRepository resource.SchemaRepositoryI val.SafeDelete([]string{"instance_initiated_shutdown_behavior"}) } }) - resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsInstanceResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if tags := val.GetMap("tags"); tags != nil { - if name, ok := tags["Name"]; ok { - attrs["Name"] = name.(string) - } - } - return attrs - }) - resourceSchemaRepository.SetFlags(AwsInstanceResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_instance_test.go b/pkg/resource/aws/aws_instance_test.go index 6f658f024..f864c0755 100644 --- a/pkg/resource/aws/aws_instance_test.go +++ b/pkg/resource/aws/aws_instance_test.go @@ -9,7 +9,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" "github.com/r3labs/diff/v2" - awsresources "github.com/snyk/driftctl/pkg/resource/aws" + awsresources "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/test/acceptance" "github.com/snyk/driftctl/test/acceptance/awsutils" ) diff --git a/pkg/resource/aws/aws_key_pair.go b/pkg/resource/aws/aws_key_pair.go index b780a42b7..0640764c4 100644 --- a/pkg/resource/aws/aws_key_pair.go +++ b/pkg/resource/aws/aws_key_pair.go @@ -1,16 +1,14 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsKeyPairResourceType = "aws_key_pair" - func initAwsKeyPairMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AwsKeyPairResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsKeyPairResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"key_name_prefix"}) val.SafeDelete([]string{"public_key"}) }) - resourceSchemaRepository.SetFlags(AwsKeyPairResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_kms_alias.go b/pkg/resource/aws/aws_kms_alias.go index 63de3103f..4b5cd4178 100644 --- a/pkg/resource/aws/aws_kms_alias.go +++ b/pkg/resource/aws/aws_kms_alias.go @@ -1,16 +1,14 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsKmsAliasResourceType = "aws_kms_alias" - func initAwsKmsAliasMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AwsKmsAliasResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsKmsAliasResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"name"}) val.SafeDelete([]string{"name_prefix"}) }) - resourceSchemaRepository.SetFlags(AwsKmsAliasResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_kms_key.go b/pkg/resource/aws/aws_kms_key.go index c7316da78..ad2425642 100644 --- a/pkg/resource/aws/aws_kms_key.go +++ b/pkg/resource/aws/aws_kms_key.go @@ -1,19 +1,13 @@ package aws import ( + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/pkg/helpers" - "github.com/snyk/driftctl/pkg/resource" ) -const AwsKmsKeyResourceType = "aws_kms_key" - func initAwsKmsKeyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.UpdateSchema(AwsKmsKeyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ - "policy": func(attributeSchema *resource.AttributeSchema) { - attributeSchema.JsonString = true - }, - }) - resourceSchemaRepository.SetNormalizeFunc(AwsKmsKeyResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsKmsKeyResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"deletion_window_in_days"}) jsonString, err := helpers.NormalizeJsonString((*val)["policy"]) @@ -22,5 +16,4 @@ func initAwsKmsKeyMetaData(resourceSchemaRepository resource.SchemaRepositoryInt } _ = val.SafeSet([]string{"policy"}, jsonString) }) - resourceSchemaRepository.SetFlags(AwsKmsKeyResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_lambda_event_source_mapping.go b/pkg/resource/aws/aws_lambda_event_source_mapping.go index 4cf4c50cd..6723a2d8c 100644 --- a/pkg/resource/aws/aws_lambda_event_source_mapping.go +++ b/pkg/resource/aws/aws_lambda_event_source_mapping.go @@ -1,13 +1,12 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsLambdaEventSourceMappingResourceType = "aws_lambda_event_source_mapping" - func initAwsLambdaEventSourceMappingMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AwsLambdaEventSourceMappingResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsLambdaEventSourceMappingResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"state_transition_reason"}) val.SafeDelete([]string{"state"}) @@ -16,16 +15,4 @@ func initAwsLambdaEventSourceMappingMetaData(resourceSchemaRepository resource.S val.SafeDelete([]string{"last_processing_result"}) val.SafeDelete([]string{"last_modified"}) }) - resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsLambdaEventSourceMappingResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - source := val.GetString("event_source_arn") - dest := val.GetString("function_name") - if source != nil && *source != "" && dest != nil && *dest != "" { - attrs["Source"] = *source - attrs["Dest"] = *dest - } - return attrs - }) - resourceSchemaRepository.SetFlags(AwsLambdaEventSourceMappingResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_lambda_function.go b/pkg/resource/aws/aws_lambda_function.go index 84b26c38d..2e825e8e6 100644 --- a/pkg/resource/aws/aws_lambda_function.go +++ b/pkg/resource/aws/aws_lambda_function.go @@ -1,20 +1,12 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsLambdaFunctionResourceType = "aws_lambda_function" - func initAwsLambdaFunctionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsLambdaFunctionResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "function_name": res.ResourceId(), - } - }) - - resourceSchemaRepository.SetNormalizeFunc(AwsLambdaFunctionResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsLambdaFunctionResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) val.SafeDelete([]string{"publish"}) @@ -27,5 +19,4 @@ func initAwsLambdaFunctionMetaData(resourceSchemaRepository resource.SchemaRepos val.DeleteIfDefault("signing_profile_version_arn") val.SafeDelete([]string{"source_code_size"}) }) - resourceSchemaRepository.SetFlags(AwsLambdaFunctionResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_network_acl_rule.go b/pkg/resource/aws/aws_network_acl_rule.go index 1a8d51f0a..18b7dd540 100644 --- a/pkg/resource/aws/aws_network_acl_rule.go +++ b/pkg/resource/aws/aws_network_acl_rule.go @@ -1,16 +1,12 @@ package aws import ( - "bytes" - "fmt" "strconv" - "github.com/hashicorp/terraform/helper/hashcode" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsNetworkACLRuleResourceType = "aws_network_acl_rule" - var protocolsNumbers = map[string]int{ // defined at https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml "all": -1, @@ -161,52 +157,7 @@ var protocolsNumbers = map[string]int{ } func initAwsNetworkACLRuleMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsNetworkACLRuleResourceType, resource.FlagDeepMode) - resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsNetworkACLRuleResourceType, func(res *resource.Resource) map[string]string { - - ruleNumber := strconv.FormatInt(int64(*res.Attrs.GetFloat64("rule_number")), 10) - if ruleNumber == "32767" { - ruleNumber = "*" - } - - attrs := map[string]string{ - "Network": *res.Attrs.GetString("network_acl_id"), - "Egress": strconv.FormatBool(*res.Attrs.GetBool("egress")), - "Rule number": ruleNumber, - } - - if proto := res.Attrs.GetString("protocol"); proto != nil { - if *proto == "-1" { - *proto = "All" - } - attrs["Protocol"] = *proto - } - - if res.Attrs.GetFloat64("from_port") != nil && res.Attrs.GetFloat64("to_port") != nil { - attrs["Port range"] = fmt.Sprintf("%d - %d", - int64(*res.Attrs.GetFloat64("from_port")), - int64(*res.Attrs.GetFloat64("to_port")), - ) - } - - if cidr := res.Attrs.GetString("cidr_block"); cidr != nil && *cidr != "" { - attrs["CIDR"] = *cidr - } - - if cidr := res.Attrs.GetString("ipv6_cidr_block"); cidr != nil && *cidr != "" { - attrs["CIDR"] = *cidr - } - - return attrs - }) - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsNetworkACLRuleResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "network_acl_id": *res.Attrs.GetString("network_acl_id"), - "rule_number": strconv.FormatInt(int64(*res.Attrs.GetFloat64("rule_number")), 10), - "egress": strconv.FormatBool(*res.Attrs.GetBool("egress")), - } - }) - resourceSchemaRepository.SetNormalizeFunc(AwsNetworkACLRuleResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsNetworkACLRuleResourceType, func(res *resource.Resource) { res.Attrs.DeleteIfDefault("icmp_code") res.Attrs.DeleteIfDefault("icmp_type") @@ -229,7 +180,7 @@ func initAwsNetworkACLRuleMetaData(resourceSchemaRepository resource.SchemaRepos // While reading remote we always got protocol as a number. // We cannot predict how the user decided to write the protocol on IaC side. // This workaround is mandatory to harmonize resources ID - res.Id = CreateNetworkACLRuleID( + res.Id = aws.CreateNetworkACLRuleID( *res.Attrs.GetString("network_acl_id"), int(*res.Attrs.GetFloat64("rule_number")), *res.Attrs.GetBool("egress"), @@ -241,12 +192,3 @@ func initAwsNetworkACLRuleMetaData(resourceSchemaRepository resource.SchemaRepos res.Attrs.DeleteIfDefault("ipv6_cidr_block") }) } - -func CreateNetworkACLRuleID(networkAclId string, ruleNumber int, egress bool, protocol string) string { - var buf bytes.Buffer - buf.WriteString(fmt.Sprintf("%s-", networkAclId)) - buf.WriteString(fmt.Sprintf("%d-", ruleNumber)) - buf.WriteString(fmt.Sprintf("%t-", egress)) - buf.WriteString(fmt.Sprintf("%s-", protocol)) - return fmt.Sprintf("nacl-%d", hashcode.String(buf.String())) -} diff --git a/pkg/resource/aws/aws_rds_cluster.go b/pkg/resource/aws/aws_rds_cluster.go index bf9eb1fbb..6ade66f36 100644 --- a/pkg/resource/aws/aws_rds_cluster.go +++ b/pkg/resource/aws/aws_rds_cluster.go @@ -1,19 +1,12 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsRDSClusterResourceType = "aws_rds_cluster" - func initAwsRDSClusterMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsRDSClusterResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "cluster_identifier": *res.Attributes().GetString("cluster_identifier"), - "database_name": *res.Attributes().GetString("database_name"), - } - }) - resourceSchemaRepository.SetNormalizeFunc(AwsRDSClusterResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsRDSClusterResourceType, func(res *resource.Resource) { val := res.Attributes() val.SafeDelete([]string{"timeouts"}) val.SafeDelete([]string{"master_password"}) @@ -24,5 +17,4 @@ func initAwsRDSClusterMetaData(resourceSchemaRepository resource.SchemaRepositor val.SafeDelete([]string{"final_snapshot_identifier"}) val.SafeDelete([]string{"source_region"}) }) - resourceSchemaRepository.SetFlags(AwsRDSClusterResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_route.go b/pkg/resource/aws/aws_route.go index 2fa9210fc..61474b512 100644 --- a/pkg/resource/aws/aws_route.go +++ b/pkg/resource/aws/aws_route.go @@ -1,31 +1,12 @@ package aws import ( - "fmt" - - "github.com/hashicorp/terraform/helper/hashcode" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsRouteResourceType = "aws_route" - func initAwsRouteMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsRouteResourceType, func(res *resource.Resource) map[string]string { - attributes := map[string]string{ - "route_table_id": *res.Attributes().GetString("route_table_id"), - } - if ipv4 := res.Attributes().GetString("destination_cidr_block"); ipv4 != nil && *ipv4 != "" { - attributes["destination_cidr_block"] = *ipv4 - } - if ipv6 := res.Attributes().GetString("destination_ipv6_cidr_block"); ipv6 != nil && *ipv6 != "" { - attributes["destination_ipv6_cidr_block"] = *ipv6 - } - if prefixes := res.Attributes().GetString("destination_prefix_list_id"); prefixes != nil && *prefixes != "" { - attributes["destination_prefix_list_id"] = *prefixes - } - return attributes - }) - resourceSchemaRepository.SetNormalizeFunc(AwsRouteResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsRouteResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) @@ -44,38 +25,4 @@ func initAwsRouteMetaData(resourceSchemaRepository resource.SchemaRepositoryInte val.DeleteIfDefault("instance_owner_id") val.DeleteIfDefault("carrier_gateway_id") }) - resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsRouteResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if rtID := val.GetString("route_table_id"); rtID != nil && *rtID != "" { - attrs["Table"] = *rtID - } - if ipv4 := val.GetString("destination_cidr_block"); ipv4 != nil && *ipv4 != "" { - attrs["Destination"] = *ipv4 - } - if ipv6 := val.GetString("destination_ipv6_cidr_block"); ipv6 != nil && *ipv6 != "" { - attrs["Destination"] = *ipv6 - } - if prefix := val.GetString("destination_prefix_list_id"); prefix != nil && *prefix != "" { - attrs["Destination"] = *prefix - } - return attrs - }) - resourceSchemaRepository.SetFlags(AwsRouteResourceType, resource.FlagDeepMode) -} - -func CalculateRouteID(tableId, CidrBlock, Ipv6CidrBlock, PrefixListId *string) string { - if CidrBlock != nil && *CidrBlock != "" { - return fmt.Sprintf("r-%s%d", *tableId, hashcode.String(*CidrBlock)) - } - - if Ipv6CidrBlock != nil && *Ipv6CidrBlock != "" { - return fmt.Sprintf("r-%s%d", *tableId, hashcode.String(*Ipv6CidrBlock)) - } - - if PrefixListId != nil && *PrefixListId != "" { - return fmt.Sprintf("r-%s%d", *tableId, hashcode.String(*PrefixListId)) - } - - return "" } diff --git a/pkg/resource/aws/aws_route53_health_check_test.go b/pkg/resource/aws/aws_route53_health_check_test.go index 45a603349..6c5ff093a 100644 --- a/pkg/resource/aws/aws_route53_health_check_test.go +++ b/pkg/resource/aws/aws_route53_health_check_test.go @@ -7,8 +7,8 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/r3labs/diff/v2" + awsresources "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/pkg/analyser" - awsresources "github.com/snyk/driftctl/pkg/resource/aws" "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/acceptance" "github.com/snyk/driftctl/test/acceptance/awsutils" diff --git a/pkg/resource/aws/aws_route53_record.go b/pkg/resource/aws/aws_route53_record.go index 09a2db095..564a2e4e9 100644 --- a/pkg/resource/aws/aws_route53_record.go +++ b/pkg/resource/aws/aws_route53_record.go @@ -1,13 +1,12 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsRoute53RecordResourceType = "aws_route53_record" - func initAwsRoute53RecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AwsRoute53RecordResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsRoute53RecordResourceType, func(res *resource.Resource) { val := res.Attrs val.DeleteIfDefault("health_check_id") val.DeleteIfDefault("set_identifier") @@ -15,19 +14,4 @@ func initAwsRoute53RecordMetaData(resourceSchemaRepository resource.SchemaReposi val.SafeDelete([]string{"name"}) val.SafeDelete([]string{"allow_overwrite"}) }) - resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsRoute53RecordResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if fqdn := val.GetString("fqdn"); fqdn != nil && *fqdn != "" { - attrs["Fqdn"] = *fqdn - } - if ty := val.GetString("type"); ty != nil && *ty != "" { - attrs["Type"] = *ty - } - if zoneID := val.GetString("zone_id"); zoneID != nil && *zoneID != "" { - attrs["ZoneId"] = *zoneID - } - return attrs - }) - resourceSchemaRepository.SetFlags(AwsRoute53RecordResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_route53_zone.go b/pkg/resource/aws/aws_route53_zone.go index 7a038a28a..6166cda9a 100644 --- a/pkg/resource/aws/aws_route53_zone.go +++ b/pkg/resource/aws/aws_route53_zone.go @@ -1,23 +1,13 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsRoute53ZoneResourceType = "aws_route53_zone" - func initAwsRoute53ZoneMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AwsRoute53ZoneResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsRoute53ZoneResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"force_destroy"}) }) - resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsRoute53ZoneResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - return attrs - }) - resourceSchemaRepository.SetFlags(AwsRoute53ZoneResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_s3_bucket.go b/pkg/resource/aws/aws_s3_bucket.go index 17d948077..bfe58785e 100644 --- a/pkg/resource/aws/aws_s3_bucket.go +++ b/pkg/resource/aws/aws_s3_bucket.go @@ -1,26 +1,14 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsS3BucketResourceType = "aws_s3_bucket" - func initAwsS3BucketMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsS3BucketResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "alias": *res.Attributes().GetString("region"), - } - }) - resourceSchemaRepository.UpdateSchema(AwsS3BucketResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ - "policy": func(attributeSchema *resource.AttributeSchema) { - attributeSchema.JsonString = true - }, - }) - resourceSchemaRepository.SetNormalizeFunc(AwsS3BucketResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsS3BucketResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"force_destroy"}) val.SafeDelete([]string{"bucket_prefix"}) }) - resourceSchemaRepository.SetFlags(AwsS3BucketResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_s3_bucket_policy.go b/pkg/resource/aws/aws_s3_bucket_policy.go index 7cbf26401..de9fc5f7a 100644 --- a/pkg/resource/aws/aws_s3_bucket_policy.go +++ b/pkg/resource/aws/aws_s3_bucket_policy.go @@ -1,24 +1,13 @@ package aws import ( + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/pkg/helpers" - "github.com/snyk/driftctl/pkg/resource" ) -const AwsS3BucketPolicyResourceType = "aws_s3_bucket_policy" - func initAwsS3BucketPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsS3BucketPolicyResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "alias": *res.Attributes().GetString("region"), - } - }) - resourceSchemaRepository.UpdateSchema(AwsS3BucketPolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ - "policy": func(attributeSchema *resource.AttributeSchema) { - attributeSchema.JsonString = true - }, - }) - resourceSchemaRepository.SetNormalizeFunc(AwsS3BucketPolicyResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsS3BucketPolicyResourceType, func(res *resource.Resource) { val := res.Attrs jsonString, err := helpers.NormalizeJsonString((*val)["policy"]) if err != nil { @@ -26,5 +15,4 @@ func initAwsS3BucketPolicyMetaData(resourceSchemaRepository resource.SchemaRepos } _ = val.SafeSet([]string{"policy"}, jsonString) }) - resourceSchemaRepository.SetFlags(AwsS3BucketPolicyResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_security_group.go b/pkg/resource/aws/aws_security_group.go index 93ec512e9..7aba0bbb0 100644 --- a/pkg/resource/aws/aws_security_group.go +++ b/pkg/resource/aws/aws_security_group.go @@ -1,18 +1,18 @@ package aws -import "github.com/snyk/driftctl/pkg/resource" - -const AwsSecurityGroupResourceType = "aws_security_group" +import ( + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" +) func initAwsSecurityGroupMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AwsSecurityGroupResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsSecurityGroupResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"revoke_rules_on_delete"}) val.SafeDelete([]string{"timeouts"}) - //TODO We need to find a way to warn users that some rules in their states could be unmanaged + // TODO We need to find a way to warn users that some rules in their states could be unmanaged val.SafeDelete([]string{"ingress"}) val.SafeDelete([]string{"egress"}) }) - resourceSchemaRepository.SetFlags(AwsSecurityGroupResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_security_group_rule.go b/pkg/resource/aws/aws_security_group_rule.go index c782abf12..80546f011 100644 --- a/pkg/resource/aws/aws_security_group_rule.go +++ b/pkg/resource/aws/aws_security_group_rule.go @@ -1,96 +1,12 @@ package aws import ( - "bytes" - "fmt" - - "github.com/hashicorp/terraform/flatmap" - "github.com/hashicorp/terraform/helper/hashcode" - "github.com/snyk/driftctl/pkg/helpers" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsSecurityGroupRuleResourceType = "aws_security_group_rule" - -func CreateSecurityGroupRuleIdHash(attrs *resource.Attributes) string { - var buf bytes.Buffer - buf.WriteString(fmt.Sprintf("%s-", *attrs.GetString("security_group_id"))) - if attrs.GetInt("from_port") != nil && *attrs.GetInt("from_port") > 0 { - buf.WriteString(fmt.Sprintf("%d-", *attrs.GetInt("from_port"))) - } - if attrs.GetInt("to_port") != nil && *attrs.GetInt("to_port") > 0 { - buf.WriteString(fmt.Sprintf("%d-", *attrs.GetInt("to_port"))) - } - buf.WriteString(fmt.Sprintf("%s-", *attrs.GetString("protocol"))) - buf.WriteString(fmt.Sprintf("%s-", *attrs.GetString("type"))) - - if attrs.GetSlice("cidr_blocks") != nil { - for _, v := range attrs.GetSlice("cidr_blocks") { - buf.WriteString(fmt.Sprintf("%s-", v)) - } - } - - if attrs.GetSlice("ipv6_cidr_blocks") != nil { - for _, v := range attrs.GetSlice("ipv6_cidr_blocks") { - buf.WriteString(fmt.Sprintf("%s-", v)) - } - } - - if attrs.GetSlice("prefix_list_ids") != nil { - for _, v := range attrs.GetSlice("prefix_list_ids") { - buf.WriteString(fmt.Sprintf("%s-", v)) - } - } - - if (attrs.GetBool("self") != nil && *attrs.GetBool("self")) || - (attrs.GetString("source_security_group_id") != nil && *attrs.GetString("source_security_group_id") != "") { - if attrs.GetBool("self") != nil && *attrs.GetBool("self") { - buf.WriteString(fmt.Sprintf("%s-", *attrs.GetString("security_group_id"))) - } else { - buf.WriteString(fmt.Sprintf("%s-", *attrs.GetString("source_security_group_id"))) - } - buf.WriteString("-") - } - - return fmt.Sprintf("sgrule-%d", hashcode.String(buf.String())) -} - func initAwsSecurityGroupRuleMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsSecurityGroupRuleResourceType, func(res *resource.Resource) map[string]string { - attrs := make(map[string]interface{}) - if v, ok := res.Attributes().Get("type"); ok { - attrs["type"] = v - } - if v, ok := res.Attributes().Get("protocol"); ok { - attrs["protocol"] = v - } - if v := res.Attributes().GetInt("from_port"); v != nil { - attrs["from_port"] = *v - } - if v := res.Attributes().GetInt("to_port"); v != nil { - attrs["to_port"] = *v - } - if v, ok := res.Attributes().Get("security_group_id"); ok { - attrs["security_group_id"] = v - } - if v, ok := res.Attributes().Get("self"); ok { - attrs["self"] = v - } - if v, ok := res.Attributes().Get("cidr_blocks"); ok { - attrs["cidr_blocks"] = v - } - if v, ok := res.Attributes().Get("ipv6_cidr_blocks"); ok { - attrs["ipv6_cidr_blocks"] = v - } - if v, ok := res.Attributes().Get("prefix_list_ids"); ok { - attrs["prefix_list_ids"] = v - } - if v, ok := res.Attributes().Get("source_security_group_id"); ok { - attrs["source_security_group_id"] = v - } - return flatmap.Flatten(attrs) - }) - resourceSchemaRepository.SetNormalizeFunc(AwsSecurityGroupRuleResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsSecurityGroupRuleResourceType, func(res *resource.Resource) { val := res.Attrs val.DeleteIfDefault("security_group_id") val.DeleteIfDefault("source_security_group_id") @@ -108,58 +24,8 @@ func initAwsSecurityGroupRuleMetaData(resourceSchemaRepository resource.SchemaRe val.SafeDelete([]string{"from_port"}) val.SafeDelete([]string{"to_port"}) - id := CreateSecurityGroupRuleIdHash(val) + id := aws.CreateSecurityGroupRuleIdHash(val) _ = val.SafeSet([]string{"id"}, id) res.Id = id }) - resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsSecurityGroupRuleResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if sgID := val.GetString("security_group_id"); sgID != nil && *sgID != "" { - attrs["SecurityGroup"] = *sgID - } - if protocol := val.GetString("protocol"); protocol != nil && *protocol != "" { - if *protocol == "-1" { - *protocol = "All" - } - attrs["Protocol"] = *protocol - } - fromPort := val.GetInt("from_port") - toPort := val.GetInt("to_port") - if fromPort != nil && toPort != nil { - portRange := "All" - if *fromPort != 0 && *fromPort == *toPort { - portRange = fmt.Sprintf("%d", *fromPort) - } - if *fromPort != 0 && *toPort != 0 && *fromPort != *toPort { - portRange = fmt.Sprintf("%d-%d", *fromPort, *toPort) - } - attrs["Ports"] = portRange - } - ty := val.GetString("type") - if ty != nil && *ty != "" { - attrs["Type"] = *ty - var sourceOrDestination string - switch *ty { - case "egress": - sourceOrDestination = "Destination" - case "ingress": - sourceOrDestination = "Source" - } - if ipv4 := val.GetSlice("cidr_blocks"); len(ipv4) > 0 { - attrs[sourceOrDestination] = helpers.Join(ipv4, ", ") - } - if ipv6 := val.GetSlice("ipv6_cidr_blocks"); len(ipv6) > 0 { - attrs[sourceOrDestination] = helpers.Join(ipv6, ", ") - } - if prefixList := val.GetSlice("prefix_list_ids"); len(prefixList) > 0 { - attrs[sourceOrDestination] = helpers.Join(prefixList, ", ") - } - if sourceSgID := val.GetString("source_security_group_id"); sourceSgID != nil && *sourceSgID != "" { - attrs[sourceOrDestination] = *sourceSgID - } - } - return attrs - }) - resourceSchemaRepository.SetFlags(AwsSecurityGroupRuleResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_sns_topic.go b/pkg/resource/aws/aws_sns_topic.go index da62d48b0..494069de9 100644 --- a/pkg/resource/aws/aws_sns_topic.go +++ b/pkg/resource/aws/aws_sns_topic.go @@ -1,24 +1,12 @@ package aws -import "github.com/snyk/driftctl/pkg/resource" - -const AwsSnsTopicResourceType = "aws_sns_topic" +import ( + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" +) func initSnsTopicMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsSnsTopicResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "topic_arn": res.ResourceId(), - } - }) - resourceSchemaRepository.UpdateSchema(AwsSnsTopicResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ - "delivery_policy": func(attributeSchema *resource.AttributeSchema) { - attributeSchema.JsonString = true - }, - "policy": func(attributeSchema *resource.AttributeSchema) { - attributeSchema.JsonString = true - }, - }) - resourceSchemaRepository.SetNormalizeFunc(AwsSnsTopicResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsSnsTopicResourceType, func(res *resource.Resource) { val := res.Attrs val.DeleteIfDefault("sqs_success_feedback_sample_rate") val.DeleteIfDefault("lambda_success_feedback_sample_rate") @@ -29,16 +17,4 @@ func initSnsTopicMetaData(resourceSchemaRepository resource.SchemaRepositoryInte val.SafeDelete([]string{"name_prefix"}) val.SafeDelete([]string{"owner"}) }) - resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsSnsTopicResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - if displayName := val.GetString("display_name"); displayName != nil && *displayName != "" { - attrs["DisplayName"] = *displayName - } - } - return attrs - }) - resourceSchemaRepository.SetFlags(AwsSnsTopicResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_sns_topic_policy.go b/pkg/resource/aws/aws_sns_topic_policy.go index a3d3f6679..a625cbc7b 100644 --- a/pkg/resource/aws/aws_sns_topic_policy.go +++ b/pkg/resource/aws/aws_sns_topic_policy.go @@ -1,26 +1,13 @@ package aws import ( + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/pkg/helpers" - "github.com/snyk/driftctl/pkg/resource" ) -const AwsSnsTopicPolicyResourceType = "aws_sns_topic_policy" - func initSnsTopicPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsSnsTopicPolicyResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "topic_arn": res.ResourceId(), - } - }) - - resourceSchemaRepository.UpdateSchema(AwsSnsTopicPolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ - "policy": func(attributeSchema *resource.AttributeSchema) { - attributeSchema.JsonString = true - }, - }) - - resourceSchemaRepository.SetNormalizeFunc(AwsSnsTopicPolicyResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsSnsTopicPolicyResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"owner"}) jsonString, err := helpers.NormalizeJsonString((*val)["policy"]) @@ -29,5 +16,4 @@ func initSnsTopicPolicyMetaData(resourceSchemaRepository resource.SchemaReposito } _ = val.SafeSet([]string{"policy"}, jsonString) }) - resourceSchemaRepository.SetFlags(AwsSnsTopicPolicyResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_sns_topic_policy_test.go b/pkg/resource/aws/aws_sns_topic_policy_test.go index 0f96334df..441106061 100644 --- a/pkg/resource/aws/aws_sns_topic_policy_test.go +++ b/pkg/resource/aws/aws_sns_topic_policy_test.go @@ -1,12 +1,12 @@ package aws_test import ( + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/cache" "testing" "time" "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/remote/cache" "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/acceptance" "github.com/snyk/driftctl/test/acceptance/awsutils" diff --git a/pkg/resource/aws/aws_sns_topic_subscription.go b/pkg/resource/aws/aws_sns_topic_subscription.go index d89721edb..ed41dacf1 100644 --- a/pkg/resource/aws/aws_sns_topic_subscription.go +++ b/pkg/resource/aws/aws_sns_topic_subscription.go @@ -1,29 +1,13 @@ package aws import ( + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/pkg/helpers" - "github.com/snyk/driftctl/pkg/resource" ) -const AwsSnsTopicSubscriptionResourceType = "aws_sns_topic_subscription" - func initSnsTopicSubscriptionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsSnsTopicSubscriptionResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "SubscriptionId": res.ResourceId(), - } - }) - - resourceSchemaRepository.UpdateSchema(AwsSnsTopicSubscriptionResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ - "delivery_policy": func(attributeSchema *resource.AttributeSchema) { - attributeSchema.JsonString = true - }, - "filter_policy": func(attributeSchema *resource.AttributeSchema) { - attributeSchema.JsonString = true - }, - }) - - resourceSchemaRepository.SetNormalizeFunc(AwsSnsTopicSubscriptionResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsSnsTopicSubscriptionResourceType, func(res *resource.Resource) { val := res.Attrs jsonString, err := helpers.NormalizeJsonString((*val)["delivery_policy"]) if err == nil { @@ -42,5 +26,4 @@ func initSnsTopicSubscriptionMetaData(resourceSchemaRepository resource.SchemaRe val.SafeDelete([]string{"confirmation_timeout_in_minutes"}) } }) - resourceSchemaRepository.SetFlags(AwsSnsTopicSubscriptionResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_sns_topic_subscription_test.go b/pkg/resource/aws/aws_sns_topic_subscription_test.go index fcd4acb4b..f5f6cecba 100644 --- a/pkg/resource/aws/aws_sns_topic_subscription_test.go +++ b/pkg/resource/aws/aws_sns_topic_subscription_test.go @@ -1,12 +1,12 @@ package aws_test import ( + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/cache" "testing" "time" "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/remote/aws/repository" - "github.com/snyk/driftctl/pkg/remote/cache" "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/acceptance" "github.com/snyk/driftctl/test/acceptance/awsutils" diff --git a/pkg/resource/aws/aws_sns_topic_test.go b/pkg/resource/aws/aws_sns_topic_test.go index cf45ddd88..e4e4492f9 100644 --- a/pkg/resource/aws/aws_sns_topic_test.go +++ b/pkg/resource/aws/aws_sns_topic_test.go @@ -1,22 +1,21 @@ package aws_test import ( + "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/cache" "strings" "testing" "time" "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/remote/cache" - - "github.com/snyk/driftctl/pkg/remote/aws/repository" "github.com/snyk/driftctl/test" "github.com/aws/aws-sdk-go/service/sns" "github.com/aws/aws-sdk-go/aws" "github.com/r3labs/diff/v2" + awsresources "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/pkg/analyser" - awsresources "github.com/snyk/driftctl/pkg/resource/aws" "github.com/snyk/driftctl/test/acceptance" "github.com/snyk/driftctl/test/acceptance/awsutils" ) diff --git a/pkg/resource/aws/aws_sqs_queue_policy.go b/pkg/resource/aws/aws_sqs_queue_policy.go index 263b1555b..7c71accdb 100644 --- a/pkg/resource/aws/aws_sqs_queue_policy.go +++ b/pkg/resource/aws/aws_sqs_queue_policy.go @@ -1,19 +1,13 @@ package aws import ( + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/pkg/helpers" - "github.com/snyk/driftctl/pkg/resource" ) -const AwsSqsQueuePolicyResourceType = "aws_sqs_queue_policy" - func initAwsSQSQueuePolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.UpdateSchema(AwsSqsQueuePolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ - "policy": func(attributeSchema *resource.AttributeSchema) { - attributeSchema.JsonString = true - }, - }) - resourceSchemaRepository.SetNormalizeFunc(AwsSqsQueuePolicyResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsSqsQueuePolicyResourceType, func(res *resource.Resource) { val := res.Attrs jsonString, err := helpers.NormalizeJsonString((*val)["policy"]) if err != nil { @@ -21,5 +15,4 @@ func initAwsSQSQueuePolicyMetaData(resourceSchemaRepository resource.SchemaRepos } _ = val.SafeSet([]string{"policy"}, jsonString) }) - resourceSchemaRepository.SetFlags(AwsSqsQueuePolicyResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_sqs_queue_test.go b/pkg/resource/aws/aws_sqs_queue_test.go index 6ace47494..b50a9d473 100644 --- a/pkg/resource/aws/aws_sqs_queue_test.go +++ b/pkg/resource/aws/aws_sqs_queue_test.go @@ -6,8 +6,8 @@ import ( "github.com/sirupsen/logrus" + awsresources "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/pkg/analyser" - awsresources "github.com/snyk/driftctl/pkg/resource/aws" "github.com/snyk/driftctl/test" "github.com/r3labs/diff/v2" diff --git a/pkg/resource/aws/aws_subnet.go b/pkg/resource/aws/aws_subnet.go index 1de8f2b53..9795a8801 100644 --- a/pkg/resource/aws/aws_subnet.go +++ b/pkg/resource/aws/aws_subnet.go @@ -1,15 +1,13 @@ package aws import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" ) -const AwsSubnetResourceType = "aws_subnet" - func initAwsSubnetMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AwsSubnetResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(aws.AwsSubnetResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) }) - resourceSchemaRepository.SetFlags(AwsSubnetResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/metadatas.go b/pkg/resource/aws/metadatas.go index 63be9bba4..5a0cc0210 100644 --- a/pkg/resource/aws/metadatas.go +++ b/pkg/resource/aws/metadatas.go @@ -1,6 +1,6 @@ package aws -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { initAwsAmiMetaData(resourceSchemaRepository) @@ -9,48 +9,30 @@ func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInt initAwsDbSubnetGroupMetaData(resourceSchemaRepository) initAwsDefaultSecurityGroupMetaData(resourceSchemaRepository) initAwsDefaultSubnetMetaData(resourceSchemaRepository) - initAwsDefaultVpcMetaData(resourceSchemaRepository) - initAwsDefaultRouteTableMetadata(resourceSchemaRepository) initAwsDynamodbTableMetaData(resourceSchemaRepository) initAwsEbsSnapshotMetaData(resourceSchemaRepository) initAwsInstanceMetaData(resourceSchemaRepository) - initAwsInternetGatewayMetaData(resourceSchemaRepository) initAwsEbsVolumeMetaData(resourceSchemaRepository) initAwsEipMetaData(resourceSchemaRepository) - initAwsEipAssociationMetaData(resourceSchemaRepository) initAwsS3BucketMetaData(resourceSchemaRepository) initAwsS3BucketPolicyMetaData(resourceSchemaRepository) - initAwsS3BucketInventoryMetadata(resourceSchemaRepository) - initAwsS3BucketMetricMetadata(resourceSchemaRepository) - initAwsS3BucketNotificationMetadata(resourceSchemaRepository) - initAwsS3BucketAnalyticsConfigurationMetaData(resourceSchemaRepository) initAwsEcrRepositoryMetaData(resourceSchemaRepository) initAwsRouteMetaData(resourceSchemaRepository) - initAwsRouteTableAssociationMetaData(resourceSchemaRepository) initAwsRoute53RecordMetaData(resourceSchemaRepository) initAwsRoute53ZoneMetaData(resourceSchemaRepository) - initAwsRoute53HealthCheckMetaData(resourceSchemaRepository) - initAwsRouteTableMetaData(resourceSchemaRepository) initSnsTopicSubscriptionMetaData(resourceSchemaRepository) initSnsTopicPolicyMetaData(resourceSchemaRepository) initSnsTopicMetaData(resourceSchemaRepository) - initSqsQueueMetaData(resourceSchemaRepository) initAwsIAMAccessKeyMetaData(resourceSchemaRepository) initAwsIAMPolicyMetaData(resourceSchemaRepository) initAwsIAMPolicyAttachmentMetaData(resourceSchemaRepository) initAwsIAMRoleMetaData(resourceSchemaRepository) - initAwsIAMRolePolicyMetaData(resourceSchemaRepository) - initAwsIamRolePolicyAttachmentMetaData(resourceSchemaRepository) - initAwsIamUserPolicyAttachmentMetaData(resourceSchemaRepository) initAwsIAMUserMetaData(resourceSchemaRepository) - initAwsIAMUserPolicyMetaData(resourceSchemaRepository) initAwsKeyPairMetaData(resourceSchemaRepository) initAwsKmsKeyMetaData(resourceSchemaRepository) initAwsKmsAliasMetaData(resourceSchemaRepository) initAwsLambdaFunctionMetaData(resourceSchemaRepository) initAwsLambdaEventSourceMappingMetaData(resourceSchemaRepository) - initNatGatewayMetaData(resourceSchemaRepository) - initAwsNetworkACLMetaData(resourceSchemaRepository) initAwsNetworkACLRuleMetaData(resourceSchemaRepository) initAwsDefaultNetworkACLMetaData(resourceSchemaRepository) initAwsSubnetMetaData(resourceSchemaRepository) @@ -59,12 +41,5 @@ func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInt initAwsSecurityGroupMetaData(resourceSchemaRepository) initAwsRDSClusterMetaData(resourceSchemaRepository) initAwsCloudformationStackMetaData(resourceSchemaRepository) - initAwsVpcMetaData(resourceSchemaRepository) initAwsAppAutoscalingTargetMetaData(resourceSchemaRepository) - initAwsAppAutoscalingPolicyMetaData(resourceSchemaRepository) - initAwsLaunchTemplateMetaData(resourceSchemaRepository) - initAwsApiGatewayV2ModelMetaData(resourceSchemaRepository) - initAwsApiGatewayV2MappingMetaData(resourceSchemaRepository) - initAwsEbsEncryptionByDefaultMetaData(resourceSchemaRepository) - initAwsLoadBalancerMetaData(resourceSchemaRepository) } diff --git a/pkg/resource/aws/testdata/acc/aws_alb/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_alb/.terraform.lock.hcl index 347063989..cb60e412e 100644 --- a/pkg/resource/aws/testdata/acc/aws_alb/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_alb/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/aws" { version = "4.8.0" hashes = [ "h1:T9Typ5V+dDwecG9USCLbW4oayxN3cxEGsG+OJzzjRgY=", + "h1:W2cPGKmqkPbTc91lu42QeC3RFBqB5TnRnS3IxNME2FM=", "zh:16cbdbc03ad13358d12433e645e2ab5a615e3a3662a74e3c317267c9377713d8", "zh:1d813c5e6c21fe370652495e29f783db4e65037f913ff0d53d28515c36fbb70a", "zh:31ad8282e31d0fac62e96fc2321a68ad4b92ab90f560be5f875d1b01a493e491", diff --git a/pkg/resource/aws/testdata/acc/aws_alb_listener/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_alb_listener/.terraform.lock.hcl index ae023925b..c236fad47 100644 --- a/pkg/resource/aws/testdata/acc/aws_alb_listener/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_alb_listener/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/aws" { version = "4.9.0" hashes = [ "h1:GtmIOZMkKmr9tMLWouHWiGXmKEL/diOTNar5XfOVLjs=", + "h1:OWIIlbMZl/iQ8qR1U7Co3sGjNHL1HJtgNRnnV1kXNuI=", "zh:084b83aef3335ad4f5e4b8323c6fe43c1ff55e17a7647c6a5cad6af519f72b42", "zh:132e47ce69f14de4523b84b213cedf7173398acda14245b1ffe7747aac50f050", "zh:2068baef7dfce3613f3b4f27314175e971f8db68d9cde9ec30b5659f80c68c6c", diff --git a/pkg/resource/aws/testdata/acc/aws_apigatewayv2_mapping/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_apigatewayv2_mapping/.terraform.lock.hcl index 01b6b4502..9e7a3811a 100644 --- a/pkg/resource/aws/testdata/acc/aws_apigatewayv2_mapping/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_apigatewayv2_mapping/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/aws" { constraints = "3.47.0" hashes = [ "h1:gXncRh1KtgLNMeb3/bYq5CvGfy8YTR+n6ds1noc5ggc=", + "h1:oiX6JcoXY6lYIdcYWmEpr7mnS4mkyDV9intCNrcjiBs=", "zh:07bb6bda5b9fdb782dd568a2e85cfe0ab108770e2218f3411e57ed845c58af40", "zh:0926b161a109e75bdc8691e8a32f568b4cd77a55510cf27573261fb5ba382287", "zh:0a91adf25a78ad31d547da513db24f493d27592d3675ed291a7698351c30992d", @@ -23,6 +24,7 @@ provider "registry.terraform.io/hashicorp/aws" { provider "registry.terraform.io/hashicorp/tls" { version = "3.1.0" hashes = [ + "h1:XTU9f6sGMZHOT8r/+LWCz2BZOPH127FBTPjMMEAAu1U=", "h1:fUJX8Zxx38e2kBln+zWr1Tl41X+OuiE++REjrEyiOM4=", "zh:3d46616b41fea215566f4a957b6d3a1aa43f1f75c26776d72a98bdba79439db6", "zh:623a203817a6dafa86f1b4141b645159e07ec418c82fe40acd4d2a27543cbaa2", diff --git a/pkg/resource/aws/testdata/acc/aws_apigatewayv2_model/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_apigatewayv2_model/.terraform.lock.hcl index 642a98810..51efd1d67 100644 --- a/pkg/resource/aws/testdata/acc/aws_apigatewayv2_model/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_apigatewayv2_model/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/aws" { constraints = "3.47.0" hashes = [ "h1:gXncRh1KtgLNMeb3/bYq5CvGfy8YTR+n6ds1noc5ggc=", + "h1:oiX6JcoXY6lYIdcYWmEpr7mnS4mkyDV9intCNrcjiBs=", "zh:07bb6bda5b9fdb782dd568a2e85cfe0ab108770e2218f3411e57ed845c58af40", "zh:0926b161a109e75bdc8691e8a32f568b4cd77a55510cf27573261fb5ba382287", "zh:0a91adf25a78ad31d547da513db24f493d27592d3675ed291a7698351c30992d", diff --git a/pkg/resource/aws/testdata/acc/aws_apigatewayv2_stage/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_apigatewayv2_stage/.terraform.lock.hcl index 642a98810..51efd1d67 100644 --- a/pkg/resource/aws/testdata/acc/aws_apigatewayv2_stage/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_apigatewayv2_stage/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/aws" { constraints = "3.47.0" hashes = [ "h1:gXncRh1KtgLNMeb3/bYq5CvGfy8YTR+n6ds1noc5ggc=", + "h1:oiX6JcoXY6lYIdcYWmEpr7mnS4mkyDV9intCNrcjiBs=", "zh:07bb6bda5b9fdb782dd568a2e85cfe0ab108770e2218f3411e57ed845c58af40", "zh:0926b161a109e75bdc8691e8a32f568b4cd77a55510cf27573261fb5ba382287", "zh:0a91adf25a78ad31d547da513db24f493d27592d3675ed291a7698351c30992d", diff --git a/pkg/resource/aws/testdata/acc/aws_appautoscaling_policy/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_appautoscaling_policy/.terraform.lock.hcl index 0b377f59f..8076e21f7 100644 --- a/pkg/resource/aws/testdata/acc/aws_appautoscaling_policy/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_appautoscaling_policy/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/aws" { constraints = "3.19.0" hashes = [ "h1:+7Vi7p13+cnrxjXbfJiTimGSFR97xCaQwkkvWcreLns=", + "h1:xur9tF49NgsovNnmwmBR8RdpN8Fcg1TD4CKQPJD6n1A=", "zh:185a5259153eb9ee4699d4be43b3d509386b473683392034319beee97d470c3b", "zh:2d9a0a01f93e8d16539d835c02b8b6e1927b7685f4076e96cb07f7dd6944bc6c", "zh:703f6da36b1b5f3497baa38fccaa7765fb8a2b6440344e4c97172516b49437dd", diff --git a/pkg/resource/aws/testdata/acc/aws_appautoscaling_scheduled_action/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_appautoscaling_scheduled_action/.terraform.lock.hcl index 0b377f59f..8076e21f7 100644 --- a/pkg/resource/aws/testdata/acc/aws_appautoscaling_scheduled_action/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_appautoscaling_scheduled_action/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/aws" { constraints = "3.19.0" hashes = [ "h1:+7Vi7p13+cnrxjXbfJiTimGSFR97xCaQwkkvWcreLns=", + "h1:xur9tF49NgsovNnmwmBR8RdpN8Fcg1TD4CKQPJD6n1A=", "zh:185a5259153eb9ee4699d4be43b3d509386b473683392034319beee97d470c3b", "zh:2d9a0a01f93e8d16539d835c02b8b6e1927b7685f4076e96cb07f7dd6944bc6c", "zh:703f6da36b1b5f3497baa38fccaa7765fb8a2b6440344e4c97172516b49437dd", diff --git a/pkg/resource/aws/testdata/acc/aws_appautoscaling_target/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_appautoscaling_target/.terraform.lock.hcl index 0b377f59f..8076e21f7 100644 --- a/pkg/resource/aws/testdata/acc/aws_appautoscaling_target/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_appautoscaling_target/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/aws" { constraints = "3.19.0" hashes = [ "h1:+7Vi7p13+cnrxjXbfJiTimGSFR97xCaQwkkvWcreLns=", + "h1:xur9tF49NgsovNnmwmBR8RdpN8Fcg1TD4CKQPJD6n1A=", "zh:185a5259153eb9ee4699d4be43b3d509386b473683392034319beee97d470c3b", "zh:2d9a0a01f93e8d16539d835c02b8b6e1927b7685f4076e96cb07f7dd6944bc6c", "zh:703f6da36b1b5f3497baa38fccaa7765fb8a2b6440344e4c97172516b49437dd", diff --git a/pkg/resource/aws/testdata/acc/aws_dynamodb_table/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_dynamodb_table/.terraform.lock.hcl index b6fbf3c6c..8a74c4b90 100644 --- a/pkg/resource/aws/testdata/acc/aws_dynamodb_table/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_dynamodb_table/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/aws" { version = "3.32.0" hashes = [ "h1:l8jJYQ4bPEbNwZUoHYmeR1woajPzJSX5hPCLWuRVFwc=", + "h1:tY5R3hRBB1v8v3MT+ofoCJ/Vz/b/4PXo3xtBKtw7T4A=", "zh:04e4f700c21b1f58e7603638160bd5ad3b85519c35dc75bada3e52b164d06d3e", "zh:09f2338404d4b2d4dcb29781ac59a6955d935745e896d4ee661d83cac8d7c677", "zh:16bdf96d8139268766921d5b891b865f67936190dc302283ba50b94e42510ec5", diff --git a/pkg/resource/aws/testdata/acc/aws_ebs_encryption_by_default/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_ebs_encryption_by_default/.terraform.lock.hcl index 347063989..cb60e412e 100644 --- a/pkg/resource/aws/testdata/acc/aws_ebs_encryption_by_default/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_ebs_encryption_by_default/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/aws" { version = "4.8.0" hashes = [ "h1:T9Typ5V+dDwecG9USCLbW4oayxN3cxEGsG+OJzzjRgY=", + "h1:W2cPGKmqkPbTc91lu42QeC3RFBqB5TnRnS3IxNME2FM=", "zh:16cbdbc03ad13358d12433e645e2ab5a615e3a3662a74e3c317267c9377713d8", "zh:1d813c5e6c21fe370652495e29f783db4e65037f913ff0d53d28515c36fbb70a", "zh:31ad8282e31d0fac62e96fc2321a68ad4b92ab90f560be5f875d1b01a493e491", diff --git a/pkg/resource/aws/testdata/acc/aws_eip/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_eip/.terraform.lock.hcl index 19dd55fa4..6d3f22df6 100644 --- a/pkg/resource/aws/testdata/acc/aws_eip/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_eip/.terraform.lock.hcl @@ -3,8 +3,9 @@ provider "registry.terraform.io/hashicorp/aws" { version = "3.44.0" - constraints = "~> 3.44.0" + constraints = "3.44.0" hashes = [ + "h1:VOVZWybe1x0E4qyawTwt7jXVBRUplTrzVFHim217DqI=", "h1:hxQ8n9SHHfAIXd/FtfAqxokFYWBedzZf7xqQZWJajUs=", "zh:0680315b29a140e9b7e4f5aeed3f2445abdfab31fc9237f34dcad06de4f410df", "zh:13811322a205fb4a0ee617f0ae51ec94176befdf569235d0c7064db911f0acc7", diff --git a/pkg/resource/aws/testdata/acc/aws_eip_association/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_eip_association/.terraform.lock.hcl index 19dd55fa4..6d3f22df6 100644 --- a/pkg/resource/aws/testdata/acc/aws_eip_association/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_eip_association/.terraform.lock.hcl @@ -3,8 +3,9 @@ provider "registry.terraform.io/hashicorp/aws" { version = "3.44.0" - constraints = "~> 3.44.0" + constraints = "3.44.0" hashes = [ + "h1:VOVZWybe1x0E4qyawTwt7jXVBRUplTrzVFHim217DqI=", "h1:hxQ8n9SHHfAIXd/FtfAqxokFYWBedzZf7xqQZWJajUs=", "zh:0680315b29a140e9b7e4f5aeed3f2445abdfab31fc9237f34dcad06de4f410df", "zh:13811322a205fb4a0ee617f0ae51ec94176befdf569235d0c7064db911f0acc7", diff --git a/pkg/resource/aws/testdata/acc/aws_elb/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_elb/.terraform.lock.hcl index 2fad61d4c..6d3f22df6 100644 --- a/pkg/resource/aws/testdata/acc/aws_elb/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_elb/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/aws" { version = "3.44.0" constraints = "3.44.0" hashes = [ + "h1:VOVZWybe1x0E4qyawTwt7jXVBRUplTrzVFHim217DqI=", "h1:hxQ8n9SHHfAIXd/FtfAqxokFYWBedzZf7xqQZWJajUs=", "zh:0680315b29a140e9b7e4f5aeed3f2445abdfab31fc9237f34dcad06de4f410df", "zh:13811322a205fb4a0ee617f0ae51ec94176befdf569235d0c7064db911f0acc7", diff --git a/pkg/resource/aws/testdata/acc/aws_iam_access_key/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_iam_access_key/.terraform.lock.hcl index 442356e05..8076e21f7 100644 --- a/pkg/resource/aws/testdata/acc/aws_iam_access_key/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_iam_access_key/.terraform.lock.hcl @@ -3,9 +3,10 @@ provider "registry.terraform.io/hashicorp/aws" { version = "3.19.0" - constraints = "~> 3.19.0" + constraints = "3.19.0" hashes = [ "h1:+7Vi7p13+cnrxjXbfJiTimGSFR97xCaQwkkvWcreLns=", + "h1:xur9tF49NgsovNnmwmBR8RdpN8Fcg1TD4CKQPJD6n1A=", "zh:185a5259153eb9ee4699d4be43b3d509386b473683392034319beee97d470c3b", "zh:2d9a0a01f93e8d16539d835c02b8b6e1927b7685f4076e96cb07f7dd6944bc6c", "zh:703f6da36b1b5f3497baa38fccaa7765fb8a2b6440344e4c97172516b49437dd", diff --git a/pkg/resource/aws/testdata/acc/aws_iam_group/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_iam_group/.terraform.lock.hcl index 0b377f59f..8076e21f7 100644 --- a/pkg/resource/aws/testdata/acc/aws_iam_group/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_iam_group/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/aws" { constraints = "3.19.0" hashes = [ "h1:+7Vi7p13+cnrxjXbfJiTimGSFR97xCaQwkkvWcreLns=", + "h1:xur9tF49NgsovNnmwmBR8RdpN8Fcg1TD4CKQPJD6n1A=", "zh:185a5259153eb9ee4699d4be43b3d509386b473683392034319beee97d470c3b", "zh:2d9a0a01f93e8d16539d835c02b8b6e1927b7685f4076e96cb07f7dd6944bc6c", "zh:703f6da36b1b5f3497baa38fccaa7765fb8a2b6440344e4c97172516b49437dd", diff --git a/pkg/resource/aws/testdata/acc/aws_iam_group_policy/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_iam_group_policy/.terraform.lock.hcl index 0b377f59f..8076e21f7 100644 --- a/pkg/resource/aws/testdata/acc/aws_iam_group_policy/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_iam_group_policy/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/aws" { constraints = "3.19.0" hashes = [ "h1:+7Vi7p13+cnrxjXbfJiTimGSFR97xCaQwkkvWcreLns=", + "h1:xur9tF49NgsovNnmwmBR8RdpN8Fcg1TD4CKQPJD6n1A=", "zh:185a5259153eb9ee4699d4be43b3d509386b473683392034319beee97d470c3b", "zh:2d9a0a01f93e8d16539d835c02b8b6e1927b7685f4076e96cb07f7dd6944bc6c", "zh:703f6da36b1b5f3497baa38fccaa7765fb8a2b6440344e4c97172516b49437dd", diff --git a/pkg/resource/aws/testdata/acc/aws_iam_group_policy_attachment/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_iam_group_policy_attachment/.terraform.lock.hcl index 0b377f59f..8076e21f7 100644 --- a/pkg/resource/aws/testdata/acc/aws_iam_group_policy_attachment/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_iam_group_policy_attachment/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/aws" { constraints = "3.19.0" hashes = [ "h1:+7Vi7p13+cnrxjXbfJiTimGSFR97xCaQwkkvWcreLns=", + "h1:xur9tF49NgsovNnmwmBR8RdpN8Fcg1TD4CKQPJD6n1A=", "zh:185a5259153eb9ee4699d4be43b3d509386b473683392034319beee97d470c3b", "zh:2d9a0a01f93e8d16539d835c02b8b6e1927b7685f4076e96cb07f7dd6944bc6c", "zh:703f6da36b1b5f3497baa38fccaa7765fb8a2b6440344e4c97172516b49437dd", diff --git a/pkg/resource/aws/testdata/acc/aws_iam_role/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_iam_role/.terraform.lock.hcl index c238c3f66..82187a94c 100644 --- a/pkg/resource/aws/testdata/acc/aws_iam_role/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_iam_role/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/aws" { version = "3.45.0" constraints = "3.45.0" hashes = [ + "h1:9l/yDPt/OPG6a0ITu7amfq1LjdnWHTsOgn/KOxM26HA=", "h1:LKU/xfna87/p+hl5yTTW3dvOqWJp5JEM+Dt3nnvSDvA=", "zh:0fdbb3af75ff55807466533f97eb314556ec41a908a543d7cafb06546930f7c6", "zh:20656895744fa0f4607096b9681c77b2385f450b1577f9151d3070818378a724", diff --git a/pkg/resource/aws/testdata/acc/aws_iam_role_with_managed_policies/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_iam_role_with_managed_policies/.terraform.lock.hcl index c238c3f66..82187a94c 100644 --- a/pkg/resource/aws/testdata/acc/aws_iam_role_with_managed_policies/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_iam_role_with_managed_policies/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/aws" { version = "3.45.0" constraints = "3.45.0" hashes = [ + "h1:9l/yDPt/OPG6a0ITu7amfq1LjdnWHTsOgn/KOxM26HA=", "h1:LKU/xfna87/p+hl5yTTW3dvOqWJp5JEM+Dt3nnvSDvA=", "zh:0fdbb3af75ff55807466533f97eb314556ec41a908a543d7cafb06546930f7c6", "zh:20656895744fa0f4607096b9681c77b2385f450b1577f9151d3070818378a724", diff --git a/pkg/resource/aws/testdata/acc/aws_instance/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_instance/.terraform.lock.hcl old mode 100755 new mode 100644 index 88e37a28e..d645626d2 --- a/pkg/resource/aws/testdata/acc/aws_instance/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_instance/.terraform.lock.hcl @@ -3,9 +3,10 @@ provider "registry.terraform.io/hashicorp/aws" { version = "3.19.0" - constraints = "~> 3.19.0" + constraints = "3.19.0" hashes = [ "h1:+7Vi7p13+cnrxjXbfJiTimGSFR97xCaQwkkvWcreLns=", + "h1:xur9tF49NgsovNnmwmBR8RdpN8Fcg1TD4CKQPJD6n1A=", "zh:185a5259153eb9ee4699d4be43b3d509386b473683392034319beee97d470c3b", "zh:2d9a0a01f93e8d16539d835c02b8b6e1927b7685f4076e96cb07f7dd6944bc6c", "zh:703f6da36b1b5f3497baa38fccaa7765fb8a2b6440344e4c97172516b49437dd", @@ -23,6 +24,7 @@ provider "registry.terraform.io/hashicorp/random" { version = "3.0.0" hashes = [ "h1:grDzxfnOdFXi90FRIIwP/ZrCzirJ/SfsGBe6cE0Shg4=", + "h1:yhHJpb4IfQQfuio7qjUXuUFTU/s+ensuEpm23A+VWz0=", "zh:0fcb00ff8b87dcac1b0ee10831e47e0203a6c46aafd76cb140ba2bab81f02c6b", "zh:123c984c0e04bad910c421028d18aa2ca4af25a153264aef747521f4e7c36a17", "zh:287443bc6fd7fa9a4341dec235589293cbcc6e467a042ae225fd5d161e4e68dc", diff --git a/pkg/resource/aws/testdata/acc/aws_instance_default/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_instance_default/.terraform.lock.hcl index c238c3f66..82187a94c 100644 --- a/pkg/resource/aws/testdata/acc/aws_instance_default/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_instance_default/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/aws" { version = "3.45.0" constraints = "3.45.0" hashes = [ + "h1:9l/yDPt/OPG6a0ITu7amfq1LjdnWHTsOgn/KOxM26HA=", "h1:LKU/xfna87/p+hl5yTTW3dvOqWJp5JEM+Dt3nnvSDvA=", "zh:0fdbb3af75ff55807466533f97eb314556ec41a908a543d7cafb06546930f7c6", "zh:20656895744fa0f4607096b9681c77b2385f450b1577f9151d3070818378a724", diff --git a/pkg/resource/aws/testdata/acc/aws_lambda_event_source_mapping/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_lambda_event_source_mapping/.terraform.lock.hcl index b6fbf3c6c..8a74c4b90 100644 --- a/pkg/resource/aws/testdata/acc/aws_lambda_event_source_mapping/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_lambda_event_source_mapping/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/aws" { version = "3.32.0" hashes = [ "h1:l8jJYQ4bPEbNwZUoHYmeR1woajPzJSX5hPCLWuRVFwc=", + "h1:tY5R3hRBB1v8v3MT+ofoCJ/Vz/b/4PXo3xtBKtw7T4A=", "zh:04e4f700c21b1f58e7603638160bd5ad3b85519c35dc75bada3e52b164d06d3e", "zh:09f2338404d4b2d4dcb29781ac59a6955d935745e896d4ee661d83cac8d7c677", "zh:16bdf96d8139268766921d5b891b865f67936190dc302283ba50b94e42510ec5", diff --git a/pkg/resource/aws/testdata/acc/aws_launch_template/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_launch_template/.terraform.lock.hcl index 0b377f59f..8076e21f7 100644 --- a/pkg/resource/aws/testdata/acc/aws_launch_template/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_launch_template/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/aws" { constraints = "3.19.0" hashes = [ "h1:+7Vi7p13+cnrxjXbfJiTimGSFR97xCaQwkkvWcreLns=", + "h1:xur9tF49NgsovNnmwmBR8RdpN8Fcg1TD4CKQPJD6n1A=", "zh:185a5259153eb9ee4699d4be43b3d509386b473683392034319beee97d470c3b", "zh:2d9a0a01f93e8d16539d835c02b8b6e1927b7685f4076e96cb07f7dd6944bc6c", "zh:703f6da36b1b5f3497baa38fccaa7765fb8a2b6440344e4c97172516b49437dd", diff --git a/pkg/resource/aws/testdata/acc/aws_lb/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_lb/.terraform.lock.hcl index 347063989..cb60e412e 100644 --- a/pkg/resource/aws/testdata/acc/aws_lb/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_lb/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/aws" { version = "4.8.0" hashes = [ "h1:T9Typ5V+dDwecG9USCLbW4oayxN3cxEGsG+OJzzjRgY=", + "h1:W2cPGKmqkPbTc91lu42QeC3RFBqB5TnRnS3IxNME2FM=", "zh:16cbdbc03ad13358d12433e645e2ab5a615e3a3662a74e3c317267c9377713d8", "zh:1d813c5e6c21fe370652495e29f783db4e65037f913ff0d53d28515c36fbb70a", "zh:31ad8282e31d0fac62e96fc2321a68ad4b92ab90f560be5f875d1b01a493e491", diff --git a/pkg/resource/aws/testdata/acc/aws_lb_listener/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_lb_listener/.terraform.lock.hcl index ae023925b..c236fad47 100644 --- a/pkg/resource/aws/testdata/acc/aws_lb_listener/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_lb_listener/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/aws" { version = "4.9.0" hashes = [ "h1:GtmIOZMkKmr9tMLWouHWiGXmKEL/diOTNar5XfOVLjs=", + "h1:OWIIlbMZl/iQ8qR1U7Co3sGjNHL1HJtgNRnnV1kXNuI=", "zh:084b83aef3335ad4f5e4b8323c6fe43c1ff55e17a7647c6a5cad6af519f72b42", "zh:132e47ce69f14de4523b84b213cedf7173398acda14245b1ffe7747aac50f050", "zh:2068baef7dfce3613f3b4f27314175e971f8db68d9cde9ec30b5659f80c68c6c", diff --git a/pkg/resource/aws/testdata/acc/aws_nat_gateway/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_nat_gateway/.terraform.lock.hcl old mode 100755 new mode 100644 index 0b377f59f..8076e21f7 --- a/pkg/resource/aws/testdata/acc/aws_nat_gateway/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_nat_gateway/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/aws" { constraints = "3.19.0" hashes = [ "h1:+7Vi7p13+cnrxjXbfJiTimGSFR97xCaQwkkvWcreLns=", + "h1:xur9tF49NgsovNnmwmBR8RdpN8Fcg1TD4CKQPJD6n1A=", "zh:185a5259153eb9ee4699d4be43b3d509386b473683392034319beee97d470c3b", "zh:2d9a0a01f93e8d16539d835c02b8b6e1927b7685f4076e96cb07f7dd6944bc6c", "zh:703f6da36b1b5f3497baa38fccaa7765fb8a2b6440344e4c97172516b49437dd", diff --git a/pkg/resource/aws/testdata/acc/aws_network_acl/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_network_acl/.terraform.lock.hcl index 642a98810..51efd1d67 100644 --- a/pkg/resource/aws/testdata/acc/aws_network_acl/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_network_acl/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/aws" { constraints = "3.47.0" hashes = [ "h1:gXncRh1KtgLNMeb3/bYq5CvGfy8YTR+n6ds1noc5ggc=", + "h1:oiX6JcoXY6lYIdcYWmEpr7mnS4mkyDV9intCNrcjiBs=", "zh:07bb6bda5b9fdb782dd568a2e85cfe0ab108770e2218f3411e57ed845c58af40", "zh:0926b161a109e75bdc8691e8a32f568b4cd77a55510cf27573261fb5ba382287", "zh:0a91adf25a78ad31d547da513db24f493d27592d3675ed291a7698351c30992d", diff --git a/pkg/resource/aws/testdata/acc/aws_rds_cluster_instance/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_rds_cluster_instance/.terraform.lock.hcl index 0b377f59f..8076e21f7 100644 --- a/pkg/resource/aws/testdata/acc/aws_rds_cluster_instance/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_rds_cluster_instance/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/aws" { constraints = "3.19.0" hashes = [ "h1:+7Vi7p13+cnrxjXbfJiTimGSFR97xCaQwkkvWcreLns=", + "h1:xur9tF49NgsovNnmwmBR8RdpN8Fcg1TD4CKQPJD6n1A=", "zh:185a5259153eb9ee4699d4be43b3d509386b473683392034319beee97d470c3b", "zh:2d9a0a01f93e8d16539d835c02b8b6e1927b7685f4076e96cb07f7dd6944bc6c", "zh:703f6da36b1b5f3497baa38fccaa7765fb8a2b6440344e4c97172516b49437dd", diff --git a/pkg/resource/aws/testdata/acc/aws_route/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_route/.terraform.lock.hcl index 2fad61d4c..6d3f22df6 100644 --- a/pkg/resource/aws/testdata/acc/aws_route/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_route/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/aws" { version = "3.44.0" constraints = "3.44.0" hashes = [ + "h1:VOVZWybe1x0E4qyawTwt7jXVBRUplTrzVFHim217DqI=", "h1:hxQ8n9SHHfAIXd/FtfAqxokFYWBedzZf7xqQZWJajUs=", "zh:0680315b29a140e9b7e4f5aeed3f2445abdfab31fc9237f34dcad06de4f410df", "zh:13811322a205fb4a0ee617f0ae51ec94176befdf569235d0c7064db911f0acc7", diff --git a/pkg/resource/aws/testdata/acc/aws_route53_health_check/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_route53_health_check/.terraform.lock.hcl index 9e715343e..a81a0e2e8 100644 --- a/pkg/resource/aws/testdata/acc/aws_route53_health_check/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_route53_health_check/.terraform.lock.hcl @@ -4,6 +4,7 @@ provider "registry.terraform.io/hashicorp/aws" { version = "3.28.0" hashes = [ + "h1:0cCqlVoOAj4YOi61kVpqoxu1bdAmB67z6uZf+lsHJOw=", "h1:zejsAukFmgZCOdQCk44L3cumXFs8YDSltRIjZN+izsU=", "zh:1fee7fce319be5bea7df2e95f28a78a04e15c18bad5eb56dcc0ecc324c97f4b8", "zh:2383ff31ef7411f7d4bef1ee288f0f79bec41cf220ac94c2b31f6a702b26f984", diff --git a/pkg/resource/aws/testdata/acc/aws_route53_record/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_route53_record/.terraform.lock.hcl old mode 100755 new mode 100644 index 442356e05..8076e21f7 --- a/pkg/resource/aws/testdata/acc/aws_route53_record/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_route53_record/.terraform.lock.hcl @@ -3,9 +3,10 @@ provider "registry.terraform.io/hashicorp/aws" { version = "3.19.0" - constraints = "~> 3.19.0" + constraints = "3.19.0" hashes = [ "h1:+7Vi7p13+cnrxjXbfJiTimGSFR97xCaQwkkvWcreLns=", + "h1:xur9tF49NgsovNnmwmBR8RdpN8Fcg1TD4CKQPJD6n1A=", "zh:185a5259153eb9ee4699d4be43b3d509386b473683392034319beee97d470c3b", "zh:2d9a0a01f93e8d16539d835c02b8b6e1927b7685f4076e96cb07f7dd6944bc6c", "zh:703f6da36b1b5f3497baa38fccaa7765fb8a2b6440344e4c97172516b49437dd", diff --git a/pkg/resource/aws/testdata/acc/aws_route_table/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_route_table/.terraform.lock.hcl index ab9ad3ade..ddde27f99 100644 --- a/pkg/resource/aws/testdata/acc/aws_route_table/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_route_table/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/aws" { version = "3.62.0" constraints = "3.62.0" hashes = [ + "h1:3aKS+Lra6yHSs6zMqgVZXBZhYG7nkHS6DED8sG+rAlo=", "h1:UjsV2CRiVU3ye7w9AabX6t/bmDuAF5mt+fr63/pfDHQ=", "zh:08a94019e17304f5927d7c85b8f5dade6b9ffebeb7b06ec0643aaa1130c4c85d", "zh:0e3709f6c1fed8c5119a5653bec7e3069258ddf91f62d851f8deeede10487fb8", diff --git a/pkg/resource/aws/testdata/acc/aws_route_table_association/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_route_table_association/.terraform.lock.hcl old mode 100755 new mode 100644 index 0b377f59f..8076e21f7 --- a/pkg/resource/aws/testdata/acc/aws_route_table_association/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_route_table_association/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/aws" { constraints = "3.19.0" hashes = [ "h1:+7Vi7p13+cnrxjXbfJiTimGSFR97xCaQwkkvWcreLns=", + "h1:xur9tF49NgsovNnmwmBR8RdpN8Fcg1TD4CKQPJD6n1A=", "zh:185a5259153eb9ee4699d4be43b3d509386b473683392034319beee97d470c3b", "zh:2d9a0a01f93e8d16539d835c02b8b6e1927b7685f4076e96cb07f7dd6944bc6c", "zh:703f6da36b1b5f3497baa38fccaa7765fb8a2b6440344e4c97172516b49437dd", diff --git a/pkg/resource/aws/testdata/acc/aws_route_with_prefix_list_id/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_route_with_prefix_list_id/.terraform.lock.hcl index 1a5ac31c3..99756de09 100644 --- a/pkg/resource/aws/testdata/acc/aws_route_with_prefix_list_id/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_route_with_prefix_list_id/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/aws" { constraints = "3.75.1" hashes = [ "h1:++H0a4igODgreQL3SJuRz71JZkC69rl41R8xLYM894o=", + "h1:zgO9MSF32Rz6lOBumY+FyPZESYwlL5SUXOViTV5cs28=", "zh:11c2ee541ca1da923356c9225575ba294523d7b6af82d6171c912470ef0f90cd", "zh:19fe975993664252b4a2ff1079546f2b186b01d1a025a94a4f15c37e023806c5", "zh:442e7fc145b2debebe9279b283d07f5f736dc1776c2e5b1702728a6eb03789d0", diff --git a/pkg/resource/aws/testdata/acc/aws_s3_bucket/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_s3_bucket/.terraform.lock.hcl old mode 100755 new mode 100644 index 8abce94cd..c41723dfa --- a/pkg/resource/aws/testdata/acc/aws_s3_bucket/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_s3_bucket/.terraform.lock.hcl @@ -3,9 +3,10 @@ provider "registry.terraform.io/hashicorp/aws" { version = "3.19.0" - constraints = "~> 3.19.0" + constraints = "3.19.0" hashes = [ "h1:+7Vi7p13+cnrxjXbfJiTimGSFR97xCaQwkkvWcreLns=", + "h1:xur9tF49NgsovNnmwmBR8RdpN8Fcg1TD4CKQPJD6n1A=", "zh:185a5259153eb9ee4699d4be43b3d509386b473683392034319beee97d470c3b", "zh:2d9a0a01f93e8d16539d835c02b8b6e1927b7685f4076e96cb07f7dd6944bc6c", "zh:703f6da36b1b5f3497baa38fccaa7765fb8a2b6440344e4c97172516b49437dd", @@ -22,6 +23,7 @@ provider "registry.terraform.io/hashicorp/aws" { provider "registry.terraform.io/hashicorp/random" { version = "3.0.1" hashes = [ + "h1:0QaSbRBgBi8vI/8IRwec1INdOqBxXbgsSFElx1O4k4g=", "h1:SzM8nt2wzLMI28A3CWAtW25g3ZCm1O4xD0h3Ps/rU1U=", "zh:0d4f683868324af056a9eb2b06306feef7c202c88dbbe6a4ad7517146a22fb50", "zh:4824b3c7914b77d41dfe90f6f333c7ac9860afb83e2a344d91fbe46e5dfbec26", diff --git a/pkg/resource/aws/testdata/acc/aws_s3_bucket_public_access_block/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_s3_bucket_public_access_block/.terraform.lock.hcl index 7d2353ee3..b7a6b26ea 100644 --- a/pkg/resource/aws/testdata/acc/aws_s3_bucket_public_access_block/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_s3_bucket_public_access_block/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/aws" { constraints = "3.19.0" hashes = [ "h1:+7Vi7p13+cnrxjXbfJiTimGSFR97xCaQwkkvWcreLns=", + "h1:xur9tF49NgsovNnmwmBR8RdpN8Fcg1TD4CKQPJD6n1A=", "zh:185a5259153eb9ee4699d4be43b3d509386b473683392034319beee97d470c3b", "zh:2d9a0a01f93e8d16539d835c02b8b6e1927b7685f4076e96cb07f7dd6944bc6c", "zh:703f6da36b1b5f3497baa38fccaa7765fb8a2b6440344e4c97172516b49437dd", @@ -23,6 +24,7 @@ provider "registry.terraform.io/hashicorp/random" { version = "3.1.2" hashes = [ "h1:5A5VsY5wNmOZlupUcLnIoziMPn8htSZBXbP3lI7lBEM=", + "h1:9A6Ghjgad0KjJRxa6nPo8i8uFvwj3Vv0wnEgy49u+24=", "zh:0daceba867b330d3f8e2c5dc895c4291845a78f31955ce1b91ab2c4d1cd1c10b", "zh:104050099efd30a630741f788f9576b19998e7a09347decbec3da0b21d64ba2d", "zh:173f4ef3fdf0c7e2564a3db0fac560e9f5afdf6afd0b75d6646af6576b122b16", diff --git a/pkg/resource/aws/testdata/acc/aws_sns_topic/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_sns_topic/.terraform.lock.hcl old mode 100755 new mode 100644 index 3c981c6f9..0cca25ba4 --- a/pkg/resource/aws/testdata/acc/aws_sns_topic/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_sns_topic/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/aws" { version = "3.26.0" hashes = [ "h1:0i78FItlPeiomd+4ThZrtm56P5K33k7/6dnEe4ZePI0=", + "h1:b1qNzEzDHZpnHSOW4fRo1PFC0U2Ft25PKKs9NSDGe3U=", "zh:26043eed36d070ca032cf04bc980c654a25821a8abc0c85e1e570e3935bbfcbb", "zh:2fe68f3f78d23830a04d7fac3eda550eef1f627dfc130486f70a65dc5c254300", "zh:3d66484c608c64678e639db25d63872783ce60363a1246e30317f21c9c23b84b", diff --git a/pkg/resource/aws/testdata/acc/aws_sns_topic_policy/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_sns_topic_policy/.terraform.lock.hcl old mode 100755 new mode 100644 index 3c981c6f9..0cca25ba4 --- a/pkg/resource/aws/testdata/acc/aws_sns_topic_policy/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_sns_topic_policy/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/aws" { version = "3.26.0" hashes = [ "h1:0i78FItlPeiomd+4ThZrtm56P5K33k7/6dnEe4ZePI0=", + "h1:b1qNzEzDHZpnHSOW4fRo1PFC0U2Ft25PKKs9NSDGe3U=", "zh:26043eed36d070ca032cf04bc980c654a25821a8abc0c85e1e570e3935bbfcbb", "zh:2fe68f3f78d23830a04d7fac3eda550eef1f627dfc130486f70a65dc5c254300", "zh:3d66484c608c64678e639db25d63872783ce60363a1246e30317f21c9c23b84b", diff --git a/pkg/resource/aws/testdata/acc/aws_sns_topic_subscription/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_sns_topic_subscription/.terraform.lock.hcl old mode 100755 new mode 100644 index a79e6a899..1ed4754df --- a/pkg/resource/aws/testdata/acc/aws_sns_topic_subscription/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_sns_topic_subscription/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/aws" { version = "3.27.0" hashes = [ "h1:ccxtk7jAtmBPvAEXswOEYJcyp5jTD9QlQeg8GEzYmxQ=", + "h1:lJaA23rrNSgLEumcW7Y0KKvno5isVVNNIEV5pT92O8E=", "zh:2986eb5a1ffbb0336c6390aad533b62efc832aa8aa5460d523e1f2daa4f42f79", "zh:825317cdb80860833125a856c0befc877cba22d41c631c5a7ca22400693d4356", "zh:a47aad668cc74058f508c56c5407cd715dbb9b6389aa68d37543e897895db43f", diff --git a/pkg/resource/aws/testdata/acc/aws_subnet/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_subnet/.terraform.lock.hcl old mode 100755 new mode 100644 index 0b377f59f..8076e21f7 --- a/pkg/resource/aws/testdata/acc/aws_subnet/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_subnet/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/aws" { constraints = "3.19.0" hashes = [ "h1:+7Vi7p13+cnrxjXbfJiTimGSFR97xCaQwkkvWcreLns=", + "h1:xur9tF49NgsovNnmwmBR8RdpN8Fcg1TD4CKQPJD6n1A=", "zh:185a5259153eb9ee4699d4be43b3d509386b473683392034319beee97d470c3b", "zh:2d9a0a01f93e8d16539d835c02b8b6e1927b7685f4076e96cb07f7dd6944bc6c", "zh:703f6da36b1b5f3497baa38fccaa7765fb8a2b6440344e4c97172516b49437dd", diff --git a/pkg/resource/aws/testdata/acc/aws_vpc/.terraform.lock.hcl b/pkg/resource/aws/testdata/acc/aws_vpc/.terraform.lock.hcl index 0b377f59f..8076e21f7 100644 --- a/pkg/resource/aws/testdata/acc/aws_vpc/.terraform.lock.hcl +++ b/pkg/resource/aws/testdata/acc/aws_vpc/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/aws" { constraints = "3.19.0" hashes = [ "h1:+7Vi7p13+cnrxjXbfJiTimGSFR97xCaQwkkvWcreLns=", + "h1:xur9tF49NgsovNnmwmBR8RdpN8Fcg1TD4CKQPJD6n1A=", "zh:185a5259153eb9ee4699d4be43b3d509386b473683392034319beee97d470c3b", "zh:2d9a0a01f93e8d16539d835c02b8b6e1927b7685f4076e96cb07f7dd6944bc6c", "zh:703f6da36b1b5f3497baa38fccaa7765fb8a2b6440344e4c97172516b49437dd", diff --git a/pkg/resource/azurerm/azurerm_lb_rule.go b/pkg/resource/azurerm/azurerm_lb_rule.go index 53e8a8f52..089eee7c4 100644 --- a/pkg/resource/azurerm/azurerm_lb_rule.go +++ b/pkg/resource/azurerm/azurerm_lb_rule.go @@ -1,24 +1,12 @@ package azurerm -import "github.com/snyk/driftctl/pkg/resource" - -const AzureLoadBalancerRuleResourceType = "azurerm_lb_rule" +import ( + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" +) func initAzureLoadBalancerRuleMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AzureLoadBalancerRuleResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(azurerm.AzureLoadBalancerRuleResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) - resourceSchemaRepository.SetResolveReadAttributesFunc(AzureLoadBalancerRuleResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "loadbalancer_id": *res.Attributes().GetString("loadbalancer_id"), - } - }) - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureLoadBalancerRuleResourceType, func(res *resource.Resource) map[string]string { - attrs := make(map[string]string) - if name := res.Attributes().GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - return attrs - }) - resourceSchemaRepository.SetFlags(AzureLoadBalancerRuleResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/azurerm/azurerm_network_security_group.go b/pkg/resource/azurerm/azurerm_network_security_group.go index 594cc5eec..b9ff04df9 100644 --- a/pkg/resource/azurerm/azurerm_network_security_group.go +++ b/pkg/resource/azurerm/azurerm_network_security_group.go @@ -1,20 +1,12 @@ package azurerm -import "github.com/snyk/driftctl/pkg/resource" - -const AzureNetworkSecurityGroupResourceType = "azurerm_network_security_group" +import ( + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" +) func initAzureNetworkSecurityGroupMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AzureNetworkSecurityGroupResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(azurerm.AzureNetworkSecurityGroupResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureNetworkSecurityGroupResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - return attrs - }) - resourceSchemaRepository.SetFlags(AzureNetworkSecurityGroupResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/azurerm/azurerm_private_dns_a_record.go b/pkg/resource/azurerm/azurerm_private_dns_a_record.go index 42367754d..467070866 100644 --- a/pkg/resource/azurerm/azurerm_private_dns_a_record.go +++ b/pkg/resource/azurerm/azurerm_private_dns_a_record.go @@ -1,25 +1,12 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) -const AzurePrivateDNSARecordResourceType = "azurerm_private_dns_a_record" - func initAzurePrivateDNSARecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSARecordResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(azurerm.AzurePrivateDNSARecordResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePrivateDNSARecordResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - if zone := val.GetString("zone_name"); zone != nil && *zone != "" { - attrs["Zone"] = *zone - } - return attrs - }) - resourceSchemaRepository.SetFlags(AzurePrivateDNSARecordResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/azurerm/azurerm_private_dns_aaaa_record.go b/pkg/resource/azurerm/azurerm_private_dns_aaaa_record.go index 7e78924b5..2b0d10034 100644 --- a/pkg/resource/azurerm/azurerm_private_dns_aaaa_record.go +++ b/pkg/resource/azurerm/azurerm_private_dns_aaaa_record.go @@ -1,25 +1,12 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) -const AzurePrivateDNSAAAARecordResourceType = "azurerm_private_dns_aaaa_record" - func initAzurePrivateDNSAAAARecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSAAAARecordResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(azurerm.AzurePrivateDNSAAAARecordResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePrivateDNSAAAARecordResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - if zone := val.GetString("zone_name"); zone != nil && *zone != "" { - attrs["Zone"] = *zone - } - return attrs - }) - resourceSchemaRepository.SetFlags(AzurePrivateDNSAAAARecordResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/azurerm/azurerm_private_dns_cname_record.go b/pkg/resource/azurerm/azurerm_private_dns_cname_record.go index a53b898dd..e15b72d13 100644 --- a/pkg/resource/azurerm/azurerm_private_dns_cname_record.go +++ b/pkg/resource/azurerm/azurerm_private_dns_cname_record.go @@ -1,24 +1,12 @@ package azurerm -import "github.com/snyk/driftctl/pkg/resource" - -const AzurePrivateDNSCNameRecordResourceType = "azurerm_private_dns_cname_record" +import ( + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" +) func initAzurePrivateDNSCNameRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AzurePrivateDNSCNameRecordResourceType, resource.FlagDeepMode) - - resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSCNameRecordResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(azurerm.AzurePrivateDNSCNameRecordResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePrivateDNSCNameRecordResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - if zone := val.GetString("zone_name"); zone != nil && *zone != "" { - attrs["Zone"] = *zone - } - return attrs - }) } diff --git a/pkg/resource/azurerm/azurerm_private_dns_mx_record.go b/pkg/resource/azurerm/azurerm_private_dns_mx_record.go index 6f3d22b70..60e92cf1c 100644 --- a/pkg/resource/azurerm/azurerm_private_dns_mx_record.go +++ b/pkg/resource/azurerm/azurerm_private_dns_mx_record.go @@ -1,25 +1,12 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) -const AzurePrivateDNSMXRecordResourceType = "azurerm_private_dns_mx_record" - func initAzurePrivateDNSMXRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSMXRecordResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(azurerm.AzurePrivateDNSMXRecordResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePrivateDNSMXRecordResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - if zone := val.GetString("zone_name"); zone != nil && *zone != "" { - attrs["Zone"] = *zone - } - return attrs - }) - resourceSchemaRepository.SetFlags(AzurePrivateDNSMXRecordResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/azurerm/azurerm_private_dns_ptr_record.go b/pkg/resource/azurerm/azurerm_private_dns_ptr_record.go index af0c58c90..c10884b82 100644 --- a/pkg/resource/azurerm/azurerm_private_dns_ptr_record.go +++ b/pkg/resource/azurerm/azurerm_private_dns_ptr_record.go @@ -1,25 +1,12 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) -const AzurePrivateDNSPTRRecordResourceType = "azurerm_private_dns_ptr_record" - func initAzurePrivateDNSPTRRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSPTRRecordResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(azurerm.AzurePrivateDNSPTRRecordResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePrivateDNSPTRRecordResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - if zone := val.GetString("zone_name"); zone != nil && *zone != "" { - attrs["Zone"] = *zone - } - return attrs - }) - resourceSchemaRepository.SetFlags(AzurePrivateDNSPTRRecordResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/azurerm/azurerm_private_dns_srv_record.go b/pkg/resource/azurerm/azurerm_private_dns_srv_record.go index 4d839b952..fbed64f9c 100644 --- a/pkg/resource/azurerm/azurerm_private_dns_srv_record.go +++ b/pkg/resource/azurerm/azurerm_private_dns_srv_record.go @@ -1,25 +1,12 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) -const AzurePrivateDNSSRVRecordResourceType = "azurerm_private_dns_srv_record" - func initAzurePrivateDNSSRVRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSSRVRecordResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(azurerm.AzurePrivateDNSSRVRecordResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePrivateDNSSRVRecordResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - if zone := val.GetString("zone_name"); zone != nil && *zone != "" { - attrs["Zone"] = *zone - } - return attrs - }) - resourceSchemaRepository.SetFlags(AzurePrivateDNSSRVRecordResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/azurerm/azurerm_private_dns_txt_record.go b/pkg/resource/azurerm/azurerm_private_dns_txt_record.go index 795e97e2b..01bbe9b81 100644 --- a/pkg/resource/azurerm/azurerm_private_dns_txt_record.go +++ b/pkg/resource/azurerm/azurerm_private_dns_txt_record.go @@ -1,25 +1,12 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) -const AzurePrivateDNSTXTRecordResourceType = "azurerm_private_dns_txt_record" - func initAzurePrivateDNSTXTRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSTXTRecordResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(azurerm.AzurePrivateDNSTXTRecordResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePrivateDNSTXTRecordResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - if zone := val.GetString("zone_name"); zone != nil && *zone != "" { - attrs["Zone"] = *zone - } - return attrs - }) - resourceSchemaRepository.SetFlags(AzurePrivateDNSTXTRecordResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/azurerm/azurerm_private_dns_zone.go b/pkg/resource/azurerm/azurerm_private_dns_zone.go index 45514f3a6..287761927 100644 --- a/pkg/resource/azurerm/azurerm_private_dns_zone.go +++ b/pkg/resource/azurerm/azurerm_private_dns_zone.go @@ -1,15 +1,13 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) -const AzurePrivateDNSZoneResourceType = "azurerm_private_dns_zone" - func initAzurePrivateDNSZoneMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSZoneResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(azurerm.AzurePrivateDNSZoneResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"number_of_record_sets"}) res.Attributes().SafeDelete([]string{"timeouts"}) }) - resourceSchemaRepository.SetFlags(AzurePrivateDNSZoneResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/azurerm/azurerm_ssh_public_key.go b/pkg/resource/azurerm/azurerm_ssh_public_key.go index 17e87abea..eaf521edb 100644 --- a/pkg/resource/azurerm/azurerm_ssh_public_key.go +++ b/pkg/resource/azurerm/azurerm_ssh_public_key.go @@ -1,23 +1,12 @@ package azurerm import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/azurerm" ) -const AzureSSHPublicKeyResourceType = "azurerm_ssh_public_key" - func initAzureSSHPublicKeyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AzureSSHPublicKeyResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(azurerm.AzureSSHPublicKeyResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureSSHPublicKeyResourceType, func(res *resource.Resource) map[string]string { - attrs := make(map[string]string) - - if v := res.Attributes().GetString("name"); v != nil && *v != "" { - attrs["Name"] = *v - } - - return attrs - }) - resourceSchemaRepository.SetFlags(AzureSSHPublicKeyResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/azurerm/metadata.go b/pkg/resource/azurerm/metadata.go index 2a4c47674..0aa92160f 100644 --- a/pkg/resource/azurerm/metadata.go +++ b/pkg/resource/azurerm/metadata.go @@ -1,19 +1,9 @@ package azurerm -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - initAzureVirtualNetworkMetaData(resourceSchemaRepository) - initAzureRouteTableMetaData(resourceSchemaRepository) - initAzureRouteMetaData(resourceSchemaRepository) - initAzureResourceGroupMetadata(resourceSchemaRepository) - initAzureContainerRegistryMetadata(resourceSchemaRepository) - initAzureFirewallMetadata(resourceSchemaRepository) - initAzurePostgresqlServerMetadata(resourceSchemaRepository) - initAzurePublicIPMetadata(resourceSchemaRepository) - initAzurePostgresqlDatabaseMetadata(resourceSchemaRepository) initAzureNetworkSecurityGroupMetadata(resourceSchemaRepository) - initAzureLoadBalancerMetadata(resourceSchemaRepository) initAzurePrivateDNSZoneMetaData(resourceSchemaRepository) initAzurePrivateDNSARecordMetaData(resourceSchemaRepository) initAzurePrivateDNSAAAARecordMetaData(resourceSchemaRepository) @@ -21,7 +11,6 @@ func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInt initAzurePrivateDNSSRVRecordMetaData(resourceSchemaRepository) initAzurePrivateDNSMXRecordMetaData(resourceSchemaRepository) initAzurePrivateDNSTXTRecordMetaData(resourceSchemaRepository) - initAzureImageMetaData(resourceSchemaRepository) initAzureSSHPublicKeyMetaData(resourceSchemaRepository) initAzurePrivateDNSCNameRecordMetaData(resourceSchemaRepository) initAzureLoadBalancerRuleMetadata(resourceSchemaRepository) diff --git a/pkg/resource/azurerm/testdata/acc/azurerm_image/.terraform.lock.hcl b/pkg/resource/azurerm/testdata/acc/azurerm_image/.terraform.lock.hcl index 67ef8eaf0..4f1629f00 100644 --- a/pkg/resource/azurerm/testdata/acc/azurerm_image/.terraform.lock.hcl +++ b/pkg/resource/azurerm/testdata/acc/azurerm_image/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/azurerm" { constraints = "~> 2.71.0" hashes = [ "h1:RiFIxNI4Yr9CqleqEdgg1ydLAZ5JiYiz6l5iTD3WcuU=", + "h1:ULax/q7p3Tl0l8DnXV9GNmdDRR1MHpimyLq8OP6E6I0=", "zh:2b9d8a703a0222f72cbceb8d2bdb580066afdcd7f28b6ad65d5ed935319b5433", "zh:332988f4c1747bcc8ebd32734bf8de2bea4c13a6fbd08d7eb97d0c43d335b15e", "zh:3a902470276ba48e23ad4dd6baff16a9ce3b60b29c0b07064dbe96ce4640a31c", diff --git a/pkg/resource/azurerm/testdata/acc/azurerm_lb_rule/.terraform.lock.hcl b/pkg/resource/azurerm/testdata/acc/azurerm_lb_rule/.terraform.lock.hcl index 392ede8bf..952bb7719 100644 --- a/pkg/resource/azurerm/testdata/acc/azurerm_lb_rule/.terraform.lock.hcl +++ b/pkg/resource/azurerm/testdata/acc/azurerm_lb_rule/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/azurerm" { constraints = "~> 2.71.0" hashes = [ "h1:RiFIxNI4Yr9CqleqEdgg1ydLAZ5JiYiz6l5iTD3WcuU=", + "h1:ULax/q7p3Tl0l8DnXV9GNmdDRR1MHpimyLq8OP6E6I0=", "zh:2b9d8a703a0222f72cbceb8d2bdb580066afdcd7f28b6ad65d5ed935319b5433", "zh:332988f4c1747bcc8ebd32734bf8de2bea4c13a6fbd08d7eb97d0c43d335b15e", "zh:3a902470276ba48e23ad4dd6baff16a9ce3b60b29c0b07064dbe96ce4640a31c", diff --git a/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_a_record/.terraform.lock.hcl b/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_a_record/.terraform.lock.hcl index 67ef8eaf0..4f1629f00 100644 --- a/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_a_record/.terraform.lock.hcl +++ b/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_a_record/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/azurerm" { constraints = "~> 2.71.0" hashes = [ "h1:RiFIxNI4Yr9CqleqEdgg1ydLAZ5JiYiz6l5iTD3WcuU=", + "h1:ULax/q7p3Tl0l8DnXV9GNmdDRR1MHpimyLq8OP6E6I0=", "zh:2b9d8a703a0222f72cbceb8d2bdb580066afdcd7f28b6ad65d5ed935319b5433", "zh:332988f4c1747bcc8ebd32734bf8de2bea4c13a6fbd08d7eb97d0c43d335b15e", "zh:3a902470276ba48e23ad4dd6baff16a9ce3b60b29c0b07064dbe96ce4640a31c", diff --git a/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_aaaa_record/.terraform.lock.hcl b/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_aaaa_record/.terraform.lock.hcl index 67ef8eaf0..4f1629f00 100644 --- a/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_aaaa_record/.terraform.lock.hcl +++ b/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_aaaa_record/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/azurerm" { constraints = "~> 2.71.0" hashes = [ "h1:RiFIxNI4Yr9CqleqEdgg1ydLAZ5JiYiz6l5iTD3WcuU=", + "h1:ULax/q7p3Tl0l8DnXV9GNmdDRR1MHpimyLq8OP6E6I0=", "zh:2b9d8a703a0222f72cbceb8d2bdb580066afdcd7f28b6ad65d5ed935319b5433", "zh:332988f4c1747bcc8ebd32734bf8de2bea4c13a6fbd08d7eb97d0c43d335b15e", "zh:3a902470276ba48e23ad4dd6baff16a9ce3b60b29c0b07064dbe96ce4640a31c", diff --git a/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_cname_record/.terraform.lock.hcl b/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_cname_record/.terraform.lock.hcl index 67ef8eaf0..4f1629f00 100644 --- a/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_cname_record/.terraform.lock.hcl +++ b/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_cname_record/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/azurerm" { constraints = "~> 2.71.0" hashes = [ "h1:RiFIxNI4Yr9CqleqEdgg1ydLAZ5JiYiz6l5iTD3WcuU=", + "h1:ULax/q7p3Tl0l8DnXV9GNmdDRR1MHpimyLq8OP6E6I0=", "zh:2b9d8a703a0222f72cbceb8d2bdb580066afdcd7f28b6ad65d5ed935319b5433", "zh:332988f4c1747bcc8ebd32734bf8de2bea4c13a6fbd08d7eb97d0c43d335b15e", "zh:3a902470276ba48e23ad4dd6baff16a9ce3b60b29c0b07064dbe96ce4640a31c", diff --git a/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_mx_record/.terraform.lock.hcl b/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_mx_record/.terraform.lock.hcl index 67ef8eaf0..4f1629f00 100644 --- a/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_mx_record/.terraform.lock.hcl +++ b/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_mx_record/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/azurerm" { constraints = "~> 2.71.0" hashes = [ "h1:RiFIxNI4Yr9CqleqEdgg1ydLAZ5JiYiz6l5iTD3WcuU=", + "h1:ULax/q7p3Tl0l8DnXV9GNmdDRR1MHpimyLq8OP6E6I0=", "zh:2b9d8a703a0222f72cbceb8d2bdb580066afdcd7f28b6ad65d5ed935319b5433", "zh:332988f4c1747bcc8ebd32734bf8de2bea4c13a6fbd08d7eb97d0c43d335b15e", "zh:3a902470276ba48e23ad4dd6baff16a9ce3b60b29c0b07064dbe96ce4640a31c", diff --git a/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_ptr_record/.terraform.lock.hcl b/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_ptr_record/.terraform.lock.hcl index 67ef8eaf0..4f1629f00 100644 --- a/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_ptr_record/.terraform.lock.hcl +++ b/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_ptr_record/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/azurerm" { constraints = "~> 2.71.0" hashes = [ "h1:RiFIxNI4Yr9CqleqEdgg1ydLAZ5JiYiz6l5iTD3WcuU=", + "h1:ULax/q7p3Tl0l8DnXV9GNmdDRR1MHpimyLq8OP6E6I0=", "zh:2b9d8a703a0222f72cbceb8d2bdb580066afdcd7f28b6ad65d5ed935319b5433", "zh:332988f4c1747bcc8ebd32734bf8de2bea4c13a6fbd08d7eb97d0c43d335b15e", "zh:3a902470276ba48e23ad4dd6baff16a9ce3b60b29c0b07064dbe96ce4640a31c", diff --git a/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_srv_record/.terraform.lock.hcl b/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_srv_record/.terraform.lock.hcl index 67ef8eaf0..4f1629f00 100644 --- a/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_srv_record/.terraform.lock.hcl +++ b/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_srv_record/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/azurerm" { constraints = "~> 2.71.0" hashes = [ "h1:RiFIxNI4Yr9CqleqEdgg1ydLAZ5JiYiz6l5iTD3WcuU=", + "h1:ULax/q7p3Tl0l8DnXV9GNmdDRR1MHpimyLq8OP6E6I0=", "zh:2b9d8a703a0222f72cbceb8d2bdb580066afdcd7f28b6ad65d5ed935319b5433", "zh:332988f4c1747bcc8ebd32734bf8de2bea4c13a6fbd08d7eb97d0c43d335b15e", "zh:3a902470276ba48e23ad4dd6baff16a9ce3b60b29c0b07064dbe96ce4640a31c", diff --git a/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_txt_record/.terraform.lock.hcl b/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_txt_record/.terraform.lock.hcl index 67ef8eaf0..4f1629f00 100644 --- a/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_txt_record/.terraform.lock.hcl +++ b/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_txt_record/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/azurerm" { constraints = "~> 2.71.0" hashes = [ "h1:RiFIxNI4Yr9CqleqEdgg1ydLAZ5JiYiz6l5iTD3WcuU=", + "h1:ULax/q7p3Tl0l8DnXV9GNmdDRR1MHpimyLq8OP6E6I0=", "zh:2b9d8a703a0222f72cbceb8d2bdb580066afdcd7f28b6ad65d5ed935319b5433", "zh:332988f4c1747bcc8ebd32734bf8de2bea4c13a6fbd08d7eb97d0c43d335b15e", "zh:3a902470276ba48e23ad4dd6baff16a9ce3b60b29c0b07064dbe96ce4640a31c", diff --git a/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_zone/.terraform.lock.hcl b/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_zone/.terraform.lock.hcl index 67ef8eaf0..4f1629f00 100644 --- a/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_zone/.terraform.lock.hcl +++ b/pkg/resource/azurerm/testdata/acc/azurerm_private_dns_zone/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/azurerm" { constraints = "~> 2.71.0" hashes = [ "h1:RiFIxNI4Yr9CqleqEdgg1ydLAZ5JiYiz6l5iTD3WcuU=", + "h1:ULax/q7p3Tl0l8DnXV9GNmdDRR1MHpimyLq8OP6E6I0=", "zh:2b9d8a703a0222f72cbceb8d2bdb580066afdcd7f28b6ad65d5ed935319b5433", "zh:332988f4c1747bcc8ebd32734bf8de2bea4c13a6fbd08d7eb97d0c43d335b15e", "zh:3a902470276ba48e23ad4dd6baff16a9ce3b60b29c0b07064dbe96ce4640a31c", diff --git a/pkg/resource/azurerm/testdata/acc/azurerm_resource_group/.terraform.lock.hcl b/pkg/resource/azurerm/testdata/acc/azurerm_resource_group/.terraform.lock.hcl old mode 100755 new mode 100644 index 67ef8eaf0..4f1629f00 --- a/pkg/resource/azurerm/testdata/acc/azurerm_resource_group/.terraform.lock.hcl +++ b/pkg/resource/azurerm/testdata/acc/azurerm_resource_group/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/azurerm" { constraints = "~> 2.71.0" hashes = [ "h1:RiFIxNI4Yr9CqleqEdgg1ydLAZ5JiYiz6l5iTD3WcuU=", + "h1:ULax/q7p3Tl0l8DnXV9GNmdDRR1MHpimyLq8OP6E6I0=", "zh:2b9d8a703a0222f72cbceb8d2bdb580066afdcd7f28b6ad65d5ed935319b5433", "zh:332988f4c1747bcc8ebd32734bf8de2bea4c13a6fbd08d7eb97d0c43d335b15e", "zh:3a902470276ba48e23ad4dd6baff16a9ce3b60b29c0b07064dbe96ce4640a31c", diff --git a/pkg/resource/deserializer.go b/pkg/resource/deserializer.go index aa71080a0..1b16a1a04 100644 --- a/pkg/resource/deserializer.go +++ b/pkg/resource/deserializer.go @@ -3,20 +3,21 @@ package resource import ( "encoding/json" + "github.com/snyk/driftctl/enumeration/resource" "github.com/zclconf/go-cty/cty" ctyjson "github.com/zclconf/go-cty/cty/json" ) type Deserializer struct { - factory ResourceFactory + factory resource.ResourceFactory } -func NewDeserializer(factory ResourceFactory) *Deserializer { +func NewDeserializer(factory resource.ResourceFactory) *Deserializer { return &Deserializer{factory} } -func (s *Deserializer) Deserialize(ty string, rawList []cty.Value) ([]*Resource, error) { - resources := make([]*Resource, 0) +func (s *Deserializer) Deserialize(ty string, rawList []cty.Value) ([]*resource.Resource, error) { + resources := make([]*resource.Resource, 0) for _, rawResource := range rawList { rawResource := rawResource res, err := s.DeserializeOne(ty, rawResource) @@ -28,7 +29,7 @@ func (s *Deserializer) Deserialize(ty string, rawList []cty.Value) ([]*Resource, return resources, nil } -func (s *Deserializer) DeserializeOne(ty string, value cty.Value) (*Resource, error) { +func (s *Deserializer) DeserializeOne(ty string, value cty.Value) (*resource.Resource, error) { if value.IsNull() { return nil, nil } @@ -37,7 +38,7 @@ func (s *Deserializer) DeserializeOne(ty string, value cty.Value) (*Resource, er // For example, this ensures we can deserialize sensitive values too. unmarkedVal, _ := value.UnmarkDeep() - var attrs Attributes + var attrs resource.Attributes bytes, _ := ctyjson.Marshal(unmarkedVal, unmarkedVal.Type()) err := json.Unmarshal(bytes, &attrs) if err != nil { diff --git a/pkg/resource/github/github_branch_protection.go b/pkg/resource/github/github_branch_protection.go index 154cb0e5f..39760431c 100644 --- a/pkg/resource/github/github_branch_protection.go +++ b/pkg/resource/github/github_branch_protection.go @@ -2,42 +2,13 @@ package github import ( - "encoding/base64" - - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/github" ) -const GithubBranchProtectionResourceType = "github_branch_protection" - func initGithubBranchProtectionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(GithubBranchProtectionResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(github.GithubBranchProtectionResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"repository_id"}) // Terraform provider is always returning nil }) - resourceSchemaRepository.SetHumanReadableAttributesFunc(GithubBranchProtectionResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - pattern := val.GetString("pattern") - repoID := val.GetString("repository_id") - if pattern != nil && *pattern != "" { - id := "" - if repoID != nil && *repoID != "" { - decodedID, err := base64.StdEncoding.DecodeString(*repoID) - if err == nil { - id = string(decodedID) - } - } - if id == "" { - attrs["Branch"] = *pattern - attrs["Id"] = res.ResourceId() - return attrs - } - attrs["Branch"] = *pattern - attrs["RepoId"] = id - return attrs - } - attrs["Id"] = res.ResourceId() - return attrs - }) - resourceSchemaRepository.SetFlags(GithubBranchProtectionResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/github/github_membership.go b/pkg/resource/github/github_membership.go index 16cf59d0a..09b4e46c3 100644 --- a/pkg/resource/github/github_membership.go +++ b/pkg/resource/github/github_membership.go @@ -1,14 +1,14 @@ // GENERATED, DO NOT EDIT THIS FILE package github -import "github.com/snyk/driftctl/pkg/resource" - -const GithubMembershipResourceType = "github_membership" +import ( + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/github" +) func initGithubMembershipMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(GithubMembershipResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(github.GithubMembershipResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"etag"}) }) - resourceSchemaRepository.SetFlags(GithubMembershipResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/github/github_repository.go b/pkg/resource/github/github_repository.go index bd4df0b03..94654bb88 100644 --- a/pkg/resource/github/github_repository.go +++ b/pkg/resource/github/github_repository.go @@ -1,14 +1,14 @@ package github -import "github.com/snyk/driftctl/pkg/resource" - -const GithubRepositoryResourceType = "github_repository" +import ( + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/github" +) func initGithubRepositoryMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(GithubRepositoryResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(github.GithubRepositoryResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"auto_init"}) val.SafeDelete([]string{"etag"}) }) - resourceSchemaRepository.SetFlags(GithubRepositoryResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/github/github_team.go b/pkg/resource/github/github_team.go index 5288480f6..302fcf0cd 100644 --- a/pkg/resource/github/github_team.go +++ b/pkg/resource/github/github_team.go @@ -1,26 +1,17 @@ // GENERATED, DO NOT EDIT THIS FILE package github -import "github.com/snyk/driftctl/pkg/resource" - -const GithubTeamResourceType = "github_team" +import ( + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/github" +) func initGithubTeamMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(GithubTeamResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(github.GithubTeamResourceType, func(res *resource.Resource) { val := res.Attrs if defaultMaintainer, exist := val.Get("create_default_maintainer"); !exist || defaultMaintainer == nil { (*val)["create_default_maintainer"] = false } val.SafeDelete([]string{"etag"}) }) - resourceSchemaRepository.SetHumanReadableAttributesFunc(GithubTeamResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - attrs["Id"] = res.ResourceId() - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - return attrs - }) - resourceSchemaRepository.SetFlags(GithubTeamResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/github/github_team_membership.go b/pkg/resource/github/github_team_membership.go index ccf42ec58..4454ed859 100644 --- a/pkg/resource/github/github_team_membership.go +++ b/pkg/resource/github/github_team_membership.go @@ -1,14 +1,14 @@ // GENERATED, DO NOT EDIT THIS FILE package github -import "github.com/snyk/driftctl/pkg/resource" - -const GithubTeamMembershipResourceType = "github_team_membership" +import ( + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/github" +) func initGithubTeamMembershipMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(GithubTeamMembershipResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(github.GithubTeamMembershipResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"etag"}) }) - resourceSchemaRepository.SetFlags(GithubTeamMembershipResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/github/metadatas.go b/pkg/resource/github/metadatas.go index 08ec32df2..246227851 100644 --- a/pkg/resource/github/metadatas.go +++ b/pkg/resource/github/metadatas.go @@ -1,6 +1,6 @@ package github -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { initGithubBranchProtectionMetaData(resourceSchemaRepository) diff --git a/pkg/resource/github/testdata/acc/github_branch_protection/.terraform.lock.hcl b/pkg/resource/github/testdata/acc/github_branch_protection/.terraform.lock.hcl old mode 100755 new mode 100644 index 0cb91a2ca..bc6235dec --- a/pkg/resource/github/testdata/acc/github_branch_protection/.terraform.lock.hcl +++ b/pkg/resource/github/testdata/acc/github_branch_protection/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/github" { version = "4.4.0" constraints = "4.4.0" hashes = [ + "h1:dgn+oL1cC8kz3ODIuT/PyHqgso00SpItPN089ZuUGt4=", "h1:eKArqtLcYoYUFf4dgNzVemqu2GsoEf7K0ZLEXjSoPBo=", "zh:0ebb07c4971ca7d60fce8614270d056328a121fd4ffbda4b29a06d4a1e90e939", "zh:178b333f2f285c1a59b9335320f584bd01304179c2d6a1919366945b55cfb293", diff --git a/pkg/resource/github/testdata/acc/github_repository/.terraform.lock.hcl b/pkg/resource/github/testdata/acc/github_repository/.terraform.lock.hcl old mode 100755 new mode 100644 index 0cb91a2ca..bc6235dec --- a/pkg/resource/github/testdata/acc/github_repository/.terraform.lock.hcl +++ b/pkg/resource/github/testdata/acc/github_repository/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/github" { version = "4.4.0" constraints = "4.4.0" hashes = [ + "h1:dgn+oL1cC8kz3ODIuT/PyHqgso00SpItPN089ZuUGt4=", "h1:eKArqtLcYoYUFf4dgNzVemqu2GsoEf7K0ZLEXjSoPBo=", "zh:0ebb07c4971ca7d60fce8614270d056328a121fd4ffbda4b29a06d4a1e90e939", "zh:178b333f2f285c1a59b9335320f584bd01304179c2d6a1919366945b55cfb293", diff --git a/pkg/resource/github/testdata/acc/github_team/.terraform.lock.hcl b/pkg/resource/github/testdata/acc/github_team/.terraform.lock.hcl old mode 100755 new mode 100644 index 0cb91a2ca..bc6235dec --- a/pkg/resource/github/testdata/acc/github_team/.terraform.lock.hcl +++ b/pkg/resource/github/testdata/acc/github_team/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/github" { version = "4.4.0" constraints = "4.4.0" hashes = [ + "h1:dgn+oL1cC8kz3ODIuT/PyHqgso00SpItPN089ZuUGt4=", "h1:eKArqtLcYoYUFf4dgNzVemqu2GsoEf7K0ZLEXjSoPBo=", "zh:0ebb07c4971ca7d60fce8614270d056328a121fd4ffbda4b29a06d4a1e90e939", "zh:178b333f2f285c1a59b9335320f584bd01304179c2d6a1919366945b55cfb293", diff --git a/pkg/resource/google/google_compute_firewall.go b/pkg/resource/google/google_compute_firewall.go index 7e9617955..953b90743 100644 --- a/pkg/resource/google/google_compute_firewall.go +++ b/pkg/resource/google/google_compute_firewall.go @@ -1,18 +1,12 @@ package google -import "github.com/snyk/driftctl/pkg/resource" - -const GoogleComputeFirewallResourceType = "google_compute_firewall" +import ( + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" +) func initGoogleComputeFirewallMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(GoogleComputeFirewallResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "name": *res.Attrs.GetString("name"), - "project": *res.Attrs.GetString("project"), - } - }) - resourceSchemaRepository.SetNormalizeFunc(GoogleComputeFirewallResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(google.GoogleComputeFirewallResourceType, func(res *resource.Resource) { res.Attrs.SafeDelete([]string{"timeouts"}) }) - resourceSchemaRepository.SetFlags(GoogleComputeFirewallResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/google/google_compute_instance_group.go b/pkg/resource/google/google_compute_instance_group.go index 16b0601fb..3fe2a939f 100644 --- a/pkg/resource/google/google_compute_instance_group.go +++ b/pkg/resource/google/google_compute_instance_group.go @@ -1,26 +1,12 @@ package google -import "github.com/snyk/driftctl/pkg/resource" - -const GoogleComputeInstanceGroupResourceType = "google_compute_instance_group" +import ( + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" +) func initGoogleComputeInstanceGroupMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(GoogleComputeInstanceGroupResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(google.GoogleComputeInstanceGroupResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) - resourceSchemaRepository.SetResolveReadAttributesFunc(GoogleComputeInstanceGroupResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "name": *res.Attributes().GetString("name"), - "project": *res.Attributes().GetString("project"), - "zone": *res.Attributes().GetString("location"), - } - }) - resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleComputeInstanceGroupResourceType, func(res *resource.Resource) map[string]string { - attrs := make(map[string]string) - if v := res.Attributes().GetString("name"); v != nil && *v != "" { - attrs["Name"] = *v - } - return attrs - }) - resourceSchemaRepository.SetFlags(GoogleComputeInstanceGroupResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/google/google_compute_network.go b/pkg/resource/google/google_compute_network.go index b679a9d89..2eaa58ceb 100644 --- a/pkg/resource/google/google_compute_network.go +++ b/pkg/resource/google/google_compute_network.go @@ -1,20 +1,15 @@ package google -import "github.com/snyk/driftctl/pkg/resource" - -const GoogleComputeNetworkResourceType = "google_compute_network" +import ( + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" +) func initGoogleComputeNetworkMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(GoogleComputeNetworkResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(google.GoogleComputeNetworkResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) res.Attributes().SafeDelete([]string{"self_link"}) res.Attributes().SafeDelete([]string{"gateway_ipv4"}) res.Attributes().SafeDelete([]string{"delete_default_routes_on_create"}) }) - resourceSchemaRepository.SetResolveReadAttributesFunc(GoogleComputeNetworkResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "name": *res.Attributes().GetString("name"), - } - }) - resourceSchemaRepository.SetFlags(GoogleComputeNetworkResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/google/google_compute_subnetwork.go b/pkg/resource/google/google_compute_subnetwork.go index 8497fad4c..3632dbd0a 100644 --- a/pkg/resource/google/google_compute_subnetwork.go +++ b/pkg/resource/google/google_compute_subnetwork.go @@ -1,27 +1,13 @@ package google -import "github.com/snyk/driftctl/pkg/resource" - -const GoogleComputeSubnetworkResourceType = "google_compute_subnetwork" +import ( + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" +) func initGoogleComputeSubnetworkMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(GoogleComputeSubnetworkResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "name": *res.Attributes().GetString("name"), - "region": *res.Attributes().GetString("region"), - } - }) - resourceSchemaRepository.SetNormalizeFunc(GoogleComputeSubnetworkResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(google.GoogleComputeSubnetworkResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) res.Attributes().SafeDelete([]string{"self_link"}) }) - resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleComputeSubnetworkResourceType, func(res *resource.Resource) map[string]string { - attrs := make(map[string]string) - - if v := res.Attributes().GetString("name"); v != nil && *v != "" { - attrs["Name"] = *v - } - return attrs - }) - resourceSchemaRepository.SetFlags(GoogleComputeSubnetworkResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/google/google_project_iam_member.go b/pkg/resource/google/google_project_iam_member.go index 23a686a6f..10d33ff1e 100644 --- a/pkg/resource/google/google_project_iam_member.go +++ b/pkg/resource/google/google_project_iam_member.go @@ -1,21 +1,13 @@ package google -import "github.com/snyk/driftctl/pkg/resource" - -const GoogleProjectIamMemberResourceType = "google_project_iam_member" +import ( + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" +) func initGoogleProjectIAMMemberMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(GoogleProjectIamMemberResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(google.GoogleProjectIamMemberResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"force_destroy"}) res.Attributes().SafeDelete([]string{"etag"}) }) - resourceSchemaRepository.SetResolveReadAttributesFunc(GoogleProjectIamMemberResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "project": *res.Attrs.GetString("project"), - "role": *res.Attrs.GetString("role"), - "member": *res.Attrs.GetString("member"), - } - }) - resourceSchemaRepository.SetFlags(GoogleProjectIamMemberResourceType, resource.FlagDeepMode) - } diff --git a/pkg/resource/google/google_storage_bucket.go b/pkg/resource/google/google_storage_bucket.go index 265f52677..903aabfe6 100644 --- a/pkg/resource/google/google_storage_bucket.go +++ b/pkg/resource/google/google_storage_bucket.go @@ -1,17 +1,12 @@ package google -import "github.com/snyk/driftctl/pkg/resource" - -const GoogleStorageBucketResourceType = "google_storage_bucket" +import ( + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" +) func initGoogleStorageBucketMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(GoogleStorageBucketResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(google.GoogleStorageBucketResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"force_destroy"}) }) - resourceSchemaRepository.SetResolveReadAttributesFunc(GoogleStorageBucketResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "name": res.ResourceId(), - } - }) - resourceSchemaRepository.SetFlags(GoogleStorageBucketResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/google/google_storage_bucket_iam_member.go b/pkg/resource/google/google_storage_bucket_iam_member.go index 5ff5e28d2..b1855db1b 100644 --- a/pkg/resource/google/google_storage_bucket_iam_member.go +++ b/pkg/resource/google/google_storage_bucket_iam_member.go @@ -1,29 +1,13 @@ package google -import "github.com/snyk/driftctl/pkg/resource" - -const GoogleStorageBucketIamMemberResourceType = "google_storage_bucket_iam_member" +import ( + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/google" +) func initGoogleStorageBucketIamBMemberMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(GoogleStorageBucketIamMemberResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(google.GoogleStorageBucketIamMemberResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"force_destroy"}) res.Attributes().SafeDelete([]string{"etag"}) }) - resourceSchemaRepository.SetResolveReadAttributesFunc(GoogleStorageBucketIamMemberResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "bucket": *res.Attrs.GetString("bucket"), - "role": *res.Attrs.GetString("role"), - "member": *res.Attrs.GetString("member"), - } - }) - resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleStorageBucketIamMemberResourceType, func(res *resource.Resource) map[string]string { - attrs := map[string]string{ - "bucket": *res.Attrs.GetString("bucket"), - "role": *res.Attrs.GetString("role"), - "member": *res.Attrs.GetString("member"), - } - return attrs - }) - resourceSchemaRepository.SetFlags(GoogleStorageBucketIamMemberResourceType, resource.FlagDeepMode) - } diff --git a/pkg/resource/google/metadatas.go b/pkg/resource/google/metadatas.go index 788d2f226..9c74aa5df 100644 --- a/pkg/resource/google/metadatas.go +++ b/pkg/resource/google/metadatas.go @@ -1,22 +1,13 @@ package google -import "github.com/snyk/driftctl/pkg/resource" +import "github.com/snyk/driftctl/enumeration/resource" func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { initGoogleStorageBucketMetadata(resourceSchemaRepository) initGoogleComputeFirewallMetadata(resourceSchemaRepository) - initGoogleComputeRouterMetadata(resourceSchemaRepository) initGoogleComputeNetworkMetadata(resourceSchemaRepository) initGoogleStorageBucketIamBMemberMetadata(resourceSchemaRepository) initGoogleComputeInstanceGroupMetadata(resourceSchemaRepository) - initGoogleBigqueryDatasetMetadata(resourceSchemaRepository) - initGoogleBigqueryTableMetadata(resourceSchemaRepository) initGoogleProjectIAMMemberMetadata(resourceSchemaRepository) - initGoogleComputeAddressMetadata(resourceSchemaRepository) - initGoogleComputeGlobalAddressMetadata(resourceSchemaRepository) initGoogleComputeSubnetworkMetadata(resourceSchemaRepository) - initGoogleComputeDiskMetadata(resourceSchemaRepository) - initGoogleComputeImageMetadata(resourceSchemaRepository) - initGoogleComputeHealthCheckMetadata(resourceSchemaRepository) - initComputeInstanceGroupManagerMetadata(resourceSchemaRepository) } diff --git a/pkg/resource/google/testdata/acc/google_bigquery_dataset/.terraform.lock.hcl b/pkg/resource/google/testdata/acc/google_bigquery_dataset/.terraform.lock.hcl index 9ba9d75b0..805a45514 100644 --- a/pkg/resource/google/testdata/acc/google_bigquery_dataset/.terraform.lock.hcl +++ b/pkg/resource/google/testdata/acc/google_bigquery_dataset/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/google" { version = "3.78.0" constraints = "3.78.0" hashes = [ + "h1:Seut9gKb/KzzUMxa9Qo59LRWcgURfBWMarqNTRjxnXE=", "h1:iCyTW8BWdr6Bvd5B89wkxlrB8xLxqHvT1CPmGuKembU=", "zh:027971c4689b6130619827fe57ce260aaca060db3446817d3a92869dba7cc07f", "zh:0876dbecc0d441bf2479edd17fe9141d77274b5071ea5f68ac26a2994bff66f3", diff --git a/pkg/resource/google/testdata/acc/google_bigquery_table/.terraform.lock.hcl b/pkg/resource/google/testdata/acc/google_bigquery_table/.terraform.lock.hcl index 9ba9d75b0..805a45514 100644 --- a/pkg/resource/google/testdata/acc/google_bigquery_table/.terraform.lock.hcl +++ b/pkg/resource/google/testdata/acc/google_bigquery_table/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/google" { version = "3.78.0" constraints = "3.78.0" hashes = [ + "h1:Seut9gKb/KzzUMxa9Qo59LRWcgURfBWMarqNTRjxnXE=", "h1:iCyTW8BWdr6Bvd5B89wkxlrB8xLxqHvT1CPmGuKembU=", "zh:027971c4689b6130619827fe57ce260aaca060db3446817d3a92869dba7cc07f", "zh:0876dbecc0d441bf2479edd17fe9141d77274b5071ea5f68ac26a2994bff66f3", diff --git a/pkg/resource/google/testdata/acc/google_bigtable_instance/.terraform.lock.hcl b/pkg/resource/google/testdata/acc/google_bigtable_instance/.terraform.lock.hcl index 9ba9d75b0..805a45514 100644 --- a/pkg/resource/google/testdata/acc/google_bigtable_instance/.terraform.lock.hcl +++ b/pkg/resource/google/testdata/acc/google_bigtable_instance/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/google" { version = "3.78.0" constraints = "3.78.0" hashes = [ + "h1:Seut9gKb/KzzUMxa9Qo59LRWcgURfBWMarqNTRjxnXE=", "h1:iCyTW8BWdr6Bvd5B89wkxlrB8xLxqHvT1CPmGuKembU=", "zh:027971c4689b6130619827fe57ce260aaca060db3446817d3a92869dba7cc07f", "zh:0876dbecc0d441bf2479edd17fe9141d77274b5071ea5f68ac26a2994bff66f3", diff --git a/pkg/resource/google/testdata/acc/google_bigtable_table/.terraform.lock.hcl b/pkg/resource/google/testdata/acc/google_bigtable_table/.terraform.lock.hcl index 9ba9d75b0..805a45514 100644 --- a/pkg/resource/google/testdata/acc/google_bigtable_table/.terraform.lock.hcl +++ b/pkg/resource/google/testdata/acc/google_bigtable_table/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/google" { version = "3.78.0" constraints = "3.78.0" hashes = [ + "h1:Seut9gKb/KzzUMxa9Qo59LRWcgURfBWMarqNTRjxnXE=", "h1:iCyTW8BWdr6Bvd5B89wkxlrB8xLxqHvT1CPmGuKembU=", "zh:027971c4689b6130619827fe57ce260aaca060db3446817d3a92869dba7cc07f", "zh:0876dbecc0d441bf2479edd17fe9141d77274b5071ea5f68ac26a2994bff66f3", diff --git a/pkg/resource/google/testdata/acc/google_cloudfunctions_function/.terraform.lock.hcl b/pkg/resource/google/testdata/acc/google_cloudfunctions_function/.terraform.lock.hcl index c14895f06..309981b66 100644 --- a/pkg/resource/google/testdata/acc/google_cloudfunctions_function/.terraform.lock.hcl +++ b/pkg/resource/google/testdata/acc/google_cloudfunctions_function/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/google" { version = "3.78.0" constraints = "3.78.0" hashes = [ + "h1:Seut9gKb/KzzUMxa9Qo59LRWcgURfBWMarqNTRjxnXE=", "h1:iCyTW8BWdr6Bvd5B89wkxlrB8xLxqHvT1CPmGuKembU=", "zh:027971c4689b6130619827fe57ce260aaca060db3446817d3a92869dba7cc07f", "zh:0876dbecc0d441bf2479edd17fe9141d77274b5071ea5f68ac26a2994bff66f3", @@ -24,6 +25,7 @@ provider "registry.terraform.io/hashicorp/random" { version = "3.1.0" hashes = [ "h1:BZMEPucF+pbu9gsPk0G0BHx7YP04+tKdq2MrRDF1EDM=", + "h1:rKYu5ZUbXwrLG1w81k7H3nce/Ys6yAxXhWcbtk36HjY=", "zh:2bbb3339f0643b5daa07480ef4397bd23a79963cc364cdfbb4e86354cb7725bc", "zh:3cd456047805bf639fbf2c761b1848880ea703a054f76db51852008b11008626", "zh:4f251b0eda5bb5e3dc26ea4400dba200018213654b69b4a5f96abee815b4f5ff", diff --git a/pkg/resource/google/testdata/acc/google_cloudrun_service/.terraform.lock.hcl b/pkg/resource/google/testdata/acc/google_cloudrun_service/.terraform.lock.hcl index 9ba9d75b0..805a45514 100644 --- a/pkg/resource/google/testdata/acc/google_cloudrun_service/.terraform.lock.hcl +++ b/pkg/resource/google/testdata/acc/google_cloudrun_service/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/google" { version = "3.78.0" constraints = "3.78.0" hashes = [ + "h1:Seut9gKb/KzzUMxa9Qo59LRWcgURfBWMarqNTRjxnXE=", "h1:iCyTW8BWdr6Bvd5B89wkxlrB8xLxqHvT1CPmGuKembU=", "zh:027971c4689b6130619827fe57ce260aaca060db3446817d3a92869dba7cc07f", "zh:0876dbecc0d441bf2479edd17fe9141d77274b5071ea5f68ac26a2994bff66f3", diff --git a/pkg/resource/google/testdata/acc/google_compute_address/.terraform.lock.hcl b/pkg/resource/google/testdata/acc/google_compute_address/.terraform.lock.hcl index 9ba9d75b0..805a45514 100644 --- a/pkg/resource/google/testdata/acc/google_compute_address/.terraform.lock.hcl +++ b/pkg/resource/google/testdata/acc/google_compute_address/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/google" { version = "3.78.0" constraints = "3.78.0" hashes = [ + "h1:Seut9gKb/KzzUMxa9Qo59LRWcgURfBWMarqNTRjxnXE=", "h1:iCyTW8BWdr6Bvd5B89wkxlrB8xLxqHvT1CPmGuKembU=", "zh:027971c4689b6130619827fe57ce260aaca060db3446817d3a92869dba7cc07f", "zh:0876dbecc0d441bf2479edd17fe9141d77274b5071ea5f68ac26a2994bff66f3", diff --git a/pkg/resource/google/testdata/acc/google_compute_disk/.terraform.lock.hcl b/pkg/resource/google/testdata/acc/google_compute_disk/.terraform.lock.hcl index 9ba9d75b0..805a45514 100644 --- a/pkg/resource/google/testdata/acc/google_compute_disk/.terraform.lock.hcl +++ b/pkg/resource/google/testdata/acc/google_compute_disk/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/google" { version = "3.78.0" constraints = "3.78.0" hashes = [ + "h1:Seut9gKb/KzzUMxa9Qo59LRWcgURfBWMarqNTRjxnXE=", "h1:iCyTW8BWdr6Bvd5B89wkxlrB8xLxqHvT1CPmGuKembU=", "zh:027971c4689b6130619827fe57ce260aaca060db3446817d3a92869dba7cc07f", "zh:0876dbecc0d441bf2479edd17fe9141d77274b5071ea5f68ac26a2994bff66f3", diff --git a/pkg/resource/google/testdata/acc/google_compute_firewall/.terraform.lock.hcl b/pkg/resource/google/testdata/acc/google_compute_firewall/.terraform.lock.hcl index 9ba9d75b0..805a45514 100644 --- a/pkg/resource/google/testdata/acc/google_compute_firewall/.terraform.lock.hcl +++ b/pkg/resource/google/testdata/acc/google_compute_firewall/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/google" { version = "3.78.0" constraints = "3.78.0" hashes = [ + "h1:Seut9gKb/KzzUMxa9Qo59LRWcgURfBWMarqNTRjxnXE=", "h1:iCyTW8BWdr6Bvd5B89wkxlrB8xLxqHvT1CPmGuKembU=", "zh:027971c4689b6130619827fe57ce260aaca060db3446817d3a92869dba7cc07f", "zh:0876dbecc0d441bf2479edd17fe9141d77274b5071ea5f68ac26a2994bff66f3", diff --git a/pkg/resource/google/testdata/acc/google_compute_global_address/.terraform.lock.hcl b/pkg/resource/google/testdata/acc/google_compute_global_address/.terraform.lock.hcl index 9ba9d75b0..805a45514 100644 --- a/pkg/resource/google/testdata/acc/google_compute_global_address/.terraform.lock.hcl +++ b/pkg/resource/google/testdata/acc/google_compute_global_address/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/google" { version = "3.78.0" constraints = "3.78.0" hashes = [ + "h1:Seut9gKb/KzzUMxa9Qo59LRWcgURfBWMarqNTRjxnXE=", "h1:iCyTW8BWdr6Bvd5B89wkxlrB8xLxqHvT1CPmGuKembU=", "zh:027971c4689b6130619827fe57ce260aaca060db3446817d3a92869dba7cc07f", "zh:0876dbecc0d441bf2479edd17fe9141d77274b5071ea5f68ac26a2994bff66f3", diff --git a/pkg/resource/google/testdata/acc/google_compute_health_check/.terraform.lock.hcl b/pkg/resource/google/testdata/acc/google_compute_health_check/.terraform.lock.hcl index 9ba9d75b0..805a45514 100644 --- a/pkg/resource/google/testdata/acc/google_compute_health_check/.terraform.lock.hcl +++ b/pkg/resource/google/testdata/acc/google_compute_health_check/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/google" { version = "3.78.0" constraints = "3.78.0" hashes = [ + "h1:Seut9gKb/KzzUMxa9Qo59LRWcgURfBWMarqNTRjxnXE=", "h1:iCyTW8BWdr6Bvd5B89wkxlrB8xLxqHvT1CPmGuKembU=", "zh:027971c4689b6130619827fe57ce260aaca060db3446817d3a92869dba7cc07f", "zh:0876dbecc0d441bf2479edd17fe9141d77274b5071ea5f68ac26a2994bff66f3", diff --git a/pkg/resource/google/testdata/acc/google_compute_image/.terraform.lock.hcl b/pkg/resource/google/testdata/acc/google_compute_image/.terraform.lock.hcl index 9ba9d75b0..805a45514 100644 --- a/pkg/resource/google/testdata/acc/google_compute_image/.terraform.lock.hcl +++ b/pkg/resource/google/testdata/acc/google_compute_image/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/google" { version = "3.78.0" constraints = "3.78.0" hashes = [ + "h1:Seut9gKb/KzzUMxa9Qo59LRWcgURfBWMarqNTRjxnXE=", "h1:iCyTW8BWdr6Bvd5B89wkxlrB8xLxqHvT1CPmGuKembU=", "zh:027971c4689b6130619827fe57ce260aaca060db3446817d3a92869dba7cc07f", "zh:0876dbecc0d441bf2479edd17fe9141d77274b5071ea5f68ac26a2994bff66f3", diff --git a/pkg/resource/google/testdata/acc/google_compute_instance/.terraform.lock.hcl b/pkg/resource/google/testdata/acc/google_compute_instance/.terraform.lock.hcl index 9ba9d75b0..805a45514 100644 --- a/pkg/resource/google/testdata/acc/google_compute_instance/.terraform.lock.hcl +++ b/pkg/resource/google/testdata/acc/google_compute_instance/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/google" { version = "3.78.0" constraints = "3.78.0" hashes = [ + "h1:Seut9gKb/KzzUMxa9Qo59LRWcgURfBWMarqNTRjxnXE=", "h1:iCyTW8BWdr6Bvd5B89wkxlrB8xLxqHvT1CPmGuKembU=", "zh:027971c4689b6130619827fe57ce260aaca060db3446817d3a92869dba7cc07f", "zh:0876dbecc0d441bf2479edd17fe9141d77274b5071ea5f68ac26a2994bff66f3", diff --git a/pkg/resource/google/testdata/acc/google_compute_instance_group_manager/.terraform.lock.hcl b/pkg/resource/google/testdata/acc/google_compute_instance_group_manager/.terraform.lock.hcl index c14895f06..309981b66 100644 --- a/pkg/resource/google/testdata/acc/google_compute_instance_group_manager/.terraform.lock.hcl +++ b/pkg/resource/google/testdata/acc/google_compute_instance_group_manager/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/google" { version = "3.78.0" constraints = "3.78.0" hashes = [ + "h1:Seut9gKb/KzzUMxa9Qo59LRWcgURfBWMarqNTRjxnXE=", "h1:iCyTW8BWdr6Bvd5B89wkxlrB8xLxqHvT1CPmGuKembU=", "zh:027971c4689b6130619827fe57ce260aaca060db3446817d3a92869dba7cc07f", "zh:0876dbecc0d441bf2479edd17fe9141d77274b5071ea5f68ac26a2994bff66f3", @@ -24,6 +25,7 @@ provider "registry.terraform.io/hashicorp/random" { version = "3.1.0" hashes = [ "h1:BZMEPucF+pbu9gsPk0G0BHx7YP04+tKdq2MrRDF1EDM=", + "h1:rKYu5ZUbXwrLG1w81k7H3nce/Ys6yAxXhWcbtk36HjY=", "zh:2bbb3339f0643b5daa07480ef4397bd23a79963cc364cdfbb4e86354cb7725bc", "zh:3cd456047805bf639fbf2c761b1848880ea703a054f76db51852008b11008626", "zh:4f251b0eda5bb5e3dc26ea4400dba200018213654b69b4a5f96abee815b4f5ff", diff --git a/pkg/resource/google/testdata/acc/google_compute_network/.terraform.lock.hcl b/pkg/resource/google/testdata/acc/google_compute_network/.terraform.lock.hcl index c14895f06..309981b66 100644 --- a/pkg/resource/google/testdata/acc/google_compute_network/.terraform.lock.hcl +++ b/pkg/resource/google/testdata/acc/google_compute_network/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/google" { version = "3.78.0" constraints = "3.78.0" hashes = [ + "h1:Seut9gKb/KzzUMxa9Qo59LRWcgURfBWMarqNTRjxnXE=", "h1:iCyTW8BWdr6Bvd5B89wkxlrB8xLxqHvT1CPmGuKembU=", "zh:027971c4689b6130619827fe57ce260aaca060db3446817d3a92869dba7cc07f", "zh:0876dbecc0d441bf2479edd17fe9141d77274b5071ea5f68ac26a2994bff66f3", @@ -24,6 +25,7 @@ provider "registry.terraform.io/hashicorp/random" { version = "3.1.0" hashes = [ "h1:BZMEPucF+pbu9gsPk0G0BHx7YP04+tKdq2MrRDF1EDM=", + "h1:rKYu5ZUbXwrLG1w81k7H3nce/Ys6yAxXhWcbtk36HjY=", "zh:2bbb3339f0643b5daa07480ef4397bd23a79963cc364cdfbb4e86354cb7725bc", "zh:3cd456047805bf639fbf2c761b1848880ea703a054f76db51852008b11008626", "zh:4f251b0eda5bb5e3dc26ea4400dba200018213654b69b4a5f96abee815b4f5ff", diff --git a/pkg/resource/google/testdata/acc/google_compute_router/.terraform.lock.hcl b/pkg/resource/google/testdata/acc/google_compute_router/.terraform.lock.hcl index 9ba9d75b0..805a45514 100644 --- a/pkg/resource/google/testdata/acc/google_compute_router/.terraform.lock.hcl +++ b/pkg/resource/google/testdata/acc/google_compute_router/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/google" { version = "3.78.0" constraints = "3.78.0" hashes = [ + "h1:Seut9gKb/KzzUMxa9Qo59LRWcgURfBWMarqNTRjxnXE=", "h1:iCyTW8BWdr6Bvd5B89wkxlrB8xLxqHvT1CPmGuKembU=", "zh:027971c4689b6130619827fe57ce260aaca060db3446817d3a92869dba7cc07f", "zh:0876dbecc0d441bf2479edd17fe9141d77274b5071ea5f68ac26a2994bff66f3", diff --git a/pkg/resource/google/testdata/acc/google_compute_subnetwork/.terraform.lock.hcl b/pkg/resource/google/testdata/acc/google_compute_subnetwork/.terraform.lock.hcl index c14895f06..309981b66 100644 --- a/pkg/resource/google/testdata/acc/google_compute_subnetwork/.terraform.lock.hcl +++ b/pkg/resource/google/testdata/acc/google_compute_subnetwork/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/google" { version = "3.78.0" constraints = "3.78.0" hashes = [ + "h1:Seut9gKb/KzzUMxa9Qo59LRWcgURfBWMarqNTRjxnXE=", "h1:iCyTW8BWdr6Bvd5B89wkxlrB8xLxqHvT1CPmGuKembU=", "zh:027971c4689b6130619827fe57ce260aaca060db3446817d3a92869dba7cc07f", "zh:0876dbecc0d441bf2479edd17fe9141d77274b5071ea5f68ac26a2994bff66f3", @@ -24,6 +25,7 @@ provider "registry.terraform.io/hashicorp/random" { version = "3.1.0" hashes = [ "h1:BZMEPucF+pbu9gsPk0G0BHx7YP04+tKdq2MrRDF1EDM=", + "h1:rKYu5ZUbXwrLG1w81k7H3nce/Ys6yAxXhWcbtk36HjY=", "zh:2bbb3339f0643b5daa07480ef4397bd23a79963cc364cdfbb4e86354cb7725bc", "zh:3cd456047805bf639fbf2c761b1848880ea703a054f76db51852008b11008626", "zh:4f251b0eda5bb5e3dc26ea4400dba200018213654b69b4a5f96abee815b4f5ff", diff --git a/pkg/resource/google/testdata/acc/google_dns_managed_zone/.terraform.lock.hcl b/pkg/resource/google/testdata/acc/google_dns_managed_zone/.terraform.lock.hcl index c14895f06..309981b66 100644 --- a/pkg/resource/google/testdata/acc/google_dns_managed_zone/.terraform.lock.hcl +++ b/pkg/resource/google/testdata/acc/google_dns_managed_zone/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/google" { version = "3.78.0" constraints = "3.78.0" hashes = [ + "h1:Seut9gKb/KzzUMxa9Qo59LRWcgURfBWMarqNTRjxnXE=", "h1:iCyTW8BWdr6Bvd5B89wkxlrB8xLxqHvT1CPmGuKembU=", "zh:027971c4689b6130619827fe57ce260aaca060db3446817d3a92869dba7cc07f", "zh:0876dbecc0d441bf2479edd17fe9141d77274b5071ea5f68ac26a2994bff66f3", @@ -24,6 +25,7 @@ provider "registry.terraform.io/hashicorp/random" { version = "3.1.0" hashes = [ "h1:BZMEPucF+pbu9gsPk0G0BHx7YP04+tKdq2MrRDF1EDM=", + "h1:rKYu5ZUbXwrLG1w81k7H3nce/Ys6yAxXhWcbtk36HjY=", "zh:2bbb3339f0643b5daa07480ef4397bd23a79963cc364cdfbb4e86354cb7725bc", "zh:3cd456047805bf639fbf2c761b1848880ea703a054f76db51852008b11008626", "zh:4f251b0eda5bb5e3dc26ea4400dba200018213654b69b4a5f96abee815b4f5ff", diff --git a/pkg/resource/google/testdata/acc/google_sql_database_instance/.terraform.lock.hcl b/pkg/resource/google/testdata/acc/google_sql_database_instance/.terraform.lock.hcl index c14895f06..309981b66 100644 --- a/pkg/resource/google/testdata/acc/google_sql_database_instance/.terraform.lock.hcl +++ b/pkg/resource/google/testdata/acc/google_sql_database_instance/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/google" { version = "3.78.0" constraints = "3.78.0" hashes = [ + "h1:Seut9gKb/KzzUMxa9Qo59LRWcgURfBWMarqNTRjxnXE=", "h1:iCyTW8BWdr6Bvd5B89wkxlrB8xLxqHvT1CPmGuKembU=", "zh:027971c4689b6130619827fe57ce260aaca060db3446817d3a92869dba7cc07f", "zh:0876dbecc0d441bf2479edd17fe9141d77274b5071ea5f68ac26a2994bff66f3", @@ -24,6 +25,7 @@ provider "registry.terraform.io/hashicorp/random" { version = "3.1.0" hashes = [ "h1:BZMEPucF+pbu9gsPk0G0BHx7YP04+tKdq2MrRDF1EDM=", + "h1:rKYu5ZUbXwrLG1w81k7H3nce/Ys6yAxXhWcbtk36HjY=", "zh:2bbb3339f0643b5daa07480ef4397bd23a79963cc364cdfbb4e86354cb7725bc", "zh:3cd456047805bf639fbf2c761b1848880ea703a054f76db51852008b11008626", "zh:4f251b0eda5bb5e3dc26ea4400dba200018213654b69b4a5f96abee815b4f5ff", diff --git a/pkg/resource/google/testdata/acc/google_storage_bucket/.terraform.lock.hcl b/pkg/resource/google/testdata/acc/google_storage_bucket/.terraform.lock.hcl index c14895f06..309981b66 100644 --- a/pkg/resource/google/testdata/acc/google_storage_bucket/.terraform.lock.hcl +++ b/pkg/resource/google/testdata/acc/google_storage_bucket/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/google" { version = "3.78.0" constraints = "3.78.0" hashes = [ + "h1:Seut9gKb/KzzUMxa9Qo59LRWcgURfBWMarqNTRjxnXE=", "h1:iCyTW8BWdr6Bvd5B89wkxlrB8xLxqHvT1CPmGuKembU=", "zh:027971c4689b6130619827fe57ce260aaca060db3446817d3a92869dba7cc07f", "zh:0876dbecc0d441bf2479edd17fe9141d77274b5071ea5f68ac26a2994bff66f3", @@ -24,6 +25,7 @@ provider "registry.terraform.io/hashicorp/random" { version = "3.1.0" hashes = [ "h1:BZMEPucF+pbu9gsPk0G0BHx7YP04+tKdq2MrRDF1EDM=", + "h1:rKYu5ZUbXwrLG1w81k7H3nce/Ys6yAxXhWcbtk36HjY=", "zh:2bbb3339f0643b5daa07480ef4397bd23a79963cc364cdfbb4e86354cb7725bc", "zh:3cd456047805bf639fbf2c761b1848880ea703a054f76db51852008b11008626", "zh:4f251b0eda5bb5e3dc26ea4400dba200018213654b69b4a5f96abee815b4f5ff", diff --git a/pkg/resource/init_metadatas.go b/pkg/resource/init_metadatas.go new file mode 100644 index 000000000..f1973b613 --- /dev/null +++ b/pkg/resource/init_metadatas.go @@ -0,0 +1,29 @@ +package resource + +import ( + "github.com/pkg/errors" + "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/pkg/resource/github" + "github.com/snyk/driftctl/pkg/resource/google" +) + +func InitMetadatas(remote string, + resourceSchemaRepository *resource.SchemaRepository) error { + switch remote { + case common.RemoteAWSTerraform: + aws.InitResourcesMetadata(resourceSchemaRepository) + case common.RemoteGithubTerraform: + github.InitResourcesMetadata(resourceSchemaRepository) + case common.RemoteGoogleTerraform: + google.InitResourcesMetadata(resourceSchemaRepository) + case common.RemoteAzureTerraform: + azurerm.InitResourcesMetadata(resourceSchemaRepository) + + default: + return errors.Errorf("unsupported remote '%s'", remote) + } + return nil +} diff --git a/pkg/resource/mock_IaCSupplier.go b/pkg/resource/mock_IaCSupplier.go index 30907b86d..508b0126e 100644 --- a/pkg/resource/mock_IaCSupplier.go +++ b/pkg/resource/mock_IaCSupplier.go @@ -2,7 +2,10 @@ package resource -import mock "github.com/stretchr/testify/mock" +import ( + "github.com/snyk/driftctl/enumeration/resource" + mock "github.com/stretchr/testify/mock" +) // MockIaCSupplier is an autogenerated mock type for the IaCSupplier type type MockIaCSupplier struct { @@ -10,15 +13,15 @@ type MockIaCSupplier struct { } // Resources provides a mock function with given fields: -func (_m *MockIaCSupplier) Resources() ([]*Resource, error) { +func (_m *MockIaCSupplier) Resources() ([]*resource.Resource, error) { ret := _m.Called() - var r0 []*Resource - if rf, ok := ret.Get(0).(func() []*Resource); ok { + var r0 []*resource.Resource + if rf, ok := ret.Get(0).(func() []*resource.Resource); ok { r0 = rf() } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]*Resource) + r0 = ret.Get(0).([]*resource.Resource) } } diff --git a/pkg/resource/mock_Supplier.go b/pkg/resource/mock_Supplier.go index 981d4f489..4367ce5ee 100644 --- a/pkg/resource/mock_Supplier.go +++ b/pkg/resource/mock_Supplier.go @@ -3,6 +3,7 @@ package resource import mock "github.com/stretchr/testify/mock" +import "github.com/snyk/driftctl/enumeration/resource" // MockSupplier is an autogenerated mock type for the Supplier type type MockSupplier struct { @@ -10,15 +11,15 @@ type MockSupplier struct { } // Resources provides a mock function with given fields: -func (_m *MockSupplier) Resources() ([]*Resource, error) { +func (_m *MockSupplier) Resources() ([]*resource.Resource, error) { ret := _m.Called() - var r0 []*Resource - if rf, ok := ret.Get(0).(func() []*Resource); ok { + var r0 []*resource.Resource + if rf, ok := ret.Get(0).(func() []*resource.Resource); ok { r0 = rf() } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]*Resource) + r0 = ret.Get(0).([]*resource.Resource) } } diff --git a/pkg/resource/supplier.go b/pkg/resource/supplier.go index 070fc8da0..aa7af767a 100644 --- a/pkg/resource/supplier.go +++ b/pkg/resource/supplier.go @@ -1,17 +1,9 @@ package resource -// Supplier supply the list of resource.Resource, it's the main interface to retrieve remote resources -type Supplier interface { - Resources() ([]*Resource, error) -} +import "github.com/snyk/driftctl/enumeration/resource" // IaCSupplier supply the list of resource.Resource, it's the main interface to retrieve state resources type IaCSupplier interface { - Supplier + resource.Supplier SourceCount() uint } - -type StoppableSupplier interface { - Supplier - Stop() -} diff --git a/pkg/telemetry/telemetry_test.go b/pkg/telemetry/telemetry_test.go index d7149e61a..c2e2fc13f 100644 --- a/pkg/telemetry/telemetry_test.go +++ b/pkg/telemetry/telemetry_test.go @@ -8,9 +8,9 @@ import ( "testing" "github.com/jarcoal/httpmock" + "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/pkg/analyser" "github.com/snyk/driftctl/pkg/memstore" - "github.com/snyk/driftctl/pkg/resource" "github.com/snyk/driftctl/pkg/version" "github.com/snyk/driftctl/test/mocks" "github.com/spf13/viper" diff --git a/test/cty_test_diff.go b/test/cty_test_diff.go index debb45e59..8d292dded 100644 --- a/test/cty_test_diff.go +++ b/test/cty_test_diff.go @@ -5,13 +5,13 @@ import ( "strings" "testing" + "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/test/goldenfile" "github.com/zclconf/go-cty/cty/json" - "github.com/snyk/driftctl/pkg/resource" - - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration/resource" "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" diff --git a/test/mocks/MockGoldenTerraformProvider.go b/test/mocks/MockGoldenTerraformProvider.go index 68d6c050a..f570a2d34 100644 --- a/test/mocks/MockGoldenTerraformProvider.go +++ b/test/mocks/MockGoldenTerraformProvider.go @@ -4,23 +4,23 @@ import ( gojson "encoding/json" "errors" "fmt" + terraform2 "github.com/snyk/driftctl/enumeration/terraform" "sort" "github.com/snyk/driftctl/test/goldenfile" "github.com/hashicorp/terraform/providers" - "github.com/snyk/driftctl/pkg/terraform" "github.com/zclconf/go-cty/cty" ctyjson "github.com/zclconf/go-cty/cty/json" ) type MockedGoldenTFProvider struct { name string - realProvider terraform.TerraformProvider + realProvider terraform2.TerraformProvider update bool } -func NewMockedGoldenTFProvider(name string, realProvider terraform.TerraformProvider, update bool) *MockedGoldenTFProvider { +func NewMockedGoldenTFProvider(name string, realProvider terraform2.TerraformProvider, update bool) *MockedGoldenTFProvider { return &MockedGoldenTFProvider{name: name, realProvider: realProvider, update: update} } @@ -33,7 +33,7 @@ func (m *MockedGoldenTFProvider) Schema() map[string]providers.Schema { return m.readSchema() } -func (m *MockedGoldenTFProvider) ReadResource(args terraform.ReadResourceArgs) (*cty.Value, error) { +func (m *MockedGoldenTFProvider) ReadResource(args terraform2.ReadResourceArgs) (*cty.Value, error) { if m.update { readResource, err := m.realProvider.ReadResource(args) m.writeReadResource(args, readResource, err) @@ -60,7 +60,7 @@ func (m *MockedGoldenTFProvider) readSchema() map[string]providers.Schema { return schema } -func (m *MockedGoldenTFProvider) writeReadResource(args terraform.ReadResourceArgs, readResource *cty.Value, err error) { +func (m *MockedGoldenTFProvider) writeReadResource(args terraform2.ReadResourceArgs, readResource *cty.Value, err error) { var readRes = ReadResource{ Value: readResource, Err: err, @@ -74,7 +74,7 @@ func (m *MockedGoldenTFProvider) writeReadResource(args terraform.ReadResourceAr goldenfile.WriteFile(m.name, marshalled, fileName) } -func (m *MockedGoldenTFProvider) readReadResource(args terraform.ReadResourceArgs) (*cty.Value, error) { +func (m *MockedGoldenTFProvider) readReadResource(args terraform2.ReadResourceArgs) (*cty.Value, error) { fileName := getFileName(args) // TODO I'm putting this here for compatibility reason... if !goldenfile.FileExists(m.name, fileName) { @@ -146,13 +146,13 @@ func (m *ReadResource) MarshalJSON() ([]byte, error) { return gojson.Marshal(unm) } -func getFileName(args terraform.ReadResourceArgs) string { +func getFileName(args terraform2.ReadResourceArgs) string { suffix := getFileNameSuffix(args) fileName := fmt.Sprintf("%s-%s%s.res.golden.json", args.Ty, args.ID, suffix) return fileName } -func getFileNameSuffix(args terraform.ReadResourceArgs) string { +func getFileNameSuffix(args terraform2.ReadResourceArgs) string { suffix := "" keys := make([]string, 0, len(args.Attributes)) for k := range args.Attributes { diff --git a/test/remote/scanner.go b/test/remote/scanner.go index 65183ad9a..63999461b 100644 --- a/test/remote/scanner.go +++ b/test/remote/scanner.go @@ -1,7 +1,7 @@ package remote import ( - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" ) type SortableScanner struct { diff --git a/test/resource/resource.go b/test/resource/resource.go index f9a32ee32..f720d3925 100644 --- a/test/resource/resource.go +++ b/test/resource/resource.go @@ -2,7 +2,7 @@ package resource import ( "github.com/hashicorp/terraform/providers" - "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/test/schemas" ) diff --git a/test/terraform/fake_terraform_provider.go b/test/terraform/fake_terraform_provider.go index 19bc4c5f0..6264448d9 100644 --- a/test/terraform/fake_terraform_provider.go +++ b/test/terraform/fake_terraform_provider.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform/providers" "github.com/pkg/errors" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration/terraform" "github.com/snyk/driftctl/test/goldenfile" "github.com/snyk/driftctl/test/mocks" "github.com/snyk/driftctl/test/schemas" diff --git a/test/terraform/provider.go b/test/terraform/provider.go index 35892d713..9aa5cf6eb 100644 --- a/test/terraform/provider.go +++ b/test/terraform/provider.go @@ -1,14 +1,14 @@ package terraform import ( + "github.com/snyk/driftctl/enumeration/remote/aws" + "github.com/snyk/driftctl/enumeration/remote/azurerm" + "github.com/snyk/driftctl/enumeration/remote/github" + "github.com/snyk/driftctl/enumeration/remote/google" + "github.com/snyk/driftctl/enumeration/terraform" "os" "github.com/snyk/driftctl/pkg/output" - "github.com/snyk/driftctl/pkg/remote/aws" - "github.com/snyk/driftctl/pkg/remote/azurerm" - "github.com/snyk/driftctl/pkg/remote/github" - "github.com/snyk/driftctl/pkg/remote/google" - "github.com/snyk/driftctl/pkg/terraform" ) func InitTestAwsProvider(providerLibrary *terraform.ProviderLibrary, version string) (*aws.AWSTerraformProvider, error) { diff --git a/test/terraform/schemas_test.go b/test/terraform/schemas_test.go index 30297bb22..398f7f2a2 100644 --- a/test/terraform/schemas_test.go +++ b/test/terraform/schemas_test.go @@ -4,7 +4,8 @@ import ( "os" "testing" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/test/schemas" ) diff --git a/test/test_diff.go b/test/test_diff.go index 4cf5b08c6..9e424f506 100644 --- a/test/test_diff.go +++ b/test/test_diff.go @@ -4,10 +4,11 @@ import ( "strings" "testing" + "github.com/snyk/driftctl/enumeration/terraform" + "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/terraform" + "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/test/goldenfile" "github.com/zclconf/go-cty/cty" "github.com/zclconf/go-cty/cty/gocty" From 7fcbbf915f006c2c59d6a2e7d80f47e009ad3dce Mon Sep 17 00:00:00 2001 From: Elie CHARRA Date: Wed, 6 Jul 2022 10:36:17 +0200 Subject: [PATCH 02/12] chore: mess with cache imports --- .../aws/repository/ec2_repository_test.go | 42 +++++------ .../aws/repository/rds_repository_test.go | 14 ++-- .../remote/azurerm/repository/network_test.go | 74 +++++++++---------- .../azurerm/repository/privatedns_test.go | 50 ++++++------- .../remote/azurerm/repository/storage_test.go | 16 ++-- 5 files changed, 98 insertions(+), 98 deletions(-) diff --git a/enumeration/remote/aws/repository/ec2_repository_test.go b/enumeration/remote/aws/repository/ec2_repository_test.go index 273a811b8..f5b6c0f56 100644 --- a/enumeration/remote/aws/repository/ec2_repository_test.go +++ b/enumeration/remote/aws/repository/ec2_repository_test.go @@ -1,11 +1,11 @@ package repository import ( - cache2 "github.com/snyk/driftctl/enumeration/remote/cache" "strings" "testing" "github.com/pkg/errors" + "github.com/snyk/driftctl/enumeration/remote/cache" awstest "github.com/snyk/driftctl/test/aws" "github.com/stretchr/testify/mock" @@ -52,7 +52,7 @@ func Test_ec2Repository_ListAllImages(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache2.New(1) + store := cache.New(1) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -131,7 +131,7 @@ func Test_ec2Repository_ListAllSnapshots(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache2.New(1) + store := cache.New(1) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -206,7 +206,7 @@ func Test_ec2Repository_ListAllVolumes(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache2.New(1) + store := cache.New(1) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -266,7 +266,7 @@ func Test_ec2Repository_ListAllAddresses(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache2.New(1) + store := cache.New(1) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -326,7 +326,7 @@ func Test_ec2Repository_ListAllAddressesAssociation(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache2.New(1) + store := cache.New(1) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -438,7 +438,7 @@ func Test_ec2Repository_ListAllInstances(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache2.New(1) + store := cache.New(1) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -497,7 +497,7 @@ func Test_ec2Repository_ListAllKeyPairs(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache2.New(1) + store := cache.New(1) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -581,7 +581,7 @@ func Test_ec2Repository_ListAllInternetGateways(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache2.New(1) + store := cache.New(1) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -692,7 +692,7 @@ func Test_ec2Repository_ListAllSubnets(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache2.New(2) + store := cache.New(2) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -786,7 +786,7 @@ func Test_ec2Repository_ListAllNatGateways(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache2.New(1) + store := cache.New(1) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -978,7 +978,7 @@ func Test_ec2Repository_ListAllRouteTables(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache2.New(1) + store := cache.New(1) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -1071,7 +1071,7 @@ func Test_ec2Repository_ListAllVPCs(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache2.New(2) + store := cache.New(2) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -1156,7 +1156,7 @@ func Test_ec2Repository_ListAllSecurityGroups(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache2.New(2) + store := cache.New(2) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -1247,7 +1247,7 @@ func Test_ec2Repository_ListAllNetworkACLs(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache2.New(2) + store := cache.New(2) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -1325,7 +1325,7 @@ func Test_ec2Repository_DescribeLaunchTemplates(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache2.New(1) + store := cache.New(1) client := &awstest.MockFakeEC2{} tt.mocks(client) r := &ec2Repository{ @@ -1362,13 +1362,13 @@ func Test_ec2Repository_IsEbsEncryptionEnabledByDefault(t *testing.T) { tests := []struct { name string - mocks func(client *awstest.MockFakeEC2, store *cache2.MockCache) + mocks func(client *awstest.MockFakeEC2, store *cache.MockCache) want bool wantErr error }{ { name: "test that encryption enabled by default", - mocks: func(client *awstest.MockFakeEC2, store *cache2.MockCache) { + mocks: func(client *awstest.MockFakeEC2, store *cache.MockCache) { store.On("Get", "ec2IsEbsEncryptionEnabledByDefault"). Return(nil). Once() @@ -1387,7 +1387,7 @@ func Test_ec2Repository_IsEbsEncryptionEnabledByDefault(t *testing.T) { }, { name: "test that encryption enabled by default (cached)", - mocks: func(client *awstest.MockFakeEC2, store *cache2.MockCache) { + mocks: func(client *awstest.MockFakeEC2, store *cache.MockCache) { store.On("Get", "ec2IsEbsEncryptionEnabledByDefault"). Return(false). Once() @@ -1396,7 +1396,7 @@ func Test_ec2Repository_IsEbsEncryptionEnabledByDefault(t *testing.T) { }, { name: "error while getting default encryption value", - mocks: func(client *awstest.MockFakeEC2, store *cache2.MockCache) { + mocks: func(client *awstest.MockFakeEC2, store *cache.MockCache) { store.On("Get", "ec2IsEbsEncryptionEnabledByDefault"). Return(nil). Once() @@ -1410,7 +1410,7 @@ func Test_ec2Repository_IsEbsEncryptionEnabledByDefault(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := &cache2.MockCache{} + store := &cache.MockCache{} client := &awstest.MockFakeEC2{} tt.mocks(client, store) r := &ec2Repository{ diff --git a/enumeration/remote/aws/repository/rds_repository_test.go b/enumeration/remote/aws/repository/rds_repository_test.go index 639ffb8c1..68b6827de 100644 --- a/enumeration/remote/aws/repository/rds_repository_test.go +++ b/enumeration/remote/aws/repository/rds_repository_test.go @@ -1,13 +1,13 @@ package repository import ( - cache2 "github.com/snyk/driftctl/enumeration/remote/cache" "strings" "testing" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/rds" "github.com/r3labs/diff/v2" + "github.com/snyk/driftctl/enumeration/remote/cache" awstest "github.com/snyk/driftctl/test/aws" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -55,7 +55,7 @@ func Test_rdsRepository_ListAllDBInstances(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache2.New(1) + store := cache.New(1) client := &awstest.MockFakeRDS{} tt.mocks(client) r := &rdsRepository{ @@ -127,7 +127,7 @@ func Test_rdsRepository_ListAllDBSubnetGroups(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := cache2.New(1) + store := cache.New(1) client := &awstest.MockFakeRDS{} tt.mocks(client) r := &rdsRepository{ @@ -160,13 +160,13 @@ func Test_rdsRepository_ListAllDBSubnetGroups(t *testing.T) { func Test_rdsRepository_ListAllDBClusters(t *testing.T) { tests := []struct { name string - mocks func(*awstest.MockFakeRDS, *cache2.MockCache) + mocks func(*awstest.MockFakeRDS, *cache.MockCache) want []*rds.DBCluster wantErr error }{ { name: "should list with 2 pages", - mocks: func(client *awstest.MockFakeRDS, store *cache2.MockCache) { + mocks: func(client *awstest.MockFakeRDS, store *cache.MockCache) { clusters := []*rds.DBCluster{ {DBClusterIdentifier: aws.String("1")}, {DBClusterIdentifier: aws.String("2")}, @@ -198,7 +198,7 @@ func Test_rdsRepository_ListAllDBClusters(t *testing.T) { }, { name: "should hit cache", - mocks: func(client *awstest.MockFakeRDS, store *cache2.MockCache) { + mocks: func(client *awstest.MockFakeRDS, store *cache.MockCache) { clusters := []*rds.DBCluster{ {DBClusterIdentifier: aws.String("1")}, {DBClusterIdentifier: aws.String("2")}, @@ -222,7 +222,7 @@ func Test_rdsRepository_ListAllDBClusters(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - store := &cache2.MockCache{} + store := &cache.MockCache{} client := &awstest.MockFakeRDS{} tt.mocks(client, store) r := &rdsRepository{ diff --git a/enumeration/remote/azurerm/repository/network_test.go b/enumeration/remote/azurerm/repository/network_test.go index 450064d9c..27f8e2b85 100644 --- a/enumeration/remote/azurerm/repository/network_test.go +++ b/enumeration/remote/azurerm/repository/network_test.go @@ -3,13 +3,13 @@ package repository import ( "context" "fmt" - cache2 "github.com/snyk/driftctl/enumeration/remote/cache" "reflect" "testing" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork" "github.com/pkg/errors" + "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -84,7 +84,7 @@ func Test_ListAllVirtualNetwork_MultiplesResults(t *testing.T) { fakeClient.On("ListAll", mock.Anything).Return(mockPager) - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("GetAndLock", "ListAllVirtualNetworks").Return(nil).Times(1) c.On("Unlock", "ListAllVirtualNetworks").Times(1) c.On("Put", "ListAllVirtualNetworks", expected).Return(true).Times(1) @@ -119,7 +119,7 @@ func Test_ListAllVirtualNetwork_MultiplesResults_WithCache(t *testing.T) { fakeClient := &mockVirtualNetworkClient{} - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("GetAndLock", "ListAllVirtualNetworks").Return(expected).Times(1) c.On("Unlock", "ListAllVirtualNetworks").Times(1) s := &networkRepository{ @@ -155,7 +155,7 @@ func Test_ListAllVirtualNetwork_Error_OnPageResponse(t *testing.T) { s := &networkRepository{ virtualNetworksClient: fakeClient, - cache: cache2.New(0), + cache: cache.New(0), } got, err := s.ListAllVirtualNetworks() @@ -180,7 +180,7 @@ func Test_ListAllVirtualNetwork_Error(t *testing.T) { s := &networkRepository{ virtualNetworksClient: fakeClient, - cache: cache2.New(0), + cache: cache.New(0), } got, err := s.ListAllVirtualNetworks() @@ -239,7 +239,7 @@ func Test_ListAllRouteTables_MultiplesResults(t *testing.T) { fakeClient.On("ListAll", mock.Anything).Return(mockPager) - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("GetAndLock", "ListAllRouteTables").Return(nil).Times(1) c.On("Unlock", "ListAllRouteTables").Times(1) c.On("Put", "ListAllRouteTables", expected).Return(true).Times(1) @@ -274,7 +274,7 @@ func Test_ListAllRouteTables_MultiplesResults_WithCache(t *testing.T) { fakeClient := &mockRouteTablesClient{} - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("GetAndLock", "ListAllRouteTables").Return(expected).Times(1) c.On("Unlock", "ListAllRouteTables").Times(1) s := &networkRepository{ @@ -310,7 +310,7 @@ func Test_ListAllRouteTables_Error_OnPageResponse(t *testing.T) { s := &networkRepository{ routeTableClient: fakeClient, - cache: cache2.New(0), + cache: cache.New(0), } got, err := s.ListAllRouteTables() @@ -335,7 +335,7 @@ func Test_ListAllRouteTables_Error(t *testing.T) { s := &networkRepository{ routeTableClient: fakeClient, - cache: cache2.New(0), + cache: cache.New(0), } got, err := s.ListAllRouteTables() @@ -423,7 +423,7 @@ func Test_ListAllSubnets_MultiplesResults(t *testing.T) { fakeClient.On("List", "test-dev", "network1", mock.Anything).Return(mockPager) - c := &cache2.MockCache{} + c := &cache.MockCache{} cacheKey := fmt.Sprintf("ListAllSubnets_%s", *network.ID) c.On("Get", cacheKey).Return(nil).Times(1) c.On("Put", cacheKey, expected).Return(true).Times(1) @@ -461,7 +461,7 @@ func Test_ListAllSubnets_MultiplesResults_WithCache(t *testing.T) { } fakeClient := &mockSubnetsClient{} - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("Get", "ListAllSubnets_networkID").Return(expected).Times(1) s := &networkRepository{ subnetsClient: fakeClient, @@ -503,7 +503,7 @@ func Test_ListAllSubnets_Error_OnPageResponse(t *testing.T) { s := &networkRepository{ subnetsClient: fakeClient, - cache: cache2.New(0), + cache: cache.New(0), } got, err := s.ListAllSubnets(network) @@ -535,7 +535,7 @@ func Test_ListAllSubnets_Error(t *testing.T) { s := &networkRepository{ subnetsClient: fakeClient, - cache: cache2.New(0), + cache: cache.New(0), } got, err := s.ListAllSubnets(network) @@ -561,7 +561,7 @@ func Test_ListAllSubnets_ErrorOnInvalidNetworkID(t *testing.T) { s := &networkRepository{ subnetsClient: fakeClient, - cache: cache2.New(0), + cache: cache.New(0), } got, err := s.ListAllSubnets(network) @@ -619,7 +619,7 @@ func Test_ListAllFirewalls_MultiplesResults(t *testing.T) { fakeClient.On("ListAll", mock.Anything).Return(mockPager) - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("Get", "ListAllFirewalls").Return(nil).Times(1) c.On("Put", "ListAllFirewalls", expected).Return(true).Times(1) s := &networkRepository{ @@ -653,7 +653,7 @@ func Test_ListAllFirewalls_MultiplesResults_WithCache(t *testing.T) { fakeClient := &mockFirewallsClient{} - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("Get", "ListAllFirewalls").Return(expected).Times(1) s := &networkRepository{ firewallsClient: fakeClient, @@ -688,7 +688,7 @@ func Test_ListAllFirewalls_Error_OnPageResponse(t *testing.T) { s := &networkRepository{ firewallsClient: fakeClient, - cache: cache2.New(0), + cache: cache.New(0), } got, err := s.ListAllFirewalls() @@ -713,7 +713,7 @@ func Test_ListAllFirewalls_Error(t *testing.T) { s := &networkRepository{ firewallsClient: fakeClient, - cache: cache2.New(0), + cache: cache.New(0), } got, err := s.ListAllFirewalls() @@ -772,7 +772,7 @@ func Test_ListAllPublicIPAddresses_MultiplesResults(t *testing.T) { fakeClient.On("ListAll", mock.Anything).Return(mockPager) - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("Get", "ListAllPublicIPAddresses").Return(nil).Times(1) c.On("Put", "ListAllPublicIPAddresses", expected).Return(true).Times(1) s := &networkRepository{ @@ -806,7 +806,7 @@ func Test_ListAllPublicIPAddresses_MultiplesResults_WithCache(t *testing.T) { fakeClient := &mockPublicIPAddressesClient{} - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("Get", "ListAllPublicIPAddresses").Return(expected).Times(1) s := &networkRepository{ publicIPAddressesClient: fakeClient, @@ -841,7 +841,7 @@ func Test_ListAllPublicIPAddresses_Error_OnPageResponse(t *testing.T) { s := &networkRepository{ publicIPAddressesClient: fakeClient, - cache: cache2.New(0), + cache: cache.New(0), } got, err := s.ListAllPublicIPAddresses() @@ -866,7 +866,7 @@ func Test_ListAllPublicIPAddresses_Error(t *testing.T) { s := &networkRepository{ publicIPAddressesClient: fakeClient, - cache: cache2.New(0), + cache: cache.New(0), } got, err := s.ListAllPublicIPAddresses() @@ -895,13 +895,13 @@ func Test_Network_ListAllSecurityGroups(t *testing.T) { testcases := []struct { name string - mocks func(*mockNetworkSecurityGroupsListAllPager, *cache2.MockCache) + mocks func(*mockNetworkSecurityGroupsListAllPager, *cache.MockCache) expected []*armnetwork.NetworkSecurityGroup wantErr string }{ { name: "should return security groups", - mocks: func(pager *mockNetworkSecurityGroupsListAllPager, mockCache *cache2.MockCache) { + mocks: func(pager *mockNetworkSecurityGroupsListAllPager, mockCache *cache.MockCache) { pager.On("NextPage", context.Background()).Return(true).Times(1) pager.On("NextPage", context.Background()).Return(false).Times(1) pager.On("PageResponse").Return(armnetwork.NetworkSecurityGroupsListAllResponse{ @@ -920,14 +920,14 @@ func Test_Network_ListAllSecurityGroups(t *testing.T) { }, { name: "should hit cache and return security groups", - mocks: func(pager *mockNetworkSecurityGroupsListAllPager, mockCache *cache2.MockCache) { + mocks: func(pager *mockNetworkSecurityGroupsListAllPager, mockCache *cache.MockCache) { mockCache.On("Get", "networkListAllSecurityGroups").Return(expectedResults).Times(1) }, expected: expectedResults, }, { name: "should return remote error", - mocks: func(pager *mockNetworkSecurityGroupsListAllPager, mockCache *cache2.MockCache) { + mocks: func(pager *mockNetworkSecurityGroupsListAllPager, mockCache *cache.MockCache) { pager.On("NextPage", context.Background()).Return(true).Times(1) pager.On("NextPage", context.Background()).Return(false).Times(1) pager.On("PageResponse").Return(armnetwork.NetworkSecurityGroupsListAllResponse{}).Times(1) @@ -943,7 +943,7 @@ func Test_Network_ListAllSecurityGroups(t *testing.T) { t.Run(tt.name, func(t *testing.T) { fakePager := &mockNetworkSecurityGroupsListAllPager{} fakeClient := &mockNetworkSecurityGroupsClient{} - mockCache := &cache2.MockCache{} + mockCache := &cache.MockCache{} fakeClient.On("ListAll", (*armnetwork.NetworkSecurityGroupsListAllOptions)(nil)).Return(fakePager).Maybe() @@ -988,13 +988,13 @@ func Test_Network_ListAllLoadBalancers(t *testing.T) { testcases := []struct { name string - mocks func(*mockLoadBalancersListAllPager, *cache2.MockCache) + mocks func(*mockLoadBalancersListAllPager, *cache.MockCache) expected []*armnetwork.LoadBalancer wantErr string }{ { name: "should return load balancers", - mocks: func(pager *mockLoadBalancersListAllPager, mockCache *cache2.MockCache) { + mocks: func(pager *mockLoadBalancersListAllPager, mockCache *cache.MockCache) { pager.On("NextPage", context.Background()).Return(true).Times(1) pager.On("NextPage", context.Background()).Return(false).Times(1) pager.On("PageResponse").Return(armnetwork.LoadBalancersListAllResponse{ @@ -1014,7 +1014,7 @@ func Test_Network_ListAllLoadBalancers(t *testing.T) { }, { name: "should hit cache and return load balancers", - mocks: func(pager *mockLoadBalancersListAllPager, mockCache *cache2.MockCache) { + mocks: func(pager *mockLoadBalancersListAllPager, mockCache *cache.MockCache) { mockCache.On("GetAndLock", "networkListAllLoadBalancers").Return(expectedResults).Times(1) mockCache.On("Unlock", "networkListAllLoadBalancers").Return(nil).Times(1) }, @@ -1022,7 +1022,7 @@ func Test_Network_ListAllLoadBalancers(t *testing.T) { }, { name: "should return remote error", - mocks: func(pager *mockLoadBalancersListAllPager, mockCache *cache2.MockCache) { + mocks: func(pager *mockLoadBalancersListAllPager, mockCache *cache.MockCache) { pager.On("NextPage", context.Background()).Return(true).Times(1) pager.On("NextPage", context.Background()).Return(false).Times(1) pager.On("PageResponse").Return(armnetwork.LoadBalancersListAllResponse{}).Times(1) @@ -1039,7 +1039,7 @@ func Test_Network_ListAllLoadBalancers(t *testing.T) { t.Run(tt.name, func(t *testing.T) { fakePager := &mockLoadBalancersListAllPager{} fakeClient := &mockLoadBalancersClient{} - mockCache := &cache2.MockCache{} + mockCache := &cache.MockCache{} fakeClient.On("ListAll", (*armnetwork.LoadBalancersListAllOptions)(nil)).Return(fakePager).Maybe() @@ -1085,7 +1085,7 @@ func Test_Network_ListLoadBalancerRules(t *testing.T) { testcases := []struct { name string loadBalancer *armnetwork.LoadBalancer - mocks func(*mockLoadBalancerRulesClient, *mockLoadBalancerRulesListAllPager, *cache2.MockCache) + mocks func(*mockLoadBalancerRulesClient, *mockLoadBalancerRulesListAllPager, *cache.MockCache) expected []*armnetwork.LoadBalancingRule wantErr string }{ @@ -1094,7 +1094,7 @@ func Test_Network_ListLoadBalancerRules(t *testing.T) { loadBalancer: &armnetwork.LoadBalancer{ Resource: armnetwork.Resource{ID: to.StringPtr("/subscriptions/xxx/resourceGroups/driftctl/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/frontendIPConfigurations/PublicIPAddress")}, }, - mocks: func(client *mockLoadBalancerRulesClient, pager *mockLoadBalancerRulesListAllPager, mockCache *cache2.MockCache) { + mocks: func(client *mockLoadBalancerRulesClient, pager *mockLoadBalancerRulesListAllPager, mockCache *cache.MockCache) { client.On("List", "driftctl", "PublicIPAddress", &armnetwork.LoadBalancerLoadBalancingRulesListOptions{}).Return(pager) pager.On("NextPage", context.Background()).Return(true).Times(1) @@ -1118,7 +1118,7 @@ func Test_Network_ListLoadBalancerRules(t *testing.T) { loadBalancer: &armnetwork.LoadBalancer{ Resource: armnetwork.Resource{ID: to.StringPtr("lb-1")}, }, - mocks: func(client *mockLoadBalancerRulesClient, pager *mockLoadBalancerRulesListAllPager, mockCache *cache2.MockCache) { + mocks: func(client *mockLoadBalancerRulesClient, pager *mockLoadBalancerRulesListAllPager, mockCache *cache.MockCache) { mockCache.On("Get", "networkListLoadBalancerRules_lb-1").Return(expectedResults).Times(1) }, expected: expectedResults, @@ -1128,7 +1128,7 @@ func Test_Network_ListLoadBalancerRules(t *testing.T) { loadBalancer: &armnetwork.LoadBalancer{ Resource: armnetwork.Resource{ID: to.StringPtr("/subscriptions/xxx/resourceGroups/driftctl/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/frontendIPConfigurations/PublicIPAddress")}, }, - mocks: func(client *mockLoadBalancerRulesClient, pager *mockLoadBalancerRulesListAllPager, mockCache *cache2.MockCache) { + mocks: func(client *mockLoadBalancerRulesClient, pager *mockLoadBalancerRulesListAllPager, mockCache *cache.MockCache) { client.On("List", "driftctl", "PublicIPAddress", &armnetwork.LoadBalancerLoadBalancingRulesListOptions{}).Return(pager) pager.On("NextPage", context.Background()).Return(true).Times(1) @@ -1146,7 +1146,7 @@ func Test_Network_ListLoadBalancerRules(t *testing.T) { t.Run(tt.name, func(t *testing.T) { fakePager := &mockLoadBalancerRulesListAllPager{} fakeClient := &mockLoadBalancerRulesClient{} - mockCache := &cache2.MockCache{} + mockCache := &cache.MockCache{} tt.mocks(fakeClient, fakePager, mockCache) diff --git a/enumeration/remote/azurerm/repository/privatedns_test.go b/enumeration/remote/azurerm/repository/privatedns_test.go index fddcb0c43..93cb41786 100644 --- a/enumeration/remote/azurerm/repository/privatedns_test.go +++ b/enumeration/remote/azurerm/repository/privatedns_test.go @@ -1,13 +1,13 @@ package repository import ( - cache2 "github.com/snyk/driftctl/enumeration/remote/cache" "reflect" "testing" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns" "github.com/pkg/errors" + "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -99,7 +99,7 @@ func Test_ListAllPrivateZones_MultiplesResults(t *testing.T) { fakeClient.On("List", mock.Anything).Return(mockPager) - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("GetAndLock", "privateDNSListAllPrivateZones").Return(nil).Times(1) c.On("Unlock", "privateDNSListAllPrivateZones").Times(1) c.On("Put", "privateDNSListAllPrivateZones", expected).Return(true).Times(1) @@ -136,7 +136,7 @@ func Test_ListAllPrivateZones_MultiplesResults_WithCache(t *testing.T) { fakeClient := &mockPrivateZonesClient{} - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("GetAndLock", "privateDNSListAllPrivateZones").Return(expected).Times(1) c.On("Unlock", "privateDNSListAllPrivateZones").Times(1) @@ -173,7 +173,7 @@ func Test_ListAllPrivateZones_Error(t *testing.T) { s := &privateDNSRepository{ zoneClient: fakeClient, - cache: cache2.New(0), + cache: cache.New(0), } got, err := s.ListAllPrivateZones() @@ -281,7 +281,7 @@ func Test_ListAllARecords_MultiplesResults(t *testing.T) { fakeRecordSetClient.On("List", "rgid", "zone", (*armprivatedns.RecordSetsListOptions)(nil)).Return(mockPager) - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("GetAndLock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return(nil).Times(1) c.On("Unlock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return().Times(1) c.On("Put", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com", mock.Anything).Return(true).Times(1) @@ -330,7 +330,7 @@ func Test_ListAllARecords_MultiplesResults_WithCache(t *testing.T) { fakeRecordSetClient := &mockPrivateRecordSetClient{} - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("GetAndLock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return(expected).Times(1) c.On("Unlock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Times(1) s := &privateDNSRepository{ @@ -373,7 +373,7 @@ func Test_ListAllARecords_Error(t *testing.T) { s := &privateDNSRepository{ recordClient: fakeClient, - cache: cache2.New(0), + cache: cache.New(0), } got, err := s.ListAllARecords(&armprivatedns.PrivateZone{ TrackedResource: armprivatedns.TrackedResource{ @@ -488,7 +488,7 @@ func Test_ListAllAAAARecords_MultiplesResults(t *testing.T) { fakeRecordSetClient.On("List", "rgid", "zone", (*armprivatedns.RecordSetsListOptions)(nil)).Return(mockPager) - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("GetAndLock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return(nil).Times(1) c.On("Unlock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return().Times(1) c.On("Put", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com", mock.Anything).Return(true).Times(1) @@ -537,7 +537,7 @@ func Test_ListAllAAAARecords_MultiplesResults_WithCache(t *testing.T) { fakeRecordSetClient := &mockPrivateRecordSetClient{} - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("GetAndLock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return(expected).Times(1) c.On("Unlock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Times(1) s := &privateDNSRepository{ @@ -580,7 +580,7 @@ func Test_ListAllAAAARecords_Error(t *testing.T) { s := &privateDNSRepository{ recordClient: fakeClient, - cache: cache2.New(0), + cache: cache.New(0), } got, err := s.ListAllAAAARecords(&armprivatedns.PrivateZone{ TrackedResource: armprivatedns.TrackedResource{ @@ -695,7 +695,7 @@ func Test_ListAllCNAMERecords_MultiplesResults(t *testing.T) { fakeRecordSetClient.On("List", "rgid", "zone", (*armprivatedns.RecordSetsListOptions)(nil)).Return(mockPager) - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("GetAndLock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return(nil).Times(1) c.On("Unlock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return().Times(1) c.On("Put", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com", mock.Anything).Return(true).Times(1) @@ -744,7 +744,7 @@ func Test_ListAllCNAMERecords_MultiplesResults_WithCache(t *testing.T) { fakeRecordSetClient := &mockPrivateRecordSetClient{} - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("GetAndLock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return(expected).Times(1) c.On("Unlock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return().Times(1) @@ -789,7 +789,7 @@ func Test_ListAllCNAMERecords_Error(t *testing.T) { s := &privateDNSRepository{ recordClient: fakeClient, - cache: cache2.New(0), + cache: cache.New(0), } got, err := s.ListAllCNAMERecords(&armprivatedns.PrivateZone{ TrackedResource: armprivatedns.TrackedResource{ @@ -904,7 +904,7 @@ func Test_ListAllPTRRecords_MultiplesResults(t *testing.T) { fakeRecordSetClient.On("List", "rgid", "zone", (*armprivatedns.RecordSetsListOptions)(nil)).Return(mockPager) - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("GetAndLock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return(nil).Times(1) c.On("Unlock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return().Times(1) c.On("Put", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com", mock.Anything).Return(true).Times(1) @@ -953,7 +953,7 @@ func Test_ListAllPTRRecords_MultiplesResults_WithCache(t *testing.T) { fakeRecordSetClient := &mockPrivateRecordSetClient{} - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("GetAndLock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return(expected).Times(1) c.On("Unlock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Times(1) s := &privateDNSRepository{ @@ -996,7 +996,7 @@ func Test_ListAllPTRRecords_Error(t *testing.T) { s := &privateDNSRepository{ recordClient: fakeClient, - cache: cache2.New(0), + cache: cache.New(0), } got, err := s.ListAllPTRRecords(&armprivatedns.PrivateZone{ TrackedResource: armprivatedns.TrackedResource{ @@ -1110,7 +1110,7 @@ func Test_ListAllMXRecords_MultiplesResults(t *testing.T) { fakeRecordSetClient.On("List", "rgid", "zone", (*armprivatedns.RecordSetsListOptions)(nil)).Return(mockPager) - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("GetAndLock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return(nil).Times(1) c.On("Unlock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return().Times(1) c.On("Put", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com", mock.Anything).Return(true).Times(1) @@ -1158,7 +1158,7 @@ func Test_ListAllMXRecords_MultiplesResults_WithCache(t *testing.T) { fakeRecordSetClient := &mockPrivateRecordSetClient{} - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("GetAndLock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return(expected).Times(1) c.On("Unlock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Times(1) s := &privateDNSRepository{ @@ -1203,7 +1203,7 @@ func Test_ListAllMXRecords_Error(t *testing.T) { s := &privateDNSRepository{ recordClient: fakeClient, - cache: cache2.New(0), + cache: cache.New(0), } got, err := s.ListAllMXRecords(&armprivatedns.PrivateZone{ @@ -1319,7 +1319,7 @@ func Test_ListAllSRVRecords_MultiplesResults(t *testing.T) { fakeRecordSetClient.On("List", "rgid", "zone", (*armprivatedns.RecordSetsListOptions)(nil)).Return(mockPager) - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("GetAndLock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return(nil).Times(1) c.On("Unlock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return().Times(1) c.On("Put", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com", mock.Anything).Return(true).Times(1) @@ -1368,7 +1368,7 @@ func Test_ListAllSRVRecords_MultiplesResults_WithCache(t *testing.T) { fakeRecordSetClient := &mockPrivateRecordSetClient{} - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("GetAndLock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return(expected).Times(1) c.On("Unlock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Times(1) s := &privateDNSRepository{ @@ -1411,7 +1411,7 @@ func Test_ListAllSRVRecords_Error(t *testing.T) { s := &privateDNSRepository{ recordClient: fakeClient, - cache: cache2.New(0), + cache: cache.New(0), } got, err := s.ListAllSRVRecords(&armprivatedns.PrivateZone{ TrackedResource: armprivatedns.TrackedResource{ @@ -1526,7 +1526,7 @@ func Test_ListAllTXTRecords_MultiplesResults(t *testing.T) { fakeRecordSetClient.On("List", "rgid", "zone", (*armprivatedns.RecordSetsListOptions)(nil)).Return(mockPager) - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("GetAndLock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return(nil).Times(1) c.On("Unlock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return().Times(1) c.On("Put", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com", mock.Anything).Return(true).Times(1) @@ -1575,7 +1575,7 @@ func Test_ListAllTXTRecords_MultiplesResults_WithCache(t *testing.T) { fakeRecordSetClient := &mockPrivateRecordSetClient{} - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("GetAndLock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Return(expected).Times(1) c.On("Unlock", "privateDNSlistAllRecords-/subscriptions/subid/resourceGroups/rgid/providers/Microsoft.Network/privateDnsZones/zone.com").Times(1) s := &privateDNSRepository{ @@ -1618,7 +1618,7 @@ func Test_ListAllTXTRecords_Error(t *testing.T) { s := &privateDNSRepository{ recordClient: fakeClient, - cache: cache2.New(0), + cache: cache.New(0), } got, err := s.ListAllTXTRecords(&armprivatedns.PrivateZone{ TrackedResource: armprivatedns.TrackedResource{ diff --git a/enumeration/remote/azurerm/repository/storage_test.go b/enumeration/remote/azurerm/repository/storage_test.go index 9ec4bb483..2deea26e1 100644 --- a/enumeration/remote/azurerm/repository/storage_test.go +++ b/enumeration/remote/azurerm/repository/storage_test.go @@ -1,13 +1,13 @@ package repository import ( - cache2 "github.com/snyk/driftctl/enumeration/remote/cache" "reflect" "testing" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage" "github.com/pkg/errors" + "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -98,7 +98,7 @@ func Test_ListAllStorageAccount_MultiplesResults(t *testing.T) { fakeClient.On("List", mock.Anything).Return(mockPager) - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("GetAndLock", "ListAllStorageAccount").Return(nil).Times(1) c.On("Unlock", "ListAllStorageAccount").Times(1) c.On("Put", "ListAllStorageAccount", expected).Return(true).Times(1) @@ -135,7 +135,7 @@ func Test_ListAllStorageAccount_MultiplesResults_WithCache(t *testing.T) { fakeClient := &mockStorageAccountClient{} - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("GetAndLock", "ListAllStorageAccount").Return(expected).Times(1) c.On("Unlock", "ListAllStorageAccount").Times(1) s := &storageRepository{ @@ -171,7 +171,7 @@ func Test_ListAllStorageAccount_Error(t *testing.T) { s := &storageRepository{ storageAccountsClient: fakeClient, - cache: cache2.New(0), + cache: cache.New(0), } got, err := s.ListAllStorageAccount() @@ -258,7 +258,7 @@ func Test_ListAllStorageContainer_MultiplesResults(t *testing.T) { fakeClient.On("List", "foobar", "testeliedriftctl", (*armstorage.BlobContainersListOptions)(nil)).Return(mockPager) - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("Get", "ListAllStorageContainer_testeliedriftctl").Return(nil).Times(1) c.On("Put", "ListAllStorageContainer_testeliedriftctl", expected).Return(true).Times(1) s := &storageRepository{ @@ -295,7 +295,7 @@ func Test_ListAllStorageContainer_MultiplesResults_WithCache(t *testing.T) { fakeClient := &mockBlobContainerClient{} - c := &cache2.MockCache{} + c := &cache.MockCache{} c.On("Get", "ListAllStorageContainer_testeliedriftctl").Return(expected).Times(1) s := &storageRepository{ blobContainerClient: fakeClient, @@ -328,7 +328,7 @@ func Test_ListAllStorageContainer_InvalidStorageAccountResourceID(t *testing.T) s := &storageRepository{ blobContainerClient: fakeClient, - cache: cache2.New(0), + cache: cache.New(0), } got, err := s.ListAllStorageContainer(&account) @@ -361,7 +361,7 @@ func Test_ListAllStorageContainer_Error(t *testing.T) { s := &storageRepository{ blobContainerClient: fakeClient, - cache: cache2.New(0), + cache: cache.New(0), } got, err := s.ListAllStorageContainer(&account) From 4fcd0e868583b4d780f5958d36635d601955eaab Mon Sep 17 00:00:00 2001 From: Elie CHARRA Date: Wed, 6 Jul 2022 10:39:33 +0200 Subject: [PATCH 03/12] chore: fix mess with repository imports --- .../aws/apigatewayv2_mapping_enumerator.go | 8 +- enumeration/remote/aws/init.go | 42 +-- .../remote/aws_api_gateway_scanner_test.go | 242 ++++++------ .../remote/aws_apigatewayv2_scanner_test.go | 168 ++++----- ...aws_applicationautoscaling_scanner_test.go | 36 +- .../remote/aws_autoscaling_scanner_test.go | 14 +- .../remote/aws_cloudformation_scanner_test.go | 16 +- .../remote/aws_cloudfront_scanner_test.go | 16 +- .../remote/aws_dynamodb_scanner_test.go | 16 +- enumeration/remote/aws_ec2_scanner_test.go | 348 +++++++++--------- enumeration/remote/aws_ecr_scanner_test.go | 24 +- .../remote/aws_elasticache_scanner_test.go | 16 +- enumeration/remote/aws_elb_scanner_test.go | 16 +- enumeration/remote/aws_elbv2_scanner_test.go | 32 +- enumeration/remote/aws_iam_scanner_test.go | 160 ++++---- enumeration/remote/aws_kms_scanner_test.go | 30 +- enumeration/remote/aws_lambda_scanner_test.go | 34 +- enumeration/remote/aws_rds_scanner_test.go | 46 +-- .../remote/aws_route53_scanner_test.go | 50 +-- enumeration/remote/aws_s3_scanner_test.go | 98 ++--- enumeration/remote/aws_sns_scanner_test.go | 46 +-- enumeration/remote/aws_sqs_scanner_test.go | 32 +- enumeration/remote/azurerm/init.go | 16 +- .../remote/azurerm_compute_scanner_test.go | 26 +- .../azurerm_containerregistry_scanner_test.go | 14 +- .../remote/azurerm_network_scanner_test.go | 118 +++--- .../remote/azurerm_postgresql_scanner_test.go | 28 +- .../remote/azurerm_privatedns_scanner_test.go | 128 +++---- .../remote/azurerm_resources_scanner_test.go | 14 +- .../remote/azurerm_storage_scanner_test.go | 30 +- ...le_storage_bucket_iam_member_enumerator.go | 8 +- enumeration/remote/google/init.go | 8 +- .../remote/google_storage_scanner_test.go | 32 +- 33 files changed, 956 insertions(+), 956 deletions(-) diff --git a/enumeration/remote/aws/apigatewayv2_mapping_enumerator.go b/enumeration/remote/aws/apigatewayv2_mapping_enumerator.go index 01e812a0d..8bd177810 100644 --- a/enumeration/remote/aws/apigatewayv2_mapping_enumerator.go +++ b/enumeration/remote/aws/apigatewayv2_mapping_enumerator.go @@ -1,19 +1,19 @@ package aws import ( - repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" remoteerror "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/enumeration/resource/aws" ) type ApiGatewayV2MappingEnumerator struct { - repository repository2.ApiGatewayV2Repository - repositoryV1 repository2.ApiGatewayRepository + repository repository.ApiGatewayV2Repository + repositoryV1 repository.ApiGatewayRepository factory resource.ResourceFactory } -func NewApiGatewayV2MappingEnumerator(repo repository2.ApiGatewayV2Repository, repov1 repository2.ApiGatewayRepository, factory resource.ResourceFactory) *ApiGatewayV2MappingEnumerator { +func NewApiGatewayV2MappingEnumerator(repo repository.ApiGatewayV2Repository, repov1 repository.ApiGatewayRepository, factory resource.ResourceFactory) *ApiGatewayV2MappingEnumerator { return &ApiGatewayV2MappingEnumerator{ repository: repo, repositoryV1: repov1, diff --git a/enumeration/remote/aws/init.go b/enumeration/remote/aws/init.go index 5d8e3409a..3225c1b17 100644 --- a/enumeration/remote/aws/init.go +++ b/enumeration/remote/aws/init.go @@ -4,7 +4,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/alerter" "github.com/snyk/driftctl/enumeration/remote/aws/client" - repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" common2 "github.com/snyk/driftctl/enumeration/remote/common" "github.com/snyk/driftctl/enumeration/resource" @@ -40,26 +40,26 @@ func Init(version string, alerter *alerter.Alerter, repositoryCache := cache.New(100) - s3Repository := repository2.NewS3Repository(client.NewAWSClientFactory(provider.session), repositoryCache) - ec2repository := repository2.NewEC2Repository(provider.session, repositoryCache) - elbv2Repository := repository2.NewELBV2Repository(provider.session, repositoryCache) - route53repository := repository2.NewRoute53Repository(provider.session, repositoryCache) - lambdaRepository := repository2.NewLambdaRepository(provider.session, repositoryCache) - rdsRepository := repository2.NewRDSRepository(provider.session, repositoryCache) - sqsRepository := repository2.NewSQSRepository(provider.session, repositoryCache) - snsRepository := repository2.NewSNSRepository(provider.session, repositoryCache) - cloudfrontRepository := repository2.NewCloudfrontRepository(provider.session, repositoryCache) - dynamoDBRepository := repository2.NewDynamoDBRepository(provider.session, repositoryCache) - ecrRepository := repository2.NewECRRepository(provider.session, repositoryCache) - kmsRepository := repository2.NewKMSRepository(provider.session, repositoryCache) - iamRepository := repository2.NewIAMRepository(provider.session, repositoryCache) - cloudformationRepository := repository2.NewCloudformationRepository(provider.session, repositoryCache) - apigatewayRepository := repository2.NewApiGatewayRepository(provider.session, repositoryCache) - appAutoScalingRepository := repository2.NewAppAutoScalingRepository(provider.session, repositoryCache) - apigatewayv2Repository := repository2.NewApiGatewayV2Repository(provider.session, repositoryCache) - autoscalingRepository := repository2.NewAutoScalingRepository(provider.session, repositoryCache) - elbRepository := repository2.NewELBRepository(provider.session, repositoryCache) - elasticacheRepository := repository2.NewElastiCacheRepository(provider.session, repositoryCache) + s3Repository := repository.NewS3Repository(client.NewAWSClientFactory(provider.session), repositoryCache) + ec2repository := repository.NewEC2Repository(provider.session, repositoryCache) + elbv2Repository := repository.NewELBV2Repository(provider.session, repositoryCache) + route53repository := repository.NewRoute53Repository(provider.session, repositoryCache) + lambdaRepository := repository.NewLambdaRepository(provider.session, repositoryCache) + rdsRepository := repository.NewRDSRepository(provider.session, repositoryCache) + sqsRepository := repository.NewSQSRepository(provider.session, repositoryCache) + snsRepository := repository.NewSNSRepository(provider.session, repositoryCache) + cloudfrontRepository := repository.NewCloudfrontRepository(provider.session, repositoryCache) + dynamoDBRepository := repository.NewDynamoDBRepository(provider.session, repositoryCache) + ecrRepository := repository.NewECRRepository(provider.session, repositoryCache) + kmsRepository := repository.NewKMSRepository(provider.session, repositoryCache) + iamRepository := repository.NewIAMRepository(provider.session, repositoryCache) + cloudformationRepository := repository.NewCloudformationRepository(provider.session, repositoryCache) + apigatewayRepository := repository.NewApiGatewayRepository(provider.session, repositoryCache) + appAutoScalingRepository := repository.NewAppAutoScalingRepository(provider.session, repositoryCache) + apigatewayv2Repository := repository.NewApiGatewayV2Repository(provider.session, repositoryCache) + autoscalingRepository := repository.NewAutoScalingRepository(provider.session, repositoryCache) + elbRepository := repository.NewELBRepository(provider.session, repositoryCache) + elasticacheRepository := repository.NewElastiCacheRepository(provider.session, repositoryCache) deserializer := resource.NewDeserializer(factory) providerLibrary.AddProvider(terraform.AWS, provider) diff --git a/enumeration/remote/aws_api_gateway_scanner_test.go b/enumeration/remote/aws_api_gateway_scanner_test.go index 8be6291ba..041afa86f 100644 --- a/enumeration/remote/aws_api_gateway_scanner_test.go +++ b/enumeration/remote/aws_api_gateway_scanner_test.go @@ -9,7 +9,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" aws2 "github.com/snyk/driftctl/enumeration/remote/aws" - repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" common2 "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/resource" @@ -28,13 +28,13 @@ func TestApiGatewayRestApi(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway rest apis", - mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllRestApis").Return([]*apigateway.RestApi{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -43,7 +43,7 @@ func TestApiGatewayRestApi(t *testing.T) { }, { test: "multiple api gateway rest apis", - mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllRestApis").Return([]*apigateway.RestApi{ {Id: awssdk.String("3of73v5ob4")}, {Id: awssdk.String("1jitcobwol")}, @@ -61,7 +61,7 @@ func TestApiGatewayRestApi(t *testing.T) { }, { test: "cannot list api gateway rest apis", - mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllRestApis").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayRestApiResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayRestApiResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, @@ -81,10 +81,10 @@ func TestApiGatewayRestApi(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayRepository{} + fakeRepo := &repository.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayRepository = fakeRepo + var repo repository.ApiGatewayRepository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayRestApiEnumerator(repo, factory)) @@ -111,13 +111,13 @@ func TestApiGatewayAccount(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway account", - mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("GetAccount").Return(nil, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -126,7 +126,7 @@ func TestApiGatewayAccount(t *testing.T) { }, { test: "empty api gateway account", - mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("GetAccount").Return(&apigateway.Account{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -138,7 +138,7 @@ func TestApiGatewayAccount(t *testing.T) { }, { test: "cannot get api gateway account", - mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("GetAccount").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayAccountResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayAccountResourceType, resourceaws.AwsApiGatewayAccountResourceType), alerts.EnumerationPhase)).Return() }, @@ -158,10 +158,10 @@ func TestApiGatewayAccount(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayRepository{} + fakeRepo := &repository.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayRepository = fakeRepo + var repo repository.ApiGatewayRepository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayAccountEnumerator(repo, factory)) @@ -188,13 +188,13 @@ func TestApiGatewayApiKey(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway api keys", - mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllApiKeys").Return([]*apigateway.ApiKey{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -203,7 +203,7 @@ func TestApiGatewayApiKey(t *testing.T) { }, { test: "multiple api gateway api keys", - mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllApiKeys").Return([]*apigateway.ApiKey{ {Id: awssdk.String("fuwnl8lrva")}, {Id: awssdk.String("9ge737dd45")}, @@ -221,7 +221,7 @@ func TestApiGatewayApiKey(t *testing.T) { }, { test: "cannot list api gateway api keys", - mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllApiKeys").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayApiKeyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayApiKeyResourceType, resourceaws.AwsApiGatewayApiKeyResourceType), alerts.EnumerationPhase)).Return() }, @@ -241,10 +241,10 @@ func TestApiGatewayApiKey(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayRepository{} + fakeRepo := &repository.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayRepository = fakeRepo + var repo repository.ApiGatewayRepository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayApiKeyEnumerator(repo, factory)) @@ -275,13 +275,13 @@ func TestApiGatewayAuthorizer(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway authorizers", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiAuthorizers", *apis[0].Id).Return([]*apigateway.Authorizer{}, nil).Once() repo.On("ListAllRestApiAuthorizers", *apis[1].Id).Return([]*apigateway.Authorizer{}, nil).Once() @@ -292,7 +292,7 @@ func TestApiGatewayAuthorizer(t *testing.T) { }, { test: "multiple api gateway authorizers", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiAuthorizers", *apis[0].Id).Return([]*apigateway.Authorizer{ {Id: awssdk.String("ypcpde")}, @@ -313,7 +313,7 @@ func TestApiGatewayAuthorizer(t *testing.T) { }, { test: "cannot list rest apis", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayAuthorizerResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayAuthorizerResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, @@ -321,7 +321,7 @@ func TestApiGatewayAuthorizer(t *testing.T) { }, { test: "cannot list api gateway resources", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiAuthorizers", *apis[0].Id).Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayAuthorizerResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayAuthorizerResourceType, resourceaws.AwsApiGatewayAuthorizerResourceType), alerts.EnumerationPhase)).Return() @@ -342,10 +342,10 @@ func TestApiGatewayAuthorizer(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayRepository{} + fakeRepo := &repository.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayRepository = fakeRepo + var repo repository.ApiGatewayRepository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayAuthorizerEnumerator(repo, factory)) @@ -375,13 +375,13 @@ func TestApiGatewayStage(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway stages", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiStages", *apis[0].Id).Return([]*apigateway.Stage{}, nil) }, @@ -391,7 +391,7 @@ func TestApiGatewayStage(t *testing.T) { }, { test: "multiple api gateway stages", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiStages", *apis[0].Id).Return([]*apigateway.Stage{ {StageName: awssdk.String("foo")}, @@ -410,7 +410,7 @@ func TestApiGatewayStage(t *testing.T) { }, { test: "cannot list rest apis", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayStageResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayStageResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, @@ -418,7 +418,7 @@ func TestApiGatewayStage(t *testing.T) { }, { test: "cannot list api gateway stages", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiStages", *apis[0].Id).Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayStageResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayStageResourceType, resourceaws.AwsApiGatewayStageResourceType), alerts.EnumerationPhase)).Return() @@ -439,10 +439,10 @@ func TestApiGatewayStage(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayRepository{} + fakeRepo := &repository.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayRepository = fakeRepo + var repo repository.ApiGatewayRepository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayStageEnumerator(repo, factory)) @@ -472,13 +472,13 @@ func TestApiGatewayResource(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway resources", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{}, nil) }, @@ -488,7 +488,7 @@ func TestApiGatewayResource(t *testing.T) { }, { test: "multiple api gateway resources", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{ {Id: awssdk.String("21zk4y"), Path: awssdk.String("/")}, @@ -507,7 +507,7 @@ func TestApiGatewayResource(t *testing.T) { }, { test: "cannot list rest apis", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayResourceResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayResourceResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, @@ -515,7 +515,7 @@ func TestApiGatewayResource(t *testing.T) { }, { test: "cannot list api gateway resources", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayResourceResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayResourceResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return() @@ -536,10 +536,10 @@ func TestApiGatewayResource(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayRepository{} + fakeRepo := &repository.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayRepository = fakeRepo + var repo repository.ApiGatewayRepository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayResourceEnumerator(repo, factory)) @@ -566,13 +566,13 @@ func TestApiGatewayDomainName(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway domain names", - mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDomainNames").Return([]*apigateway.DomainName{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -581,7 +581,7 @@ func TestApiGatewayDomainName(t *testing.T) { }, { test: "single api gateway domain name", - mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDomainNames").Return([]*apigateway.DomainName{ {DomainName: awssdk.String("example-driftctl.com")}, }, nil) @@ -595,7 +595,7 @@ func TestApiGatewayDomainName(t *testing.T) { }, { test: "cannot list api gateway domain names", - mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDomainNames").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayDomainNameResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayDomainNameResourceType, resourceaws.AwsApiGatewayDomainNameResourceType), alerts.EnumerationPhase)).Return() }, @@ -615,10 +615,10 @@ func TestApiGatewayDomainName(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayRepository{} + fakeRepo := &repository.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayRepository = fakeRepo + var repo repository.ApiGatewayRepository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayDomainNameEnumerator(repo, factory)) @@ -645,13 +645,13 @@ func TestApiGatewayVpcLink(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway vpc links", - mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllVpcLinks").Return([]*apigateway.UpdateVpcLinkOutput{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -660,7 +660,7 @@ func TestApiGatewayVpcLink(t *testing.T) { }, { test: "single api gateway vpc link", - mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllVpcLinks").Return([]*apigateway.UpdateVpcLinkOutput{ {Id: awssdk.String("ipu24n")}, }, nil) @@ -674,7 +674,7 @@ func TestApiGatewayVpcLink(t *testing.T) { }, { test: "cannot list api gateway vpc links", - mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllVpcLinks").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayVpcLinkResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayVpcLinkResourceType, resourceaws.AwsApiGatewayVpcLinkResourceType), alerts.EnumerationPhase)).Return() }, @@ -694,10 +694,10 @@ func TestApiGatewayVpcLink(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayRepository{} + fakeRepo := &repository.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayRepository = fakeRepo + var repo repository.ApiGatewayRepository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayVpcLinkEnumerator(repo, factory)) @@ -727,13 +727,13 @@ func TestApiGatewayRequestValidator(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway request validators", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiRequestValidators", *apis[0].Id).Return([]*apigateway.UpdateRequestValidatorOutput{}, nil) }, @@ -743,7 +743,7 @@ func TestApiGatewayRequestValidator(t *testing.T) { }, { test: "multiple api gateway request validators", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiRequestValidators", *apis[0].Id).Return([]*apigateway.UpdateRequestValidatorOutput{ {Id: awssdk.String("ywlcuf")}, @@ -762,7 +762,7 @@ func TestApiGatewayRequestValidator(t *testing.T) { }, { test: "cannot list rest apis", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayRequestValidatorResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayRequestValidatorResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, @@ -770,7 +770,7 @@ func TestApiGatewayRequestValidator(t *testing.T) { }, { test: "cannot list api gateway request validators", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiRequestValidators", *apis[0].Id).Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayRequestValidatorResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayRequestValidatorResourceType, resourceaws.AwsApiGatewayRequestValidatorResourceType), alerts.EnumerationPhase)).Return() @@ -791,10 +791,10 @@ func TestApiGatewayRequestValidator(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayRepository{} + fakeRepo := &repository.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayRepository = fakeRepo + var repo repository.ApiGatewayRepository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayRequestValidatorEnumerator(repo, factory)) @@ -821,13 +821,13 @@ func TestApiGatewayRestApiPolicy(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway rest api policies", - mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllRestApis").Return([]*apigateway.RestApi{ {Id: awssdk.String("3of73v5ob4")}, {Id: awssdk.String("9x7kq9pbyh"), Policy: awssdk.String("")}, @@ -839,7 +839,7 @@ func TestApiGatewayRestApiPolicy(t *testing.T) { }, { test: "multiple api gateway rest api policies", - mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllRestApis").Return([]*apigateway.RestApi{ {Id: awssdk.String("c3n3aqga5d"), Policy: awssdk.String("{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":\"execute-api:Invoke\",\"Resource\":\"arn:aws:execute-api:us-east-1:111111111111:c3n3aqga5d/*\",\"Condition\":{\"IpAddress\":{\"aws:SourceIp\":\"123.123.123.123/32\"}}}]}")}, {Id: awssdk.String("9y1eus3hr7"), Policy: awssdk.String("{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":\"execute-api:Invoke\",\"Resource\":\"arn:aws:execute-api:us-east-1:111111111111:9y1eus3hr7/*\",\"Condition\":{\"IpAddress\":{\"aws:SourceIp\":\"123.123.123.123/32\"}}}]}")}, @@ -857,7 +857,7 @@ func TestApiGatewayRestApiPolicy(t *testing.T) { }, { test: "cannot list rest apis", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayRestApiPolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayRestApiPolicyResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, @@ -877,10 +877,10 @@ func TestApiGatewayRestApiPolicy(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayRepository{} + fakeRepo := &repository.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayRepository = fakeRepo + var repo repository.ApiGatewayRepository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayRestApiPolicyEnumerator(repo, factory)) @@ -910,13 +910,13 @@ func TestApiGatewayBasePathMapping(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no domain name base path mappings", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllDomainNames").Return(domainNames, nil) repo.On("ListAllDomainNameBasePathMappings", *domainNames[0].DomainName).Return([]*apigateway.BasePathMapping{}, nil) }, @@ -926,7 +926,7 @@ func TestApiGatewayBasePathMapping(t *testing.T) { }, { test: "multiple domain name base path mappings", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllDomainNames").Return(domainNames, nil) repo.On("ListAllDomainNameBasePathMappings", *domainNames[0].DomainName).Return([]*apigateway.BasePathMapping{ {BasePath: awssdk.String("foo")}, @@ -945,7 +945,7 @@ func TestApiGatewayBasePathMapping(t *testing.T) { }, { test: "cannot list domain names", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllDomainNames").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayBasePathMappingResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayBasePathMappingResourceType, resourceaws.AwsApiGatewayDomainNameResourceType), alerts.EnumerationPhase)).Return() }, @@ -953,7 +953,7 @@ func TestApiGatewayBasePathMapping(t *testing.T) { }, { test: "cannot list domain name base path mappings", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllDomainNames").Return(domainNames, nil) repo.On("ListAllDomainNameBasePathMappings", *domainNames[0].DomainName).Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayBasePathMappingResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayBasePathMappingResourceType, resourceaws.AwsApiGatewayBasePathMappingResourceType), alerts.EnumerationPhase)).Return() @@ -974,10 +974,10 @@ func TestApiGatewayBasePathMapping(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayRepository{} + fakeRepo := &repository.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayRepository = fakeRepo + var repo repository.ApiGatewayRepository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayBasePathMappingEnumerator(repo, factory)) @@ -1007,13 +1007,13 @@ func TestApiGatewayMethod(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway methods", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{ {Id: awssdk.String("hl7ksq"), Path: awssdk.String("/foo")}, @@ -1025,7 +1025,7 @@ func TestApiGatewayMethod(t *testing.T) { }, { test: "multiple api gateway methods", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{ {Id: awssdk.String("hl7ksq"), Path: awssdk.String("/foo"), ResourceMethods: map[string]*apigateway.Method{ @@ -1050,7 +1050,7 @@ func TestApiGatewayMethod(t *testing.T) { }, { test: "cannot list rest apis", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, @@ -1058,7 +1058,7 @@ func TestApiGatewayMethod(t *testing.T) { }, { test: "cannot list api gateway resources", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return() @@ -1079,10 +1079,10 @@ func TestApiGatewayMethod(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayRepository{} + fakeRepo := &repository.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayRepository = fakeRepo + var repo repository.ApiGatewayRepository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayMethodEnumerator(repo, factory)) @@ -1112,13 +1112,13 @@ func TestApiGatewayModel(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway models", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiModels", *apis[0].Id).Return([]*apigateway.Model{}, nil) }, @@ -1128,7 +1128,7 @@ func TestApiGatewayModel(t *testing.T) { }, { test: "multiple api gateway models", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiModels", *apis[0].Id).Return([]*apigateway.Model{ {Id: awssdk.String("g68a4s")}, @@ -1147,7 +1147,7 @@ func TestApiGatewayModel(t *testing.T) { }, { test: "cannot list rest apis", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayModelResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayModelResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, @@ -1155,7 +1155,7 @@ func TestApiGatewayModel(t *testing.T) { }, { test: "cannot list api gateway models", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiModels", *apis[0].Id).Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayModelResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayModelResourceType, resourceaws.AwsApiGatewayModelResourceType), alerts.EnumerationPhase)).Return() @@ -1176,10 +1176,10 @@ func TestApiGatewayModel(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayRepository{} + fakeRepo := &repository.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayRepository = fakeRepo + var repo repository.ApiGatewayRepository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayModelEnumerator(repo, factory)) @@ -1209,13 +1209,13 @@ func TestApiGatewayMethodResponse(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway method responses", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{ {Id: awssdk.String("hl7ksq"), Path: awssdk.String("/foo"), ResourceMethods: map[string]*apigateway.Method{ @@ -1229,7 +1229,7 @@ func TestApiGatewayMethodResponse(t *testing.T) { }, { test: "multiple api gateway method responses", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{ {Id: awssdk.String("hl7ksq"), Path: awssdk.String("/foo"), ResourceMethods: map[string]*apigateway.Method{ @@ -1256,7 +1256,7 @@ func TestApiGatewayMethodResponse(t *testing.T) { }, { test: "cannot list rest apis", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResponseResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, @@ -1264,7 +1264,7 @@ func TestApiGatewayMethodResponse(t *testing.T) { }, { test: "cannot list api gateway resources", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResponseResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return() @@ -1285,10 +1285,10 @@ func TestApiGatewayMethodResponse(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayRepository{} + fakeRepo := &repository.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayRepository = fakeRepo + var repo repository.ApiGatewayRepository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayMethodResponseEnumerator(repo, factory)) @@ -1318,13 +1318,13 @@ func TestApiGatewayGatewayResponse(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway gateway responses", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiGatewayResponses", *apis[0].Id).Return([]*apigateway.UpdateGatewayResponseOutput{}, nil) }, @@ -1334,7 +1334,7 @@ func TestApiGatewayGatewayResponse(t *testing.T) { }, { test: "multiple api gateway gateway responses", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiGatewayResponses", *apis[0].Id).Return([]*apigateway.UpdateGatewayResponseOutput{ {ResponseType: awssdk.String("UNAUTHORIZED")}, @@ -1353,7 +1353,7 @@ func TestApiGatewayGatewayResponse(t *testing.T) { }, { test: "cannot list rest apis", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayGatewayResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayGatewayResponseResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, @@ -1361,7 +1361,7 @@ func TestApiGatewayGatewayResponse(t *testing.T) { }, { test: "cannot list api gateway gateway responses", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiGatewayResponses", *apis[0].Id).Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayGatewayResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayGatewayResponseResourceType, resourceaws.AwsApiGatewayGatewayResponseResourceType), alerts.EnumerationPhase)).Return() @@ -1382,10 +1382,10 @@ func TestApiGatewayGatewayResponse(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayRepository{} + fakeRepo := &repository.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayRepository = fakeRepo + var repo repository.ApiGatewayRepository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayGatewayResponseEnumerator(repo, factory)) @@ -1415,13 +1415,13 @@ func TestApiGatewayMethodSettings(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway method settings", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiStages", *apis[0].Id).Return([]*apigateway.Stage{ {StageName: awssdk.String("foo"), MethodSettings: map[string]*apigateway.MethodSetting{}}, @@ -1433,7 +1433,7 @@ func TestApiGatewayMethodSettings(t *testing.T) { }, { test: "multiple api gateway method settings", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiStages", *apis[0].Id).Return([]*apigateway.Stage{ {StageName: awssdk.String("foo"), MethodSettings: map[string]*apigateway.MethodSetting{ @@ -1458,7 +1458,7 @@ func TestApiGatewayMethodSettings(t *testing.T) { }, { test: "cannot list rest apis", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodSettingsResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodSettingsResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, @@ -1466,7 +1466,7 @@ func TestApiGatewayMethodSettings(t *testing.T) { }, { test: "cannot list api gateway settings", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiStages", *apis[0].Id).Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodSettingsResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodSettingsResourceType, resourceaws.AwsApiGatewayStageResourceType), alerts.EnumerationPhase)).Return() @@ -1487,10 +1487,10 @@ func TestApiGatewayMethodSettings(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayRepository{} + fakeRepo := &repository.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayRepository = fakeRepo + var repo repository.ApiGatewayRepository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayMethodSettingsEnumerator(repo, factory)) @@ -1520,13 +1520,13 @@ func TestApiGatewayIntegration(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway integrations", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{ {Id: awssdk.String("z9ag20"), Path: awssdk.String("/foo")}, @@ -1538,7 +1538,7 @@ func TestApiGatewayIntegration(t *testing.T) { }, { test: "multiple api gateway integrations", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{ {Id: awssdk.String("z9ag20"), Path: awssdk.String("/foo"), ResourceMethods: map[string]*apigateway.Method{ @@ -1563,7 +1563,7 @@ func TestApiGatewayIntegration(t *testing.T) { }, { test: "cannot list rest apis", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayIntegrationResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, @@ -1571,7 +1571,7 @@ func TestApiGatewayIntegration(t *testing.T) { }, { test: "cannot list api gateway resources", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayIntegrationResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return() @@ -1592,10 +1592,10 @@ func TestApiGatewayIntegration(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayRepository{} + fakeRepo := &repository.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayRepository = fakeRepo + var repo repository.ApiGatewayRepository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayIntegrationEnumerator(repo, factory)) @@ -1625,13 +1625,13 @@ func TestApiGatewayIntegrationResponse(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway integration responses", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{ {Id: awssdk.String("z9ag20"), Path: awssdk.String("/foo"), ResourceMethods: map[string]*apigateway.Method{ @@ -1645,7 +1645,7 @@ func TestApiGatewayIntegrationResponse(t *testing.T) { }, { test: "multiple api gateway integration responses", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{ {Id: awssdk.String("z9ag20"), Path: awssdk.String("/foo"), ResourceMethods: map[string]*apigateway.Method{ @@ -1672,7 +1672,7 @@ func TestApiGatewayIntegrationResponse(t *testing.T) { }, { test: "cannot list rest apis", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayIntegrationResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResponseResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, @@ -1680,7 +1680,7 @@ func TestApiGatewayIntegrationResponse(t *testing.T) { }, { test: "cannot list api gateway resources", - mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayIntegrationResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResponseResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return() @@ -1701,10 +1701,10 @@ func TestApiGatewayIntegrationResponse(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayRepository{} + fakeRepo := &repository.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayRepository = fakeRepo + var repo repository.ApiGatewayRepository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayIntegrationResponseEnumerator(repo, factory)) diff --git a/enumeration/remote/aws_apigatewayv2_scanner_test.go b/enumeration/remote/aws_apigatewayv2_scanner_test.go index 564b34b56..e6a07bca6 100644 --- a/enumeration/remote/aws_apigatewayv2_scanner_test.go +++ b/enumeration/remote/aws_apigatewayv2_scanner_test.go @@ -6,7 +6,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" aws2 "github.com/snyk/driftctl/enumeration/remote/aws" - repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" common2 "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/terraform" @@ -29,13 +29,13 @@ func TestApiGatewayV2Api(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway v2 api", - mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -44,7 +44,7 @@ func TestApiGatewayV2Api(t *testing.T) { }, { test: "single api gateway v2 api", - mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{ {ApiId: awssdk.String("f5vdrg12tk")}, }, nil) @@ -58,7 +58,7 @@ func TestApiGatewayV2Api(t *testing.T) { }, { test: "cannot list api gateway v2 apis", - mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayV2ApiResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), alerts.EnumerationPhase)).Return() }, @@ -78,10 +78,10 @@ func TestApiGatewayV2Api(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayV2Repository{} + fakeRepo := &repository.MockApiGatewayV2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayV2Repository = fakeRepo + var repo repository.ApiGatewayV2Repository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2ApiEnumerator(repo, factory)) @@ -108,13 +108,13 @@ func TestApiGatewayV2Route(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway v2 api", - mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -123,7 +123,7 @@ func TestApiGatewayV2Route(t *testing.T) { }, { test: "single api gateway v2 api with a single route", - mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{ {ApiId: awssdk.String("a-gateway")}, }, nil) @@ -147,7 +147,7 @@ func TestApiGatewayV2Route(t *testing.T) { }, { test: "cannot list api gateway v2 apis", - mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayV2RouteResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2RouteResourceType), alerts.EnumerationPhase)).Return() }, @@ -167,10 +167,10 @@ func TestApiGatewayV2Route(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayV2Repository{} + fakeRepo := &repository.MockApiGatewayV2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayV2Repository = fakeRepo + var repo repository.ApiGatewayV2Repository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2RouteEnumerator(repo, factory)) @@ -197,13 +197,13 @@ func TestApiGatewayV2Deployment(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "single api gateway v2 api with a single deployment", - mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{ {ApiId: awssdk.String("a-gateway")}, }, nil) @@ -223,7 +223,7 @@ func TestApiGatewayV2Deployment(t *testing.T) { }, { test: "no API gateways", - mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -232,7 +232,7 @@ func TestApiGatewayV2Deployment(t *testing.T) { }, { test: "single API gateway with no deployments", - mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{ {ApiId: awssdk.String("a-gateway")}, }, nil) @@ -245,7 +245,7 @@ func TestApiGatewayV2Deployment(t *testing.T) { }, { test: "error listing API gateways", - mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayV2DeploymentResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2RouteResourceType), alerts.EnumerationPhase)).Return() }, @@ -253,7 +253,7 @@ func TestApiGatewayV2Deployment(t *testing.T) { }, { test: "error listing deployments of an API", - mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{ {ApiId: awssdk.String("a-gateway")}, }, nil) @@ -276,10 +276,10 @@ func TestApiGatewayV2Deployment(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayV2Repository{} + fakeRepo := &repository.MockApiGatewayV2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayV2Repository = fakeRepo + var repo repository.ApiGatewayV2Repository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2DeploymentEnumerator(repo, factory)) @@ -306,13 +306,13 @@ func TestApiGatewayV2VpcLink(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway v2 vpc links", - mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllVpcLinks").Return([]*apigatewayv2.VpcLink{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -321,7 +321,7 @@ func TestApiGatewayV2VpcLink(t *testing.T) { }, { test: "single api gateway v2 vpc link", - mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllVpcLinks").Return([]*apigatewayv2.VpcLink{ {VpcLinkId: awssdk.String("b8r351")}, }, nil) @@ -335,7 +335,7 @@ func TestApiGatewayV2VpcLink(t *testing.T) { }, { test: "cannot list api gateway v2 vpc links", - mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllVpcLinks").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayV2VpcLinkResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2VpcLinkResourceType, resourceaws.AwsApiGatewayV2VpcLinkResourceType), alerts.EnumerationPhase)).Return() }, @@ -355,10 +355,10 @@ func TestApiGatewayV2VpcLink(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayV2Repository{} + fakeRepo := &repository.MockApiGatewayV2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayV2Repository = fakeRepo + var repo repository.ApiGatewayV2Repository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2VpcLinkEnumerator(repo, factory)) @@ -390,13 +390,13 @@ func TestApiGatewayV2Authorizer(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway v2 authorizers", - mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(apis, nil) repo.On("ListAllApiAuthorizers", *apis[0].ApiId).Return([]*apigatewayv2.Authorizer{}, nil).Once() repo.On("ListAllApiAuthorizers", *apis[1].ApiId).Return([]*apigatewayv2.Authorizer{}, nil).Once() @@ -407,7 +407,7 @@ func TestApiGatewayV2Authorizer(t *testing.T) { }, { test: "multiple api gateway v2 authorizers", - mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(apis, nil) repo.On("ListAllApiAuthorizers", *apis[0].ApiId).Return([]*apigatewayv2.Authorizer{ {AuthorizerId: awssdk.String("xaappu")}, @@ -428,7 +428,7 @@ func TestApiGatewayV2Authorizer(t *testing.T) { }, { test: "cannot list apis", - mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayV2AuthorizerResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2AuthorizerResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), alerts.EnumerationPhase)).Return() }, @@ -436,7 +436,7 @@ func TestApiGatewayV2Authorizer(t *testing.T) { }, { test: "cannot list api gateway v2 authorizers", - mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(apis, nil) repo.On("ListAllApiAuthorizers", *apis[0].ApiId).Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayV2AuthorizerResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2AuthorizerResourceType, resourceaws.AwsApiGatewayV2AuthorizerResourceType), alerts.EnumerationPhase)).Return() @@ -457,10 +457,10 @@ func TestApiGatewayV2Authorizer(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayV2Repository{} + fakeRepo := &repository.MockApiGatewayV2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayV2Repository = fakeRepo + var repo repository.ApiGatewayV2Repository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2AuthorizerEnumerator(repo, factory)) @@ -492,13 +492,13 @@ func TestApiGatewayV2Integration(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway v2 integrations", - mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(apis, nil) repo.On("ListAllApiIntegrations", *apis[0].ApiId).Return([]*apigatewayv2.Integration{}, nil).Once() repo.On("ListAllApiIntegrations", *apis[1].ApiId).Return([]*apigatewayv2.Integration{}, nil).Once() @@ -509,7 +509,7 @@ func TestApiGatewayV2Integration(t *testing.T) { }, { test: "multiple api gateway v2 integrations", - mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(apis, nil) repo.On("ListAllApiIntegrations", *apis[0].ApiId).Return([]*apigatewayv2.Integration{ { @@ -536,7 +536,7 @@ func TestApiGatewayV2Integration(t *testing.T) { }, { test: "cannot list apis", - mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayV2IntegrationResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2IntegrationResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), alerts.EnumerationPhase)).Return() }, @@ -544,7 +544,7 @@ func TestApiGatewayV2Integration(t *testing.T) { }, { test: "cannot list api gateway v2 integrations", - mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(apis, nil) repo.On("ListAllApiIntegrations", *apis[0].ApiId).Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayV2IntegrationResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2IntegrationResourceType, resourceaws.AwsApiGatewayV2IntegrationResourceType), alerts.EnumerationPhase)).Return() @@ -565,10 +565,10 @@ func TestApiGatewayV2Integration(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayV2Repository{} + fakeRepo := &repository.MockApiGatewayV2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayV2Repository = fakeRepo + var repo repository.ApiGatewayV2Repository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2IntegrationEnumerator(repo, factory)) @@ -600,13 +600,13 @@ func TestApiGatewayV2Model(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway v2 models", - mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(apis, nil) repo.On("ListAllApiModels", *apis[0].ApiId).Return([]*apigatewayv2.Model{}, nil).Once() repo.On("ListAllApiModels", *apis[1].ApiId).Return([]*apigatewayv2.Model{}, nil).Once() @@ -617,7 +617,7 @@ func TestApiGatewayV2Model(t *testing.T) { }, { test: "multiple api gateway v2 models", - mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(apis, nil) repo.On("ListAllApiModels", *apis[0].ApiId).Return([]*apigatewayv2.Model{ { @@ -647,7 +647,7 @@ func TestApiGatewayV2Model(t *testing.T) { }, { test: "cannot list apis", - mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayV2ModelResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ModelResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), alerts.EnumerationPhase)).Return() }, @@ -655,7 +655,7 @@ func TestApiGatewayV2Model(t *testing.T) { }, { test: "cannot list api gateway v2 model", - mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(apis, nil) repo.On("ListAllApiModels", *apis[0].ApiId).Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayV2ModelResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ModelResourceType, resourceaws.AwsApiGatewayV2ModelResourceType), alerts.EnumerationPhase)).Return() @@ -676,10 +676,10 @@ func TestApiGatewayV2Model(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayV2Repository{} + fakeRepo := &repository.MockApiGatewayV2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayV2Repository = fakeRepo + var repo repository.ApiGatewayV2Repository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2ModelEnumerator(repo, factory)) @@ -706,13 +706,13 @@ func TestApiGatewayV2Stage(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway v2 api", - mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -721,7 +721,7 @@ func TestApiGatewayV2Stage(t *testing.T) { }, { test: "single api gateway v2 api with a single stage", - mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{ {ApiId: awssdk.String("a-gateway")}, }, nil) @@ -739,7 +739,7 @@ func TestApiGatewayV2Stage(t *testing.T) { }, { test: "cannot list api gateway v2 apis", - mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayV2StageResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2StageResourceType), alerts.EnumerationPhase)).Return() }, @@ -759,10 +759,10 @@ func TestApiGatewayV2Stage(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayV2Repository{} + fakeRepo := &repository.MockApiGatewayV2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayV2Repository = fakeRepo + var repo repository.ApiGatewayV2Repository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2StageEnumerator(repo, factory)) @@ -789,13 +789,13 @@ func TestApiGatewayV2RouteResponse(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway v2 route responses", - mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{ {ApiId: awssdk.String("77ooqulkke")}, }, nil) @@ -812,7 +812,7 @@ func TestApiGatewayV2RouteResponse(t *testing.T) { }, { test: "single api gateway v2 route with one route response", - mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{ {ApiId: awssdk.String("77ooqulkke")}, }, nil) @@ -834,7 +834,7 @@ func TestApiGatewayV2RouteResponse(t *testing.T) { }, { test: "cannot list api gateway v2 apis", - mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayV2RouteResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2RouteResponseResourceType), alerts.EnumerationPhase)).Return() }, @@ -842,7 +842,7 @@ func TestApiGatewayV2RouteResponse(t *testing.T) { }, { test: "cannot list api gateway v2 routes", - mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{ {ApiId: awssdk.String("77ooqulkke")}, }, nil) @@ -853,7 +853,7 @@ func TestApiGatewayV2RouteResponse(t *testing.T) { }, { test: "cannot list api gateway v2 route responses", - mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{ {ApiId: awssdk.String("77ooqulkke")}, }, nil) @@ -880,10 +880,10 @@ func TestApiGatewayV2RouteResponse(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayV2Repository{} + fakeRepo := &repository.MockApiGatewayV2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayV2Repository = fakeRepo + var repo repository.ApiGatewayV2Repository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2RouteResponseEnumerator(repo, factory)) @@ -910,13 +910,13 @@ func TestApiGatewayV2Mapping(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayRepository, *repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayRepository, *repository.MockApiGatewayV2Repository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway v2 domains", - mocks: func(repositoryV1 *repository2.MockApiGatewayRepository, repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repositoryV1 *repository.MockApiGatewayRepository, repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repositoryV1.On("ListAllDomainNames").Return([]*apigateway.DomainName{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -925,7 +925,7 @@ func TestApiGatewayV2Mapping(t *testing.T) { }, { test: "single api gateway v2 domain with a single mapping", - mocks: func(repositoryV1 *repository2.MockApiGatewayRepository, repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repositoryV1 *repository.MockApiGatewayRepository, repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repositoryV1.On("ListAllDomainNames").Return([]*apigateway.DomainName{ {DomainName: awssdk.String("example.com")}, }, nil) @@ -945,7 +945,7 @@ func TestApiGatewayV2Mapping(t *testing.T) { }, { test: "cannot list api gateway v2 domains", - mocks: func(repositoryV1 *repository2.MockApiGatewayRepository, repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repositoryV1 *repository.MockApiGatewayRepository, repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repositoryV1.On("ListAllDomainNames").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayV2MappingResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayDomainNameResourceType, resourceaws.AwsApiGatewayV2MappingResourceType), alerts.EnumerationPhase)).Return() }, @@ -953,7 +953,7 @@ func TestApiGatewayV2Mapping(t *testing.T) { }, { test: "cannot list api gateway v2 mappings", - mocks: func(repositoryV1 *repository2.MockApiGatewayRepository, repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repositoryV1 *repository.MockApiGatewayRepository, repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repositoryV1.On("ListAllDomainNames").Return([]*apigateway.DomainName{ {DomainName: awssdk.String("example.com")}, }, nil) @@ -965,7 +965,7 @@ func TestApiGatewayV2Mapping(t *testing.T) { }, { test: "returning mapping with invalid attributes", - mocks: func(repositoryV1 *repository2.MockApiGatewayRepository, repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repositoryV1 *repository.MockApiGatewayRepository, repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repositoryV1.On("ListAllDomainNames").Return([]*apigateway.DomainName{ {DomainName: awssdk.String("example.com")}, }, nil) @@ -1005,8 +1005,8 @@ func TestApiGatewayV2Mapping(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepoV1 := &repository2.MockApiGatewayRepository{} - fakeRepo := &repository2.MockApiGatewayV2Repository{} + fakeRepoV1 := &repository.MockApiGatewayRepository{} + fakeRepo := &repository.MockApiGatewayV2Repository{} c.mocks(fakeRepoV1, fakeRepo, alerter) remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2MappingEnumerator(fakeRepo, fakeRepoV1, factory)) @@ -1035,13 +1035,13 @@ func TestApiGatewayV2DomainName(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway v2 domain names", - mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDomainNames").Return([]*apigateway.DomainName{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -1050,7 +1050,7 @@ func TestApiGatewayV2DomainName(t *testing.T) { }, { test: "single api gateway v2 domain name", - mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDomainNames").Return([]*apigateway.DomainName{ {DomainName: awssdk.String("b8r351.example.com")}, }, nil) @@ -1064,7 +1064,7 @@ func TestApiGatewayV2DomainName(t *testing.T) { }, { test: "cannot list api gateway v2 domain names", - mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDomainNames").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayV2DomainNameResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2DomainNameResourceType, resourceaws.AwsApiGatewayV2DomainNameResourceType), alerts.EnumerationPhase)).Return() }, @@ -1084,10 +1084,10 @@ func TestApiGatewayV2DomainName(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayRepository{} + fakeRepo := &repository.MockApiGatewayRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayRepository = fakeRepo + var repo repository.ApiGatewayRepository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2DomainNameEnumerator(repo, factory)) @@ -1114,13 +1114,13 @@ func TestApiGatewayV2IntegrationResponse(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no api gateway v2 integration responses", - mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{ {ApiId: awssdk.String("yw28nwdf34")}, }, nil) @@ -1137,7 +1137,7 @@ func TestApiGatewayV2IntegrationResponse(t *testing.T) { }, { test: "single api gateway v2 integration with one integration response", - mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{ {ApiId: awssdk.String("yw28nwdf34")}, }, nil) @@ -1159,7 +1159,7 @@ func TestApiGatewayV2IntegrationResponse(t *testing.T) { }, { test: "cannot list api gateway v2 apis", - mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return(nil, dummyError) alerter.On("SendAlert", resourceaws.AwsApiGatewayV2IntegrationResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2IntegrationResponseResourceType), alerts.EnumerationPhase)).Return() }, @@ -1167,7 +1167,7 @@ func TestApiGatewayV2IntegrationResponse(t *testing.T) { }, { test: "cannot list api gateway v2 integrations", - mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{ {ApiId: awssdk.String("yw28nwdf34")}, }, nil) @@ -1178,7 +1178,7 @@ func TestApiGatewayV2IntegrationResponse(t *testing.T) { }, { test: "cannot list api gateway v2 integration responses", - mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return([]*apigatewayv2.Api{ {ApiId: awssdk.String("yw28nwdf34")}, }, nil) @@ -1205,10 +1205,10 @@ func TestApiGatewayV2IntegrationResponse(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockApiGatewayV2Repository{} + fakeRepo := &repository.MockApiGatewayV2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.ApiGatewayV2Repository = fakeRepo + var repo repository.ApiGatewayV2Repository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2IntegrationResponseEnumerator(repo, factory)) diff --git a/enumeration/remote/aws_applicationautoscaling_scanner_test.go b/enumeration/remote/aws_applicationautoscaling_scanner_test.go index 75ff488ea..3b159fcac 100644 --- a/enumeration/remote/aws_applicationautoscaling_scanner_test.go +++ b/enumeration/remote/aws_applicationautoscaling_scanner_test.go @@ -5,7 +5,7 @@ import ( "github.com/snyk/driftctl/enumeration" aws2 "github.com/snyk/driftctl/enumeration/remote/aws" - repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" common2 "github.com/snyk/driftctl/enumeration/remote/common" remoteerror "github.com/snyk/driftctl/enumeration/remote/error" @@ -31,13 +31,13 @@ func TestAppAutoScalingTarget(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockAppAutoScalingRepository, *mocks.AlerterInterface) + mocks func(*repository.MockAppAutoScalingRepository, *mocks.AlerterInterface) wantErr error }{ { test: "should return one target", dirName: "aws_appautoscaling_target_single", - mocks: func(client *repository2.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) { client.On("ServiceNamespaceValues").Return(applicationautoscaling.ServiceNamespace_Values()).Once() client.On("DescribeScalableTargets", "dynamodb").Return([]*applicationautoscaling.ScalableTarget{ @@ -58,7 +58,7 @@ func TestAppAutoScalingTarget(t *testing.T) { { test: "should return remote error", dirName: "aws_appautoscaling_target_single", - mocks: func(client *repository2.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) { client.On("ServiceNamespaceValues").Return(applicationautoscaling.ServiceNamespace_Values()).Once() client.On("DescribeScalableTargets", mock.AnythingOfType("string")).Return(nil, errors.New("remote error")).Once() @@ -86,10 +86,10 @@ func TestAppAutoScalingTarget(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockAppAutoScalingRepository{} + fakeRepo := &repository.MockAppAutoScalingRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.AppAutoScalingRepository = fakeRepo + var repo repository.AppAutoScalingRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -105,7 +105,7 @@ func TestAppAutoScalingTarget(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewAppAutoScalingRepository(sess, cache.New(0)) + repo = repository.NewAppAutoScalingRepository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewAppAutoscalingTargetEnumerator(repo, factory)) @@ -136,13 +136,13 @@ func TestAppAutoScalingPolicy(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockAppAutoScalingRepository, *mocks.AlerterInterface) + mocks func(*repository.MockAppAutoScalingRepository, *mocks.AlerterInterface) wantErr error }{ { test: "should return one policy", dirName: "aws_appautoscaling_policy_single", - mocks: func(client *repository2.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) { client.On("ServiceNamespaceValues").Return(applicationautoscaling.ServiceNamespace_Values()).Once() client.On("DescribeScalingPolicies", "dynamodb").Return([]*applicationautoscaling.ScalingPolicy{ @@ -161,7 +161,7 @@ func TestAppAutoScalingPolicy(t *testing.T) { { test: "should return remote error", dirName: "aws_appautoscaling_policy_single", - mocks: func(client *repository2.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) { client.On("ServiceNamespaceValues").Return(applicationautoscaling.ServiceNamespace_Values()).Once() client.On("DescribeScalingPolicies", mock.AnythingOfType("string")).Return(nil, errors.New("remote error")).Once() @@ -189,10 +189,10 @@ func TestAppAutoScalingPolicy(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockAppAutoScalingRepository{} + fakeRepo := &repository.MockAppAutoScalingRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.AppAutoScalingRepository = fakeRepo + var repo repository.AppAutoScalingRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -208,7 +208,7 @@ func TestAppAutoScalingPolicy(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewAppAutoScalingRepository(sess, cache.New(0)) + repo = repository.NewAppAutoScalingRepository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewAppAutoscalingPolicyEnumerator(repo, factory)) @@ -240,13 +240,13 @@ func TestAppAutoScalingScheduledAction(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockAppAutoScalingRepository, *mocks.AlerterInterface) + mocks func(*repository.MockAppAutoScalingRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "should return one scheduled action", - mocks: func(client *repository2.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) { matchServiceNamespaceFunc := func(ns string) bool { for _, n := range applicationautoscaling.ServiceNamespace_Values() { if n == ns { @@ -278,7 +278,7 @@ func TestAppAutoScalingScheduledAction(t *testing.T) { }, { test: "should return remote error", - mocks: func(client *repository2.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) { client.On("ServiceNamespaceValues").Return(applicationautoscaling.ServiceNamespace_Values()).Once() client.On("DescribeScheduledActions", mock.AnythingOfType("string")).Return(nil, dummyError).Once() @@ -302,10 +302,10 @@ func TestAppAutoScalingScheduledAction(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockAppAutoScalingRepository{} + fakeRepo := &repository.MockAppAutoScalingRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.AppAutoScalingRepository = fakeRepo + var repo repository.AppAutoScalingRepository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewAppAutoscalingScheduledActionEnumerator(repo, factory)) diff --git a/enumeration/remote/aws_autoscaling_scanner_test.go b/enumeration/remote/aws_autoscaling_scanner_test.go index acb411551..4dedb86fe 100644 --- a/enumeration/remote/aws_autoscaling_scanner_test.go +++ b/enumeration/remote/aws_autoscaling_scanner_test.go @@ -6,7 +6,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" "github.com/snyk/driftctl/enumeration/remote/aws" - repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" common2 "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/terraform" @@ -27,13 +27,13 @@ import ( func TestAutoscaling_LaunchConfiguration(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockAutoScalingRepository, *mocks.AlerterInterface) + mocks func(*repository.MockAutoScalingRepository, *mocks.AlerterInterface) assertExpected func(*testing.T, []*resource.Resource) wantErr error }{ { test: "no launch configuration", - mocks: func(repository *repository2.MockAutoScalingRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockAutoScalingRepository, alerter *mocks.AlerterInterface) { repository.On("DescribeLaunchConfigurations").Return([]*autoscaling.LaunchConfiguration{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -42,7 +42,7 @@ func TestAutoscaling_LaunchConfiguration(t *testing.T) { }, { test: "multiple launch configurations", - mocks: func(repository *repository2.MockAutoScalingRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockAutoScalingRepository, alerter *mocks.AlerterInterface) { repository.On("DescribeLaunchConfigurations").Return([]*autoscaling.LaunchConfiguration{ {LaunchConfigurationName: awssdk.String("web_config_1")}, {LaunchConfigurationName: awssdk.String("web_config_2")}, @@ -60,7 +60,7 @@ func TestAutoscaling_LaunchConfiguration(t *testing.T) { }, { test: "cannot list launch configurations", - mocks: func(repository *repository2.MockAutoScalingRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockAutoScalingRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("DescribeLaunchConfigurations").Return(nil, awsError) @@ -85,10 +85,10 @@ func TestAutoscaling_LaunchConfiguration(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockAutoScalingRepository{} + fakeRepo := &repository.MockAutoScalingRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.AutoScalingRepository = fakeRepo + var repo repository.AutoScalingRepository = fakeRepo remoteLibrary.AddEnumerator(aws.NewLaunchConfigurationEnumerator(repo, factory)) diff --git a/enumeration/remote/aws_cloudformation_scanner_test.go b/enumeration/remote/aws_cloudformation_scanner_test.go index c4bfba87e..5a7e588be 100644 --- a/enumeration/remote/aws_cloudformation_scanner_test.go +++ b/enumeration/remote/aws_cloudformation_scanner_test.go @@ -7,7 +7,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" "github.com/snyk/driftctl/enumeration/remote/aws" - repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" common2 "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" @@ -33,20 +33,20 @@ func TestCloudformationStack(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockCloudformationRepository, *mocks.AlerterInterface) + mocks func(*repository.MockCloudformationRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no cloudformation stacks", dirName: "aws_cloudformation_stack_empty", - mocks: func(repository *repository2.MockCloudformationRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockCloudformationRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllStacks").Return([]*cloudformation.Stack{}, nil) }, }, { test: "multiple cloudformation stacks", dirName: "aws_cloudformation_stack_multiple", - mocks: func(repository *repository2.MockCloudformationRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockCloudformationRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllStacks").Return([]*cloudformation.Stack{ {StackId: awssdk.String("arn:aws:cloudformation:us-east-1:047081014315:stack/bar-stack/c7a96e70-0f21-11ec-bd2a-0a2d95c2b2ab")}, {StackId: awssdk.String("arn:aws:cloudformation:us-east-1:047081014315:stack/foo-stack/c7aa0ab0-0f21-11ec-ba25-129d8c0b3757")}, @@ -56,7 +56,7 @@ func TestCloudformationStack(t *testing.T) { { test: "cannot list cloudformation stacks", dirName: "aws_cloudformation_stack_list", - mocks: func(repository *repository2.MockCloudformationRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockCloudformationRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 400, "") repository.On("ListAllStacks").Return(nil, awsError) @@ -85,10 +85,10 @@ func TestCloudformationStack(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockCloudformationRepository{} + fakeRepo := &repository.MockCloudformationRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.CloudformationRepository = fakeRepo + var repo repository.CloudformationRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -104,7 +104,7 @@ func TestCloudformationStack(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewCloudformationRepository(sess, cache.New(0)) + repo = repository.NewCloudformationRepository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws.NewCloudformationStackEnumerator(repo, factory)) diff --git a/enumeration/remote/aws_cloudfront_scanner_test.go b/enumeration/remote/aws_cloudfront_scanner_test.go index 39d8ac548..0521b1966 100644 --- a/enumeration/remote/aws_cloudfront_scanner_test.go +++ b/enumeration/remote/aws_cloudfront_scanner_test.go @@ -6,7 +6,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" "github.com/snyk/driftctl/enumeration/remote/aws" - repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" common2 "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" @@ -33,20 +33,20 @@ func TestCloudfrontDistribution(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockCloudfrontRepository, *mocks.AlerterInterface) + mocks func(*repository.MockCloudfrontRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no cloudfront distributions", dirName: "aws_cloudfront_distribution_empty", - mocks: func(repository *repository2.MockCloudfrontRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockCloudfrontRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDistributions").Return([]*cloudfront.DistributionSummary{}, nil) }, }, { test: "single cloudfront distribution", dirName: "aws_cloudfront_distribution_single", - mocks: func(repository *repository2.MockCloudfrontRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockCloudfrontRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDistributions").Return([]*cloudfront.DistributionSummary{ {Id: awssdk.String("E1M9CNS0XSHI19")}, }, nil) @@ -55,7 +55,7 @@ func TestCloudfrontDistribution(t *testing.T) { { test: "cannot list cloudfront distributions", dirName: "aws_cloudfront_distribution_list", - mocks: func(repository *repository2.MockCloudfrontRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockCloudfrontRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 400, "") repository.On("ListAllDistributions").Return(nil, awsError) @@ -84,10 +84,10 @@ func TestCloudfrontDistribution(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockCloudfrontRepository{} + fakeRepo := &repository.MockCloudfrontRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.CloudfrontRepository = fakeRepo + var repo repository.CloudfrontRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -103,7 +103,7 @@ func TestCloudfrontDistribution(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewCloudfrontRepository(sess, cache.New(0)) + repo = repository.NewCloudfrontRepository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws.NewCloudfrontDistributionEnumerator(repo, factory)) diff --git a/enumeration/remote/aws_dynamodb_scanner_test.go b/enumeration/remote/aws_dynamodb_scanner_test.go index 7c21587c1..6ed7272df 100644 --- a/enumeration/remote/aws_dynamodb_scanner_test.go +++ b/enumeration/remote/aws_dynamodb_scanner_test.go @@ -7,7 +7,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" "github.com/snyk/driftctl/enumeration/remote/aws" - repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" common2 "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" @@ -32,13 +32,13 @@ func TestDynamoDBTable(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockDynamoDBRepository, *mocks.AlerterInterface) + mocks func(*repository.MockDynamoDBRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no DynamoDB Table", dirName: "aws_dynamodb_table_empty", - mocks: func(client *repository2.MockDynamoDBRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockDynamoDBRepository, alerter *mocks.AlerterInterface) { client.On("ListAllTables").Return([]*string{}, nil) }, wantErr: nil, @@ -46,7 +46,7 @@ func TestDynamoDBTable(t *testing.T) { { test: "Multiple DynamoDB Table", dirName: "aws_dynamodb_table_multiple", - mocks: func(client *repository2.MockDynamoDBRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockDynamoDBRepository, alerter *mocks.AlerterInterface) { client.On("ListAllTables").Return([]*string{ awssdk.String("GameScores"), awssdk.String("example"), @@ -57,7 +57,7 @@ func TestDynamoDBTable(t *testing.T) { { test: "cannot list DynamoDB Table", dirName: "aws_dynamodb_table_list", - mocks: func(client *repository2.MockDynamoDBRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockDynamoDBRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 400, "") client.On("ListAllTables").Return(nil, awsError) @@ -86,10 +86,10 @@ func TestDynamoDBTable(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockDynamoDBRepository{} + fakeRepo := &repository.MockDynamoDBRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.DynamoDBRepository = fakeRepo + var repo repository.DynamoDBRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -105,7 +105,7 @@ func TestDynamoDBTable(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewDynamoDBRepository(sess, cache.New(0)) + repo = repository.NewDynamoDBRepository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws.NewDynamoDBTableEnumerator(repo, factory)) diff --git a/enumeration/remote/aws_ec2_scanner_test.go b/enumeration/remote/aws_ec2_scanner_test.go index 9ba6b9a45..2e91694b6 100644 --- a/enumeration/remote/aws_ec2_scanner_test.go +++ b/enumeration/remote/aws_ec2_scanner_test.go @@ -6,7 +6,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" aws2 "github.com/snyk/driftctl/enumeration/remote/aws" - repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" common2 "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" @@ -33,20 +33,20 @@ func TestEC2EbsVolume(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no volumes", dirName: "aws_ec2_ebs_volume_empty", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllVolumes").Return([]*ec2.Volume{}, nil) }, }, { test: "multiple volumes", dirName: "aws_ec2_ebs_volume_multiple", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllVolumes").Return([]*ec2.Volume{ {VolumeId: awssdk.String("vol-081c7272a57a09db1")}, {VolumeId: awssdk.String("vol-01ddc91d3d9d1318b")}, @@ -56,7 +56,7 @@ func TestEC2EbsVolume(t *testing.T) { { test: "cannot list volumes", dirName: "aws_ec2_ebs_volume_list", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllVolumes").Return(nil, awsError) @@ -85,10 +85,10 @@ func TestEC2EbsVolume(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockEC2Repository{} + fakeRepo := &repository.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.EC2Repository = fakeRepo + var repo repository.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -104,7 +104,7 @@ func TestEC2EbsVolume(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewEC2Repository(sess, cache.New(0)) + repo = repository.NewEC2Repository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewEC2EbsVolumeEnumerator(repo, factory)) @@ -130,20 +130,20 @@ func TestEC2EbsSnapshot(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no snapshots", dirName: "aws_ec2_ebs_snapshot_empty", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllSnapshots").Return([]*ec2.Snapshot{}, nil) }, }, { test: "multiple snapshots", dirName: "aws_ec2_ebs_snapshot_multiple", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllSnapshots").Return([]*ec2.Snapshot{ {SnapshotId: awssdk.String("snap-0c509a2a880d95a39")}, {SnapshotId: awssdk.String("snap-00672558cecd93a61")}, @@ -153,7 +153,7 @@ func TestEC2EbsSnapshot(t *testing.T) { { test: "cannot list snapshots", dirName: "aws_ec2_ebs_snapshot_list", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllSnapshots").Return(nil, awsError) @@ -182,10 +182,10 @@ func TestEC2EbsSnapshot(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockEC2Repository{} + fakeRepo := &repository.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.EC2Repository = fakeRepo + var repo repository.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -201,7 +201,7 @@ func TestEC2EbsSnapshot(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewEC2Repository(sess, cache.New(0)) + repo = repository.NewEC2Repository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewEC2EbsSnapshotEnumerator(repo, factory)) @@ -227,13 +227,13 @@ func TestEC2Eip(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no eips", dirName: "aws_ec2_eip_empty", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllAddresses").Return([]*ec2.Address{ {}, // Test Eip without AllocationId because it can happen (seen in sentry) }, nil) @@ -242,7 +242,7 @@ func TestEC2Eip(t *testing.T) { { test: "multiple eips", dirName: "aws_ec2_eip_multiple", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllAddresses").Return([]*ec2.Address{ {AllocationId: awssdk.String("eipalloc-017d5267e4dda73f1")}, {AllocationId: awssdk.String("eipalloc-0cf714dc097c992cc")}, @@ -252,7 +252,7 @@ func TestEC2Eip(t *testing.T) { { test: "cannot list eips", dirName: "aws_ec2_eip_list", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllAddresses").Return(nil, awsError) @@ -281,10 +281,10 @@ func TestEC2Eip(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockEC2Repository{} + fakeRepo := &repository.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.EC2Repository = fakeRepo + var repo repository.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -300,7 +300,7 @@ func TestEC2Eip(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewEC2Repository(sess, cache.New(0)) + repo = repository.NewEC2Repository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewEC2EipEnumerator(repo, factory)) @@ -326,20 +326,20 @@ func TestEC2Ami(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no amis", dirName: "aws_ec2_ami_empty", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllImages").Return([]*ec2.Image{}, nil) }, }, { test: "multiple amis", dirName: "aws_ec2_ami_multiple", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllImages").Return([]*ec2.Image{ {ImageId: awssdk.String("ami-03a578b46f4c3081b")}, {ImageId: awssdk.String("ami-025962fd8b456731f")}, @@ -349,7 +349,7 @@ func TestEC2Ami(t *testing.T) { { test: "cannot list ami", dirName: "aws_ec2_ami_list", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllImages").Return(nil, awsError) @@ -378,10 +378,10 @@ func TestEC2Ami(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockEC2Repository{} + fakeRepo := &repository.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.EC2Repository = fakeRepo + var repo repository.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -397,7 +397,7 @@ func TestEC2Ami(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewEC2Repository(sess, cache.New(0)) + repo = repository.NewEC2Repository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewEC2AmiEnumerator(repo, factory)) @@ -423,20 +423,20 @@ func TestEC2KeyPair(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no key pairs", dirName: "aws_ec2_key_pair_empty", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllKeyPairs").Return([]*ec2.KeyPairInfo{}, nil) }, }, { test: "multiple key pairs", dirName: "aws_ec2_key_pair_multiple", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllKeyPairs").Return([]*ec2.KeyPairInfo{ {KeyName: awssdk.String("test")}, {KeyName: awssdk.String("bar")}, @@ -446,7 +446,7 @@ func TestEC2KeyPair(t *testing.T) { { test: "cannot list key pairs", dirName: "aws_ec2_key_pair_list", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllKeyPairs").Return(nil, awsError) @@ -475,10 +475,10 @@ func TestEC2KeyPair(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockEC2Repository{} + fakeRepo := &repository.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.EC2Repository = fakeRepo + var repo repository.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -494,7 +494,7 @@ func TestEC2KeyPair(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewEC2Repository(sess, cache.New(0)) + repo = repository.NewEC2Repository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewEC2KeyPairEnumerator(repo, factory)) @@ -520,20 +520,20 @@ func TestEC2EipAssociation(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no eip associations", dirName: "aws_ec2_eip_association_empty", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllAddressesAssociation").Return([]*ec2.Address{}, nil) }, }, { test: "single eip association", dirName: "aws_ec2_eip_association_single", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllAddressesAssociation").Return([]*ec2.Address{ { AssociationId: awssdk.String("eipassoc-0e9a7356e30f0c3d1"), @@ -545,7 +545,7 @@ func TestEC2EipAssociation(t *testing.T) { { test: "cannot list eip associations", dirName: "aws_ec2_eip_association_list", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllAddressesAssociation").Return(nil, awsError) @@ -574,10 +574,10 @@ func TestEC2EipAssociation(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockEC2Repository{} + fakeRepo := &repository.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.EC2Repository = fakeRepo + var repo repository.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -593,7 +593,7 @@ func TestEC2EipAssociation(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewEC2Repository(sess, cache.New(0)) + repo = repository.NewEC2Repository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewEC2EipAssociationEnumerator(repo, factory)) @@ -619,20 +619,20 @@ func TestEC2Instance(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no instances", dirName: "aws_ec2_instance_empty", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllInstances").Return([]*ec2.Instance{}, nil) }, }, { test: "multiple instances", dirName: "aws_ec2_instance_multiple", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllInstances").Return([]*ec2.Instance{ {InstanceId: awssdk.String("i-0d3650a23f4e45dc0")}, {InstanceId: awssdk.String("i-010376047a71419f1")}, @@ -642,7 +642,7 @@ func TestEC2Instance(t *testing.T) { { test: "terminated instances", dirName: "aws_ec2_instance_terminated", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllInstances").Return([]*ec2.Instance{ {InstanceId: awssdk.String("i-0e1543baf4f2cd990")}, {InstanceId: awssdk.String("i-0a3a7ed51ae2b4fa0")}, // Nil @@ -652,7 +652,7 @@ func TestEC2Instance(t *testing.T) { { test: "cannot list instances", dirName: "aws_ec2_instance_list", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllInstances").Return(nil, awsError) @@ -681,10 +681,10 @@ func TestEC2Instance(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockEC2Repository{} + fakeRepo := &repository.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.EC2Repository = fakeRepo + var repo repository.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -700,7 +700,7 @@ func TestEC2Instance(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewEC2Repository(sess, cache.New(0)) + repo = repository.NewEC2Repository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewEC2InstanceEnumerator(repo, factory)) @@ -726,20 +726,20 @@ func TestEC2InternetGateway(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no internet gateways", dirName: "aws_ec2_internet_gateway_empty", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllInternetGateways").Return([]*ec2.InternetGateway{}, nil) }, }, { test: "multiple internet gateways", dirName: "aws_ec2_internet_gateway_multiple", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllInternetGateways").Return([]*ec2.InternetGateway{ {InternetGatewayId: awssdk.String("igw-0184eb41aadc62d1c")}, {InternetGatewayId: awssdk.String("igw-047b487f5c60fca99")}, @@ -749,7 +749,7 @@ func TestEC2InternetGateway(t *testing.T) { { test: "cannot list internet gateways", dirName: "aws_ec2_internet_gateway_list", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllInternetGateways").Return(nil, awsError) @@ -778,10 +778,10 @@ func TestEC2InternetGateway(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockEC2Repository{} + fakeRepo := &repository.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.EC2Repository = fakeRepo + var repo repository.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -797,7 +797,7 @@ func TestEC2InternetGateway(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewEC2Repository(sess, cache.New(0)) + repo = repository.NewEC2Repository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewEC2InternetGatewayEnumerator(repo, factory)) @@ -824,13 +824,13 @@ func TestVPC(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no VPC", dirName: "aws_vpc_empty", - mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { client.On("ListAllVPCs").Once().Return([]*ec2.Vpc{}, []*ec2.Vpc{}, nil) }, wantErr: nil, @@ -838,7 +838,7 @@ func TestVPC(t *testing.T) { { test: "VPC results", dirName: "aws_vpc", - mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { client.On("ListAllVPCs").Once().Return([]*ec2.Vpc{ { VpcId: awssdk.String("vpc-0768e1fd0029e3fc3"), @@ -863,7 +863,7 @@ func TestVPC(t *testing.T) { { test: "cannot list VPC", dirName: "aws_vpc_empty", - mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllVPCs").Once().Return(nil, nil, awsError) @@ -892,10 +892,10 @@ func TestVPC(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockEC2Repository{} + fakeRepo := &repository.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.EC2Repository = fakeRepo + var repo repository.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -911,7 +911,7 @@ func TestVPC(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewEC2Repository(sess, cache.New(0)) + repo = repository.NewEC2Repository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewVPCEnumerator(repo, factory)) @@ -938,13 +938,13 @@ func TestDefaultVPC(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no VPC", dirName: "aws_vpc_empty", - mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { client.On("ListAllVPCs").Once().Return([]*ec2.Vpc{}, []*ec2.Vpc{}, nil) }, wantErr: nil, @@ -952,7 +952,7 @@ func TestDefaultVPC(t *testing.T) { { test: "default VPC results", dirName: "aws_default_vpc", - mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { client.On("ListAllVPCs").Once().Return([]*ec2.Vpc{ { VpcId: awssdk.String("vpc-0768e1fd0029e3fc3"), @@ -974,7 +974,7 @@ func TestDefaultVPC(t *testing.T) { { test: "cannot list VPC", dirName: "aws_vpc_empty", - mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllVPCs").Once().Return(nil, nil, awsError) @@ -1003,10 +1003,10 @@ func TestDefaultVPC(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockEC2Repository{} + fakeRepo := &repository.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.EC2Repository = fakeRepo + var repo repository.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -1022,7 +1022,7 @@ func TestDefaultVPC(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewEC2Repository(sess, cache.New(0)) + repo = repository.NewEC2Repository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewDefaultVPCEnumerator(repo, factory)) @@ -1048,13 +1048,13 @@ func TestEC2RouteTableAssociation(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no route table associations (test for nil values)", dirName: "aws_ec2_route_table_association_empty", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return([]*ec2.RouteTable{ { RouteTableId: awssdk.String("assoc_with_nil"), @@ -1076,7 +1076,7 @@ func TestEC2RouteTableAssociation(t *testing.T) { { test: "multiple route table associations (mixed subnet and gateway associations)", dirName: "aws_ec2_route_table_association_multiple", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return([]*ec2.RouteTable{ { RouteTableId: awssdk.String("rtb-05aa6c5673311a17b"), // route @@ -1140,7 +1140,7 @@ func TestEC2RouteTableAssociation(t *testing.T) { { test: "cannot list route table associations", dirName: "aws_ec2_route_table_association_list", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllRouteTables").Return(nil, awsError) @@ -1169,10 +1169,10 @@ func TestEC2RouteTableAssociation(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockEC2Repository{} + fakeRepo := &repository.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.EC2Repository = fakeRepo + var repo repository.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -1188,7 +1188,7 @@ func TestEC2RouteTableAssociation(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewEC2Repository(sess, cache.New(0)) + repo = repository.NewEC2Repository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewEC2RouteTableAssociationEnumerator(repo, factory)) @@ -1214,20 +1214,20 @@ func TestEC2Subnet(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no subnets", dirName: "aws_ec2_subnet_empty", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllSubnets").Return([]*ec2.Subnet{}, []*ec2.Subnet{}, nil) }, }, { test: "multiple subnets", dirName: "aws_ec2_subnet_multiple", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllSubnets").Return([]*ec2.Subnet{ { SubnetId: awssdk.String("subnet-05810d3f933925f6d"), // subnet1 @@ -1260,7 +1260,7 @@ func TestEC2Subnet(t *testing.T) { { test: "cannot list subnets", dirName: "aws_ec2_subnet_list", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllSubnets").Return(nil, nil, awsError) @@ -1289,10 +1289,10 @@ func TestEC2Subnet(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockEC2Repository{} + fakeRepo := &repository.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.EC2Repository = fakeRepo + var repo repository.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -1308,7 +1308,7 @@ func TestEC2Subnet(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewEC2Repository(sess, cache.New(0)) + repo = repository.NewEC2Repository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewEC2SubnetEnumerator(repo, factory)) @@ -1334,20 +1334,20 @@ func TestEC2DefaultSubnet(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no default subnets", dirName: "aws_ec2_default_subnet_empty", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllSubnets").Return([]*ec2.Subnet{}, []*ec2.Subnet{}, nil) }, }, { test: "multiple default subnets", dirName: "aws_ec2_default_subnet_multiple", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllSubnets").Return([]*ec2.Subnet{ { SubnetId: awssdk.String("subnet-05810d3f933925f6d"), // subnet1 @@ -1380,7 +1380,7 @@ func TestEC2DefaultSubnet(t *testing.T) { { test: "cannot list default subnets", dirName: "aws_ec2_default_subnet_list", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllSubnets").Return(nil, nil, awsError) @@ -1409,10 +1409,10 @@ func TestEC2DefaultSubnet(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockEC2Repository{} + fakeRepo := &repository.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.EC2Repository = fakeRepo + var repo repository.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -1428,7 +1428,7 @@ func TestEC2DefaultSubnet(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewEC2Repository(sess, cache.New(0)) + repo = repository.NewEC2Repository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewEC2DefaultSubnetEnumerator(repo, factory)) @@ -1454,20 +1454,20 @@ func TestEC2RouteTable(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no route tables", dirName: "aws_ec2_route_table_empty", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return([]*ec2.RouteTable{}, nil) }, }, { test: "multiple route tables", dirName: "aws_ec2_route_table_multiple", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return([]*ec2.RouteTable{ {RouteTableId: awssdk.String("rtb-08b7b71af15e183ce")}, // table1 {RouteTableId: awssdk.String("rtb-0002ac731f6fdea55")}, // table2 @@ -1487,7 +1487,7 @@ func TestEC2RouteTable(t *testing.T) { { test: "cannot list route tables", dirName: "aws_ec2_route_table_list", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllRouteTables").Return(nil, awsError) @@ -1516,10 +1516,10 @@ func TestEC2RouteTable(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockEC2Repository{} + fakeRepo := &repository.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.EC2Repository = fakeRepo + var repo repository.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -1535,7 +1535,7 @@ func TestEC2RouteTable(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewEC2Repository(sess, cache.New(0)) + repo = repository.NewEC2Repository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewEC2RouteTableEnumerator(repo, factory)) @@ -1561,20 +1561,20 @@ func TestEC2DefaultRouteTable(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no default route tables", dirName: "aws_ec2_default_route_table_empty", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return([]*ec2.RouteTable{}, nil) }, }, { test: "multiple default route tables", dirName: "aws_ec2_default_route_table_single", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return([]*ec2.RouteTable{ {RouteTableId: awssdk.String("rtb-08b7b71af15e183ce")}, // table1 {RouteTableId: awssdk.String("rtb-0002ac731f6fdea55")}, // table2 @@ -1594,7 +1594,7 @@ func TestEC2DefaultRouteTable(t *testing.T) { { test: "cannot list default route tables", dirName: "aws_ec2_default_route_table_list", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllRouteTables").Return(nil, awsError) @@ -1623,10 +1623,10 @@ func TestEC2DefaultRouteTable(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockEC2Repository{} + fakeRepo := &repository.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.EC2Repository = fakeRepo + var repo repository.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -1642,7 +1642,7 @@ func TestEC2DefaultRouteTable(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewEC2Repository(sess, cache.New(0)) + repo = repository.NewEC2Repository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewEC2DefaultRouteTableEnumerator(repo, factory)) @@ -1669,13 +1669,13 @@ func TestVpcSecurityGroup(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no security groups", dirName: "aws_vpc_security_group_empty", - mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { client.On("ListAllSecurityGroups").Once().Return([]*ec2.SecurityGroup{}, []*ec2.SecurityGroup{}, nil) }, wantErr: nil, @@ -1683,7 +1683,7 @@ func TestVpcSecurityGroup(t *testing.T) { { test: "with security groups", dirName: "aws_vpc_security_group_multiple", - mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { client.On("ListAllSecurityGroups").Once().Return([]*ec2.SecurityGroup{ { GroupId: awssdk.String("sg-0254c038e32f25530"), @@ -1701,7 +1701,7 @@ func TestVpcSecurityGroup(t *testing.T) { { test: "cannot list security groups", dirName: "aws_vpc_security_group_empty", - mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllSecurityGroups").Return(nil, nil, awsError) @@ -1730,10 +1730,10 @@ func TestVpcSecurityGroup(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockEC2Repository{} + fakeRepo := &repository.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.EC2Repository = fakeRepo + var repo repository.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -1749,7 +1749,7 @@ func TestVpcSecurityGroup(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewEC2Repository(sess, cache.New(0)) + repo = repository.NewEC2Repository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewVPCSecurityGroupEnumerator(repo, factory)) @@ -1776,13 +1776,13 @@ func TestVpcDefaultSecurityGroup(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no security groups", dirName: "aws_vpc_default_security_group_empty", - mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { client.On("ListAllSecurityGroups").Once().Return([]*ec2.SecurityGroup{}, []*ec2.SecurityGroup{}, nil) }, wantErr: nil, @@ -1790,7 +1790,7 @@ func TestVpcDefaultSecurityGroup(t *testing.T) { { test: "with security groups", dirName: "aws_vpc_default_security_group_multiple", - mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { client.On("ListAllSecurityGroups").Once().Return([]*ec2.SecurityGroup{ { GroupId: awssdk.String("sg-0254c038e32f25530"), @@ -1808,7 +1808,7 @@ func TestVpcDefaultSecurityGroup(t *testing.T) { { test: "cannot list security groups", dirName: "aws_vpc_default_security_group_empty", - mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllSecurityGroups").Return(nil, nil, awsError) @@ -1837,10 +1837,10 @@ func TestVpcDefaultSecurityGroup(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockEC2Repository{} + fakeRepo := &repository.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.EC2Repository = fakeRepo + var repo repository.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -1856,7 +1856,7 @@ func TestVpcDefaultSecurityGroup(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewEC2Repository(sess, cache.New(0)) + repo = repository.NewEC2Repository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewVPCDefaultSecurityGroupEnumerator(repo, factory)) @@ -1882,20 +1882,20 @@ func TestEC2NatGateway(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no nat gateways", dirName: "aws_ec2_nat_gateway_empty", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllNatGateways").Return([]*ec2.NatGateway{}, nil) }, }, { test: "single nat gateway", dirName: "aws_ec2_nat_gateway_single", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllNatGateways").Return([]*ec2.NatGateway{ {NatGatewayId: awssdk.String("nat-0a5408508b19ef490")}, }, nil) @@ -1904,7 +1904,7 @@ func TestEC2NatGateway(t *testing.T) { { test: "cannot list nat gateways", dirName: "aws_ec2_nat_gateway_list", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllNatGateways").Return(nil, awsError) @@ -1933,10 +1933,10 @@ func TestEC2NatGateway(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockEC2Repository{} + fakeRepo := &repository.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.EC2Repository = fakeRepo + var repo repository.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -1952,7 +1952,7 @@ func TestEC2NatGateway(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewEC2Repository(sess, cache.New(0)) + repo = repository.NewEC2Repository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewEC2NatGatewayEnumerator(repo, factory)) @@ -1978,20 +1978,20 @@ func TestEC2NetworkACL(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no network ACL", dirName: "aws_ec2_network_acl_empty", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllNetworkACLs").Return([]*ec2.NetworkAcl{}, nil) }, }, { test: "network acl", dirName: "aws_ec2_network_acl", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllNetworkACLs").Return([]*ec2.NetworkAcl{ { NetworkAclId: awssdk.String("acl-043880b4682d2366b"), @@ -2011,7 +2011,7 @@ func TestEC2NetworkACL(t *testing.T) { { test: "cannot list network acl", dirName: "aws_ec2_network_acl_empty", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllNetworkACLs").Return(nil, awsError) @@ -2051,10 +2051,10 @@ func TestEC2NetworkACL(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockEC2Repository{} + fakeRepo := &repository.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.EC2Repository = fakeRepo + var repo repository.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -2070,7 +2070,7 @@ func TestEC2NetworkACL(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewEC2Repository(sess, cache.New(0)) + repo = repository.NewEC2Repository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewEC2NetworkACLEnumerator(repo, factory)) @@ -2096,20 +2096,20 @@ func TestEC2NetworkACLRule(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no network ACL", dirName: "aws_ec2_network_acl_rule_empty", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllNetworkACLs").Return([]*ec2.NetworkAcl{}, nil) }, }, { test: "network acl rules", dirName: "aws_ec2_network_acl_rule", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllNetworkACLs").Return([]*ec2.NetworkAcl{ { NetworkAclId: awssdk.String("acl-0ad6d657494d17ee2"), // test @@ -2164,7 +2164,7 @@ func TestEC2NetworkACLRule(t *testing.T) { { test: "cannot list network acl", dirName: "aws_ec2_network_acl_rule_empty", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllNetworkACLs").Return(nil, awsError) @@ -2201,10 +2201,10 @@ func TestEC2NetworkACLRule(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockEC2Repository{} + fakeRepo := &repository.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.EC2Repository = fakeRepo + var repo repository.EC2Repository = fakeRepo providerVersion := version realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -2245,13 +2245,13 @@ func TestEC2DefaultNetworkACL(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no network ACL", dirName: "aws_ec2_default_network_acl_empty", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllNetworkACLs").Return([]*ec2.NetworkAcl{}, nil) }, }, @@ -2278,7 +2278,7 @@ func TestEC2DefaultNetworkACL(t *testing.T) { { test: "cannot list default network acl", dirName: "aws_ec2_default_network_acl_empty", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllNetworkACLs").Return(nil, awsError) @@ -2318,10 +2318,10 @@ func TestEC2DefaultNetworkACL(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockEC2Repository{} + fakeRepo := &repository.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.EC2Repository = fakeRepo + var repo repository.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -2337,7 +2337,7 @@ func TestEC2DefaultNetworkACL(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewEC2Repository(sess, cache.New(0)) + repo = repository.NewEC2Repository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewEC2DefaultNetworkACLEnumerator(repo, factory)) @@ -2363,7 +2363,7 @@ func TestEC2Route(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { @@ -2371,14 +2371,14 @@ func TestEC2Route(t *testing.T) { // as a default route will always be present in each route table test: "no routes", dirName: "aws_ec2_route_empty", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return([]*ec2.RouteTable{}, nil) }, }, { test: "multiple routes (mixed default_route_table and route_table)", dirName: "aws_ec2_route_multiple", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return([]*ec2.RouteTable{ { RouteTableId: awssdk.String("rtb-096bdfb69309c54c3"), // table1 @@ -2458,7 +2458,7 @@ func TestEC2Route(t *testing.T) { { test: "cannot list routes", dirName: "aws_ec2_route_list", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllRouteTables").Return(nil, awsError) @@ -2487,10 +2487,10 @@ func TestEC2Route(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockEC2Repository{} + fakeRepo := &repository.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.EC2Repository = fakeRepo + var repo repository.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -2506,7 +2506,7 @@ func TestEC2Route(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewEC2Repository(sess, cache.New(0)) + repo = repository.NewEC2Repository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewEC2RouteEnumerator(repo, factory)) @@ -2533,13 +2533,13 @@ func TestVpcSecurityGroupRule(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no security group rules", dirName: "aws_vpc_security_group_rule_empty", - mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { client.On("ListAllSecurityGroups").Once().Return([]*ec2.SecurityGroup{ { GroupId: awssdk.String("sg-0254c038e32f25530"), @@ -2553,7 +2553,7 @@ func TestVpcSecurityGroupRule(t *testing.T) { { test: "with security group rules", dirName: "aws_vpc_security_group_rule_multiple", - mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { client.On("ListAllSecurityGroups").Once().Return([]*ec2.SecurityGroup{ { GroupId: awssdk.String("sg-0254c038e32f25530"), @@ -2649,7 +2649,7 @@ func TestVpcSecurityGroupRule(t *testing.T) { { test: "cannot list security group rules", dirName: "aws_vpc_security_group_rule_empty", - mocks: func(client *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllSecurityGroups").Once().Return(nil, nil, awsError) @@ -2678,10 +2678,10 @@ func TestVpcSecurityGroupRule(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockEC2Repository{} + fakeRepo := &repository.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.EC2Repository = fakeRepo + var repo repository.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -2697,7 +2697,7 @@ func TestVpcSecurityGroupRule(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewEC2Repository(sess, cache.New(0)) + repo = repository.NewEC2Repository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewVPCSecurityGroupRuleEnumerator(repo, factory)) @@ -2723,20 +2723,20 @@ func TestEC2LaunchTemplate(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no launch template", dirName: "aws_launch_template", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("DescribeLaunchTemplates").Return([]*ec2.LaunchTemplate{}, nil) }, }, { test: "multiple launch templates", dirName: "aws_launch_template_multiple", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { launchTemplates := []*ec2.LaunchTemplate{ {LaunchTemplateId: awssdk.String("lt-0ed993d09ce6afc67"), LatestVersionNumber: awssdk.Int64(1)}, {LaunchTemplateId: awssdk.String("lt-00b2d18c6cee7fe23"), LatestVersionNumber: awssdk.Int64(1)}, @@ -2748,7 +2748,7 @@ func TestEC2LaunchTemplate(t *testing.T) { { test: "cannot list launch templates", dirName: "aws_launch_template", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("DescribeLaunchTemplates").Return(nil, awsError) @@ -2777,10 +2777,10 @@ func TestEC2LaunchTemplate(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockEC2Repository{} + fakeRepo := &repository.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.EC2Repository = fakeRepo + var repo repository.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -2796,7 +2796,7 @@ func TestEC2LaunchTemplate(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewEC2Repository(sess, cache.New(0)) + repo = repository.NewEC2Repository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewLaunchTemplateEnumerator(repo, factory)) @@ -2823,20 +2823,20 @@ func TestEC2EbsEncryptionByDefault(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockEC2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockEC2Repository, *mocks.AlerterInterface) wantErr error }{ { test: "no encryption by default resource", dirName: "aws_ebs_encryption_by_default_list", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { repository.On("IsEbsEncryptionEnabledByDefault").Return(false, nil) }, }, { test: "cannot list encryption by default resources", dirName: "aws_ebs_encryption_by_default_error", - mocks: func(repository *repository2.MockEC2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockEC2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("IsEbsEncryptionEnabledByDefault").Return(false, awsError) @@ -2865,10 +2865,10 @@ func TestEC2EbsEncryptionByDefault(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockEC2Repository{} + fakeRepo := &repository.MockEC2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.EC2Repository = fakeRepo + var repo repository.EC2Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -2884,7 +2884,7 @@ func TestEC2EbsEncryptionByDefault(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewEC2Repository(sess, cache.New(0)) + repo = repository.NewEC2Repository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewEC2EbsEncryptionByDefaultEnumerator(repo, factory)) diff --git a/enumeration/remote/aws_ecr_scanner_test.go b/enumeration/remote/aws_ecr_scanner_test.go index 3f4b7e46e..ad914a40c 100644 --- a/enumeration/remote/aws_ecr_scanner_test.go +++ b/enumeration/remote/aws_ecr_scanner_test.go @@ -6,7 +6,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" aws2 "github.com/snyk/driftctl/enumeration/remote/aws" - repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" common2 "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" @@ -33,13 +33,13 @@ func TestECRRepository(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockECRRepository, *mocks.AlerterInterface) + mocks func(*repository.MockECRRepository, *mocks.AlerterInterface) err error }{ { test: "no repository", dirName: "aws_ecr_repository_empty", - mocks: func(client *repository2.MockECRRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockECRRepository, alerter *mocks.AlerterInterface) { client.On("ListAllRepositories").Return([]*ecr.Repository{}, nil) }, err: nil, @@ -47,7 +47,7 @@ func TestECRRepository(t *testing.T) { { test: "multiple repositories", dirName: "aws_ecr_repository_multiple", - mocks: func(client *repository2.MockECRRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockECRRepository, alerter *mocks.AlerterInterface) { client.On("ListAllRepositories").Return([]*ecr.Repository{ {RepositoryName: awssdk.String("test_ecr")}, {RepositoryName: awssdk.String("bar")}, @@ -58,7 +58,7 @@ func TestECRRepository(t *testing.T) { { test: "cannot list repository", dirName: "aws_ecr_repository_empty", - mocks: func(client *repository2.MockECRRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockECRRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllRepositories").Return(nil, awsError) @@ -87,10 +87,10 @@ func TestECRRepository(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockECRRepository{} + fakeRepo := &repository.MockECRRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.ECRRepository = fakeRepo + var repo repository.ECRRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -106,7 +106,7 @@ func TestECRRepository(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewECRRepository(sess, cache.New(0)) + repo = repository.NewECRRepository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewECRRepositoryEnumerator(repo, factory)) @@ -131,13 +131,13 @@ func TestECRRepository(t *testing.T) { func TestECRRepositoryPolicy(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockECRRepository, *mocks.AlerterInterface) + mocks func(*repository.MockECRRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) err error }{ { test: "single repository policy", - mocks: func(client *repository2.MockECRRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockECRRepository, alerter *mocks.AlerterInterface) { client.On("ListAllRepositories").Return([]*ecr.Repository{ {RepositoryName: awssdk.String("test_ecr_repo_policy")}, {RepositoryName: awssdk.String("test_ecr_repo_without_policy")}, @@ -173,10 +173,10 @@ func TestECRRepositoryPolicy(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockECRRepository{} + fakeRepo := &repository.MockECRRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.ECRRepository = fakeRepo + var repo repository.ECRRepository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewECRRepositoryPolicyEnumerator(repo, factory)) diff --git a/enumeration/remote/aws_elasticache_scanner_test.go b/enumeration/remote/aws_elasticache_scanner_test.go index 299a6d2f6..ec4b72f8d 100644 --- a/enumeration/remote/aws_elasticache_scanner_test.go +++ b/enumeration/remote/aws_elasticache_scanner_test.go @@ -7,7 +7,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" "github.com/snyk/driftctl/enumeration/remote/aws" - repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" common2 "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/terraform" @@ -29,13 +29,13 @@ func TestElastiCacheCluster(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockElastiCacheRepository, *mocks.AlerterInterface) + mocks func(*repository.MockElastiCacheRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no elasticache clusters", - mocks: func(repository *repository2.MockElastiCacheRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockElastiCacheRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllCacheClusters").Return([]*elasticache.CacheCluster{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -44,7 +44,7 @@ func TestElastiCacheCluster(t *testing.T) { }, { test: "should list elasticache clusters", - mocks: func(repository *repository2.MockElastiCacheRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockElastiCacheRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllCacheClusters").Return([]*elasticache.CacheCluster{ {CacheClusterId: awssdk.String("cluster-foo")}, }, nil) @@ -57,7 +57,7 @@ func TestElastiCacheCluster(t *testing.T) { }, { test: "cannot list elasticache clusters (403)", - mocks: func(repository *repository2.MockElastiCacheRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockElastiCacheRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllCacheClusters").Return(nil, awsError) alerter.On("SendAlert", resourceaws.AwsElastiCacheClusterResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsElastiCacheClusterResourceType, resourceaws.AwsElastiCacheClusterResourceType), alerts.EnumerationPhase)).Return() @@ -68,7 +68,7 @@ func TestElastiCacheCluster(t *testing.T) { }, { test: "cannot list elasticache clusters (dummy error)", - mocks: func(repository *repository2.MockElastiCacheRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockElastiCacheRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllCacheClusters").Return(nil, dummyError) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -90,10 +90,10 @@ func TestElastiCacheCluster(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockElastiCacheRepository{} + fakeRepo := &repository.MockElastiCacheRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.ElastiCacheRepository = fakeRepo + var repo repository.ElastiCacheRepository = fakeRepo remoteLibrary.AddEnumerator(aws.NewElastiCacheClusterEnumerator(repo, factory)) diff --git a/enumeration/remote/aws_elb_scanner_test.go b/enumeration/remote/aws_elb_scanner_test.go index f4ae592eb..4122bfb1f 100644 --- a/enumeration/remote/aws_elb_scanner_test.go +++ b/enumeration/remote/aws_elb_scanner_test.go @@ -7,7 +7,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" "github.com/snyk/driftctl/enumeration/remote/aws" - repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" common2 "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/terraform" @@ -29,13 +29,13 @@ func TestELB_LoadBalancer(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockELBRepository, *mocks.AlerterInterface) + mocks func(*repository.MockELBRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no load balancer", - mocks: func(repository *repository2.MockELBRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockELBRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllLoadBalancers").Return([]*elb.LoadBalancerDescription{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -44,7 +44,7 @@ func TestELB_LoadBalancer(t *testing.T) { }, { test: "should list load balancers", - mocks: func(repository *repository2.MockELBRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockELBRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllLoadBalancers").Return([]*elb.LoadBalancerDescription{ { LoadBalancerName: awssdk.String("acc-test-lb-tf"), @@ -59,7 +59,7 @@ func TestELB_LoadBalancer(t *testing.T) { }, { test: "cannot list load balancers", - mocks: func(repository *repository2.MockELBRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockELBRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllLoadBalancers").Return(nil, awsError) @@ -71,7 +71,7 @@ func TestELB_LoadBalancer(t *testing.T) { }, { test: "cannot list load balancers (dummy error)", - mocks: func(repository *repository2.MockELBRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockELBRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllLoadBalancers").Return(nil, dummyError) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -93,10 +93,10 @@ func TestELB_LoadBalancer(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockELBRepository{} + fakeRepo := &repository.MockELBRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.ELBRepository = fakeRepo + var repo repository.ELBRepository = fakeRepo remoteLibrary.AddEnumerator(aws.NewClassicLoadBalancerEnumerator(repo, factory)) diff --git a/enumeration/remote/aws_elbv2_scanner_test.go b/enumeration/remote/aws_elbv2_scanner_test.go index a59d53f71..80739fe4d 100644 --- a/enumeration/remote/aws_elbv2_scanner_test.go +++ b/enumeration/remote/aws_elbv2_scanner_test.go @@ -7,7 +7,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" aws2 "github.com/snyk/driftctl/enumeration/remote/aws" - repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" common2 "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/terraform" @@ -29,13 +29,13 @@ func TestELBV2_LoadBalancer(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockELBV2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockELBV2Repository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no load balancer", - mocks: func(repository *repository2.MockELBV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllLoadBalancers").Return([]*elbv2.LoadBalancer{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -44,7 +44,7 @@ func TestELBV2_LoadBalancer(t *testing.T) { }, { test: "should list load balancers", - mocks: func(repository *repository2.MockELBV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllLoadBalancers").Return([]*elbv2.LoadBalancer{ { LoadBalancerArn: awssdk.String("arn:aws:elasticloadbalancing:us-east-1:533948124879:loadbalancer/app/acc-test-lb-tf/9114c60e08560420"), @@ -60,7 +60,7 @@ func TestELBV2_LoadBalancer(t *testing.T) { }, { test: "cannot list load balancers (403)", - mocks: func(repository *repository2.MockELBV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllLoadBalancers").Return(nil, awsError) @@ -72,7 +72,7 @@ func TestELBV2_LoadBalancer(t *testing.T) { }, { test: "cannot list load balancers (dummy error)", - mocks: func(repository *repository2.MockELBV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllLoadBalancers").Return(nil, dummyError) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -94,10 +94,10 @@ func TestELBV2_LoadBalancer(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockELBV2Repository{} + fakeRepo := &repository.MockELBV2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.ELBV2Repository = fakeRepo + var repo repository.ELBV2Repository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewLoadBalancerEnumerator(repo, factory)) @@ -123,13 +123,13 @@ func TestELBV2_LoadBalancerListener(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockELBV2Repository, *mocks.AlerterInterface) + mocks func(*repository.MockELBV2Repository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no load balancer listener", - mocks: func(repository *repository2.MockELBV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllLoadBalancers").Return([]*elbv2.LoadBalancer{ { LoadBalancerArn: awssdk.String("test-lb"), @@ -143,7 +143,7 @@ func TestELBV2_LoadBalancerListener(t *testing.T) { }, { test: "should list load balancer listener", - mocks: func(repository *repository2.MockELBV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllLoadBalancers").Return([]*elbv2.LoadBalancer{ { LoadBalancerArn: awssdk.String("test-lb"), @@ -164,7 +164,7 @@ func TestELBV2_LoadBalancerListener(t *testing.T) { }, { test: "cannot list load balancer listeners (403)", - mocks: func(repository *repository2.MockELBV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllLoadBalancers").Return([]*elbv2.LoadBalancer{ { LoadBalancerArn: awssdk.String("test-lb"), @@ -182,7 +182,7 @@ func TestELBV2_LoadBalancerListener(t *testing.T) { }, { test: "cannot list load balancers (403)", - mocks: func(repository *repository2.MockELBV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllLoadBalancers").Return(nil, awsError) @@ -194,7 +194,7 @@ func TestELBV2_LoadBalancerListener(t *testing.T) { }, { test: "cannot list load balancer listeners (dummy error)", - mocks: func(repository *repository2.MockELBV2Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllLoadBalancers").Return([]*elbv2.LoadBalancer{ { LoadBalancerArn: awssdk.String("test-lb"), @@ -222,10 +222,10 @@ func TestELBV2_LoadBalancerListener(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockELBV2Repository{} + fakeRepo := &repository.MockELBV2Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.ELBV2Repository = fakeRepo + var repo repository.ELBV2Repository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewLoadBalancerListenerEnumerator(repo, factory)) diff --git a/enumeration/remote/aws_iam_scanner_test.go b/enumeration/remote/aws_iam_scanner_test.go index 78adf7758..b157de257 100644 --- a/enumeration/remote/aws_iam_scanner_test.go +++ b/enumeration/remote/aws_iam_scanner_test.go @@ -6,7 +6,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" aws2 "github.com/snyk/driftctl/enumeration/remote/aws" - repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" common2 "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" @@ -34,13 +34,13 @@ func TestIamUser(t *testing.T) { cases := []struct { test string dirName string - mocks func(*repository2.MockIAMRepository, *mocks.AlerterInterface) + mocks func(*repository.MockIAMRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no iam user", dirName: "aws_iam_user_empty", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllUsers").Return([]*iam.User{}, nil) }, wantErr: nil, @@ -48,7 +48,7 @@ func TestIamUser(t *testing.T) { { test: "iam multiples users", dirName: "aws_iam_user_multiple", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllUsers").Return([]*iam.User{ { UserName: aws.String("test-driftctl-0"), @@ -66,7 +66,7 @@ func TestIamUser(t *testing.T) { { test: "cannot list iam user", dirName: "aws_iam_user_empty", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllUsers").Return(nil, awsError) @@ -94,10 +94,10 @@ func TestIamUser(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockIAMRepository{} + fakeRepo := &repository.MockIAMRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.IAMRepository = fakeRepo + var repo repository.IAMRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -113,7 +113,7 @@ func TestIamUser(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewIAMRepository(sess, cache.New(0)) + repo = repository.NewIAMRepository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewIamUserEnumerator(repo, factory)) @@ -140,13 +140,13 @@ func TestIamUserPolicy(t *testing.T) { cases := []struct { test string dirName string - mocks func(*repository2.MockIAMRepository, *mocks.AlerterInterface) + mocks func(*repository.MockIAMRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no iam user policy", dirName: "aws_iam_user_policy_empty", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { users := []*iam.User{ { UserName: aws.String("loadbalancer"), @@ -160,7 +160,7 @@ func TestIamUserPolicy(t *testing.T) { { test: "iam multiples users multiple policies", dirName: "aws_iam_user_policy_multiple", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { users := []*iam.User{ { UserName: aws.String("loadbalancer"), @@ -193,7 +193,7 @@ func TestIamUserPolicy(t *testing.T) { { test: "cannot list user", dirName: "aws_iam_user_policy_empty", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllUsers").Return(nil, awsError) @@ -204,7 +204,7 @@ func TestIamUserPolicy(t *testing.T) { { test: "cannot list user policy", dirName: "aws_iam_user_policy_empty", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllUsers").Once().Return([]*iam.User{}, nil) awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllUserPolicies", mock.Anything).Return(nil, awsError) @@ -233,10 +233,10 @@ func TestIamUserPolicy(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockIAMRepository{} + fakeRepo := &repository.MockIAMRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.IAMRepository = fakeRepo + var repo repository.IAMRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -252,7 +252,7 @@ func TestIamUserPolicy(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewIAMRepository(sess, cache.New(0)) + repo = repository.NewIAMRepository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewIamUserPolicyEnumerator(repo, factory)) @@ -279,13 +279,13 @@ func TestIamPolicy(t *testing.T) { cases := []struct { test string dirName string - mocks func(*repository2.MockIAMRepository, *mocks.AlerterInterface) + mocks func(*repository.MockIAMRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no iam custom policies", dirName: "aws_iam_policy_empty", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllPolicies").Once().Return([]*iam.Policy{}, nil) }, wantErr: nil, @@ -293,7 +293,7 @@ func TestIamPolicy(t *testing.T) { { test: "iam multiples custom policies", dirName: "aws_iam_policy_multiple", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllPolicies").Once().Return([]*iam.Policy{ { Arn: aws.String("arn:aws:iam::929327065333:policy/policy-0"), @@ -311,7 +311,7 @@ func TestIamPolicy(t *testing.T) { { test: "cannot list iam custom policies", dirName: "aws_iam_policy_empty", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllPolicies").Once().Return(nil, awsError) @@ -340,10 +340,10 @@ func TestIamPolicy(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockIAMRepository{} + fakeRepo := &repository.MockIAMRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.IAMRepository = fakeRepo + var repo repository.IAMRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -359,7 +359,7 @@ func TestIamPolicy(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewIAMRepository(sess, cache.New(0)) + repo = repository.NewIAMRepository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewIamPolicyEnumerator(repo, factory)) @@ -386,13 +386,13 @@ func TestIamRole(t *testing.T) { cases := []struct { test string dirName string - mocks func(*repository2.MockIAMRepository, *mocks.AlerterInterface) + mocks func(*repository.MockIAMRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no iam roles", dirName: "aws_iam_role_empty", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRoles").Return([]*iam.Role{}, nil) }, wantErr: nil, @@ -400,7 +400,7 @@ func TestIamRole(t *testing.T) { { test: "iam multiples roles", dirName: "aws_iam_role_multiple", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRoles").Return([]*iam.Role{ { RoleName: aws.String("test_role_0"), @@ -421,7 +421,7 @@ func TestIamRole(t *testing.T) { { test: "iam roles ignore services roles", dirName: "aws_iam_role_ignore_services_roles", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRoles").Return([]*iam.Role{ { RoleName: aws.String("AWSServiceRoleForOrganizations"), @@ -460,10 +460,10 @@ func TestIamRole(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockIAMRepository{} + fakeRepo := &repository.MockIAMRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.IAMRepository = fakeRepo + var repo repository.IAMRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -479,7 +479,7 @@ func TestIamRole(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewIAMRepository(sess, cache.New(0)) + repo = repository.NewIAMRepository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewIamRoleEnumerator(repo, factory)) @@ -506,27 +506,27 @@ func TestIamRolePolicyAttachment(t *testing.T) { cases := []struct { test string dirName string - mocks func(*repository2.MockIAMRepository, *mocks.AlerterInterface) + mocks func(*repository.MockIAMRepository, *mocks.AlerterInterface) err error }{ { test: "no iam role policy", dirName: "aws_aws_iam_role_policy_empty", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { roles := []*iam.Role{ { RoleName: aws.String("test-role"), }, } repo.On("ListAllRoles").Return(roles, nil) - repo.On("ListAllRolePolicyAttachments", roles).Return([]*repository2.AttachedRolePolicy{}, nil) + repo.On("ListAllRolePolicyAttachments", roles).Return([]*repository.AttachedRolePolicy{}, nil) }, err: nil, }, { test: "iam multiples roles multiple policies", dirName: "aws_iam_role_policy_attachment_multiple", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { roles := []*iam.Role{ { RoleName: aws.String("test-role"), @@ -536,7 +536,7 @@ func TestIamRolePolicyAttachment(t *testing.T) { }, } repo.On("ListAllRoles").Return(roles, nil) - repo.On("ListAllRolePolicyAttachments", roles).Return([]*repository2.AttachedRolePolicy{ + repo.On("ListAllRolePolicyAttachments", roles).Return([]*repository.AttachedRolePolicy{ { AttachedPolicy: iam.AttachedPolicy{ PolicyArn: aws.String("arn:aws:iam::929327065333:policy/test-policy"), @@ -586,7 +586,7 @@ func TestIamRolePolicyAttachment(t *testing.T) { { test: "iam multiples roles for ignored roles", dirName: "aws_iam_role_policy_attachment_empty", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { roles := []*iam.Role{ { RoleName: aws.String("AWSServiceRoleForSupport"), @@ -604,7 +604,7 @@ func TestIamRolePolicyAttachment(t *testing.T) { { test: "Cannot list roles", dirName: "aws_iam_role_policy_attachment_empty", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllRoles").Once().Return(nil, awsError) @@ -614,7 +614,7 @@ func TestIamRolePolicyAttachment(t *testing.T) { { test: "Cannot list roles policy attachment", dirName: "aws_iam_role_policy_attachment_empty", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRoles").Once().Return([]*iam.Role{{RoleName: aws.String("test")}}, nil) awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllRolePolicyAttachments", mock.Anything).Return(nil, awsError) @@ -643,10 +643,10 @@ func TestIamRolePolicyAttachment(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockIAMRepository{} + fakeRepo := &repository.MockIAMRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.IAMRepository = fakeRepo + var repo repository.IAMRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -662,7 +662,7 @@ func TestIamRolePolicyAttachment(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewIAMRepository(sess, cache.New(0)) + repo = repository.NewIAMRepository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewIamRolePolicyAttachmentEnumerator(repo, factory)) @@ -689,13 +689,13 @@ func TestIamAccessKey(t *testing.T) { cases := []struct { test string dirName string - mocks func(*repository2.MockIAMRepository, *mocks.AlerterInterface) + mocks func(*repository.MockIAMRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no iam access_key", dirName: "aws_iam_access_key_empty", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { users := []*iam.User{ { UserName: aws.String("test-driftctl"), @@ -709,7 +709,7 @@ func TestIamAccessKey(t *testing.T) { { test: "iam multiples keys for multiples users", dirName: "aws_iam_access_key_multiple", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { users := []*iam.User{ { UserName: aws.String("test-driftctl"), @@ -740,7 +740,7 @@ func TestIamAccessKey(t *testing.T) { { test: "Cannot list iam user", dirName: "aws_iam_access_key_empty", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllUsers").Once().Return(nil, awsError) @@ -751,7 +751,7 @@ func TestIamAccessKey(t *testing.T) { { test: "Cannot list iam access_key", dirName: "aws_iam_access_key_empty", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllUsers").Once().Return([]*iam.User{}, nil) awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllAccessKeys", mock.Anything).Return(nil, awsError) @@ -781,10 +781,10 @@ func TestIamAccessKey(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockIAMRepository{} + fakeRepo := &repository.MockIAMRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.IAMRepository = fakeRepo + var repo repository.IAMRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -800,7 +800,7 @@ func TestIamAccessKey(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewIAMRepository(sess, cache.New(0)) + repo = repository.NewIAMRepository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewIamAccessKeyEnumerator(repo, factory)) @@ -827,27 +827,27 @@ func TestIamUserPolicyAttachment(t *testing.T) { cases := []struct { test string dirName string - mocks func(*repository2.MockIAMRepository, *mocks.AlerterInterface) + mocks func(*repository.MockIAMRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no iam user policy", dirName: "aws_iam_user_policy_empty", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { users := []*iam.User{ { UserName: aws.String("loadbalancer"), }, } repo.On("ListAllUsers").Return(users, nil) - repo.On("ListAllUserPolicyAttachments", users).Return([]*repository2.AttachedUserPolicy{}, nil) + repo.On("ListAllUserPolicyAttachments", users).Return([]*repository.AttachedUserPolicy{}, nil) }, wantErr: nil, }, { test: "iam multiples users multiple policies", dirName: "aws_iam_user_policy_attachment_multiple", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { users := []*iam.User{ { UserName: aws.String("loadbalancer"), @@ -860,7 +860,7 @@ func TestIamUserPolicyAttachment(t *testing.T) { }, } repo.On("ListAllUsers").Return(users, nil) - repo.On("ListAllUserPolicyAttachments", users).Return([]*repository2.AttachedUserPolicy{ + repo.On("ListAllUserPolicyAttachments", users).Return([]*repository.AttachedUserPolicy{ { AttachedPolicy: iam.AttachedPolicy{ PolicyArn: aws.String("arn:aws:iam::726421854799:policy/test"), @@ -953,7 +953,7 @@ func TestIamUserPolicyAttachment(t *testing.T) { { test: "cannot list user", dirName: "aws_iam_user_policy_empty", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllUsers").Return(nil, awsError) @@ -964,7 +964,7 @@ func TestIamUserPolicyAttachment(t *testing.T) { { test: "cannot list user policies attachment", dirName: "aws_iam_user_policy_empty", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllUsers").Once().Return([]*iam.User{}, nil) awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllUserPolicyAttachments", mock.Anything).Return(nil, awsError) @@ -994,10 +994,10 @@ func TestIamUserPolicyAttachment(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockIAMRepository{} + fakeRepo := &repository.MockIAMRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.IAMRepository = fakeRepo + var repo repository.IAMRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -1013,7 +1013,7 @@ func TestIamUserPolicyAttachment(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewIAMRepository(sess, cache.New(0)) + repo = repository.NewIAMRepository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewIamUserPolicyAttachmentEnumerator(repo, factory)) @@ -1040,27 +1040,27 @@ func TestIamRolePolicy(t *testing.T) { cases := []struct { test string dirName string - mocks func(*repository2.MockIAMRepository, *mocks.AlerterInterface) + mocks func(*repository.MockIAMRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no iam role policy", dirName: "aws_iam_role_policy_empty", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { roles := []*iam.Role{ { RoleName: aws.String("test_role"), }, } repo.On("ListAllRoles").Return(roles, nil) - repo.On("ListAllRolePolicies", roles).Return([]repository2.RolePolicy{}, nil) + repo.On("ListAllRolePolicies", roles).Return([]repository.RolePolicy{}, nil) }, wantErr: nil, }, { test: "multiples roles with inline policies", dirName: "aws_iam_role_policy_multiple", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { roles := []*iam.Role{ { RoleName: aws.String("test_role_0"), @@ -1070,7 +1070,7 @@ func TestIamRolePolicy(t *testing.T) { }, } repo.On("ListAllRoles").Return(roles, nil) - repo.On("ListAllRolePolicies", roles).Return([]repository2.RolePolicy{ + repo.On("ListAllRolePolicies", roles).Return([]repository.RolePolicy{ {Policy: "policy-role0-0", RoleName: "test_role_0"}, {Policy: "policy-role0-1", RoleName: "test_role_0"}, {Policy: "policy-role0-2", RoleName: "test_role_0"}, @@ -1084,7 +1084,7 @@ func TestIamRolePolicy(t *testing.T) { { test: "Cannot list roles", dirName: "aws_iam_role_policy_empty", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllRoles").Once().Return(nil, awsError) @@ -1095,7 +1095,7 @@ func TestIamRolePolicy(t *testing.T) { { test: "cannot list role policy", dirName: "aws_iam_role_policy_empty", - mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRoles").Once().Return([]*iam.Role{}, nil) awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllRolePolicies", mock.Anything).Return(nil, awsError) @@ -1125,10 +1125,10 @@ func TestIamRolePolicy(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockIAMRepository{} + fakeRepo := &repository.MockIAMRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.IAMRepository = fakeRepo + var repo repository.IAMRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -1144,7 +1144,7 @@ func TestIamRolePolicy(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewIAMRepository(sess, cache.New(0)) + repo = repository.NewIAMRepository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewIamRolePolicyEnumerator(repo, factory)) @@ -1171,13 +1171,13 @@ func TestIamGroupPolicy(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockIAMRepository) + mocks func(*repository.MockIAMRepository) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "multiple groups, with multiples policies", - mocks: func(repository *repository2.MockIAMRepository) { + mocks: func(repository *repository.MockIAMRepository) { repository.On("ListAllGroups").Return(nil, nil) repository.On("ListAllGroupPolicies", []*iam.Group(nil)). Return([]string{"group1:policy1", "group2:policy2"}, nil) @@ -1192,14 +1192,14 @@ func TestIamGroupPolicy(t *testing.T) { }, { test: "cannot list groups", - mocks: func(repository *repository2.MockIAMRepository) { + mocks: func(repository *repository.MockIAMRepository) { repository.On("ListAllGroups").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsIamGroupPolicyResourceType, resourceaws.AwsIamGroupResourceType), }, { test: "cannot list policies", - mocks: func(repository *repository2.MockIAMRepository) { + mocks: func(repository *repository.MockIAMRepository) { repository.On("ListAllGroups").Return(nil, nil) repository.On("ListAllGroupPolicies", []*iam.Group(nil)).Return(nil, dummyError) }, @@ -1219,10 +1219,10 @@ func TestIamGroupPolicy(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockIAMRepository{} + fakeRepo := &repository.MockIAMRepository{} c.mocks(fakeRepo) - var repo repository2.IAMRepository = fakeRepo + var repo repository.IAMRepository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewIamGroupPolicyEnumerator( repo, factory, @@ -1251,13 +1251,13 @@ func TestIamGroup(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockIAMRepository) + mocks func(*repository.MockIAMRepository) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "multiple groups, with multiples groups", - mocks: func(repository *repository2.MockIAMRepository) { + mocks: func(repository *repository.MockIAMRepository) { repository.On("ListAllGroups").Return([]*iam.Group{ { GroupName: aws.String("group1"), @@ -1277,7 +1277,7 @@ func TestIamGroup(t *testing.T) { }, { test: "cannot list groups", - mocks: func(repository *repository2.MockIAMRepository) { + mocks: func(repository *repository.MockIAMRepository) { repository.On("ListAllGroups").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsIamGroupResourceType), @@ -1296,10 +1296,10 @@ func TestIamGroup(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockIAMRepository{} + fakeRepo := &repository.MockIAMRepository{} c.mocks(fakeRepo) - var repo repository2.IAMRepository = fakeRepo + var repo repository.IAMRepository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewIamGroupEnumerator( repo, factory, diff --git a/enumeration/remote/aws_kms_scanner_test.go b/enumeration/remote/aws_kms_scanner_test.go index 166f62fab..71a40fc4e 100644 --- a/enumeration/remote/aws_kms_scanner_test.go +++ b/enumeration/remote/aws_kms_scanner_test.go @@ -6,7 +6,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" aws2 "github.com/snyk/driftctl/enumeration/remote/aws" - repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" common2 "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" @@ -33,20 +33,20 @@ func TestKMSKey(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockKMSRepository, *mocks.AlerterInterface) + mocks func(*repository.MockKMSRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no keys", dirName: "aws_kms_key_empty", - mocks: func(repository *repository2.MockKMSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockKMSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllKeys").Return([]*kms.KeyListEntry{}, nil) }, }, { test: "multiple keys", dirName: "aws_kms_key_multiple", - mocks: func(repository *repository2.MockKMSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockKMSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllKeys").Return([]*kms.KeyListEntry{ {KeyId: awssdk.String("8ee21d91-c000-428c-8032-235aac55da36")}, {KeyId: awssdk.String("5d765f32-bfdc-4610-b6ab-f82db5d0601b")}, @@ -57,7 +57,7 @@ func TestKMSKey(t *testing.T) { { test: "cannot list keys", dirName: "aws_kms_key_list", - mocks: func(repository *repository2.MockKMSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockKMSRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllKeys").Return(nil, awsError) @@ -86,10 +86,10 @@ func TestKMSKey(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockKMSRepository{} + fakeRepo := &repository.MockKMSRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.KMSRepository = fakeRepo + var repo repository.KMSRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -105,7 +105,7 @@ func TestKMSKey(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewKMSRepository(sess, cache.New(0)) + repo = repository.NewKMSRepository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewKMSKeyEnumerator(repo, factory)) @@ -131,20 +131,20 @@ func TestKMSAlias(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockKMSRepository, *mocks.AlerterInterface) + mocks func(*repository.MockKMSRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no aliases", dirName: "aws_kms_alias_empty", - mocks: func(repository *repository2.MockKMSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockKMSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllAliases").Return([]*kms.AliasListEntry{}, nil) }, }, { test: "multiple aliases", dirName: "aws_kms_alias_multiple", - mocks: func(repository *repository2.MockKMSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockKMSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllAliases").Return([]*kms.AliasListEntry{ {AliasName: awssdk.String("alias/foo")}, {AliasName: awssdk.String("alias/bar")}, @@ -155,7 +155,7 @@ func TestKMSAlias(t *testing.T) { { test: "cannot list aliases", dirName: "aws_kms_alias_list", - mocks: func(repository *repository2.MockKMSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockKMSRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllAliases").Return(nil, awsError) @@ -184,10 +184,10 @@ func TestKMSAlias(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockKMSRepository{} + fakeRepo := &repository.MockKMSRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.KMSRepository = fakeRepo + var repo repository.KMSRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -203,7 +203,7 @@ func TestKMSAlias(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewKMSRepository(sess, cache.New(0)) + repo = repository.NewKMSRepository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewKMSAliasEnumerator(repo, factory)) diff --git a/enumeration/remote/aws_lambda_scanner_test.go b/enumeration/remote/aws_lambda_scanner_test.go index 5025d796c..047f71d8d 100644 --- a/enumeration/remote/aws_lambda_scanner_test.go +++ b/enumeration/remote/aws_lambda_scanner_test.go @@ -6,7 +6,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" aws2 "github.com/snyk/driftctl/enumeration/remote/aws" - repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" common2 "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" @@ -36,13 +36,13 @@ func TestScanLambdaFunction(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockLambdaRepository, *mocks.AlerterInterface) + mocks func(*repository.MockLambdaRepository, *mocks.AlerterInterface) err error }{ { test: "no lambda functions", dirName: "aws_lambda_function_empty", - mocks: func(repo *repository2.MockLambdaRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockLambdaRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllLambdaFunctions").Return([]*lambda.FunctionConfiguration{}, nil) }, err: nil, @@ -50,7 +50,7 @@ func TestScanLambdaFunction(t *testing.T) { { test: "with lambda functions", dirName: "aws_lambda_function_multiple", - mocks: func(repo *repository2.MockLambdaRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockLambdaRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllLambdaFunctions").Return([]*lambda.FunctionConfiguration{ { FunctionName: awssdk.String("foo"), @@ -65,7 +65,7 @@ func TestScanLambdaFunction(t *testing.T) { { test: "One lambda with signing", dirName: "aws_lambda_function_signed", - mocks: func(repo *repository2.MockLambdaRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockLambdaRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllLambdaFunctions").Return([]*lambda.FunctionConfiguration{ { FunctionName: awssdk.String("foo"), @@ -77,7 +77,7 @@ func TestScanLambdaFunction(t *testing.T) { { test: "cannot list lambda functions", dirName: "aws_lambda_function_empty", - mocks: func(repo *repository2.MockLambdaRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockLambdaRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllLambdaFunctions").Return([]*lambda.FunctionConfiguration{}, awsError) @@ -106,10 +106,10 @@ func TestScanLambdaFunction(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockLambdaRepository{} + fakeRepo := &repository.MockLambdaRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.LambdaRepository = fakeRepo + var repo repository.LambdaRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -125,7 +125,7 @@ func TestScanLambdaFunction(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewLambdaRepository(session, cache.New(0)) + repo = repository.NewLambdaRepository(session, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewLambdaFunctionEnumerator(repo, factory)) @@ -152,13 +152,13 @@ func TestScanLambdaEventSourceMapping(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockLambdaRepository, *mocks.AlerterInterface) + mocks func(*repository.MockLambdaRepository, *mocks.AlerterInterface) err error }{ { test: "no EventSourceMapping", dirName: "aws_lambda_source_mapping_empty", - mocks: func(repo *repository2.MockLambdaRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockLambdaRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllLambdaEventSourceMappings").Return([]*lambda.EventSourceMappingConfiguration{}, nil) }, err: nil, @@ -166,7 +166,7 @@ func TestScanLambdaEventSourceMapping(t *testing.T) { { test: "with 2 sqs EventSourceMapping", dirName: "aws_lambda_source_mapping_sqs_multiple", - mocks: func(repo *repository2.MockLambdaRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockLambdaRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllLambdaEventSourceMappings").Return([]*lambda.EventSourceMappingConfiguration{ { UUID: awssdk.String("13ff66f8-37eb-4ad6-a0a8-594fea72df4f"), @@ -181,7 +181,7 @@ func TestScanLambdaEventSourceMapping(t *testing.T) { { test: "with dynamo EventSourceMapping", dirName: "aws_lambda_source_mapping_dynamo_multiple", - mocks: func(repo *repository2.MockLambdaRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockLambdaRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllLambdaEventSourceMappings").Return([]*lambda.EventSourceMappingConfiguration{ { UUID: awssdk.String("1aa9c4a0-060b-41c1-a9ae-dc304ebcdb00"), @@ -193,7 +193,7 @@ func TestScanLambdaEventSourceMapping(t *testing.T) { { test: "cannot list lambda functions", dirName: "aws_lambda_function_empty", - mocks: func(repo *repository2.MockLambdaRepository, alerter *mocks.AlerterInterface) { + mocks: func(repo *repository.MockLambdaRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllLambdaEventSourceMappings").Return([]*lambda.EventSourceMappingConfiguration{}, awsError) @@ -222,10 +222,10 @@ func TestScanLambdaEventSourceMapping(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockLambdaRepository{} + fakeRepo := &repository.MockLambdaRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.LambdaRepository = fakeRepo + var repo repository.LambdaRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -241,7 +241,7 @@ func TestScanLambdaEventSourceMapping(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewLambdaRepository(session, cache.New(0)) + repo = repository.NewLambdaRepository(session, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewLambdaEventSourceMappingEnumerator(repo, factory)) diff --git a/enumeration/remote/aws_rds_scanner_test.go b/enumeration/remote/aws_rds_scanner_test.go index 594c5a9c5..2e4ac1bf4 100644 --- a/enumeration/remote/aws_rds_scanner_test.go +++ b/enumeration/remote/aws_rds_scanner_test.go @@ -6,7 +6,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" aws2 "github.com/snyk/driftctl/enumeration/remote/aws" - repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" common2 "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" @@ -33,20 +33,20 @@ func TestRDSDBInstance(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockRDSRepository, *mocks.AlerterInterface) + mocks func(*repository.MockRDSRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no db instances", dirName: "aws_rds_db_instance_empty", - mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDBInstances").Return([]*rds.DBInstance{}, nil) }, }, { test: "single db instance", dirName: "aws_rds_db_instance_single", - mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDBInstances").Return([]*rds.DBInstance{ {DBInstanceIdentifier: awssdk.String("terraform-20201015115018309600000001")}, }, nil) @@ -55,7 +55,7 @@ func TestRDSDBInstance(t *testing.T) { { test: "multiple mixed db instances", dirName: "aws_rds_db_instance_multiple", - mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDBInstances").Return([]*rds.DBInstance{ {DBInstanceIdentifier: awssdk.String("terraform-20201015115018309600000001")}, {DBInstanceIdentifier: awssdk.String("database-1")}, @@ -65,7 +65,7 @@ func TestRDSDBInstance(t *testing.T) { { test: "cannot list db instances", dirName: "aws_rds_db_instance_list", - mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllDBInstances").Return(nil, awsError) @@ -94,10 +94,10 @@ func TestRDSDBInstance(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockRDSRepository{} + fakeRepo := &repository.MockRDSRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.RDSRepository = fakeRepo + var repo repository.RDSRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -113,7 +113,7 @@ func TestRDSDBInstance(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewRDSRepository(sess, cache.New(0)) + repo = repository.NewRDSRepository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewRDSDBInstanceEnumerator(repo, factory)) @@ -139,20 +139,20 @@ func TestRDSDBSubnetGroup(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockRDSRepository, *mocks.AlerterInterface) + mocks func(*repository.MockRDSRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no db subnet groups", dirName: "aws_rds_db_subnet_group_empty", - mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDBSubnetGroups").Return([]*rds.DBSubnetGroup{}, nil) }, }, { test: "multiple db subnet groups", dirName: "aws_rds_db_subnet_group_multiple", - mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDBSubnetGroups").Return([]*rds.DBSubnetGroup{ {DBSubnetGroupName: awssdk.String("foo")}, {DBSubnetGroupName: awssdk.String("bar")}, @@ -162,7 +162,7 @@ func TestRDSDBSubnetGroup(t *testing.T) { { test: "cannot list db subnet groups", dirName: "aws_rds_db_subnet_group_list", - mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllDBSubnetGroups").Return(nil, awsError) @@ -191,10 +191,10 @@ func TestRDSDBSubnetGroup(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockRDSRepository{} + fakeRepo := &repository.MockRDSRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.RDSRepository = fakeRepo + var repo repository.RDSRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -210,7 +210,7 @@ func TestRDSDBSubnetGroup(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewRDSRepository(sess, cache.New(0)) + repo = repository.NewRDSRepository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewRDSDBSubnetGroupEnumerator(repo, factory)) @@ -236,20 +236,20 @@ func TestRDSCluster(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockRDSRepository, *mocks.AlerterInterface) + mocks func(*repository.MockRDSRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no cluster", dirName: "aws_rds_cluster_empty", - mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDBClusters").Return([]*rds.DBCluster{}, nil) }, }, { test: "should return one result", dirName: "aws_rds_clusters_results", - mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDBClusters").Return([]*rds.DBCluster{ { DBClusterIdentifier: awssdk.String("aurora-cluster-demo"), @@ -264,7 +264,7 @@ func TestRDSCluster(t *testing.T) { { test: "cannot list clusters", dirName: "aws_rds_cluster_denied", - mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 400, "") repository.On("ListAllDBClusters").Return(nil, awsError).Once() @@ -293,10 +293,10 @@ func TestRDSCluster(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockRDSRepository{} + fakeRepo := &repository.MockRDSRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.RDSRepository = fakeRepo + var repo repository.RDSRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -312,7 +312,7 @@ func TestRDSCluster(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewRDSRepository(sess, cache.New(0)) + repo = repository.NewRDSRepository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewRDSClusterEnumerator(repo, factory)) diff --git a/enumeration/remote/aws_route53_scanner_test.go b/enumeration/remote/aws_route53_scanner_test.go index 5ccedb449..c3e29d414 100644 --- a/enumeration/remote/aws_route53_scanner_test.go +++ b/enumeration/remote/aws_route53_scanner_test.go @@ -4,7 +4,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" aws2 "github.com/snyk/driftctl/enumeration/remote/aws" - repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" common2 "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" @@ -35,13 +35,13 @@ func TestRoute53_HealthCheck(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockRoute53Repository, *mocks.AlerterInterface) + mocks func(*repository.MockRoute53Repository, *mocks.AlerterInterface) err error }{ { test: "no health check", dirName: "aws_route53_health_check_empty", - mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) { client.On("ListAllHealthChecks").Return([]*route53.HealthCheck{}, nil) }, err: nil, @@ -49,7 +49,7 @@ func TestRoute53_HealthCheck(t *testing.T) { { test: "Multiple health check", dirName: "aws_route53_health_check_multiple", - mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) { client.On("ListAllHealthChecks").Return([]*route53.HealthCheck{ {Id: awssdk.String("7001a9df-ded4-4802-9909-668eb80b972b")}, {Id: awssdk.String("84fc318a-2e0d-41d6-b638-280e2f0f4e26")}, @@ -60,7 +60,7 @@ func TestRoute53_HealthCheck(t *testing.T) { { test: "cannot list health check", dirName: "aws_route53_health_check_empty", - mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllHealthChecks").Return(nil, awsError) @@ -89,10 +89,10 @@ func TestRoute53_HealthCheck(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockRoute53Repository{} + fakeRepo := &repository.MockRoute53Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.Route53Repository = fakeRepo + var repo repository.Route53Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -108,7 +108,7 @@ func TestRoute53_HealthCheck(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewRoute53Repository(session, cache.New(0)) + repo = repository.NewRoute53Repository(session, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewRoute53HealthCheckEnumerator(repo, factory)) @@ -135,13 +135,13 @@ func TestRoute53_Zone(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockRoute53Repository, *mocks.AlerterInterface) + mocks func(*repository.MockRoute53Repository, *mocks.AlerterInterface) err error }{ { test: "no zones", dirName: "aws_route53_zone_empty", - mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) { client.On("ListAllZones").Return( []*route53.HostedZone{}, nil, @@ -152,7 +152,7 @@ func TestRoute53_Zone(t *testing.T) { { test: "single zone", dirName: "aws_route53_zone_single", - mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) { client.On("ListAllZones").Return( []*route53.HostedZone{ { @@ -168,7 +168,7 @@ func TestRoute53_Zone(t *testing.T) { { test: "multiples zone (test pagination)", dirName: "aws_route53_zone_multiples", - mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) { client.On("ListAllZones").Return( []*route53.HostedZone{ { @@ -192,7 +192,7 @@ func TestRoute53_Zone(t *testing.T) { { test: "cannot list zones", dirName: "aws_route53_zone_empty", - mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllZones").Return( []*route53.HostedZone{}, @@ -224,10 +224,10 @@ func TestRoute53_Zone(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockRoute53Repository{} + fakeRepo := &repository.MockRoute53Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.Route53Repository = fakeRepo + var repo repository.Route53Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -243,7 +243,7 @@ func TestRoute53_Zone(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewRoute53Repository(session, cache.New(0)) + repo = repository.NewRoute53Repository(session, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewRoute53ZoneEnumerator(repo, factory)) @@ -270,13 +270,13 @@ func TestRoute53_Record(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockRoute53Repository, *mocks.AlerterInterface) + mocks func(*repository.MockRoute53Repository, *mocks.AlerterInterface) err error }{ { test: "no records", dirName: "aws_route53_zone_with_no_record", - mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) { client.On("ListAllZones").Return( []*route53.HostedZone{ { @@ -293,7 +293,7 @@ func TestRoute53_Record(t *testing.T) { { test: "multiples records in multiples zones", dirName: "aws_route53_record_multiples", - mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) { client.On("ListAllZones").Return( []*route53.HostedZone{ { @@ -341,7 +341,7 @@ func TestRoute53_Record(t *testing.T) { { test: "explicit subdomain records", dirName: "aws_route53_record_explicit_subdomain", - mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) { client.On("ListAllZones").Return( []*route53.HostedZone{ { @@ -383,7 +383,7 @@ func TestRoute53_Record(t *testing.T) { { test: "cannot list zones", dirName: "aws_route53_zone_with_no_record", - mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllZones").Return( []*route53.HostedZone{}, @@ -396,7 +396,7 @@ func TestRoute53_Record(t *testing.T) { { test: "cannot list records", dirName: "aws_route53_zone_with_no_record", - mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) { client.On("ListAllZones").Return( []*route53.HostedZone{ { @@ -434,10 +434,10 @@ func TestRoute53_Record(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockRoute53Repository{} + fakeRepo := &repository.MockRoute53Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.Route53Repository = fakeRepo + var repo repository.Route53Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -453,7 +453,7 @@ func TestRoute53_Record(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewRoute53Repository(session, cache.New(0)) + repo = repository.NewRoute53Repository(session, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewRoute53RecordEnumerator(repo, factory)) diff --git a/enumeration/remote/aws_s3_scanner_test.go b/enumeration/remote/aws_s3_scanner_test.go index 1616460f6..d9f15c025 100644 --- a/enumeration/remote/aws_s3_scanner_test.go +++ b/enumeration/remote/aws_s3_scanner_test.go @@ -7,7 +7,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/alerts" aws2 "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/client" - repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" common2 "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" @@ -38,12 +38,12 @@ func TestS3Bucket(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockS3Repository, *mocks.AlerterInterface) + mocks func(*repository.MockS3Repository, *mocks.AlerterInterface) wantErr error }{ { test: "multiple bucket", dirName: "aws_s3_bucket_multiple", - mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On( "ListAllBuckets", ).Return([]*s3.Bucket{ @@ -79,7 +79,7 @@ func TestS3Bucket(t *testing.T) { }, { test: "cannot list bucket", dirName: "aws_s3_bucket_list", - mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllBuckets").Return(nil, awsError) @@ -108,9 +108,9 @@ func TestS3Bucket(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockS3Repository{} + fakeRepo := &repository.MockS3Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.S3Repository = fakeRepo + var repo repository.S3Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -126,7 +126,7 @@ func TestS3Bucket(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) + repo = repository.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewS3BucketEnumerator(repo, factory, tf.TerraformProviderConfig{ @@ -156,12 +156,12 @@ func TestS3BucketInventory(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockS3Repository, *mocks.AlerterInterface) + mocks func(*repository.MockS3Repository, *mocks.AlerterInterface) wantErr error }{ { test: "multiple bucket with multiple inventories", dirName: "aws_s3_bucket_inventories_multiple", - mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On( "ListAllBuckets", ).Return([]*s3.Bucket{ @@ -209,7 +209,7 @@ func TestS3BucketInventory(t *testing.T) { }, { test: "cannot list bucket", dirName: "aws_s3_bucket_inventories_list_bucket", - mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllBuckets").Return(nil, awsError) @@ -219,7 +219,7 @@ func TestS3BucketInventory(t *testing.T) { }, { test: "cannot list bucket inventories", dirName: "aws_s3_bucket_inventories_list_inventories", - mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllBuckets").Return( []*s3.Bucket{ {Name: awssdk.String("bucket-martin-test-drift")}, @@ -268,9 +268,9 @@ func TestS3BucketInventory(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockS3Repository{} + fakeRepo := &repository.MockS3Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.S3Repository = fakeRepo + var repo repository.S3Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -286,7 +286,7 @@ func TestS3BucketInventory(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) + repo = repository.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewS3BucketInventoryEnumerator(repo, factory, tf.TerraformProviderConfig{ @@ -316,13 +316,13 @@ func TestS3BucketNotification(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockS3Repository, *mocks.AlerterInterface) + mocks func(*repository.MockS3Repository, *mocks.AlerterInterface) wantErr error }{ { test: "single bucket without notifications", dirName: "aws_s3_bucket_notifications_no_notif", - mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On( "ListAllBuckets", ).Return([]*s3.Bucket{ @@ -349,7 +349,7 @@ func TestS3BucketNotification(t *testing.T) { }, { test: "multiple bucket with notifications", dirName: "aws_s3_bucket_notifications_multiple", - mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On( "ListAllBuckets", ).Return([]*s3.Bucket{ @@ -403,7 +403,7 @@ func TestS3BucketNotification(t *testing.T) { }, { test: "Cannot get bucket notification", dirName: "aws_s3_bucket_notifications_list_bucket", - mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On( "ListAllBuckets", ).Return([]*s3.Bucket{ @@ -425,7 +425,7 @@ func TestS3BucketNotification(t *testing.T) { }, { test: "Cannot list bucket", dirName: "aws_s3_bucket_notifications_list_bucket", - mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllBuckets").Return(nil, awsError) @@ -454,9 +454,9 @@ func TestS3BucketNotification(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockS3Repository{} + fakeRepo := &repository.MockS3Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.S3Repository = fakeRepo + var repo repository.S3Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -472,7 +472,7 @@ func TestS3BucketNotification(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) + repo = repository.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewS3BucketNotificationEnumerator(repo, factory, tf.TerraformProviderConfig{ @@ -502,12 +502,12 @@ func TestS3BucketMetrics(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockS3Repository, *mocks.AlerterInterface) + mocks func(*repository.MockS3Repository, *mocks.AlerterInterface) wantErr error }{ { test: "multiple bucket with multiple metrics", dirName: "aws_s3_bucket_metrics_multiple", - mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On( "ListAllBuckets", ).Return([]*s3.Bucket{ @@ -555,7 +555,7 @@ func TestS3BucketMetrics(t *testing.T) { }, { test: "cannot list bucket", dirName: "aws_s3_bucket_metrics_list_bucket", - mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllBuckets").Return(nil, awsError) @@ -565,7 +565,7 @@ func TestS3BucketMetrics(t *testing.T) { }, { test: "cannot list metrics", dirName: "aws_s3_bucket_metrics_list_metrics", - mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllBuckets").Return( []*s3.Bucket{ {Name: awssdk.String("bucket-martin-test-drift")}, @@ -615,9 +615,9 @@ func TestS3BucketMetrics(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockS3Repository{} + fakeRepo := &repository.MockS3Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.S3Repository = fakeRepo + var repo repository.S3Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -633,7 +633,7 @@ func TestS3BucketMetrics(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) + repo = repository.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewS3BucketMetricsEnumerator(repo, factory, tf.TerraformProviderConfig{ @@ -663,13 +663,13 @@ func TestS3BucketPolicy(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockS3Repository, *mocks.AlerterInterface) + mocks func(*repository.MockS3Repository, *mocks.AlerterInterface) wantErr error }{ { test: "single bucket without policy", dirName: "aws_s3_bucket_policy_no_policy", - mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On( "ListAllBuckets", ).Return([]*s3.Bucket{ @@ -696,7 +696,7 @@ func TestS3BucketPolicy(t *testing.T) { }, { test: "multiple bucket with policies", dirName: "aws_s3_bucket_policies_multiple", - mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On( "ListAllBuckets", ).Return([]*s3.Bucket{ @@ -744,7 +744,7 @@ func TestS3BucketPolicy(t *testing.T) { }, { test: "cannot list bucket", dirName: "aws_s3_bucket_policies_list_bucket", - mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllBuckets").Return(nil, awsError) @@ -773,9 +773,9 @@ func TestS3BucketPolicy(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockS3Repository{} + fakeRepo := &repository.MockS3Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.S3Repository = fakeRepo + var repo repository.S3Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -791,7 +791,7 @@ func TestS3BucketPolicy(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) + repo = repository.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewS3BucketPolicyEnumerator(repo, factory, tf.TerraformProviderConfig{ @@ -821,13 +821,13 @@ func TestS3BucketPublicAccessBlock(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockS3Repository, *mocks.AlerterInterface) + mocks func(*repository.MockS3Repository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "multiple bucket, one with access block", - mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllBuckets").Return([]*s3.Bucket{ {Name: awssdk.String("bucket-with-public-access-block")}, {Name: awssdk.String("bucket-without-public-access-block")}, @@ -861,14 +861,14 @@ func TestS3BucketPublicAccessBlock(t *testing.T) { }, { test: "cannot list bucket", - mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllBuckets").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsS3BucketPublicAccessBlockResourceType, resourceaws.AwsS3BucketResourceType), }, { test: "cannot list public access block", - mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllBuckets").Return([]*s3.Bucket{{Name: awssdk.String("foobar")}}, nil) repository.On("GetBucketLocation", "foobar").Return("us-east-1", nil) repository.On("GetBucketPublicAccessBlock", "foobar", "us-east-1").Return(nil, dummyError) @@ -892,10 +892,10 @@ func TestS3BucketPublicAccessBlock(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockS3Repository{} + fakeRepo := &repository.MockS3Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.S3Repository = fakeRepo + var repo repository.S3Repository = fakeRepo remoteLibrary.AddEnumerator(aws2.NewS3BucketPublicAccessBlockEnumerator( repo, factory, @@ -926,13 +926,13 @@ func TestS3BucketAnalytic(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockS3Repository, *mocks.AlerterInterface) + mocks func(*repository.MockS3Repository, *mocks.AlerterInterface) wantErr error }{ { test: "multiple bucket with multiple analytics", dirName: "aws_s3_bucket_analytics_multiple", - mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On( "ListAllBuckets", ).Return([]*s3.Bucket{ @@ -980,7 +980,7 @@ func TestS3BucketAnalytic(t *testing.T) { }, { test: "cannot list bucket", dirName: "aws_s3_bucket_analytics_list_bucket", - mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllBuckets").Return(nil, awsError) @@ -990,7 +990,7 @@ func TestS3BucketAnalytic(t *testing.T) { }, { test: "cannot list Analytics", dirName: "aws_s3_bucket_analytics_list_analytics", - mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllBuckets").Return( []*s3.Bucket{ {Name: awssdk.String("bucket-martin-test-drift")}, @@ -1040,9 +1040,9 @@ func TestS3BucketAnalytic(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockS3Repository{} + fakeRepo := &repository.MockS3Repository{} c.mocks(fakeRepo, alerter) - var repo repository2.S3Repository = fakeRepo + var repo repository.S3Repository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -1058,7 +1058,7 @@ func TestS3BucketAnalytic(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) + repo = repository.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewS3BucketAnalyticEnumerator(repo, factory, tf.TerraformProviderConfig{ diff --git a/enumeration/remote/aws_sns_scanner_test.go b/enumeration/remote/aws_sns_scanner_test.go index 9ed38085a..ebe6741dc 100644 --- a/enumeration/remote/aws_sns_scanner_test.go +++ b/enumeration/remote/aws_sns_scanner_test.go @@ -6,7 +6,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" aws2 "github.com/snyk/driftctl/enumeration/remote/aws" - repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" common2 "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" @@ -36,13 +36,13 @@ func TestScanSNSTopic(t *testing.T) { cases := []struct { test string dirName string - mocks func(*repository2.MockSNSRepository, *mocks.AlerterInterface) + mocks func(*repository.MockSNSRepository, *mocks.AlerterInterface) err error }{ { test: "no SNS Topic", dirName: "aws_sns_topic_empty", - mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) { client.On("ListAllTopics").Return([]*sns.Topic{}, nil) }, err: nil, @@ -50,7 +50,7 @@ func TestScanSNSTopic(t *testing.T) { { test: "Multiple SNSTopic", dirName: "aws_sns_topic_multiple", - mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) { client.On("ListAllTopics").Return([]*sns.Topic{ {TopicArn: awssdk.String("arn:aws:sns:eu-west-3:526954929923:user-updates-topic")}, {TopicArn: awssdk.String("arn:aws:sns:eu-west-3:526954929923:user-updates-topic2")}, @@ -62,7 +62,7 @@ func TestScanSNSTopic(t *testing.T) { { test: "cannot list SNSTopic", dirName: "aws_sns_topic_empty", - mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllTopics").Return(nil, awsError) @@ -91,10 +91,10 @@ func TestScanSNSTopic(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockSNSRepository{} + fakeRepo := &repository.MockSNSRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.SNSRepository = fakeRepo + var repo repository.SNSRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -110,7 +110,7 @@ func TestScanSNSTopic(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewSNSRepository(sess, cache.New(0)) + repo = repository.NewSNSRepository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewSNSTopicEnumerator(repo, factory)) @@ -137,13 +137,13 @@ func TestSNSTopicPolicyScan(t *testing.T) { cases := []struct { test string dirName string - mocks func(*repository2.MockSNSRepository, *mocks.AlerterInterface) + mocks func(*repository.MockSNSRepository, *mocks.AlerterInterface) err error }{ { test: "no SNS Topic policy", dirName: "aws_sns_topic_policy_empty", - mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) { client.On("ListAllTopics").Return([]*sns.Topic{}, nil) }, err: nil, @@ -151,7 +151,7 @@ func TestSNSTopicPolicyScan(t *testing.T) { { test: "Multiple SNSTopicPolicy", dirName: "aws_sns_topic_policy_multiple", - mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) { client.On("ListAllTopics").Return([]*sns.Topic{ {TopicArn: awssdk.String("arn:aws:sns:us-east-1:526954929923:my-topic-with-policy")}, {TopicArn: awssdk.String("arn:aws:sns:us-east-1:526954929923:my-topic-with-policy2")}, @@ -162,7 +162,7 @@ func TestSNSTopicPolicyScan(t *testing.T) { { test: "cannot list SNSTopic", dirName: "aws_sns_topic_policy_topic_list", - mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllTopics").Return(nil, awsError) @@ -191,10 +191,10 @@ func TestSNSTopicPolicyScan(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockSNSRepository{} + fakeRepo := &repository.MockSNSRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.SNSRepository = fakeRepo + var repo repository.SNSRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -210,7 +210,7 @@ func TestSNSTopicPolicyScan(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewSNSRepository(sess, cache.New(0)) + repo = repository.NewSNSRepository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewSNSTopicPolicyEnumerator(repo, factory)) @@ -237,13 +237,13 @@ func TestSNSTopicSubscriptionScan(t *testing.T) { cases := []struct { test string dirName string - mocks func(*repository2.MockSNSRepository, *mocks.AlerterInterface) + mocks func(*repository.MockSNSRepository, *mocks.AlerterInterface) err error }{ { test: "no SNS Topic Subscription", dirName: "aws_sns_topic_subscription_empty", - mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) { client.On("ListAllSubscriptions").Return([]*sns.Subscription{}, nil) }, err: nil, @@ -251,7 +251,7 @@ func TestSNSTopicSubscriptionScan(t *testing.T) { { test: "Multiple SNSTopic Subscription", dirName: "aws_sns_topic_subscription_multiple", - mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) { client.On("ListAllSubscriptions").Return([]*sns.Subscription{ {SubscriptionArn: awssdk.String("arn:aws:sns:us-east-1:526954929923:user-updates-topic2:c0f794c5-a009-4db4-9147-4c55959787fa")}, {SubscriptionArn: awssdk.String("arn:aws:sns:us-east-1:526954929923:user-updates-topic:b6e66147-2b31-4486-8d4b-2a2272264c8e")}, @@ -262,7 +262,7 @@ func TestSNSTopicSubscriptionScan(t *testing.T) { { test: "Multiple SNSTopic Subscription with one pending and one incorrect", dirName: "aws_sns_topic_subscription_multiple", - mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) { client.On("ListAllSubscriptions").Return([]*sns.Subscription{ {SubscriptionArn: awssdk.String("PendingConfirmation"), Endpoint: awssdk.String("TEST")}, {SubscriptionArn: awssdk.String("Incorrect"), Endpoint: awssdk.String("INCORRECT")}, @@ -279,7 +279,7 @@ func TestSNSTopicSubscriptionScan(t *testing.T) { { test: "cannot list SNSTopic subscription", dirName: "aws_sns_topic_subscription_list", - mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllSubscriptions").Return(nil, awsError) @@ -308,10 +308,10 @@ func TestSNSTopicSubscriptionScan(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockSNSRepository{} + fakeRepo := &repository.MockSNSRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.SNSRepository = fakeRepo + var repo repository.SNSRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -327,7 +327,7 @@ func TestSNSTopicSubscriptionScan(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewSNSRepository(sess, cache.New(0)) + repo = repository.NewSNSRepository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewSNSTopicSubscriptionEnumerator(repo, factory, alerter)) diff --git a/enumeration/remote/aws_sqs_scanner_test.go b/enumeration/remote/aws_sqs_scanner_test.go index 72b7345ab..14a009a54 100644 --- a/enumeration/remote/aws_sqs_scanner_test.go +++ b/enumeration/remote/aws_sqs_scanner_test.go @@ -6,7 +6,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" aws2 "github.com/snyk/driftctl/enumeration/remote/aws" - repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository" + "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" common2 "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" @@ -33,13 +33,13 @@ func TestSQSQueue(t *testing.T) { cases := []struct { test string dirName string - mocks func(*repository2.MockSQSRepository, *mocks.AlerterInterface) + mocks func(*repository.MockSQSRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no sqs queues", dirName: "aws_sqs_queue_empty", - mocks: func(client *repository2.MockSQSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockSQSRepository, alerter *mocks.AlerterInterface) { client.On("ListAllQueues").Return([]*string{}, nil) }, wantErr: nil, @@ -47,7 +47,7 @@ func TestSQSQueue(t *testing.T) { { test: "multiple sqs queues", dirName: "aws_sqs_queue_multiple", - mocks: func(client *repository2.MockSQSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockSQSRepository, alerter *mocks.AlerterInterface) { client.On("ListAllQueues").Return([]*string{ awssdk.String("https://sqs.eu-west-3.amazonaws.com/047081014315/bar.fifo"), awssdk.String("https://sqs.eu-west-3.amazonaws.com/047081014315/foo"), @@ -58,7 +58,7 @@ func TestSQSQueue(t *testing.T) { { test: "cannot list sqs queues", dirName: "aws_sqs_queue_empty", - mocks: func(client *repository2.MockSQSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockSQSRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllQueues").Return(nil, awsError) @@ -87,9 +87,9 @@ func TestSQSQueue(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockSQSRepository{} + fakeRepo := &repository.MockSQSRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.SQSRepository = fakeRepo + var repo repository.SQSRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -105,7 +105,7 @@ func TestSQSQueue(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewSQSRepository(sess, cache.New(0)) + repo = repository.NewSQSRepository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewSQSQueueEnumerator(repo, factory)) @@ -131,7 +131,7 @@ func TestSQSQueuePolicy(t *testing.T) { cases := []struct { test string dirName string - mocks func(*repository2.MockSQSRepository, *mocks.AlerterInterface) + mocks func(*repository.MockSQSRepository, *mocks.AlerterInterface) wantErr error }{ { @@ -139,7 +139,7 @@ func TestSQSQueuePolicy(t *testing.T) { // as a default SQSDefaultPolicy (e.g. policy="") will always be present in each queue test: "no sqs queue policies", dirName: "aws_sqs_queue_policy_empty", - mocks: func(client *repository2.MockSQSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockSQSRepository, alerter *mocks.AlerterInterface) { client.On("ListAllQueues").Return([]*string{}, nil) }, wantErr: nil, @@ -147,7 +147,7 @@ func TestSQSQueuePolicy(t *testing.T) { { test: "multiple sqs queue policies (default or not)", dirName: "aws_sqs_queue_policy_multiple", - mocks: func(client *repository2.MockSQSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockSQSRepository, alerter *mocks.AlerterInterface) { client.On("ListAllQueues").Return([]*string{ awssdk.String("https://sqs.eu-west-3.amazonaws.com/047081014315/bar.fifo"), awssdk.String("https://sqs.eu-west-3.amazonaws.com/047081014315/foo"), @@ -168,7 +168,7 @@ func TestSQSQueuePolicy(t *testing.T) { { test: "multiple sqs queue policies (with nil attributes)", dirName: "aws_sqs_queue_policy_multiple", - mocks: func(client *repository2.MockSQSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockSQSRepository, alerter *mocks.AlerterInterface) { client.On("ListAllQueues").Return([]*string{ awssdk.String("https://sqs.eu-west-3.amazonaws.com/047081014315/bar.fifo"), awssdk.String("https://sqs.eu-west-3.amazonaws.com/047081014315/foo"), @@ -185,7 +185,7 @@ func TestSQSQueuePolicy(t *testing.T) { { test: "cannot list sqs queues, thus sqs queue policies", dirName: "aws_sqs_queue_policy_empty", - mocks: func(client *repository2.MockSQSRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *repository.MockSQSRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllQueues").Return(nil, awsError) @@ -214,9 +214,9 @@ func TestSQSQueuePolicy(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockSQSRepository{} + fakeRepo := &repository.MockSQSRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.SQSRepository = fakeRepo + var repo repository.SQSRepository = fakeRepo providerVersion := "3.19.0" realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) if err != nil { @@ -232,7 +232,7 @@ func TestSQSQueuePolicy(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = repository2.NewSQSRepository(sess, cache.New(0)) + repo = repository.NewSQSRepository(sess, cache.New(0)) } remoteLibrary.AddEnumerator(aws2.NewSQSQueuePolicyEnumerator(repo, factory)) diff --git a/enumeration/remote/azurerm/init.go b/enumeration/remote/azurerm/init.go index a0eb44803..f74b8e58f 100644 --- a/enumeration/remote/azurerm/init.go +++ b/enumeration/remote/azurerm/init.go @@ -5,7 +5,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/alerter" - repository2 "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" "github.com/snyk/driftctl/enumeration/remote/cache" common2 "github.com/snyk/driftctl/enumeration/remote/common" "github.com/snyk/driftctl/enumeration/resource" @@ -45,13 +45,13 @@ func Init( c := cache.New(100) - storageAccountRepo := repository2.NewStorageRepository(cred, clientOptions, providerConfig, c) - networkRepo := repository2.NewNetworkRepository(cred, clientOptions, providerConfig, c) - resourcesRepo := repository2.NewResourcesRepository(cred, clientOptions, providerConfig, c) - containerRegistryRepo := repository2.NewContainerRegistryRepository(cred, clientOptions, providerConfig, c) - postgresqlRepo := repository2.NewPostgresqlRepository(cred, clientOptions, providerConfig, c) - privateDNSRepo := repository2.NewPrivateDNSRepository(cred, clientOptions, providerConfig, c) - computeRepo := repository2.NewComputeRepository(cred, clientOptions, providerConfig, c) + storageAccountRepo := repository.NewStorageRepository(cred, clientOptions, providerConfig, c) + networkRepo := repository.NewNetworkRepository(cred, clientOptions, providerConfig, c) + resourcesRepo := repository.NewResourcesRepository(cred, clientOptions, providerConfig, c) + containerRegistryRepo := repository.NewContainerRegistryRepository(cred, clientOptions, providerConfig, c) + postgresqlRepo := repository.NewPostgresqlRepository(cred, clientOptions, providerConfig, c) + privateDNSRepo := repository.NewPrivateDNSRepository(cred, clientOptions, providerConfig, c) + computeRepo := repository.NewComputeRepository(cred, clientOptions, providerConfig, c) providerLibrary.AddProvider(terraform.AZURE, provider) deserializer := resource.NewDeserializer(factory) diff --git a/enumeration/remote/azurerm_compute_scanner_test.go b/enumeration/remote/azurerm_compute_scanner_test.go index cb12ac8fd..65bfdad6b 100644 --- a/enumeration/remote/azurerm_compute_scanner_test.go +++ b/enumeration/remote/azurerm_compute_scanner_test.go @@ -5,7 +5,7 @@ import ( "github.com/snyk/driftctl/enumeration" azurerm2 "github.com/snyk/driftctl/enumeration/remote/azurerm" - repository2 "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" "github.com/snyk/driftctl/enumeration/remote/cache" common2 "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" @@ -34,13 +34,13 @@ func TestAzurermCompute_Image(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockComputeRepository, *mocks.AlerterInterface) + mocks func(*repository.MockComputeRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no images", - mocks: func(repository *repository2.MockComputeRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockComputeRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllImages").Return([]*armcompute.Image{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -49,14 +49,14 @@ func TestAzurermCompute_Image(t *testing.T) { }, { test: "error listing images", - mocks: func(repository *repository2.MockComputeRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockComputeRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllImages").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceazure.AzureImageResourceType), }, { test: "multiple images including an invalid ID", - mocks: func(repository *repository2.MockComputeRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockComputeRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllImages").Return([]*armcompute.Image{ { Resource: armcompute.Resource{ @@ -102,7 +102,7 @@ func TestAzurermCompute_Image(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockComputeRepository{} + fakeRepo := &repository.MockComputeRepository{} c.mocks(fakeRepo, alerter) remoteLibrary.AddEnumerator(azurerm2.NewAzurermImageEnumerator(fakeRepo, factory)) @@ -131,20 +131,20 @@ func TestAzurermCompute_SSHPublicKey(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockComputeRepository, *mocks.AlerterInterface) + mocks func(*repository.MockComputeRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no public key", dirName: "azurerm_ssh_public_key_empty", - mocks: func(repository *repository2.MockComputeRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockComputeRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllSSHPublicKeys").Return([]*armcompute.SSHPublicKeyResource{}, nil) }, }, { test: "error listing public keys", dirName: "azurerm_ssh_public_key_empty", - mocks: func(repository *repository2.MockComputeRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockComputeRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllSSHPublicKeys").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceazure.AzureSSHPublicKeyResourceType), @@ -152,7 +152,7 @@ func TestAzurermCompute_SSHPublicKey(t *testing.T) { { test: "multiple public keys", dirName: "azurerm_ssh_public_key_multiple", - mocks: func(repository *repository2.MockComputeRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockComputeRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllSSHPublicKeys").Return([]*armcompute.SSHPublicKeyResource{ { Resource: armcompute.Resource{ @@ -187,10 +187,10 @@ func TestAzurermCompute_SSHPublicKey(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockComputeRepository{} + fakeRepo := &repository.MockComputeRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.ComputeRepository = fakeRepo + var repo repository.ComputeRepository = fakeRepo providerVersion := "2.71.0" realProvider, err := terraform2.InitTestAzureProvider(providerLibrary, providerVersion) if err != nil { @@ -211,7 +211,7 @@ func TestAzurermCompute_SSHPublicKey(t *testing.T) { t.Fatal(err) } clientOptions := &arm.ClientOptions{} - repo = repository2.NewComputeRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) + repo = repository.NewComputeRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } remoteLibrary.AddEnumerator(azurerm2.NewAzurermSSHPublicKeyEnumerator(repo, factory)) diff --git a/enumeration/remote/azurerm_containerregistry_scanner_test.go b/enumeration/remote/azurerm_containerregistry_scanner_test.go index 070e77d6f..06fbaadf9 100644 --- a/enumeration/remote/azurerm_containerregistry_scanner_test.go +++ b/enumeration/remote/azurerm_containerregistry_scanner_test.go @@ -5,7 +5,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/azurerm" - repository2 "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" "github.com/snyk/driftctl/enumeration/remote/common" error2 "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/terraform" @@ -28,13 +28,13 @@ func TestAzurermContainerRegistry(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockContainerRegistryRepository, *mocks.AlerterInterface) + mocks func(*repository.MockContainerRegistryRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no container registry", - mocks: func(repository *repository2.MockContainerRegistryRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockContainerRegistryRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllContainerRegistries").Return([]*armcontainerregistry.Registry{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -43,14 +43,14 @@ func TestAzurermContainerRegistry(t *testing.T) { }, { test: "error listing container registry", - mocks: func(repository *repository2.MockContainerRegistryRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockContainerRegistryRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllContainerRegistries").Return(nil, dummyError) }, wantErr: error2.NewResourceListingError(dummyError, resourceazure.AzureContainerRegistryResourceType), }, { test: "multiple container registries", - mocks: func(repository *repository2.MockContainerRegistryRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockContainerRegistryRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllContainerRegistries").Return([]*armcontainerregistry.Registry{ { Resource: armcontainerregistry.Resource{ @@ -89,10 +89,10 @@ func TestAzurermContainerRegistry(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockContainerRegistryRepository{} + fakeRepo := &repository.MockContainerRegistryRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.ContainerRegistryRepository = fakeRepo + var repo repository.ContainerRegistryRepository = fakeRepo remoteLibrary.AddEnumerator(azurerm.NewAzurermContainerRegistryEnumerator(repo, factory)) diff --git a/enumeration/remote/azurerm_network_scanner_test.go b/enumeration/remote/azurerm_network_scanner_test.go index 629ce5a71..0197872ec 100644 --- a/enumeration/remote/azurerm_network_scanner_test.go +++ b/enumeration/remote/azurerm_network_scanner_test.go @@ -5,7 +5,7 @@ import ( "github.com/snyk/driftctl/enumeration" azurerm2 "github.com/snyk/driftctl/enumeration/remote/azurerm" - repository2 "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" "github.com/snyk/driftctl/enumeration/remote/cache" common2 "github.com/snyk/driftctl/enumeration/remote/common" error2 "github.com/snyk/driftctl/enumeration/remote/error" @@ -34,13 +34,13 @@ func TestAzurermVirtualNetwork(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockNetworkRepository, *mocks.AlerterInterface) + mocks func(*repository.MockNetworkRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no virtual network", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllVirtualNetworks").Return([]*armnetwork.VirtualNetwork{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -49,14 +49,14 @@ func TestAzurermVirtualNetwork(t *testing.T) { }, { test: "error listing virtual network", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllVirtualNetworks").Return(nil, dummyError) }, wantErr: error2.NewResourceListingError(dummyError, resourceazure.AzureVirtualNetworkResourceType), }, { test: "multiple virtual network", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllVirtualNetworks").Return([]*armnetwork.VirtualNetwork{ { Resource: armnetwork.Resource{ @@ -97,10 +97,10 @@ func TestAzurermVirtualNetwork(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockNetworkRepository{} + fakeRepo := &repository.MockNetworkRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.NetworkRepository = fakeRepo + var repo repository.NetworkRepository = fakeRepo remoteLibrary.AddEnumerator(azurerm2.NewAzurermVirtualNetworkEnumerator(repo, factory)) @@ -127,13 +127,13 @@ func TestAzurermRouteTables(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockNetworkRepository, *mocks.AlerterInterface) + mocks func(*repository.MockNetworkRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no route tables", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return([]*armnetwork.RouteTable{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -142,14 +142,14 @@ func TestAzurermRouteTables(t *testing.T) { }, { test: "error listing route tables", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return(nil, dummyError) }, wantErr: error2.NewResourceListingError(dummyError, resourceazure.AzureRouteTableResourceType), }, { test: "multiple route tables", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return([]*armnetwork.RouteTable{ { Resource: armnetwork.Resource{ @@ -190,10 +190,10 @@ func TestAzurermRouteTables(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockNetworkRepository{} + fakeRepo := &repository.MockNetworkRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.NetworkRepository = fakeRepo + var repo repository.NetworkRepository = fakeRepo remoteLibrary.AddEnumerator(azurerm2.NewAzurermRouteTableEnumerator(repo, factory)) @@ -220,13 +220,13 @@ func TestAzurermRoutes(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockNetworkRepository, *mocks.AlerterInterface) + mocks func(*repository.MockNetworkRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no route tables", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return([]*armnetwork.RouteTable{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -235,7 +235,7 @@ func TestAzurermRoutes(t *testing.T) { }, { test: "no routes", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return([]*armnetwork.RouteTable{ { Properties: &armnetwork.RouteTablePropertiesFormat{ @@ -255,14 +255,14 @@ func TestAzurermRoutes(t *testing.T) { }, { test: "error listing route tables", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return(nil, dummyError) }, wantErr: error2.NewResourceListingErrorWithType(dummyError, resourceazure.AzureRouteResourceType, resourceazure.AzureRouteTableResourceType), }, { test: "multiple routes", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllRouteTables").Return([]*armnetwork.RouteTable{ { Resource: armnetwork.Resource{ @@ -339,10 +339,10 @@ func TestAzurermRoutes(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockNetworkRepository{} + fakeRepo := &repository.MockNetworkRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.NetworkRepository = fakeRepo + var repo repository.NetworkRepository = fakeRepo remoteLibrary.AddEnumerator(azurerm2.NewAzurermRouteEnumerator(repo, factory)) @@ -382,13 +382,13 @@ func TestAzurermSubnets(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockNetworkRepository, *mocks.AlerterInterface) + mocks func(*repository.MockNetworkRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no subnets", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllVirtualNetworks").Return(networks, nil) repository.On("ListAllSubnets", networks[0]).Return([]*armnetwork.Subnet{}, nil).Times(1) repository.On("ListAllSubnets", networks[1]).Return([]*armnetwork.Subnet{}, nil).Times(1) @@ -399,14 +399,14 @@ func TestAzurermSubnets(t *testing.T) { }, { test: "error listing virtual network", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllVirtualNetworks").Return(nil, dummyError) }, wantErr: error2.NewResourceListingErrorWithType(dummyError, resourceazure.AzureSubnetResourceType, resourceazure.AzureVirtualNetworkResourceType), }, { test: "error listing subnets", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllVirtualNetworks").Return(networks, nil) repository.On("ListAllSubnets", networks[0]).Return(nil, dummyError).Times(1) }, @@ -414,7 +414,7 @@ func TestAzurermSubnets(t *testing.T) { }, { test: "multiple subnets", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllVirtualNetworks").Return(networks, nil) repository.On("ListAllSubnets", networks[0]).Return([]*armnetwork.Subnet{ { @@ -472,10 +472,10 @@ func TestAzurermSubnets(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockNetworkRepository{} + fakeRepo := &repository.MockNetworkRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.NetworkRepository = fakeRepo + var repo repository.NetworkRepository = fakeRepo remoteLibrary.AddEnumerator(azurerm2.NewAzurermSubnetEnumerator(repo, factory)) @@ -502,13 +502,13 @@ func TestAzurermFirewalls(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockNetworkRepository, *mocks.AlerterInterface) + mocks func(*repository.MockNetworkRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no firewall", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllFirewalls").Return([]*armnetwork.AzureFirewall{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -517,14 +517,14 @@ func TestAzurermFirewalls(t *testing.T) { }, { test: "error listing firewalls", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllFirewalls").Return(nil, dummyError) }, wantErr: error2.NewResourceListingError(dummyError, resourceazure.AzureFirewallResourceType), }, { test: "multiple firewalls", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllFirewalls").Return([]*armnetwork.AzureFirewall{ { Resource: armnetwork.Resource{ @@ -565,10 +565,10 @@ func TestAzurermFirewalls(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockNetworkRepository{} + fakeRepo := &repository.MockNetworkRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.NetworkRepository = fakeRepo + var repo repository.NetworkRepository = fakeRepo remoteLibrary.AddEnumerator(azurerm2.NewAzurermFirewallsEnumerator(repo, factory)) @@ -595,13 +595,13 @@ func TestAzurermPublicIP(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockNetworkRepository, *mocks.AlerterInterface) + mocks func(*repository.MockNetworkRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no public IP", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPublicIPAddresses").Return([]*armnetwork.PublicIPAddress{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -610,14 +610,14 @@ func TestAzurermPublicIP(t *testing.T) { }, { test: "error listing public IPs", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPublicIPAddresses").Return(nil, dummyError) }, wantErr: error2.NewResourceListingError(dummyError, resourceazure.AzurePublicIPResourceType), }, { test: "multiple public IP", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPublicIPAddresses").Return([]*armnetwork.PublicIPAddress{ { Resource: armnetwork.Resource{ @@ -658,10 +658,10 @@ func TestAzurermPublicIP(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockNetworkRepository{} + fakeRepo := &repository.MockNetworkRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.NetworkRepository = fakeRepo + var repo repository.NetworkRepository = fakeRepo remoteLibrary.AddEnumerator(azurerm2.NewAzurermPublicIPEnumerator(repo, factory)) @@ -689,20 +689,20 @@ func TestAzurermSecurityGroups(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockNetworkRepository, *mocks.AlerterInterface) + mocks func(*repository.MockNetworkRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no security group", dirName: "azurerm_network_security_group_empty", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllSecurityGroups").Return([]*armnetwork.NetworkSecurityGroup{}, nil) }, }, { test: "error listing security groups", dirName: "azurerm_network_security_group_empty", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllSecurityGroups").Return(nil, dummyError) }, wantErr: error2.NewResourceListingError(dummyError, resourceazure.AzureNetworkSecurityGroupResourceType), @@ -710,7 +710,7 @@ func TestAzurermSecurityGroups(t *testing.T) { { test: "multiple security groups", dirName: "azurerm_network_security_group_multiple", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllSecurityGroups").Return([]*armnetwork.NetworkSecurityGroup{ { Resource: armnetwork.Resource{ @@ -745,10 +745,10 @@ func TestAzurermSecurityGroups(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockNetworkRepository{} + fakeRepo := &repository.MockNetworkRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.NetworkRepository = fakeRepo + var repo repository.NetworkRepository = fakeRepo providerVersion := "2.71.0" realProvider, err := terraform2.InitTestAzureProvider(providerLibrary, providerVersion) if err != nil { @@ -769,7 +769,7 @@ func TestAzurermSecurityGroups(t *testing.T) { t.Fatal(err) } clientOptions := &arm.ClientOptions{} - repo = repository2.NewNetworkRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) + repo = repository.NewNetworkRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } remoteLibrary.AddEnumerator(azurerm2.NewAzurermNetworkSecurityGroupEnumerator(repo, factory)) @@ -798,13 +798,13 @@ func TestAzurermLoadBalancers(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockNetworkRepository, *mocks.AlerterInterface) + mocks func(*repository.MockNetworkRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no load balancer", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllLoadBalancers").Return([]*armnetwork.LoadBalancer{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -813,14 +813,14 @@ func TestAzurermLoadBalancers(t *testing.T) { }, { test: "error listing load balancers", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllLoadBalancers").Return(nil, dummyError) }, wantErr: error2.NewResourceListingError(dummyError, resourceazure.AzureLoadBalancerResourceType), }, { test: "multiple load balancers", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllLoadBalancers").Return([]*armnetwork.LoadBalancer{ { Resource: armnetwork.Resource{ @@ -861,10 +861,10 @@ func TestAzurermLoadBalancers(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockNetworkRepository{} + fakeRepo := &repository.MockNetworkRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.NetworkRepository = fakeRepo + var repo repository.NetworkRepository = fakeRepo remoteLibrary.AddEnumerator(azurerm2.NewAzurermLoadBalancerEnumerator(repo, factory)) @@ -892,13 +892,13 @@ func TestAzurermLoadBalancerRules(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockNetworkRepository, *mocks.AlerterInterface) + mocks func(*repository.MockNetworkRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no load balancer rule", dirName: "azurerm_lb_rule_empty", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { loadbalancer := &armnetwork.LoadBalancer{ Resource: armnetwork.Resource{ ID: to.StringPtr("/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/frontendIPConfigurations/PublicIPAddress"), @@ -914,7 +914,7 @@ func TestAzurermLoadBalancerRules(t *testing.T) { { test: "error listing load balancer rules", dirName: "azurerm_lb_rule_empty", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllLoadBalancers").Return(nil, dummyError) }, wantErr: error2.NewResourceListingErrorWithType(dummyError, resourceazure.AzureLoadBalancerRuleResourceType, resourceazure.AzureLoadBalancerResourceType), @@ -922,7 +922,7 @@ func TestAzurermLoadBalancerRules(t *testing.T) { { test: "multiple load balancer rules", dirName: "azurerm_lb_rule_multiple", - mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) { loadbalancer := &armnetwork.LoadBalancer{ Resource: armnetwork.Resource{ ID: to.StringPtr("/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/frontendIPConfigurations/PublicIPAddress"), @@ -966,10 +966,10 @@ func TestAzurermLoadBalancerRules(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockNetworkRepository{} + fakeRepo := &repository.MockNetworkRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.NetworkRepository = fakeRepo + var repo repository.NetworkRepository = fakeRepo providerVersion := "2.71.0" realProvider, err := terraform2.InitTestAzureProvider(providerLibrary, providerVersion) if err != nil { @@ -990,7 +990,7 @@ func TestAzurermLoadBalancerRules(t *testing.T) { t.Fatal(err) } clientOptions := &arm.ClientOptions{} - repo = repository2.NewNetworkRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) + repo = repository.NewNetworkRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } remoteLibrary.AddEnumerator(azurerm2.NewAzurermLoadBalancerRuleEnumerator(repo, factory)) diff --git a/enumeration/remote/azurerm_postgresql_scanner_test.go b/enumeration/remote/azurerm_postgresql_scanner_test.go index 9de49e5dd..8887b29ea 100644 --- a/enumeration/remote/azurerm_postgresql_scanner_test.go +++ b/enumeration/remote/azurerm_postgresql_scanner_test.go @@ -5,7 +5,7 @@ import ( "github.com/snyk/driftctl/enumeration" azurerm2 "github.com/snyk/driftctl/enumeration/remote/azurerm" - repository2 "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/terraform" @@ -28,13 +28,13 @@ func TestAzurermPostgresqlServer(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockPostgresqlRespository, *mocks.AlerterInterface) + mocks func(*repository.MockPostgresqlRespository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no postgres server", - mocks: func(repository *repository2.MockPostgresqlRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPostgresqlRespository, alerter *mocks.AlerterInterface) { repository.On("ListAllServers").Return([]*armpostgresql.Server{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -43,14 +43,14 @@ func TestAzurermPostgresqlServer(t *testing.T) { }, { test: "error listing postgres servers", - mocks: func(repository *repository2.MockPostgresqlRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPostgresqlRespository, alerter *mocks.AlerterInterface) { repository.On("ListAllServers").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceazure.AzurePostgresqlServerResourceType), }, { test: "multiple postgres servers", - mocks: func(repository *repository2.MockPostgresqlRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPostgresqlRespository, alerter *mocks.AlerterInterface) { repository.On("ListAllServers").Return([]*armpostgresql.Server{ { TrackedResource: armpostgresql.TrackedResource{ @@ -95,10 +95,10 @@ func TestAzurermPostgresqlServer(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockPostgresqlRespository{} + fakeRepo := &repository.MockPostgresqlRespository{} c.mocks(fakeRepo, alerter) - var repo repository2.PostgresqlRespository = fakeRepo + var repo repository.PostgresqlRespository = fakeRepo remoteLibrary.AddEnumerator(azurerm2.NewAzurermPostgresqlServerEnumerator(repo, factory)) @@ -125,13 +125,13 @@ func TestAzurermPostgresqlDatabase(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockPostgresqlRespository, *mocks.AlerterInterface) + mocks func(*repository.MockPostgresqlRespository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no postgres database", - mocks: func(repository *repository2.MockPostgresqlRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPostgresqlRespository, alerter *mocks.AlerterInterface) { repository.On("ListAllServers").Return([]*armpostgresql.Server{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -140,14 +140,14 @@ func TestAzurermPostgresqlDatabase(t *testing.T) { }, { test: "error listing postgres servers", - mocks: func(repository *repository2.MockPostgresqlRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPostgresqlRespository, alerter *mocks.AlerterInterface) { repository.On("ListAllServers").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceazure.AzurePostgresqlDatabaseResourceType, resourceazure.AzurePostgresqlServerResourceType), }, { test: "error listing postgres databases", - mocks: func(repository *repository2.MockPostgresqlRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPostgresqlRespository, alerter *mocks.AlerterInterface) { repository.On("ListAllServers").Return([]*armpostgresql.Server{ { TrackedResource: armpostgresql.TrackedResource{ @@ -165,7 +165,7 @@ func TestAzurermPostgresqlDatabase(t *testing.T) { }, { test: "multiple postgres databases", - mocks: func(repository *repository2.MockPostgresqlRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPostgresqlRespository, alerter *mocks.AlerterInterface) { repository.On("ListAllServers").Return([]*armpostgresql.Server{ { TrackedResource: armpostgresql.TrackedResource{ @@ -221,10 +221,10 @@ func TestAzurermPostgresqlDatabase(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockPostgresqlRespository{} + fakeRepo := &repository.MockPostgresqlRespository{} c.mocks(fakeRepo, alerter) - var repo repository2.PostgresqlRespository = fakeRepo + var repo repository.PostgresqlRespository = fakeRepo remoteLibrary.AddEnumerator(azurerm2.NewAzurermPostgresqlDatabaseEnumerator(repo, factory)) diff --git a/enumeration/remote/azurerm_privatedns_scanner_test.go b/enumeration/remote/azurerm_privatedns_scanner_test.go index e546d41eb..3f39b8b1f 100644 --- a/enumeration/remote/azurerm_privatedns_scanner_test.go +++ b/enumeration/remote/azurerm_privatedns_scanner_test.go @@ -5,7 +5,7 @@ import ( "github.com/snyk/driftctl/enumeration" azurerm2 "github.com/snyk/driftctl/enumeration/remote/azurerm" - repository2 "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" "github.com/snyk/driftctl/enumeration/remote/cache" common2 "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" @@ -35,20 +35,20 @@ func TestAzurermPrivateDNSZone(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockPrivateDNSRepository, *mocks.AlerterInterface) + mocks func(*repository.MockPrivateDNSRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no private zone", dirName: "azurerm_private_dns_private_zone_empty", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{}, nil) }, }, { test: "error listing private zones", dirName: "azurerm_private_dns_private_zone_empty", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceazure.AzurePrivateDNSZoneResourceType), @@ -56,7 +56,7 @@ func TestAzurermPrivateDNSZone(t *testing.T) { { test: "multiple private zones", dirName: "azurerm_private_dns_private_zone_multiple", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -103,10 +103,10 @@ func TestAzurermPrivateDNSZone(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockPrivateDNSRepository{} + fakeRepo := &repository.MockPrivateDNSRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.PrivateDNSRepository = fakeRepo + var repo repository.PrivateDNSRepository = fakeRepo providerVersion := "2.71.0" realProvider, err := terraformtest.InitTestAzureProvider(providerLibrary, providerVersion) if err != nil { @@ -127,7 +127,7 @@ func TestAzurermPrivateDNSZone(t *testing.T) { t.Fatal(err) } clientOptions := &arm.ClientOptions{} - repo = repository2.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) + repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSZoneEnumerator(repo, factory)) @@ -157,20 +157,20 @@ func TestAzurermPrivateDNSARecord(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockPrivateDNSRepository, *mocks.AlerterInterface) + mocks func(*repository.MockPrivateDNSRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no private a record", dirName: "azurerm_private_dns_a_record_empty", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{}, nil) }, }, { test: "error listing private zone", dirName: "azurerm_private_dns_a_record_empty", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceazure.AzurePrivateDNSARecordResourceType, resourceazure.AzurePrivateDNSZoneResourceType), @@ -178,7 +178,7 @@ func TestAzurermPrivateDNSARecord(t *testing.T) { { test: "error listing private a records", dirName: "azurerm_private_dns_a_record_empty", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -196,7 +196,7 @@ func TestAzurermPrivateDNSARecord(t *testing.T) { { test: "multiple private a records", dirName: "azurerm_private_dns_a_record_multiple", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -257,10 +257,10 @@ func TestAzurermPrivateDNSARecord(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockPrivateDNSRepository{} + fakeRepo := &repository.MockPrivateDNSRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.PrivateDNSRepository = fakeRepo + var repo repository.PrivateDNSRepository = fakeRepo providerVersion := "2.71.0" realProvider, err := terraformtest.InitTestAzureProvider(providerLibrary, providerVersion) if err != nil { @@ -281,7 +281,7 @@ func TestAzurermPrivateDNSARecord(t *testing.T) { t.Fatal(err) } clientOptions := &arm.ClientOptions{} - repo = repository2.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) + repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSARecordEnumerator(repo, factory)) @@ -311,20 +311,20 @@ func TestAzurermPrivateDNSAAAARecord(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockPrivateDNSRepository, *mocks.AlerterInterface) + mocks func(*repository.MockPrivateDNSRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no private aaaa record", dirName: "azurerm_private_dns_aaaa_record_empty", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{}, nil) }, }, { test: "error listing private zone", dirName: "azurerm_private_dns_aaaa_record_empty", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceazure.AzurePrivateDNSAAAARecordResourceType, resourceazure.AzurePrivateDNSZoneResourceType), @@ -332,7 +332,7 @@ func TestAzurermPrivateDNSAAAARecord(t *testing.T) { { test: "error listing private aaaa records", dirName: "azurerm_private_dns_aaaa_record_empty", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -350,7 +350,7 @@ func TestAzurermPrivateDNSAAAARecord(t *testing.T) { { test: "multiple private aaaaa records", dirName: "azurerm_private_dns_aaaaa_record_multiple", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -412,10 +412,10 @@ func TestAzurermPrivateDNSAAAARecord(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockPrivateDNSRepository{} + fakeRepo := &repository.MockPrivateDNSRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.PrivateDNSRepository = fakeRepo + var repo repository.PrivateDNSRepository = fakeRepo providerVersion := "2.71.0" realProvider, err := terraformtest.InitTestAzureProvider(providerLibrary, providerVersion) if err != nil { @@ -436,7 +436,7 @@ func TestAzurermPrivateDNSAAAARecord(t *testing.T) { t.Fatal(err) } clientOptions := &arm.ClientOptions{} - repo = repository2.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) + repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSAAAARecordEnumerator(repo, factory)) @@ -466,20 +466,20 @@ func TestAzurermPrivateDNSCNAMERecord(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockPrivateDNSRepository, *mocks.AlerterInterface) + mocks func(*repository.MockPrivateDNSRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no private cname record", dirName: "azurerm_private_dns_cname_record_empty", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{}, nil) }, }, { test: "error listing private zone", dirName: "azurerm_private_dns_cname_record_empty", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceazure.AzurePrivateDNSCNameRecordResourceType, resourceazure.AzurePrivateDNSZoneResourceType), @@ -487,7 +487,7 @@ func TestAzurermPrivateDNSCNAMERecord(t *testing.T) { { test: "error listing private cname records", dirName: "azurerm_private_dns_cname_record_empty", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -505,7 +505,7 @@ func TestAzurermPrivateDNSCNAMERecord(t *testing.T) { { test: "multiple private cname records", dirName: "azurerm_private_dns_cname_record_multiple", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -555,10 +555,10 @@ func TestAzurermPrivateDNSCNAMERecord(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockPrivateDNSRepository{} + fakeRepo := &repository.MockPrivateDNSRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.PrivateDNSRepository = fakeRepo + var repo repository.PrivateDNSRepository = fakeRepo providerVersion := "2.71.0" realProvider, err := terraformtest.InitTestAzureProvider(providerLibrary, providerVersion) if err != nil { @@ -579,7 +579,7 @@ func TestAzurermPrivateDNSCNAMERecord(t *testing.T) { t.Fatal(err) } clientOptions := &arm.ClientOptions{} - repo = repository2.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) + repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSCNameRecordEnumerator(repo, factory)) @@ -609,20 +609,20 @@ func TestAzurermPrivateDNSPTRRecord(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockPrivateDNSRepository, *mocks.AlerterInterface) + mocks func(*repository.MockPrivateDNSRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no private ptr record", dirName: "azurerm_private_dns_ptr_record_empty", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{}, nil) }, }, { test: "error listing private zone", dirName: "azurerm_private_dns_ptr_record_empty", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceazure.AzurePrivateDNSPTRRecordResourceType, resourceazure.AzurePrivateDNSZoneResourceType), @@ -630,7 +630,7 @@ func TestAzurermPrivateDNSPTRRecord(t *testing.T) { { test: "error listing private ptr records", dirName: "azurerm_private_dns_ptr_record_empty", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -648,7 +648,7 @@ func TestAzurermPrivateDNSPTRRecord(t *testing.T) { { test: "multiple private ptra records", dirName: "azurerm_private_dns_ptr_record_multiple", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -709,10 +709,10 @@ func TestAzurermPrivateDNSPTRRecord(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockPrivateDNSRepository{} + fakeRepo := &repository.MockPrivateDNSRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.PrivateDNSRepository = fakeRepo + var repo repository.PrivateDNSRepository = fakeRepo providerVersion := "2.71.0" realProvider, err := terraformtest.InitTestAzureProvider(providerLibrary, providerVersion) if err != nil { @@ -733,7 +733,7 @@ func TestAzurermPrivateDNSPTRRecord(t *testing.T) { t.Fatal(err) } clientOptions := &arm.ClientOptions{} - repo = repository2.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) + repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSPTRRecordEnumerator(repo, factory)) @@ -763,20 +763,20 @@ func TestAzurermPrivateDNSMXRecord(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockPrivateDNSRepository, *mocks.AlerterInterface) + mocks func(*repository.MockPrivateDNSRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no private mx record", dirName: "azurerm_private_dns_mx_record_empty", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{}, nil) }, }, { test: "error listing private zone", dirName: "azurerm_private_dns_mx_record_empty", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceazure.AzurePrivateDNSMXRecordResourceType, resourceazure.AzurePrivateDNSZoneResourceType), @@ -784,7 +784,7 @@ func TestAzurermPrivateDNSMXRecord(t *testing.T) { { test: "error listing private mx records", dirName: "azurerm_private_dns_mx_record_empty", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -802,7 +802,7 @@ func TestAzurermPrivateDNSMXRecord(t *testing.T) { { test: "multiple private mx records", dirName: "azurerm_private_dns_mx_record_multiple", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -864,10 +864,10 @@ func TestAzurermPrivateDNSMXRecord(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockPrivateDNSRepository{} + fakeRepo := &repository.MockPrivateDNSRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.PrivateDNSRepository = fakeRepo + var repo repository.PrivateDNSRepository = fakeRepo providerVersion := "2.71.0" realProvider, err := terraformtest.InitTestAzureProvider(providerLibrary, providerVersion) if err != nil { @@ -888,7 +888,7 @@ func TestAzurermPrivateDNSMXRecord(t *testing.T) { t.Fatal(err) } clientOptions := &arm.ClientOptions{} - repo = repository2.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) + repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSMXRecordEnumerator(repo, factory)) @@ -918,20 +918,20 @@ func TestAzurermPrivateDNSSRVRecord(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockPrivateDNSRepository, *mocks.AlerterInterface) + mocks func(*repository.MockPrivateDNSRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no private srv record", dirName: "azurerm_private_dns_srv_record_empty", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{}, nil) }, }, { test: "error listing private zone", dirName: "azurerm_private_dns_srv_record_empty", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceazure.AzurePrivateDNSSRVRecordResourceType, resourceazure.AzurePrivateDNSZoneResourceType), @@ -939,7 +939,7 @@ func TestAzurermPrivateDNSSRVRecord(t *testing.T) { { test: "error listing private srv records", dirName: "azurerm_private_dns_srv_record_empty", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -957,7 +957,7 @@ func TestAzurermPrivateDNSSRVRecord(t *testing.T) { { test: "multiple private srv records", dirName: "azurerm_private_dns_srv_record_multiple", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -1018,10 +1018,10 @@ func TestAzurermPrivateDNSSRVRecord(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockPrivateDNSRepository{} + fakeRepo := &repository.MockPrivateDNSRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.PrivateDNSRepository = fakeRepo + var repo repository.PrivateDNSRepository = fakeRepo providerVersion := "2.71.0" realProvider, err := terraformtest.InitTestAzureProvider(providerLibrary, providerVersion) if err != nil { @@ -1042,7 +1042,7 @@ func TestAzurermPrivateDNSSRVRecord(t *testing.T) { t.Fatal(err) } clientOptions := &arm.ClientOptions{} - repo = repository2.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) + repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSSRVRecordEnumerator(repo, factory)) @@ -1072,20 +1072,20 @@ func TestAzurermPrivateDNSTXTRecord(t *testing.T) { tests := []struct { test string dirName string - mocks func(*repository2.MockPrivateDNSRepository, *mocks.AlerterInterface) + mocks func(*repository.MockPrivateDNSRepository, *mocks.AlerterInterface) wantErr error }{ { test: "no private txt record", dirName: "azurerm_private_dns_txt_record_empty", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{}, nil) }, }, { test: "error listing private zone", dirName: "azurerm_private_dns_txt_record_empty", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return(nil, dummyError) }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceazure.AzurePrivateDNSTXTRecordResourceType, resourceazure.AzurePrivateDNSZoneResourceType), @@ -1093,7 +1093,7 @@ func TestAzurermPrivateDNSTXTRecord(t *testing.T) { { test: "error listing private txt records", dirName: "azurerm_private_dns_txt_record_empty", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -1111,7 +1111,7 @@ func TestAzurermPrivateDNSTXTRecord(t *testing.T) { { test: "multiple private txt records", dirName: "azurerm_private_dns_txt_record_multiple", - mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{ { TrackedResource: armprivatedns.TrackedResource{ @@ -1172,10 +1172,10 @@ func TestAzurermPrivateDNSTXTRecord(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockPrivateDNSRepository{} + fakeRepo := &repository.MockPrivateDNSRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.PrivateDNSRepository = fakeRepo + var repo repository.PrivateDNSRepository = fakeRepo providerVersion := "2.71.0" realProvider, err := terraformtest.InitTestAzureProvider(providerLibrary, providerVersion) if err != nil { @@ -1196,7 +1196,7 @@ func TestAzurermPrivateDNSTXTRecord(t *testing.T) { t.Fatal(err) } clientOptions := &arm.ClientOptions{} - repo = repository2.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) + repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSTXTRecordEnumerator(repo, factory)) diff --git a/enumeration/remote/azurerm_resources_scanner_test.go b/enumeration/remote/azurerm_resources_scanner_test.go index 40b427f9c..edf1c6327 100644 --- a/enumeration/remote/azurerm_resources_scanner_test.go +++ b/enumeration/remote/azurerm_resources_scanner_test.go @@ -5,7 +5,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/azurerm" - repository2 "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" "github.com/snyk/driftctl/enumeration/remote/common" error2 "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/terraform" @@ -28,13 +28,13 @@ func TestAzurermResourceGroups(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockResourcesRepository, *mocks.AlerterInterface) + mocks func(*repository.MockResourcesRepository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no resource group", - mocks: func(repository *repository2.MockResourcesRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockResourcesRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllResourceGroups").Return([]*armresources.ResourceGroup{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -43,14 +43,14 @@ func TestAzurermResourceGroups(t *testing.T) { }, { test: "error listing resource groups", - mocks: func(repository *repository2.MockResourcesRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockResourcesRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllResourceGroups").Return(nil, dummyError) }, wantErr: error2.NewResourceListingError(dummyError, resourceazure.AzureResourceGroupResourceType), }, { test: "multiple resource groups", - mocks: func(repository *repository2.MockResourcesRepository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockResourcesRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllResourceGroups").Return([]*armresources.ResourceGroup{ { ID: to.StringPtr("group1"), @@ -87,10 +87,10 @@ func TestAzurermResourceGroups(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockResourcesRepository{} + fakeRepo := &repository.MockResourcesRepository{} c.mocks(fakeRepo, alerter) - var repo repository2.ResourcesRepository = fakeRepo + var repo repository.ResourcesRepository = fakeRepo remoteLibrary.AddEnumerator(azurerm.NewAzurermResourceGroupEnumerator(repo, factory)) diff --git a/enumeration/remote/azurerm_storage_scanner_test.go b/enumeration/remote/azurerm_storage_scanner_test.go index 581f1a540..be7d56944 100644 --- a/enumeration/remote/azurerm_storage_scanner_test.go +++ b/enumeration/remote/azurerm_storage_scanner_test.go @@ -5,7 +5,7 @@ import ( "github.com/snyk/driftctl/enumeration" azurerm2 "github.com/snyk/driftctl/enumeration/remote/azurerm" - repository2 "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" + "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" "github.com/snyk/driftctl/enumeration/remote/common" error2 "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/terraform" @@ -27,13 +27,13 @@ func TestAzurermStorageAccount(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockStorageRespository, *mocks.AlerterInterface) + mocks func(*repository.MockStorageRespository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no storage accounts", - mocks: func(repository *repository2.MockStorageRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockStorageRespository, alerter *mocks.AlerterInterface) { repository.On("ListAllStorageAccount").Return([]*armstorage.StorageAccount{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -42,14 +42,14 @@ func TestAzurermStorageAccount(t *testing.T) { }, { test: "error listing storage accounts", - mocks: func(repository *repository2.MockStorageRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockStorageRespository, alerter *mocks.AlerterInterface) { repository.On("ListAllStorageAccount").Return(nil, dummyError) }, wantErr: error2.NewResourceListingError(dummyError, resourceazure.AzureStorageAccountResourceType), }, { test: "multiple storage accounts", - mocks: func(repository *repository2.MockStorageRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockStorageRespository, alerter *mocks.AlerterInterface) { repository.On("ListAllStorageAccount").Return([]*armstorage.StorageAccount{ { TrackedResource: armstorage.TrackedResource{ @@ -92,10 +92,10 @@ func TestAzurermStorageAccount(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockStorageRespository{} + fakeRepo := &repository.MockStorageRespository{} c.mocks(fakeRepo, alerter) - var repo repository2.StorageRespository = fakeRepo + var repo repository.StorageRespository = fakeRepo remoteLibrary.AddEnumerator(azurerm2.NewAzurermStorageAccountEnumerator(repo, factory)) @@ -122,13 +122,13 @@ func TestAzurermStorageContainer(t *testing.T) { tests := []struct { test string - mocks func(*repository2.MockStorageRespository, *mocks.AlerterInterface) + mocks func(*repository.MockStorageRespository, *mocks.AlerterInterface) assertExpected func(t *testing.T, got []*resource.Resource) wantErr error }{ { test: "no storage accounts", - mocks: func(repository *repository2.MockStorageRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockStorageRespository, alerter *mocks.AlerterInterface) { repository.On("ListAllStorageAccount").Return([]*armstorage.StorageAccount{}, nil) }, assertExpected: func(t *testing.T, got []*resource.Resource) { @@ -137,7 +137,7 @@ func TestAzurermStorageContainer(t *testing.T) { }, { test: "no storage containers", - mocks: func(repository *repository2.MockStorageRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockStorageRespository, alerter *mocks.AlerterInterface) { account1 := &armstorage.StorageAccount{ TrackedResource: armstorage.TrackedResource{ Resource: armstorage.Resource{ @@ -165,14 +165,14 @@ func TestAzurermStorageContainer(t *testing.T) { }, { test: "error listing storage accounts", - mocks: func(repository *repository2.MockStorageRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockStorageRespository, alerter *mocks.AlerterInterface) { repository.On("ListAllStorageAccount").Return(nil, dummyError) }, wantErr: error2.NewResourceListingErrorWithType(dummyError, resourceazure.AzureStorageContainerResourceType, resourceazure.AzureStorageAccountResourceType), }, { test: "error listing storage container", - mocks: func(repository *repository2.MockStorageRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockStorageRespository, alerter *mocks.AlerterInterface) { account := &armstorage.StorageAccount{ TrackedResource: armstorage.TrackedResource{ Resource: armstorage.Resource{ @@ -187,7 +187,7 @@ func TestAzurermStorageContainer(t *testing.T) { }, { test: "multiple storage containers", - mocks: func(repository *repository2.MockStorageRespository, alerter *mocks.AlerterInterface) { + mocks: func(repository *repository.MockStorageRespository, alerter *mocks.AlerterInterface) { account1 := &armstorage.StorageAccount{ TrackedResource: armstorage.TrackedResource{ Resource: armstorage.Resource{ @@ -237,10 +237,10 @@ func TestAzurermStorageContainer(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - fakeRepo := &repository2.MockStorageRespository{} + fakeRepo := &repository.MockStorageRespository{} c.mocks(fakeRepo, alerter) - var repo repository2.StorageRespository = fakeRepo + var repo repository.StorageRespository = fakeRepo remoteLibrary.AddEnumerator(azurerm2.NewAzurermStorageContainerEnumerator(repo, factory)) diff --git a/enumeration/remote/google/google_storage_bucket_iam_member_enumerator.go b/enumeration/remote/google/google_storage_bucket_iam_member_enumerator.go index 1006bb434..c38187db2 100644 --- a/enumeration/remote/google/google_storage_bucket_iam_member_enumerator.go +++ b/enumeration/remote/google/google_storage_bucket_iam_member_enumerator.go @@ -3,19 +3,19 @@ package google import ( "fmt" remoteerror "github.com/snyk/driftctl/enumeration/remote/error" - repository2 "github.com/snyk/driftctl/enumeration/remote/google/repository" + "github.com/snyk/driftctl/enumeration/remote/google/repository" "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/enumeration/resource/google" ) type GoogleStorageBucketIamMemberEnumerator struct { - repository repository2.AssetRepository - storageRepository repository2.StorageRepository + repository repository.AssetRepository + storageRepository repository.StorageRepository factory resource.ResourceFactory } -func NewGoogleStorageBucketIamMemberEnumerator(repo repository2.AssetRepository, storageRepo repository2.StorageRepository, factory resource.ResourceFactory) *GoogleStorageBucketIamMemberEnumerator { +func NewGoogleStorageBucketIamMemberEnumerator(repo repository.AssetRepository, storageRepo repository.StorageRepository, factory resource.ResourceFactory) *GoogleStorageBucketIamMemberEnumerator { return &GoogleStorageBucketIamMemberEnumerator{ repository: repo, storageRepository: storageRepo, diff --git a/enumeration/remote/google/init.go b/enumeration/remote/google/init.go index be795acd1..99e9deae8 100644 --- a/enumeration/remote/google/init.go +++ b/enumeration/remote/google/init.go @@ -8,7 +8,7 @@ import ( "github.com/snyk/driftctl/enumeration/alerter" "github.com/snyk/driftctl/enumeration/remote/cache" common2 "github.com/snyk/driftctl/enumeration/remote/common" - repository2 "github.com/snyk/driftctl/enumeration/remote/google/repository" + "github.com/snyk/driftctl/enumeration/remote/google/repository" "github.com/snyk/driftctl/enumeration/terraform" asset "cloud.google.com/go/asset/apiv1" @@ -59,9 +59,9 @@ func Init(version string, alerter *alerter.Alerter, return err } - assetRepository := repository2.NewAssetRepository(assetClient, provider.GetConfig(), repositoryCache) - storageRepository := repository2.NewStorageRepository(storageClient, repositoryCache) - iamRepository := repository2.NewCloudResourceManagerRepository(crmService, provider.GetConfig(), repositoryCache) + assetRepository := repository.NewAssetRepository(assetClient, provider.GetConfig(), repositoryCache) + storageRepository := repository.NewStorageRepository(storageClient, repositoryCache) + iamRepository := repository.NewCloudResourceManagerRepository(crmService, provider.GetConfig(), repositoryCache) providerLibrary.AddProvider(terraform.GOOGLE, provider) deserializer := resource.NewDeserializer(factory) diff --git a/enumeration/remote/google_storage_scanner_test.go b/enumeration/remote/google_storage_scanner_test.go index 57f7a76fc..75027fb7c 100644 --- a/enumeration/remote/google_storage_scanner_test.go +++ b/enumeration/remote/google_storage_scanner_test.go @@ -10,7 +10,7 @@ import ( common2 "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" google2 "github.com/snyk/driftctl/enumeration/remote/google" - repository2 "github.com/snyk/driftctl/enumeration/remote/google/repository" + "github.com/snyk/driftctl/enumeration/remote/google/repository" terraform3 "github.com/snyk/driftctl/enumeration/terraform" asset "cloud.google.com/go/asset/apiv1" @@ -140,7 +140,7 @@ func TestGoogleStorageBucket(t *testing.T) { provider.ShouldUpdate() } - repo := repository2.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) + repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) remoteLibrary.AddEnumerator(google2.NewGoogleStorageBucketEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resType, common2.NewGenericDetailsFetcher(resType, provider, deserializer)) @@ -166,8 +166,8 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { cases := []struct { test string dirName string - assetRepositoryMock func(assetRepository *repository2.MockAssetRepository) - storageRepositoryMock func(storageRepository *repository2.MockStorageRepository) + assetRepositoryMock func(assetRepository *repository.MockAssetRepository) + storageRepositoryMock func(storageRepository *repository.MockStorageRepository) responseErr error setupAlerterMock func(alerter *mocks.AlerterInterface) wantErr error @@ -175,7 +175,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { { test: "no storage buckets", dirName: "google_storage_bucket_member_empty", - assetRepositoryMock: func(assetRepository *repository2.MockAssetRepository) { + assetRepositoryMock: func(assetRepository *repository.MockAssetRepository) { assetRepository.On("SearchAllBuckets").Return([]*assetpb.ResourceSearchResult{}, nil) }, wantErr: nil, @@ -183,7 +183,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { { test: "multiples storage buckets, no bindings", dirName: "google_storage_bucket_member_empty", - assetRepositoryMock: func(assetRepository *repository2.MockAssetRepository) { + assetRepositoryMock: func(assetRepository *repository.MockAssetRepository) { assetRepository.On("SearchAllBuckets").Return([]*assetpb.ResourceSearchResult{ { AssetType: "storage.googleapis.com/Bucket", @@ -195,7 +195,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { }, }, nil) }, - storageRepositoryMock: func(storageRepository *repository2.MockStorageRepository) { + storageRepositoryMock: func(storageRepository *repository.MockStorageRepository) { storageRepository.On("ListAllBindings", "dctlgstoragebucketiambinding-1").Return(map[string][]string{}, nil) storageRepository.On("ListAllBindings", "dctlgstoragebucketiambinding-2").Return(map[string][]string{}, nil) }, @@ -204,7 +204,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { { test: "Cannot list bindings", dirName: "google_storage_bucket_member_listing_error", - assetRepositoryMock: func(assetRepository *repository2.MockAssetRepository) { + assetRepositoryMock: func(assetRepository *repository.MockAssetRepository) { assetRepository.On("SearchAllBuckets").Return([]*assetpb.ResourceSearchResult{ { AssetType: "storage.googleapis.com/Bucket", @@ -212,7 +212,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { }, }, nil) }, - storageRepositoryMock: func(storageRepository *repository2.MockStorageRepository) { + storageRepositoryMock: func(storageRepository *repository.MockStorageRepository) { storageRepository.On("ListAllBindings", "dctlgstoragebucketiambinding-1").Return( map[string][]string{}, errors.New("googleapi: Error 403: driftctl-acc-circle@driftctl-qa-1.iam.gserviceaccount.com does not have storage.buckets.getIamPolicy access to the Google Cloud Storage bucket., forbidden")) @@ -236,7 +236,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { { test: "multiples storage buckets, multiple bindings", dirName: "google_storage_bucket_member_listing_multiple", - assetRepositoryMock: func(assetRepository *repository2.MockAssetRepository) { + assetRepositoryMock: func(assetRepository *repository.MockAssetRepository) { assetRepository.On("SearchAllBuckets").Return([]*assetpb.ResourceSearchResult{ { AssetType: "storage.googleapis.com/Bucket", @@ -248,7 +248,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { }, }, nil) }, - storageRepositoryMock: func(storageRepository *repository2.MockStorageRepository) { + storageRepositoryMock: func(storageRepository *repository.MockStorageRepository) { storageRepository.On("ListAllBindings", "dctlgstoragebucketiambinding-1").Return(map[string][]string{ "roles/storage.admin": {"user:elie.charra@cloudskiff.com"}, "roles/storage.objectViewer": {"user:william.beuil@cloudskiff.com"}, @@ -286,24 +286,24 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { c.setupAlerterMock(alerter) } - storageRepo := &repository2.MockStorageRepository{} + storageRepo := &repository.MockStorageRepository{} if c.storageRepositoryMock != nil { c.storageRepositoryMock(storageRepo) } - var storageRepository repository2.StorageRepository = storageRepo + var storageRepository repository.StorageRepository = storageRepo if shouldUpdate { storageClient, err := storage.NewClient(context.Background()) if err != nil { panic(err) } - storageRepository = repository2.NewStorageRepository(storageClient, repositoryCache) + storageRepository = repository.NewStorageRepository(storageClient, repositoryCache) } - assetRepo := &repository2.MockAssetRepository{} + assetRepo := &repository.MockAssetRepository{} if c.assetRepositoryMock != nil { c.assetRepositoryMock(assetRepo) } - var assetRepository repository2.AssetRepository = assetRepo + var assetRepository repository.AssetRepository = assetRepo realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion) if err != nil { From 9392281176d323d6a611ec6bb7dc3e53b01bae1b Mon Sep 17 00:00:00 2001 From: Elie CHARRA Date: Wed, 6 Jul 2022 10:44:42 +0200 Subject: [PATCH 04/12] chore: fix mess with common imports --- enumeration/remote/aws/init.go | 120 +++++++------- .../remote/aws_api_gateway_scanner_test.go | 98 +++++------ .../remote/aws_apigatewayv2_scanner_test.go | 68 ++++---- ...aws_applicationautoscaling_scanner_test.go | 12 +- .../remote/aws_autoscaling_scanner_test.go | 6 +- .../remote/aws_cloudformation_scanner_test.go | 8 +- .../remote/aws_cloudfront_scanner_test.go | 8 +- .../remote/aws_dynamodb_scanner_test.go | 8 +- enumeration/remote/aws_ec2_scanner_test.go | 152 +++++++++--------- enumeration/remote/aws_ecr_scanner_test.go | 10 +- .../remote/aws_elasticache_scanner_test.go | 6 +- enumeration/remote/aws_elb_scanner_test.go | 6 +- enumeration/remote/aws_elbv2_scanner_test.go | 12 +- enumeration/remote/aws_iam_scanner_test.go | 62 +++---- enumeration/remote/aws_kms_scanner_test.go | 14 +- enumeration/remote/aws_lambda_scanner_test.go | 14 +- enumeration/remote/aws_rds_scanner_test.go | 20 +-- .../remote/aws_route53_scanner_test.go | 22 +-- enumeration/remote/aws_s3_scanner_test.go | 50 +++--- enumeration/remote/aws_sns_scanner_test.go | 20 +-- enumeration/remote/aws_sqs_scanner_test.go | 12 +- enumeration/remote/azurerm/init.go | 26 +-- .../remote/azurerm_compute_scanner_test.go | 8 +- .../remote/azurerm_network_scanner_test.go | 24 +-- .../remote/azurerm_privatedns_scanner_test.go | 34 ++-- enumeration/remote/github/init.go | 14 +- .../github_branch_protection_scanner_test.go | 8 +- .../remote/github_membership_scanner_test.go | 8 +- .../remote/github_repository_scanner_test.go | 8 +- .../github_team_membership_scanner_test.go | 8 +- .../remote/github_team_scanner_test.go | 8 +- enumeration/remote/google/init.go | 18 +-- .../remote/google_bigquery_scanner_test.go | 10 +- .../remote/google_bigtable_scanner_test.go | 10 +- .../google_cloudfunctions_scanner_test.go | 6 +- .../remote/google_cloudrun_scanner_test.go | 6 +- .../remote/google_compute_scanner_test.go | 70 ++++---- .../remote/google_network_scanner_test.go | 6 +- .../remote/google_project_scanner_test.go | 6 +- enumeration/remote/google_sql_scanner_test.go | 6 +- .../remote/google_storage_scanner_test.go | 12 +- enumeration/remote/remote.go | 20 +-- enumeration/remote/scanner_test.go | 6 +- 43 files changed, 525 insertions(+), 525 deletions(-) diff --git a/enumeration/remote/aws/init.go b/enumeration/remote/aws/init.go index 3225c1b17..c14a7eddc 100644 --- a/enumeration/remote/aws/init.go +++ b/enumeration/remote/aws/init.go @@ -6,7 +6,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/aws/client" "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/enumeration/terraform" @@ -19,7 +19,7 @@ import ( func Init(version string, alerter *alerter.Alerter, providerLibrary *terraform.ProviderLibrary, - remoteLibrary *common2.RemoteLibrary, + remoteLibrary *common.RemoteLibrary, progress enumeration.ProgressCounter, resourceSchemaRepository *resource.SchemaRepository, factory resource.ResourceFactory, @@ -65,139 +65,139 @@ func Init(version string, alerter *alerter.Alerter, providerLibrary.AddProvider(terraform.AWS, provider) remoteLibrary.AddEnumerator(NewS3BucketEnumerator(s3Repository, factory, provider.Config, alerter)) - remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketResourceType, common2.NewGenericDetailsFetcher(aws.AwsS3BucketResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketResourceType, common.NewGenericDetailsFetcher(aws.AwsS3BucketResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewS3BucketInventoryEnumerator(s3Repository, factory, provider.Config, alerter)) - remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketInventoryResourceType, common2.NewGenericDetailsFetcher(aws.AwsS3BucketInventoryResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketInventoryResourceType, common.NewGenericDetailsFetcher(aws.AwsS3BucketInventoryResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewS3BucketNotificationEnumerator(s3Repository, factory, provider.Config, alerter)) - remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketNotificationResourceType, common2.NewGenericDetailsFetcher(aws.AwsS3BucketNotificationResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketNotificationResourceType, common.NewGenericDetailsFetcher(aws.AwsS3BucketNotificationResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewS3BucketMetricsEnumerator(s3Repository, factory, provider.Config, alerter)) - remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketMetricResourceType, common2.NewGenericDetailsFetcher(aws.AwsS3BucketMetricResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketMetricResourceType, common.NewGenericDetailsFetcher(aws.AwsS3BucketMetricResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewS3BucketPolicyEnumerator(s3Repository, factory, provider.Config, alerter)) - remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketPolicyResourceType, common2.NewGenericDetailsFetcher(aws.AwsS3BucketPolicyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketPolicyResourceType, common.NewGenericDetailsFetcher(aws.AwsS3BucketPolicyResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewS3BucketAnalyticEnumerator(s3Repository, factory, provider.Config, alerter)) - remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketAnalyticsConfigurationResourceType, common2.NewGenericDetailsFetcher(aws.AwsS3BucketAnalyticsConfigurationResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketAnalyticsConfigurationResourceType, common.NewGenericDetailsFetcher(aws.AwsS3BucketAnalyticsConfigurationResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewS3BucketPublicAccessBlockEnumerator(s3Repository, factory, provider.Config, alerter)) remoteLibrary.AddEnumerator(NewEC2EbsVolumeEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsEbsVolumeResourceType, common2.NewGenericDetailsFetcher(aws.AwsEbsVolumeResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsEbsVolumeResourceType, common.NewGenericDetailsFetcher(aws.AwsEbsVolumeResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2EbsSnapshotEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsEbsSnapshotResourceType, common2.NewGenericDetailsFetcher(aws.AwsEbsSnapshotResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsEbsSnapshotResourceType, common.NewGenericDetailsFetcher(aws.AwsEbsSnapshotResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2EipEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsEipResourceType, common2.NewGenericDetailsFetcher(aws.AwsEipResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsEipResourceType, common.NewGenericDetailsFetcher(aws.AwsEipResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2AmiEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsAmiResourceType, common2.NewGenericDetailsFetcher(aws.AwsAmiResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsAmiResourceType, common.NewGenericDetailsFetcher(aws.AwsAmiResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2KeyPairEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsKeyPairResourceType, common2.NewGenericDetailsFetcher(aws.AwsKeyPairResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsKeyPairResourceType, common.NewGenericDetailsFetcher(aws.AwsKeyPairResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2EipAssociationEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsEipAssociationResourceType, common2.NewGenericDetailsFetcher(aws.AwsEipAssociationResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsEipAssociationResourceType, common.NewGenericDetailsFetcher(aws.AwsEipAssociationResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2InstanceEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsInstanceResourceType, common2.NewGenericDetailsFetcher(aws.AwsInstanceResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsInstanceResourceType, common.NewGenericDetailsFetcher(aws.AwsInstanceResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2InternetGatewayEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsInternetGatewayResourceType, common2.NewGenericDetailsFetcher(aws.AwsInternetGatewayResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsInternetGatewayResourceType, common.NewGenericDetailsFetcher(aws.AwsInternetGatewayResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewVPCEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsVpcResourceType, common2.NewGenericDetailsFetcher(aws.AwsVpcResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsVpcResourceType, common.NewGenericDetailsFetcher(aws.AwsVpcResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewDefaultVPCEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsDefaultVpcResourceType, common2.NewGenericDetailsFetcher(aws.AwsDefaultVpcResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsDefaultVpcResourceType, common.NewGenericDetailsFetcher(aws.AwsDefaultVpcResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2RouteTableEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsRouteTableResourceType, common2.NewGenericDetailsFetcher(aws.AwsRouteTableResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsRouteTableResourceType, common.NewGenericDetailsFetcher(aws.AwsRouteTableResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2DefaultRouteTableEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsDefaultRouteTableResourceType, common2.NewGenericDetailsFetcher(aws.AwsDefaultRouteTableResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsDefaultRouteTableResourceType, common.NewGenericDetailsFetcher(aws.AwsDefaultRouteTableResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2RouteTableAssociationEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsRouteTableAssociationResourceType, common2.NewGenericDetailsFetcher(aws.AwsRouteTableAssociationResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsRouteTableAssociationResourceType, common.NewGenericDetailsFetcher(aws.AwsRouteTableAssociationResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2SubnetEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsSubnetResourceType, common2.NewGenericDetailsFetcher(aws.AwsSubnetResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsSubnetResourceType, common.NewGenericDetailsFetcher(aws.AwsSubnetResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2DefaultSubnetEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsDefaultSubnetResourceType, common2.NewGenericDetailsFetcher(aws.AwsDefaultSubnetResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsDefaultSubnetResourceType, common.NewGenericDetailsFetcher(aws.AwsDefaultSubnetResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewVPCSecurityGroupEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsSecurityGroupResourceType, common2.NewGenericDetailsFetcher(aws.AwsSecurityGroupResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsSecurityGroupResourceType, common.NewGenericDetailsFetcher(aws.AwsSecurityGroupResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewVPCDefaultSecurityGroupEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsDefaultSecurityGroupResourceType, common2.NewGenericDetailsFetcher(aws.AwsDefaultSecurityGroupResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsDefaultSecurityGroupResourceType, common.NewGenericDetailsFetcher(aws.AwsDefaultSecurityGroupResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2NatGatewayEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsNatGatewayResourceType, common2.NewGenericDetailsFetcher(aws.AwsNatGatewayResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsNatGatewayResourceType, common.NewGenericDetailsFetcher(aws.AwsNatGatewayResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2NetworkACLEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsNetworkACLResourceType, common2.NewGenericDetailsFetcher(aws.AwsNetworkACLResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsNetworkACLResourceType, common.NewGenericDetailsFetcher(aws.AwsNetworkACLResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2NetworkACLRuleEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsNetworkACLRuleResourceType, common2.NewGenericDetailsFetcher(aws.AwsNetworkACLRuleResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsNetworkACLRuleResourceType, common.NewGenericDetailsFetcher(aws.AwsNetworkACLRuleResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2DefaultNetworkACLEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsDefaultNetworkACLResourceType, common2.NewGenericDetailsFetcher(aws.AwsDefaultNetworkACLResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsDefaultNetworkACLResourceType, common.NewGenericDetailsFetcher(aws.AwsDefaultNetworkACLResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2RouteEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsRouteResourceType, common2.NewGenericDetailsFetcher(aws.AwsRouteResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsRouteResourceType, common.NewGenericDetailsFetcher(aws.AwsRouteResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewVPCSecurityGroupRuleEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsSecurityGroupRuleResourceType, common2.NewGenericDetailsFetcher(aws.AwsSecurityGroupRuleResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsSecurityGroupRuleResourceType, common.NewGenericDetailsFetcher(aws.AwsSecurityGroupRuleResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewLaunchTemplateEnumerator(ec2repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsLaunchTemplateResourceType, common2.NewGenericDetailsFetcher(aws.AwsLaunchTemplateResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsLaunchTemplateResourceType, common.NewGenericDetailsFetcher(aws.AwsLaunchTemplateResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewEC2EbsEncryptionByDefaultEnumerator(ec2repository, factory)) remoteLibrary.AddEnumerator(NewKMSKeyEnumerator(kmsRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsKmsKeyResourceType, common2.NewGenericDetailsFetcher(aws.AwsKmsKeyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsKmsKeyResourceType, common.NewGenericDetailsFetcher(aws.AwsKmsKeyResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewKMSAliasEnumerator(kmsRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsKmsAliasResourceType, common2.NewGenericDetailsFetcher(aws.AwsKmsAliasResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsKmsAliasResourceType, common.NewGenericDetailsFetcher(aws.AwsKmsAliasResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewRoute53HealthCheckEnumerator(route53repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsRoute53HealthCheckResourceType, common2.NewGenericDetailsFetcher(aws.AwsRoute53HealthCheckResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsRoute53HealthCheckResourceType, common.NewGenericDetailsFetcher(aws.AwsRoute53HealthCheckResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewRoute53ZoneEnumerator(route53repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsRoute53ZoneResourceType, common2.NewGenericDetailsFetcher(aws.AwsRoute53ZoneResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsRoute53ZoneResourceType, common.NewGenericDetailsFetcher(aws.AwsRoute53ZoneResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewRoute53RecordEnumerator(route53repository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsRoute53RecordResourceType, common2.NewGenericDetailsFetcher(aws.AwsRoute53RecordResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsRoute53RecordResourceType, common.NewGenericDetailsFetcher(aws.AwsRoute53RecordResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewCloudfrontDistributionEnumerator(cloudfrontRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsCloudfrontDistributionResourceType, common2.NewGenericDetailsFetcher(aws.AwsCloudfrontDistributionResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsCloudfrontDistributionResourceType, common.NewGenericDetailsFetcher(aws.AwsCloudfrontDistributionResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewRDSDBInstanceEnumerator(rdsRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsDbInstanceResourceType, common2.NewGenericDetailsFetcher(aws.AwsDbInstanceResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsDbInstanceResourceType, common.NewGenericDetailsFetcher(aws.AwsDbInstanceResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewRDSDBSubnetGroupEnumerator(rdsRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsDbSubnetGroupResourceType, common2.NewGenericDetailsFetcher(aws.AwsDbSubnetGroupResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsDbSubnetGroupResourceType, common.NewGenericDetailsFetcher(aws.AwsDbSubnetGroupResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewSQSQueueEnumerator(sqsRepository, factory)) remoteLibrary.AddDetailsFetcher(aws.AwsSqsQueueResourceType, NewSQSQueueDetailsFetcher(provider, deserializer)) remoteLibrary.AddEnumerator(NewSQSQueuePolicyEnumerator(sqsRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsSqsQueuePolicyResourceType, common2.NewGenericDetailsFetcher(aws.AwsSqsQueuePolicyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsSqsQueuePolicyResourceType, common.NewGenericDetailsFetcher(aws.AwsSqsQueuePolicyResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewSNSTopicEnumerator(snsRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsSnsTopicResourceType, common2.NewGenericDetailsFetcher(aws.AwsSnsTopicResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsSnsTopicResourceType, common.NewGenericDetailsFetcher(aws.AwsSnsTopicResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewSNSTopicPolicyEnumerator(snsRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsSnsTopicPolicyResourceType, common2.NewGenericDetailsFetcher(aws.AwsSnsTopicPolicyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsSnsTopicPolicyResourceType, common.NewGenericDetailsFetcher(aws.AwsSnsTopicPolicyResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewSNSTopicSubscriptionEnumerator(snsRepository, factory, alerter)) - remoteLibrary.AddDetailsFetcher(aws.AwsSnsTopicSubscriptionResourceType, common2.NewGenericDetailsFetcher(aws.AwsSnsTopicSubscriptionResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsSnsTopicSubscriptionResourceType, common.NewGenericDetailsFetcher(aws.AwsSnsTopicSubscriptionResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewDynamoDBTableEnumerator(dynamoDBRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsDynamodbTableResourceType, common2.NewGenericDetailsFetcher(aws.AwsDynamodbTableResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsDynamodbTableResourceType, common.NewGenericDetailsFetcher(aws.AwsDynamodbTableResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewIamPolicyEnumerator(iamRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsIamPolicyResourceType, common2.NewGenericDetailsFetcher(aws.AwsIamPolicyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsIamPolicyResourceType, common.NewGenericDetailsFetcher(aws.AwsIamPolicyResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewLambdaFunctionEnumerator(lambdaRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsLambdaFunctionResourceType, common2.NewGenericDetailsFetcher(aws.AwsLambdaFunctionResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsLambdaFunctionResourceType, common.NewGenericDetailsFetcher(aws.AwsLambdaFunctionResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewLambdaEventSourceMappingEnumerator(lambdaRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsLambdaEventSourceMappingResourceType, common2.NewGenericDetailsFetcher(aws.AwsLambdaEventSourceMappingResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsLambdaEventSourceMappingResourceType, common.NewGenericDetailsFetcher(aws.AwsLambdaEventSourceMappingResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewIamUserEnumerator(iamRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsIamUserResourceType, common2.NewGenericDetailsFetcher(aws.AwsIamUserResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsIamUserResourceType, common.NewGenericDetailsFetcher(aws.AwsIamUserResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewIamUserPolicyEnumerator(iamRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsIamUserPolicyResourceType, common2.NewGenericDetailsFetcher(aws.AwsIamUserPolicyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsIamUserPolicyResourceType, common.NewGenericDetailsFetcher(aws.AwsIamUserPolicyResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewIamRoleEnumerator(iamRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsIamRoleResourceType, common2.NewGenericDetailsFetcher(aws.AwsIamRoleResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsIamRoleResourceType, common.NewGenericDetailsFetcher(aws.AwsIamRoleResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewIamAccessKeyEnumerator(iamRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsIamAccessKeyResourceType, common2.NewGenericDetailsFetcher(aws.AwsIamAccessKeyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsIamAccessKeyResourceType, common.NewGenericDetailsFetcher(aws.AwsIamAccessKeyResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewIamRolePolicyAttachmentEnumerator(iamRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsIamRolePolicyAttachmentResourceType, common2.NewGenericDetailsFetcher(aws.AwsIamRolePolicyAttachmentResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsIamRolePolicyAttachmentResourceType, common.NewGenericDetailsFetcher(aws.AwsIamRolePolicyAttachmentResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewIamRolePolicyEnumerator(iamRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsIamRolePolicyResourceType, common2.NewGenericDetailsFetcher(aws.AwsIamRolePolicyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsIamRolePolicyResourceType, common.NewGenericDetailsFetcher(aws.AwsIamRolePolicyResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewIamUserPolicyAttachmentEnumerator(iamRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsIamUserPolicyAttachmentResourceType, common2.NewGenericDetailsFetcher(aws.AwsIamUserPolicyAttachmentResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsIamUserPolicyAttachmentResourceType, common.NewGenericDetailsFetcher(aws.AwsIamUserPolicyAttachmentResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewIamGroupPolicyEnumerator(iamRepository, factory)) remoteLibrary.AddEnumerator(NewIamGroupEnumerator(iamRepository, factory)) remoteLibrary.AddEnumerator(NewIamGroupPolicyAttachmentEnumerator(iamRepository, factory)) remoteLibrary.AddEnumerator(NewECRRepositoryEnumerator(ecrRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsEcrRepositoryResourceType, common2.NewGenericDetailsFetcher(aws.AwsEcrRepositoryResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsEcrRepositoryResourceType, common.NewGenericDetailsFetcher(aws.AwsEcrRepositoryResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewECRRepositoryPolicyEnumerator(ecrRepository, factory)) remoteLibrary.AddEnumerator(NewRDSClusterEnumerator(rdsRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsRDSClusterResourceType, common2.NewGenericDetailsFetcher(aws.AwsRDSClusterResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsRDSClusterResourceType, common.NewGenericDetailsFetcher(aws.AwsRDSClusterResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewCloudformationStackEnumerator(cloudformationRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsCloudformationStackResourceType, common2.NewGenericDetailsFetcher(aws.AwsCloudformationStackResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsCloudformationStackResourceType, common.NewGenericDetailsFetcher(aws.AwsCloudformationStackResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewApiGatewayRestApiEnumerator(apigatewayRepository, factory)) remoteLibrary.AddEnumerator(NewApiGatewayAccountEnumerator(apigatewayRepository, factory)) @@ -232,10 +232,10 @@ func Init(version string, alerter *alerter.Alerter, remoteLibrary.AddEnumerator(NewApiGatewayV2IntegrationResponseEnumerator(apigatewayv2Repository, factory)) remoteLibrary.AddEnumerator(NewAppAutoscalingTargetEnumerator(appAutoScalingRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsAppAutoscalingTargetResourceType, common2.NewGenericDetailsFetcher(aws.AwsAppAutoscalingTargetResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsAppAutoscalingTargetResourceType, common.NewGenericDetailsFetcher(aws.AwsAppAutoscalingTargetResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewAppAutoscalingPolicyEnumerator(appAutoScalingRepository, factory)) - remoteLibrary.AddDetailsFetcher(aws.AwsAppAutoscalingPolicyResourceType, common2.NewGenericDetailsFetcher(aws.AwsAppAutoscalingPolicyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(aws.AwsAppAutoscalingPolicyResourceType, common.NewGenericDetailsFetcher(aws.AwsAppAutoscalingPolicyResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewAppAutoscalingScheduledActionEnumerator(appAutoScalingRepository, factory)) diff --git a/enumeration/remote/aws_api_gateway_scanner_test.go b/enumeration/remote/aws_api_gateway_scanner_test.go index 041afa86f..0545f8946 100644 --- a/enumeration/remote/aws_api_gateway_scanner_test.go +++ b/enumeration/remote/aws_api_gateway_scanner_test.go @@ -10,7 +10,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/alerts" aws2 "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/resource" resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" @@ -63,7 +63,7 @@ func TestApiGatewayRestApi(t *testing.T) { test: "cannot list api gateway rest apis", mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllRestApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayRestApiResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayRestApiResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayRestApiResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayRestApiResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayRestApiResourceType), }, @@ -77,7 +77,7 @@ func TestApiGatewayRestApi(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -140,7 +140,7 @@ func TestApiGatewayAccount(t *testing.T) { test: "cannot get api gateway account", mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("GetAccount").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayAccountResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayAccountResourceType, resourceaws.AwsApiGatewayAccountResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayAccountResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayAccountResourceType, resourceaws.AwsApiGatewayAccountResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayAccountResourceType), }, @@ -154,7 +154,7 @@ func TestApiGatewayAccount(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -223,7 +223,7 @@ func TestApiGatewayApiKey(t *testing.T) { test: "cannot list api gateway api keys", mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllApiKeys").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayApiKeyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayApiKeyResourceType, resourceaws.AwsApiGatewayApiKeyResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayApiKeyResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayApiKeyResourceType, resourceaws.AwsApiGatewayApiKeyResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayApiKeyResourceType), }, @@ -237,7 +237,7 @@ func TestApiGatewayApiKey(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -315,7 +315,7 @@ func TestApiGatewayAuthorizer(t *testing.T) { test: "cannot list rest apis", mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayAuthorizerResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayAuthorizerResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayAuthorizerResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayAuthorizerResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayAuthorizerResourceType, resourceaws.AwsApiGatewayRestApiResourceType), }, @@ -324,7 +324,7 @@ func TestApiGatewayAuthorizer(t *testing.T) { mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiAuthorizers", *apis[0].Id).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayAuthorizerResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayAuthorizerResourceType, resourceaws.AwsApiGatewayAuthorizerResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayAuthorizerResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayAuthorizerResourceType, resourceaws.AwsApiGatewayAuthorizerResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayAuthorizerResourceType), }, @@ -338,7 +338,7 @@ func TestApiGatewayAuthorizer(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -412,7 +412,7 @@ func TestApiGatewayStage(t *testing.T) { test: "cannot list rest apis", mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayStageResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayStageResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayStageResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayStageResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayStageResourceType, resourceaws.AwsApiGatewayRestApiResourceType), }, @@ -421,7 +421,7 @@ func TestApiGatewayStage(t *testing.T) { mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiStages", *apis[0].Id).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayStageResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayStageResourceType, resourceaws.AwsApiGatewayStageResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayStageResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayStageResourceType, resourceaws.AwsApiGatewayStageResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayStageResourceType), }, @@ -435,7 +435,7 @@ func TestApiGatewayStage(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -509,7 +509,7 @@ func TestApiGatewayResource(t *testing.T) { test: "cannot list rest apis", mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayResourceResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayResourceResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayResourceResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayResourceResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayResourceResourceType, resourceaws.AwsApiGatewayRestApiResourceType), }, @@ -518,7 +518,7 @@ func TestApiGatewayResource(t *testing.T) { mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayResourceResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayResourceResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayResourceResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayResourceResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayResourceResourceType), }, @@ -532,7 +532,7 @@ func TestApiGatewayResource(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -597,7 +597,7 @@ func TestApiGatewayDomainName(t *testing.T) { test: "cannot list api gateway domain names", mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDomainNames").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayDomainNameResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayDomainNameResourceType, resourceaws.AwsApiGatewayDomainNameResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayDomainNameResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayDomainNameResourceType, resourceaws.AwsApiGatewayDomainNameResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayDomainNameResourceType), }, @@ -611,7 +611,7 @@ func TestApiGatewayDomainName(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -676,7 +676,7 @@ func TestApiGatewayVpcLink(t *testing.T) { test: "cannot list api gateway vpc links", mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllVpcLinks").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayVpcLinkResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayVpcLinkResourceType, resourceaws.AwsApiGatewayVpcLinkResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayVpcLinkResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayVpcLinkResourceType, resourceaws.AwsApiGatewayVpcLinkResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayVpcLinkResourceType), }, @@ -690,7 +690,7 @@ func TestApiGatewayVpcLink(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -764,7 +764,7 @@ func TestApiGatewayRequestValidator(t *testing.T) { test: "cannot list rest apis", mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayRequestValidatorResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayRequestValidatorResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayRequestValidatorResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayRequestValidatorResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayRequestValidatorResourceType, resourceaws.AwsApiGatewayRestApiResourceType), }, @@ -773,7 +773,7 @@ func TestApiGatewayRequestValidator(t *testing.T) { mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiRequestValidators", *apis[0].Id).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayRequestValidatorResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayRequestValidatorResourceType, resourceaws.AwsApiGatewayRequestValidatorResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayRequestValidatorResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayRequestValidatorResourceType, resourceaws.AwsApiGatewayRequestValidatorResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayRequestValidatorResourceType), }, @@ -787,7 +787,7 @@ func TestApiGatewayRequestValidator(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -859,7 +859,7 @@ func TestApiGatewayRestApiPolicy(t *testing.T) { test: "cannot list rest apis", mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayRestApiPolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayRestApiPolicyResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayRestApiPolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayRestApiPolicyResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayRestApiPolicyResourceType, resourceaws.AwsApiGatewayRestApiResourceType), }, @@ -873,7 +873,7 @@ func TestApiGatewayRestApiPolicy(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -947,7 +947,7 @@ func TestApiGatewayBasePathMapping(t *testing.T) { test: "cannot list domain names", mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllDomainNames").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayBasePathMappingResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayBasePathMappingResourceType, resourceaws.AwsApiGatewayDomainNameResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayBasePathMappingResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayBasePathMappingResourceType, resourceaws.AwsApiGatewayDomainNameResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayBasePathMappingResourceType, resourceaws.AwsApiGatewayDomainNameResourceType), }, @@ -956,7 +956,7 @@ func TestApiGatewayBasePathMapping(t *testing.T) { mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllDomainNames").Return(domainNames, nil) repo.On("ListAllDomainNameBasePathMappings", *domainNames[0].DomainName).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayBasePathMappingResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayBasePathMappingResourceType, resourceaws.AwsApiGatewayBasePathMappingResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayBasePathMappingResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayBasePathMappingResourceType, resourceaws.AwsApiGatewayBasePathMappingResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayBasePathMappingResourceType), }, @@ -970,7 +970,7 @@ func TestApiGatewayBasePathMapping(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1052,7 +1052,7 @@ func TestApiGatewayMethod(t *testing.T) { test: "cannot list rest apis", mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResourceType, resourceaws.AwsApiGatewayRestApiResourceType), }, @@ -1061,7 +1061,7 @@ func TestApiGatewayMethod(t *testing.T) { mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResourceType, resourceaws.AwsApiGatewayResourceResourceType), }, @@ -1075,7 +1075,7 @@ func TestApiGatewayMethod(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1149,7 +1149,7 @@ func TestApiGatewayModel(t *testing.T) { test: "cannot list rest apis", mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayModelResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayModelResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayModelResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayModelResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayModelResourceType, resourceaws.AwsApiGatewayRestApiResourceType), }, @@ -1158,7 +1158,7 @@ func TestApiGatewayModel(t *testing.T) { mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiModels", *apis[0].Id).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayModelResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayModelResourceType, resourceaws.AwsApiGatewayModelResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayModelResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayModelResourceType, resourceaws.AwsApiGatewayModelResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayModelResourceType), }, @@ -1172,7 +1172,7 @@ func TestApiGatewayModel(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1258,7 +1258,7 @@ func TestApiGatewayMethodResponse(t *testing.T) { test: "cannot list rest apis", mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResponseResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResponseResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResponseResourceType, resourceaws.AwsApiGatewayRestApiResourceType), }, @@ -1267,7 +1267,7 @@ func TestApiGatewayMethodResponse(t *testing.T) { mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResponseResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResponseResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResponseResourceType, resourceaws.AwsApiGatewayResourceResourceType), }, @@ -1281,7 +1281,7 @@ func TestApiGatewayMethodResponse(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1355,7 +1355,7 @@ func TestApiGatewayGatewayResponse(t *testing.T) { test: "cannot list rest apis", mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayGatewayResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayGatewayResponseResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayGatewayResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayGatewayResponseResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayGatewayResponseResourceType, resourceaws.AwsApiGatewayRestApiResourceType), }, @@ -1364,7 +1364,7 @@ func TestApiGatewayGatewayResponse(t *testing.T) { mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiGatewayResponses", *apis[0].Id).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayGatewayResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayGatewayResponseResourceType, resourceaws.AwsApiGatewayGatewayResponseResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayGatewayResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayGatewayResponseResourceType, resourceaws.AwsApiGatewayGatewayResponseResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayGatewayResponseResourceType), }, @@ -1378,7 +1378,7 @@ func TestApiGatewayGatewayResponse(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1460,7 +1460,7 @@ func TestApiGatewayMethodSettings(t *testing.T) { test: "cannot list rest apis", mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodSettingsResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodSettingsResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodSettingsResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodSettingsResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodSettingsResourceType, resourceaws.AwsApiGatewayRestApiResourceType), }, @@ -1469,7 +1469,7 @@ func TestApiGatewayMethodSettings(t *testing.T) { mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiStages", *apis[0].Id).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodSettingsResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodSettingsResourceType, resourceaws.AwsApiGatewayStageResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodSettingsResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodSettingsResourceType, resourceaws.AwsApiGatewayStageResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodSettingsResourceType, resourceaws.AwsApiGatewayStageResourceType), }, @@ -1483,7 +1483,7 @@ func TestApiGatewayMethodSettings(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1565,7 +1565,7 @@ func TestApiGatewayIntegration(t *testing.T) { test: "cannot list rest apis", mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayIntegrationResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayIntegrationResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResourceType, resourceaws.AwsApiGatewayRestApiResourceType), }, @@ -1574,7 +1574,7 @@ func TestApiGatewayIntegration(t *testing.T) { mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayIntegrationResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayIntegrationResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResourceType, resourceaws.AwsApiGatewayResourceResourceType), }, @@ -1588,7 +1588,7 @@ func TestApiGatewayIntegration(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1674,7 +1674,7 @@ func TestApiGatewayIntegrationResponse(t *testing.T) { test: "cannot list rest apis", mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayIntegrationResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResponseResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayIntegrationResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResponseResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResponseResourceType, resourceaws.AwsApiGatewayRestApiResourceType), }, @@ -1683,7 +1683,7 @@ func TestApiGatewayIntegrationResponse(t *testing.T) { mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repo.On("ListAllRestApis").Return(apis, nil) repo.On("ListAllRestApiResources", *apis[0].Id).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayIntegrationResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResponseResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayIntegrationResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResponseResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResponseResourceType, resourceaws.AwsApiGatewayResourceResourceType), }, @@ -1697,7 +1697,7 @@ func TestApiGatewayIntegrationResponse(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} diff --git a/enumeration/remote/aws_apigatewayv2_scanner_test.go b/enumeration/remote/aws_apigatewayv2_scanner_test.go index e6a07bca6..2b87b96a9 100644 --- a/enumeration/remote/aws_apigatewayv2_scanner_test.go +++ b/enumeration/remote/aws_apigatewayv2_scanner_test.go @@ -7,7 +7,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/alerts" aws2 "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/terraform" @@ -60,7 +60,7 @@ func TestApiGatewayV2Api(t *testing.T) { test: "cannot list api gateway v2 apis", mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2ApiResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2ApiResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType), }, @@ -74,7 +74,7 @@ func TestApiGatewayV2Api(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -149,7 +149,7 @@ func TestApiGatewayV2Route(t *testing.T) { test: "cannot list api gateway v2 apis", mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2RouteResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2RouteResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2RouteResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2RouteResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2RouteResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), }, @@ -163,7 +163,7 @@ func TestApiGatewayV2Route(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -247,7 +247,7 @@ func TestApiGatewayV2Deployment(t *testing.T) { test: "error listing API gateways", mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2DeploymentResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2RouteResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2DeploymentResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2RouteResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2DeploymentResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), }, @@ -258,7 +258,7 @@ func TestApiGatewayV2Deployment(t *testing.T) { {ApiId: awssdk.String("a-gateway")}, }, nil) repository.On("ListAllApiDeployments", awssdk.String("a-gateway")).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2DeploymentResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2DeploymentResourceType, resourceaws.AwsApiGatewayV2DeploymentResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2DeploymentResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2DeploymentResourceType, resourceaws.AwsApiGatewayV2DeploymentResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2DeploymentResourceType, resourceaws.AwsApiGatewayV2DeploymentResourceType), }, @@ -272,7 +272,7 @@ func TestApiGatewayV2Deployment(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -337,7 +337,7 @@ func TestApiGatewayV2VpcLink(t *testing.T) { test: "cannot list api gateway v2 vpc links", mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllVpcLinks").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2VpcLinkResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2VpcLinkResourceType, resourceaws.AwsApiGatewayV2VpcLinkResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2VpcLinkResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2VpcLinkResourceType, resourceaws.AwsApiGatewayV2VpcLinkResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayV2VpcLinkResourceType), }, @@ -351,7 +351,7 @@ func TestApiGatewayV2VpcLink(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -430,7 +430,7 @@ func TestApiGatewayV2Authorizer(t *testing.T) { test: "cannot list apis", mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2AuthorizerResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2AuthorizerResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2AuthorizerResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2AuthorizerResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2AuthorizerResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), }, @@ -439,7 +439,7 @@ func TestApiGatewayV2Authorizer(t *testing.T) { mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(apis, nil) repo.On("ListAllApiAuthorizers", *apis[0].ApiId).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2AuthorizerResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2AuthorizerResourceType, resourceaws.AwsApiGatewayV2AuthorizerResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2AuthorizerResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2AuthorizerResourceType, resourceaws.AwsApiGatewayV2AuthorizerResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayV2AuthorizerResourceType), }, @@ -453,7 +453,7 @@ func TestApiGatewayV2Authorizer(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -538,7 +538,7 @@ func TestApiGatewayV2Integration(t *testing.T) { test: "cannot list apis", mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2IntegrationResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2IntegrationResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2IntegrationResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2IntegrationResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2IntegrationResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), }, @@ -547,7 +547,7 @@ func TestApiGatewayV2Integration(t *testing.T) { mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(apis, nil) repo.On("ListAllApiIntegrations", *apis[0].ApiId).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2IntegrationResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2IntegrationResourceType, resourceaws.AwsApiGatewayV2IntegrationResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2IntegrationResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2IntegrationResourceType, resourceaws.AwsApiGatewayV2IntegrationResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayV2IntegrationResourceType), }, @@ -561,7 +561,7 @@ func TestApiGatewayV2Integration(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -649,7 +649,7 @@ func TestApiGatewayV2Model(t *testing.T) { test: "cannot list apis", mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2ModelResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ModelResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2ModelResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ModelResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ModelResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), }, @@ -658,7 +658,7 @@ func TestApiGatewayV2Model(t *testing.T) { mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repo.On("ListAllApis").Return(apis, nil) repo.On("ListAllApiModels", *apis[0].ApiId).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2ModelResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ModelResourceType, resourceaws.AwsApiGatewayV2ModelResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2ModelResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ModelResourceType, resourceaws.AwsApiGatewayV2ModelResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayV2ModelResourceType), }, @@ -672,7 +672,7 @@ func TestApiGatewayV2Model(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -741,7 +741,7 @@ func TestApiGatewayV2Stage(t *testing.T) { test: "cannot list api gateway v2 apis", mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2StageResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2StageResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2StageResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2StageResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2StageResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), }, @@ -755,7 +755,7 @@ func TestApiGatewayV2Stage(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -836,7 +836,7 @@ func TestApiGatewayV2RouteResponse(t *testing.T) { test: "cannot list api gateway v2 apis", mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2RouteResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2RouteResponseResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2RouteResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2RouteResponseResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2RouteResponseResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), }, @@ -847,7 +847,7 @@ func TestApiGatewayV2RouteResponse(t *testing.T) { {ApiId: awssdk.String("77ooqulkke")}, }, nil) repository.On("ListAllApiRoutes", awssdk.String("77ooqulkke")).Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2RouteResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2RouteResourceType, resourceaws.AwsApiGatewayV2RouteResponseResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2RouteResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2RouteResourceType, resourceaws.AwsApiGatewayV2RouteResponseResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2RouteResponseResourceType, resourceaws.AwsApiGatewayV2RouteResourceType), }, @@ -862,7 +862,7 @@ func TestApiGatewayV2RouteResponse(t *testing.T) { {RouteId: awssdk.String("liqc5u4")}, }, nil) repository.On("ListAllApiRouteResponses", "77ooqulkke", "liqc5u4").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2RouteResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2RouteResponseResourceType, resourceaws.AwsApiGatewayV2RouteResponseResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2RouteResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2RouteResponseResourceType, resourceaws.AwsApiGatewayV2RouteResponseResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2RouteResponseResourceType, resourceaws.AwsApiGatewayV2RouteResponseResourceType), }, @@ -876,7 +876,7 @@ func TestApiGatewayV2RouteResponse(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -947,7 +947,7 @@ func TestApiGatewayV2Mapping(t *testing.T) { test: "cannot list api gateway v2 domains", mocks: func(repositoryV1 *repository.MockApiGatewayRepository, repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repositoryV1.On("ListAllDomainNames").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2MappingResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayDomainNameResourceType, resourceaws.AwsApiGatewayV2MappingResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2MappingResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayDomainNameResourceType, resourceaws.AwsApiGatewayV2MappingResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2MappingResourceType, resourceaws.AwsApiGatewayDomainNameResourceType), }, @@ -959,7 +959,7 @@ func TestApiGatewayV2Mapping(t *testing.T) { }, nil) repository.On("ListAllApiMappings", "example.com"). Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2MappingResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2MappingResourceType, resourceaws.AwsApiGatewayV2MappingResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2MappingResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2MappingResourceType, resourceaws.AwsApiGatewayV2MappingResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayV2MappingResourceType), }, @@ -1001,7 +1001,7 @@ func TestApiGatewayV2Mapping(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1066,7 +1066,7 @@ func TestApiGatewayV2DomainName(t *testing.T) { test: "cannot list api gateway v2 domain names", mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) { repository.On("ListAllDomainNames").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2DomainNameResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2DomainNameResourceType, resourceaws.AwsApiGatewayV2DomainNameResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2DomainNameResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2DomainNameResourceType, resourceaws.AwsApiGatewayV2DomainNameResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsApiGatewayV2DomainNameResourceType), }, @@ -1080,7 +1080,7 @@ func TestApiGatewayV2DomainName(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1161,7 +1161,7 @@ func TestApiGatewayV2IntegrationResponse(t *testing.T) { test: "cannot list api gateway v2 apis", mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) { repository.On("ListAllApis").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2IntegrationResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2IntegrationResponseResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2IntegrationResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2IntegrationResponseResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2IntegrationResponseResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), }, @@ -1172,7 +1172,7 @@ func TestApiGatewayV2IntegrationResponse(t *testing.T) { {ApiId: awssdk.String("yw28nwdf34")}, }, nil) repository.On("ListAllApiIntegrations", "yw28nwdf34").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2IntegrationResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2IntegrationResourceType, resourceaws.AwsApiGatewayV2IntegrationResponseResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2IntegrationResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2IntegrationResourceType, resourceaws.AwsApiGatewayV2IntegrationResponseResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2IntegrationResponseResourceType, resourceaws.AwsApiGatewayV2IntegrationResourceType), }, @@ -1187,7 +1187,7 @@ func TestApiGatewayV2IntegrationResponse(t *testing.T) { {IntegrationId: awssdk.String("fmezvlh")}, }, nil) repository.On("ListAllApiIntegrationResponses", "yw28nwdf34", "fmezvlh").Return(nil, dummyError) - alerter.On("SendAlert", resourceaws.AwsApiGatewayV2IntegrationResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2IntegrationResponseResourceType, resourceaws.AwsApiGatewayV2IntegrationResponseResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsApiGatewayV2IntegrationResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2IntegrationResponseResourceType, resourceaws.AwsApiGatewayV2IntegrationResponseResourceType), alerts.EnumerationPhase)).Return() }, wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2IntegrationResponseResourceType, resourceaws.AwsApiGatewayV2IntegrationResponseResourceType), }, @@ -1201,7 +1201,7 @@ func TestApiGatewayV2IntegrationResponse(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} diff --git a/enumeration/remote/aws_applicationautoscaling_scanner_test.go b/enumeration/remote/aws_applicationautoscaling_scanner_test.go index 3b159fcac..265139deb 100644 --- a/enumeration/remote/aws_applicationautoscaling_scanner_test.go +++ b/enumeration/remote/aws_applicationautoscaling_scanner_test.go @@ -7,7 +7,7 @@ import ( aws2 "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerror "github.com/snyk/driftctl/enumeration/remote/error" terraform3 "github.com/snyk/driftctl/enumeration/terraform" @@ -82,7 +82,7 @@ func TestAppAutoScalingTarget(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -109,7 +109,7 @@ func TestAppAutoScalingTarget(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewAppAutoscalingTargetEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsAppAutoscalingTargetResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsAppAutoscalingTargetResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsAppAutoscalingTargetResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsAppAutoscalingTargetResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -185,7 +185,7 @@ func TestAppAutoScalingPolicy(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -212,7 +212,7 @@ func TestAppAutoScalingPolicy(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewAppAutoscalingPolicyEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsAppAutoscalingPolicyResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsAppAutoscalingPolicyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsAppAutoscalingPolicyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsAppAutoscalingPolicyResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -298,7 +298,7 @@ func TestAppAutoScalingScheduledAction(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} diff --git a/enumeration/remote/aws_autoscaling_scanner_test.go b/enumeration/remote/aws_autoscaling_scanner_test.go index 4dedb86fe..eb66ba726 100644 --- a/enumeration/remote/aws_autoscaling_scanner_test.go +++ b/enumeration/remote/aws_autoscaling_scanner_test.go @@ -7,7 +7,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/alerts" "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/terraform" @@ -64,7 +64,7 @@ func TestAutoscaling_LaunchConfiguration(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("DescribeLaunchConfigurations").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsLaunchConfigurationResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsLaunchConfigurationResourceType, resourceaws.AwsLaunchConfigurationResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsLaunchConfigurationResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsLaunchConfigurationResourceType, resourceaws.AwsLaunchConfigurationResourceType), alerts.EnumerationPhase)).Return() }, assertExpected: func(t *testing.T, got []*resource.Resource) { assert.Len(t, got, 0) @@ -81,7 +81,7 @@ func TestAutoscaling_LaunchConfiguration(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} diff --git a/enumeration/remote/aws_cloudformation_scanner_test.go b/enumeration/remote/aws_cloudformation_scanner_test.go index 5a7e588be..778fd7dc0 100644 --- a/enumeration/remote/aws_cloudformation_scanner_test.go +++ b/enumeration/remote/aws_cloudformation_scanner_test.go @@ -9,7 +9,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" terraform3 "github.com/snyk/driftctl/enumeration/terraform" @@ -60,7 +60,7 @@ func TestCloudformationStack(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 400, "") repository.On("ListAllStacks").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsCloudformationStackResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsCloudformationStackResourceType, resourceaws.AwsCloudformationStackResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsCloudformationStackResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsCloudformationStackResourceType, resourceaws.AwsCloudformationStackResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -81,7 +81,7 @@ func TestCloudformationStack(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -108,7 +108,7 @@ func TestCloudformationStack(t *testing.T) { } remoteLibrary.AddEnumerator(aws.NewCloudformationStackEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsCloudformationStackResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsCloudformationStackResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsCloudformationStackResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsCloudformationStackResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) diff --git a/enumeration/remote/aws_cloudfront_scanner_test.go b/enumeration/remote/aws_cloudfront_scanner_test.go index 0521b1966..81c9549c3 100644 --- a/enumeration/remote/aws_cloudfront_scanner_test.go +++ b/enumeration/remote/aws_cloudfront_scanner_test.go @@ -8,7 +8,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" terraform3 "github.com/snyk/driftctl/enumeration/terraform" @@ -59,7 +59,7 @@ func TestCloudfrontDistribution(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 400, "") repository.On("ListAllDistributions").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsCloudfrontDistributionResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsCloudfrontDistributionResourceType, resourceaws.AwsCloudfrontDistributionResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsCloudfrontDistributionResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsCloudfrontDistributionResourceType, resourceaws.AwsCloudfrontDistributionResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -80,7 +80,7 @@ func TestCloudfrontDistribution(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -107,7 +107,7 @@ func TestCloudfrontDistribution(t *testing.T) { } remoteLibrary.AddEnumerator(aws.NewCloudfrontDistributionEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsCloudfrontDistributionResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsCloudfrontDistributionResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsCloudfrontDistributionResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsCloudfrontDistributionResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) diff --git a/enumeration/remote/aws_dynamodb_scanner_test.go b/enumeration/remote/aws_dynamodb_scanner_test.go index 6ed7272df..3a19dec2b 100644 --- a/enumeration/remote/aws_dynamodb_scanner_test.go +++ b/enumeration/remote/aws_dynamodb_scanner_test.go @@ -9,7 +9,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" terraform3 "github.com/snyk/driftctl/enumeration/terraform" @@ -61,7 +61,7 @@ func TestDynamoDBTable(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 400, "") client.On("ListAllTables").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsDynamodbTableResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsDynamodbTableResourceType, resourceaws.AwsDynamodbTableResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsDynamodbTableResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsDynamodbTableResourceType, resourceaws.AwsDynamodbTableResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -82,7 +82,7 @@ func TestDynamoDBTable(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -109,7 +109,7 @@ func TestDynamoDBTable(t *testing.T) { } remoteLibrary.AddEnumerator(aws.NewDynamoDBTableEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsDynamodbTableResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsDynamodbTableResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsDynamodbTableResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDynamodbTableResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) diff --git a/enumeration/remote/aws_ec2_scanner_test.go b/enumeration/remote/aws_ec2_scanner_test.go index 2e91694b6..fbdd11fd8 100644 --- a/enumeration/remote/aws_ec2_scanner_test.go +++ b/enumeration/remote/aws_ec2_scanner_test.go @@ -8,7 +8,7 @@ import ( aws2 "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" terraform3 "github.com/snyk/driftctl/enumeration/terraform" @@ -60,7 +60,7 @@ func TestEC2EbsVolume(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllVolumes").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsEbsVolumeResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsEbsVolumeResourceType, resourceaws.AwsEbsVolumeResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsEbsVolumeResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsEbsVolumeResourceType, resourceaws.AwsEbsVolumeResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -81,7 +81,7 @@ func TestEC2EbsVolume(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -108,7 +108,7 @@ func TestEC2EbsVolume(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewEC2EbsVolumeEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsEbsVolumeResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsEbsVolumeResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsEbsVolumeResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEbsVolumeResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -157,7 +157,7 @@ func TestEC2EbsSnapshot(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllSnapshots").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsEbsSnapshotResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsEbsSnapshotResourceType, resourceaws.AwsEbsSnapshotResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsEbsSnapshotResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsEbsSnapshotResourceType, resourceaws.AwsEbsSnapshotResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -178,7 +178,7 @@ func TestEC2EbsSnapshot(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -205,7 +205,7 @@ func TestEC2EbsSnapshot(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewEC2EbsSnapshotEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsEbsSnapshotResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsEbsSnapshotResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsEbsSnapshotResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEbsSnapshotResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -256,7 +256,7 @@ func TestEC2Eip(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllAddresses").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsEipResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsEipResourceType, resourceaws.AwsEipResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsEipResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsEipResourceType, resourceaws.AwsEipResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -277,7 +277,7 @@ func TestEC2Eip(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -304,7 +304,7 @@ func TestEC2Eip(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewEC2EipEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsEipResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsEipResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsEipResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEipResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -353,7 +353,7 @@ func TestEC2Ami(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllImages").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsAmiResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsAmiResourceType, resourceaws.AwsAmiResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsAmiResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsAmiResourceType, resourceaws.AwsAmiResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -374,7 +374,7 @@ func TestEC2Ami(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -401,7 +401,7 @@ func TestEC2Ami(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewEC2AmiEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsAmiResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsAmiResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsAmiResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsAmiResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -450,7 +450,7 @@ func TestEC2KeyPair(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllKeyPairs").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsKeyPairResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsKeyPairResourceType, resourceaws.AwsKeyPairResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsKeyPairResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsKeyPairResourceType, resourceaws.AwsKeyPairResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -471,7 +471,7 @@ func TestEC2KeyPair(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -498,7 +498,7 @@ func TestEC2KeyPair(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewEC2KeyPairEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsKeyPairResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsKeyPairResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsKeyPairResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsKeyPairResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -549,7 +549,7 @@ func TestEC2EipAssociation(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllAddressesAssociation").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsEipAssociationResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsEipAssociationResourceType, resourceaws.AwsEipAssociationResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsEipAssociationResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsEipAssociationResourceType, resourceaws.AwsEipAssociationResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -570,7 +570,7 @@ func TestEC2EipAssociation(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -597,7 +597,7 @@ func TestEC2EipAssociation(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewEC2EipAssociationEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsEipAssociationResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsEipAssociationResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsEipAssociationResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEipAssociationResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -656,7 +656,7 @@ func TestEC2Instance(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllInstances").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsInstanceResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsInstanceResourceType, resourceaws.AwsInstanceResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsInstanceResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsInstanceResourceType, resourceaws.AwsInstanceResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -677,7 +677,7 @@ func TestEC2Instance(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -704,7 +704,7 @@ func TestEC2Instance(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewEC2InstanceEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsInstanceResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsInstanceResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsInstanceResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsInstanceResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -753,7 +753,7 @@ func TestEC2InternetGateway(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllInternetGateways").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsInternetGatewayResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsInternetGatewayResourceType, resourceaws.AwsInternetGatewayResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsInternetGatewayResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsInternetGatewayResourceType, resourceaws.AwsInternetGatewayResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -774,7 +774,7 @@ func TestEC2InternetGateway(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -801,7 +801,7 @@ func TestEC2InternetGateway(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewEC2InternetGatewayEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsInternetGatewayResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsInternetGatewayResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsInternetGatewayResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsInternetGatewayResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -867,7 +867,7 @@ func TestVPC(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllVPCs").Once().Return(nil, nil, awsError) - alerter.On("SendAlert", resourceaws.AwsVpcResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsVpcResourceType, resourceaws.AwsVpcResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsVpcResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsVpcResourceType, resourceaws.AwsVpcResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -888,7 +888,7 @@ func TestVPC(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -915,7 +915,7 @@ func TestVPC(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewVPCEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsVpcResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsVpcResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsVpcResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsVpcResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -978,7 +978,7 @@ func TestDefaultVPC(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllVPCs").Once().Return(nil, nil, awsError) - alerter.On("SendAlert", resourceaws.AwsDefaultVpcResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsDefaultVpcResourceType, resourceaws.AwsDefaultVpcResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsDefaultVpcResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsDefaultVpcResourceType, resourceaws.AwsDefaultVpcResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -999,7 +999,7 @@ func TestDefaultVPC(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1026,7 +1026,7 @@ func TestDefaultVPC(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewDefaultVPCEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultVpcResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsDefaultVpcResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultVpcResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDefaultVpcResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1144,7 +1144,7 @@ func TestEC2RouteTableAssociation(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllRouteTables").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsRouteTableAssociationResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRouteTableAssociationResourceType, resourceaws.AwsRouteTableResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsRouteTableAssociationResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRouteTableAssociationResourceType, resourceaws.AwsRouteTableResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -1165,7 +1165,7 @@ func TestEC2RouteTableAssociation(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1192,7 +1192,7 @@ func TestEC2RouteTableAssociation(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewEC2RouteTableAssociationEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsRouteTableAssociationResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsRouteTableAssociationResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsRouteTableAssociationResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsRouteTableAssociationResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1264,7 +1264,7 @@ func TestEC2Subnet(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllSubnets").Return(nil, nil, awsError) - alerter.On("SendAlert", resourceaws.AwsSubnetResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSubnetResourceType, resourceaws.AwsSubnetResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsSubnetResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSubnetResourceType, resourceaws.AwsSubnetResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -1285,7 +1285,7 @@ func TestEC2Subnet(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1312,7 +1312,7 @@ func TestEC2Subnet(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewEC2SubnetEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsSubnetResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsSubnetResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsSubnetResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSubnetResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1384,7 +1384,7 @@ func TestEC2DefaultSubnet(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllSubnets").Return(nil, nil, awsError) - alerter.On("SendAlert", resourceaws.AwsDefaultSubnetResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsDefaultSubnetResourceType, resourceaws.AwsDefaultSubnetResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsDefaultSubnetResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsDefaultSubnetResourceType, resourceaws.AwsDefaultSubnetResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -1405,7 +1405,7 @@ func TestEC2DefaultSubnet(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1432,7 +1432,7 @@ func TestEC2DefaultSubnet(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewEC2DefaultSubnetEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultSubnetResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsDefaultSubnetResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultSubnetResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDefaultSubnetResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1491,7 +1491,7 @@ func TestEC2RouteTable(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllRouteTables").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsRouteTableResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRouteTableResourceType, resourceaws.AwsRouteTableResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsRouteTableResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRouteTableResourceType, resourceaws.AwsRouteTableResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -1512,7 +1512,7 @@ func TestEC2RouteTable(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1539,7 +1539,7 @@ func TestEC2RouteTable(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewEC2RouteTableEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsRouteTableResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsRouteTableResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsRouteTableResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsRouteTableResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1598,7 +1598,7 @@ func TestEC2DefaultRouteTable(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllRouteTables").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsDefaultRouteTableResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsDefaultRouteTableResourceType, resourceaws.AwsDefaultRouteTableResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsDefaultRouteTableResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsDefaultRouteTableResourceType, resourceaws.AwsDefaultRouteTableResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -1619,7 +1619,7 @@ func TestEC2DefaultRouteTable(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1646,7 +1646,7 @@ func TestEC2DefaultRouteTable(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewEC2DefaultRouteTableEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultRouteTableResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsDefaultRouteTableResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultRouteTableResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDefaultRouteTableResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1705,7 +1705,7 @@ func TestVpcSecurityGroup(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllSecurityGroups").Return(nil, nil, awsError) - alerter.On("SendAlert", resourceaws.AwsSecurityGroupResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSecurityGroupResourceType, resourceaws.AwsSecurityGroupResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsSecurityGroupResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSecurityGroupResourceType, resourceaws.AwsSecurityGroupResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -1726,7 +1726,7 @@ func TestVpcSecurityGroup(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1753,7 +1753,7 @@ func TestVpcSecurityGroup(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewVPCSecurityGroupEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsSecurityGroupResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsSecurityGroupResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsSecurityGroupResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSecurityGroupResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1812,7 +1812,7 @@ func TestVpcDefaultSecurityGroup(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllSecurityGroups").Return(nil, nil, awsError) - alerter.On("SendAlert", resourceaws.AwsDefaultSecurityGroupResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsDefaultSecurityGroupResourceType, resourceaws.AwsDefaultSecurityGroupResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsDefaultSecurityGroupResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsDefaultSecurityGroupResourceType, resourceaws.AwsDefaultSecurityGroupResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -1833,7 +1833,7 @@ func TestVpcDefaultSecurityGroup(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1860,7 +1860,7 @@ func TestVpcDefaultSecurityGroup(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewVPCDefaultSecurityGroupEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultSecurityGroupResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsDefaultSecurityGroupResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultSecurityGroupResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDefaultSecurityGroupResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1908,7 +1908,7 @@ func TestEC2NatGateway(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllNatGateways").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsNatGatewayResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsNatGatewayResourceType, resourceaws.AwsNatGatewayResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsNatGatewayResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsNatGatewayResourceType, resourceaws.AwsNatGatewayResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -1929,7 +1929,7 @@ func TestEC2NatGateway(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1956,7 +1956,7 @@ func TestEC2NatGateway(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewEC2NatGatewayEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsNatGatewayResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsNatGatewayResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsNatGatewayResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsNatGatewayResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -2018,7 +2018,7 @@ func TestEC2NetworkACL(t *testing.T) { alerter.On("SendAlert", resourceaws.AwsNetworkACLResourceType, alerts.NewRemoteAccessDeniedAlert( - common2.RemoteAWSTerraform, + common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType( awsError, resourceaws.AwsNetworkACLResourceType, @@ -2047,7 +2047,7 @@ func TestEC2NetworkACL(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -2074,7 +2074,7 @@ func TestEC2NetworkACL(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewEC2NetworkACLEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsNetworkACLResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsNetworkACLResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsNetworkACLResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsNetworkACLResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -2171,7 +2171,7 @@ func TestEC2NetworkACLRule(t *testing.T) { alerter.On("SendAlert", resourceaws.AwsNetworkACLRuleResourceType, alerts.NewRemoteAccessDeniedAlert( - common2.RemoteAWSTerraform, + common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType( awsError, resourceaws.AwsNetworkACLRuleResourceType, @@ -2197,7 +2197,7 @@ func TestEC2NetworkACLRule(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -2223,7 +2223,7 @@ func TestEC2NetworkACLRule(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewEC2NetworkACLRuleEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsNetworkACLRuleResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsNetworkACLRuleResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsNetworkACLRuleResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsNetworkACLRuleResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -2285,7 +2285,7 @@ func TestEC2DefaultNetworkACL(t *testing.T) { alerter.On("SendAlert", resourceaws.AwsDefaultNetworkACLResourceType, alerts.NewRemoteAccessDeniedAlert( - common2.RemoteAWSTerraform, + common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType( awsError, resourceaws.AwsDefaultNetworkACLResourceType, @@ -2314,7 +2314,7 @@ func TestEC2DefaultNetworkACL(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -2341,7 +2341,7 @@ func TestEC2DefaultNetworkACL(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewEC2DefaultNetworkACLEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultNetworkACLResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsDefaultNetworkACLResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultNetworkACLResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDefaultNetworkACLResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -2462,7 +2462,7 @@ func TestEC2Route(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllRouteTables").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsRouteResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRouteResourceType, resourceaws.AwsRouteTableResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsRouteResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRouteResourceType, resourceaws.AwsRouteTableResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -2483,7 +2483,7 @@ func TestEC2Route(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -2510,7 +2510,7 @@ func TestEC2Route(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewEC2RouteEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsRouteResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsRouteResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsRouteResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsRouteResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -2653,7 +2653,7 @@ func TestVpcSecurityGroupRule(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllSecurityGroups").Once().Return(nil, nil, awsError) - alerter.On("SendAlert", resourceaws.AwsSecurityGroupRuleResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSecurityGroupRuleResourceType, resourceaws.AwsSecurityGroupResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsSecurityGroupRuleResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSecurityGroupRuleResourceType, resourceaws.AwsSecurityGroupResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -2674,7 +2674,7 @@ func TestVpcSecurityGroupRule(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -2701,7 +2701,7 @@ func TestVpcSecurityGroupRule(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewVPCSecurityGroupRuleEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsSecurityGroupRuleResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsSecurityGroupRuleResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsSecurityGroupRuleResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSecurityGroupRuleResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -2752,7 +2752,7 @@ func TestEC2LaunchTemplate(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("DescribeLaunchTemplates").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsLaunchTemplateResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsLaunchTemplateResourceType, resourceaws.AwsLaunchTemplateResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsLaunchTemplateResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsLaunchTemplateResourceType, resourceaws.AwsLaunchTemplateResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -2773,7 +2773,7 @@ func TestEC2LaunchTemplate(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -2800,7 +2800,7 @@ func TestEC2LaunchTemplate(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewLaunchTemplateEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsLaunchTemplateResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsLaunchTemplateResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsLaunchTemplateResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsLaunchTemplateResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -2840,7 +2840,7 @@ func TestEC2EbsEncryptionByDefault(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("IsEbsEncryptionEnabledByDefault").Return(false, awsError) - alerter.On("SendAlert", resourceaws.AwsEbsEncryptionByDefaultResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsEbsEncryptionByDefaultResourceType, resourceaws.AwsEbsEncryptionByDefaultResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsEbsEncryptionByDefaultResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsEbsEncryptionByDefaultResourceType, resourceaws.AwsEbsEncryptionByDefaultResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -2861,7 +2861,7 @@ func TestEC2EbsEncryptionByDefault(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -2888,7 +2888,7 @@ func TestEC2EbsEncryptionByDefault(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewEC2EbsEncryptionByDefaultEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsEbsEncryptionByDefaultResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsEbsEncryptionByDefaultResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsEbsEncryptionByDefaultResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEbsEncryptionByDefaultResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) diff --git a/enumeration/remote/aws_ecr_scanner_test.go b/enumeration/remote/aws_ecr_scanner_test.go index ad914a40c..4cc44eb05 100644 --- a/enumeration/remote/aws_ecr_scanner_test.go +++ b/enumeration/remote/aws_ecr_scanner_test.go @@ -8,7 +8,7 @@ import ( aws2 "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" terraform3 "github.com/snyk/driftctl/enumeration/terraform" @@ -62,7 +62,7 @@ func TestECRRepository(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllRepositories").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsEcrRepositoryResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsEcrRepositoryResourceType, resourceaws.AwsEcrRepositoryResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsEcrRepositoryResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsEcrRepositoryResourceType, resourceaws.AwsEcrRepositoryResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -83,7 +83,7 @@ func TestECRRepository(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -110,7 +110,7 @@ func TestECRRepository(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewECRRepositoryEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsEcrRepositoryResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsEcrRepositoryResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsEcrRepositoryResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEcrRepositoryResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -169,7 +169,7 @@ func TestECRRepositoryPolicy(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} diff --git a/enumeration/remote/aws_elasticache_scanner_test.go b/enumeration/remote/aws_elasticache_scanner_test.go index ec4b72f8d..05e3a14a0 100644 --- a/enumeration/remote/aws_elasticache_scanner_test.go +++ b/enumeration/remote/aws_elasticache_scanner_test.go @@ -8,7 +8,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/alerts" "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/terraform" @@ -60,7 +60,7 @@ func TestElastiCacheCluster(t *testing.T) { mocks: func(repository *repository.MockElastiCacheRepository, alerter *mocks.AlerterInterface) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllCacheClusters").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsElastiCacheClusterResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsElastiCacheClusterResourceType, resourceaws.AwsElastiCacheClusterResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsElastiCacheClusterResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsElastiCacheClusterResourceType, resourceaws.AwsElastiCacheClusterResourceType), alerts.EnumerationPhase)).Return() }, assertExpected: func(t *testing.T, got []*resource.Resource) { assert.Len(t, got, 0) @@ -86,7 +86,7 @@ func TestElastiCacheCluster(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} diff --git a/enumeration/remote/aws_elb_scanner_test.go b/enumeration/remote/aws_elb_scanner_test.go index 4122bfb1f..b0243705a 100644 --- a/enumeration/remote/aws_elb_scanner_test.go +++ b/enumeration/remote/aws_elb_scanner_test.go @@ -8,7 +8,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/alerts" "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/terraform" @@ -63,7 +63,7 @@ func TestELB_LoadBalancer(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllLoadBalancers").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsClassicLoadBalancerResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsClassicLoadBalancerResourceType, resourceaws.AwsClassicLoadBalancerResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsClassicLoadBalancerResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsClassicLoadBalancerResourceType, resourceaws.AwsClassicLoadBalancerResourceType), alerts.EnumerationPhase)).Return() }, assertExpected: func(t *testing.T, got []*resource.Resource) { assert.Len(t, got, 0) @@ -89,7 +89,7 @@ func TestELB_LoadBalancer(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} diff --git a/enumeration/remote/aws_elbv2_scanner_test.go b/enumeration/remote/aws_elbv2_scanner_test.go index 80739fe4d..954e645ae 100644 --- a/enumeration/remote/aws_elbv2_scanner_test.go +++ b/enumeration/remote/aws_elbv2_scanner_test.go @@ -8,7 +8,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/alerts" aws2 "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/terraform" @@ -64,7 +64,7 @@ func TestELBV2_LoadBalancer(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllLoadBalancers").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsLoadBalancerResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsLoadBalancerResourceType, resourceaws.AwsLoadBalancerResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsLoadBalancerResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsLoadBalancerResourceType, resourceaws.AwsLoadBalancerResourceType), alerts.EnumerationPhase)).Return() }, assertExpected: func(t *testing.T, got []*resource.Resource) { assert.Len(t, got, 0) @@ -90,7 +90,7 @@ func TestELBV2_LoadBalancer(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -174,7 +174,7 @@ func TestELBV2_LoadBalancerListener(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllLoadBalancerListeners", "test-lb").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsLoadBalancerListenerResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingError(awsError, resourceaws.AwsLoadBalancerListenerResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsLoadBalancerListenerResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingError(awsError, resourceaws.AwsLoadBalancerListenerResourceType), alerts.EnumerationPhase)).Return() }, assertExpected: func(t *testing.T, got []*resource.Resource) { assert.Len(t, got, 0) @@ -186,7 +186,7 @@ func TestELBV2_LoadBalancerListener(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllLoadBalancers").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsLoadBalancerListenerResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsLoadBalancerListenerResourceType, resourceaws.AwsLoadBalancerResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsLoadBalancerListenerResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsLoadBalancerListenerResourceType, resourceaws.AwsLoadBalancerResourceType), alerts.EnumerationPhase)).Return() }, assertExpected: func(t *testing.T, got []*resource.Resource) { assert.Len(t, got, 0) @@ -218,7 +218,7 @@ func TestELBV2_LoadBalancerListener(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} diff --git a/enumeration/remote/aws_iam_scanner_test.go b/enumeration/remote/aws_iam_scanner_test.go index b157de257..69959959a 100644 --- a/enumeration/remote/aws_iam_scanner_test.go +++ b/enumeration/remote/aws_iam_scanner_test.go @@ -8,7 +8,7 @@ import ( aws2 "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" terraform3 "github.com/snyk/driftctl/enumeration/terraform" @@ -70,7 +70,7 @@ func TestIamUser(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllUsers").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsIamUserResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamUserResourceType, resourceaws.AwsIamUserResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsIamUserResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamUserResourceType, resourceaws.AwsIamUserResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -90,7 +90,7 @@ func TestIamUser(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -117,7 +117,7 @@ func TestIamUser(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewIamUserEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamUserResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsIamUserResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamUserResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsIamUserResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -197,7 +197,7 @@ func TestIamUserPolicy(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllUsers").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsIamUserPolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamUserPolicyResourceType, resourceaws.AwsIamUserResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsIamUserPolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamUserPolicyResourceType, resourceaws.AwsIamUserResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -209,7 +209,7 @@ func TestIamUserPolicy(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllUserPolicies", mock.Anything).Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsIamUserPolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamUserPolicyResourceType, resourceaws.AwsIamUserPolicyResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsIamUserPolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamUserPolicyResourceType, resourceaws.AwsIamUserPolicyResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -229,7 +229,7 @@ func TestIamUserPolicy(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -256,7 +256,7 @@ func TestIamUserPolicy(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewIamUserPolicyEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamUserPolicyResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsIamUserPolicyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamUserPolicyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsIamUserPolicyResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -315,7 +315,7 @@ func TestIamPolicy(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllPolicies").Once().Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsIamPolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamPolicyResourceType, resourceaws.AwsIamPolicyResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsIamPolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamPolicyResourceType, resourceaws.AwsIamPolicyResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -336,7 +336,7 @@ func TestIamPolicy(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -363,7 +363,7 @@ func TestIamPolicy(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewIamPolicyEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamPolicyResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsIamPolicyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamPolicyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsIamPolicyResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -456,7 +456,7 @@ func TestIamRole(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -483,7 +483,7 @@ func TestIamRole(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewIamRoleEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamRoleResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsIamRoleResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamRoleResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsIamRoleResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -608,7 +608,7 @@ func TestIamRolePolicyAttachment(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllRoles").Once().Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsIamRolePolicyAttachmentResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamRolePolicyAttachmentResourceType, resourceaws.AwsIamRoleResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsIamRolePolicyAttachmentResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamRolePolicyAttachmentResourceType, resourceaws.AwsIamRoleResourceType), alerts.EnumerationPhase)).Return() }, }, { @@ -619,7 +619,7 @@ func TestIamRolePolicyAttachment(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllRolePolicyAttachments", mock.Anything).Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsIamRolePolicyAttachmentResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamRolePolicyAttachmentResourceType, resourceaws.AwsIamRolePolicyAttachmentResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsIamRolePolicyAttachmentResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamRolePolicyAttachmentResourceType, resourceaws.AwsIamRolePolicyAttachmentResourceType), alerts.EnumerationPhase)).Return() }, }, } @@ -639,7 +639,7 @@ func TestIamRolePolicyAttachment(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -666,7 +666,7 @@ func TestIamRolePolicyAttachment(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewIamRolePolicyAttachmentEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamRolePolicyAttachmentResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsIamRolePolicyAttachmentResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamRolePolicyAttachmentResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsIamRolePolicyAttachmentResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -744,7 +744,7 @@ func TestIamAccessKey(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllUsers").Once().Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsIamAccessKeyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamAccessKeyResourceType, resourceaws.AwsIamUserResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsIamAccessKeyResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamAccessKeyResourceType, resourceaws.AwsIamUserResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -756,7 +756,7 @@ func TestIamAccessKey(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllAccessKeys", mock.Anything).Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsIamAccessKeyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamAccessKeyResourceType, resourceaws.AwsIamAccessKeyResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsIamAccessKeyResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamAccessKeyResourceType, resourceaws.AwsIamAccessKeyResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -777,7 +777,7 @@ func TestIamAccessKey(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -804,7 +804,7 @@ func TestIamAccessKey(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewIamAccessKeyEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamAccessKeyResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsIamAccessKeyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamAccessKeyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsIamAccessKeyResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -957,7 +957,7 @@ func TestIamUserPolicyAttachment(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllUsers").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsIamUserPolicyAttachmentResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamUserPolicyAttachmentResourceType, resourceaws.AwsIamUserResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsIamUserPolicyAttachmentResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamUserPolicyAttachmentResourceType, resourceaws.AwsIamUserResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -969,7 +969,7 @@ func TestIamUserPolicyAttachment(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllUserPolicyAttachments", mock.Anything).Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsIamUserPolicyAttachmentResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamUserPolicyAttachmentResourceType, resourceaws.AwsIamUserPolicyAttachmentResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsIamUserPolicyAttachmentResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamUserPolicyAttachmentResourceType, resourceaws.AwsIamUserPolicyAttachmentResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -990,7 +990,7 @@ func TestIamUserPolicyAttachment(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1017,7 +1017,7 @@ func TestIamUserPolicyAttachment(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewIamUserPolicyAttachmentEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamUserPolicyAttachmentResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsIamUserPolicyAttachmentResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamUserPolicyAttachmentResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsIamUserPolicyAttachmentResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1088,7 +1088,7 @@ func TestIamRolePolicy(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllRoles").Once().Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsIamRolePolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamRolePolicyResourceType, resourceaws.AwsIamRoleResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsIamRolePolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamRolePolicyResourceType, resourceaws.AwsIamRoleResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -1100,7 +1100,7 @@ func TestIamRolePolicy(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllRolePolicies", mock.Anything).Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsIamRolePolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamRolePolicyResourceType, resourceaws.AwsIamRolePolicyResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsIamRolePolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsIamRolePolicyResourceType, resourceaws.AwsIamRolePolicyResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -1121,7 +1121,7 @@ func TestIamRolePolicy(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1148,7 +1148,7 @@ func TestIamRolePolicy(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewIamRolePolicyEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamRolePolicyResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsIamRolePolicyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamRolePolicyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsIamRolePolicyResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1215,7 +1215,7 @@ func TestIamGroupPolicy(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1292,7 +1292,7 @@ func TestIamGroup(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} diff --git a/enumeration/remote/aws_kms_scanner_test.go b/enumeration/remote/aws_kms_scanner_test.go index 71a40fc4e..909be64dd 100644 --- a/enumeration/remote/aws_kms_scanner_test.go +++ b/enumeration/remote/aws_kms_scanner_test.go @@ -8,7 +8,7 @@ import ( aws2 "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" terraform3 "github.com/snyk/driftctl/enumeration/terraform" @@ -61,7 +61,7 @@ func TestKMSKey(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllKeys").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsKmsKeyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsKmsKeyResourceType, resourceaws.AwsKmsKeyResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsKmsKeyResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsKmsKeyResourceType, resourceaws.AwsKmsKeyResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -82,7 +82,7 @@ func TestKMSKey(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -109,7 +109,7 @@ func TestKMSKey(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewKMSKeyEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsKmsKeyResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsKmsKeyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsKmsKeyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsKmsKeyResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -159,7 +159,7 @@ func TestKMSAlias(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllAliases").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsKmsAliasResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsKmsAliasResourceType, resourceaws.AwsKmsAliasResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsKmsAliasResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsKmsAliasResourceType, resourceaws.AwsKmsAliasResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -180,7 +180,7 @@ func TestKMSAlias(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -207,7 +207,7 @@ func TestKMSAlias(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewKMSAliasEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsKmsAliasResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsKmsAliasResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsKmsAliasResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsKmsAliasResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) diff --git a/enumeration/remote/aws_lambda_scanner_test.go b/enumeration/remote/aws_lambda_scanner_test.go index 047f71d8d..6f6bfea56 100644 --- a/enumeration/remote/aws_lambda_scanner_test.go +++ b/enumeration/remote/aws_lambda_scanner_test.go @@ -8,7 +8,7 @@ import ( aws2 "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" terraform3 "github.com/snyk/driftctl/enumeration/terraform" @@ -81,7 +81,7 @@ func TestScanLambdaFunction(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllLambdaFunctions").Return([]*lambda.FunctionConfiguration{}, awsError) - alerter.On("SendAlert", resourceaws.AwsLambdaFunctionResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsLambdaFunctionResourceType, resourceaws.AwsLambdaFunctionResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsLambdaFunctionResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsLambdaFunctionResourceType, resourceaws.AwsLambdaFunctionResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -102,7 +102,7 @@ func TestScanLambdaFunction(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -129,7 +129,7 @@ func TestScanLambdaFunction(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewLambdaFunctionEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsLambdaFunctionResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsLambdaFunctionResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsLambdaFunctionResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsLambdaFunctionResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -197,7 +197,7 @@ func TestScanLambdaEventSourceMapping(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repo.On("ListAllLambdaEventSourceMappings").Return([]*lambda.EventSourceMappingConfiguration{}, awsError) - alerter.On("SendAlert", resourceaws.AwsLambdaEventSourceMappingResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsLambdaEventSourceMappingResourceType, resourceaws.AwsLambdaEventSourceMappingResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsLambdaEventSourceMappingResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsLambdaEventSourceMappingResourceType, resourceaws.AwsLambdaEventSourceMappingResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -218,7 +218,7 @@ func TestScanLambdaEventSourceMapping(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -245,7 +245,7 @@ func TestScanLambdaEventSourceMapping(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewLambdaEventSourceMappingEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsLambdaEventSourceMappingResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsLambdaEventSourceMappingResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsLambdaEventSourceMappingResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsLambdaEventSourceMappingResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) diff --git a/enumeration/remote/aws_rds_scanner_test.go b/enumeration/remote/aws_rds_scanner_test.go index 2e4ac1bf4..278b547cb 100644 --- a/enumeration/remote/aws_rds_scanner_test.go +++ b/enumeration/remote/aws_rds_scanner_test.go @@ -8,7 +8,7 @@ import ( aws2 "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" terraform3 "github.com/snyk/driftctl/enumeration/terraform" @@ -69,7 +69,7 @@ func TestRDSDBInstance(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllDBInstances").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsDbInstanceResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsDbInstanceResourceType, resourceaws.AwsDbInstanceResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsDbInstanceResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsDbInstanceResourceType, resourceaws.AwsDbInstanceResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -90,7 +90,7 @@ func TestRDSDBInstance(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -117,7 +117,7 @@ func TestRDSDBInstance(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewRDSDBInstanceEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsDbInstanceResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsDbInstanceResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsDbInstanceResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDbInstanceResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -166,7 +166,7 @@ func TestRDSDBSubnetGroup(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllDBSubnetGroups").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsDbSubnetGroupResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsDbSubnetGroupResourceType, resourceaws.AwsDbSubnetGroupResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsDbSubnetGroupResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsDbSubnetGroupResourceType, resourceaws.AwsDbSubnetGroupResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -187,7 +187,7 @@ func TestRDSDBSubnetGroup(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -214,7 +214,7 @@ func TestRDSDBSubnetGroup(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewRDSDBSubnetGroupEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsDbSubnetGroupResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsDbSubnetGroupResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsDbSubnetGroupResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDbSubnetGroupResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -268,7 +268,7 @@ func TestRDSCluster(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 400, "") repository.On("ListAllDBClusters").Return(nil, awsError).Once() - alerter.On("SendAlert", resourceaws.AwsRDSClusterResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRDSClusterResourceType, resourceaws.AwsRDSClusterResourceType), alerts.EnumerationPhase)).Return().Once() + alerter.On("SendAlert", resourceaws.AwsRDSClusterResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRDSClusterResourceType, resourceaws.AwsRDSClusterResourceType), alerts.EnumerationPhase)).Return().Once() }, wantErr: nil, }, @@ -289,7 +289,7 @@ func TestRDSCluster(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -316,7 +316,7 @@ func TestRDSCluster(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewRDSClusterEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsRDSClusterResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsRDSClusterResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsRDSClusterResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsRDSClusterResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) diff --git a/enumeration/remote/aws_route53_scanner_test.go b/enumeration/remote/aws_route53_scanner_test.go index c3e29d414..781801424 100644 --- a/enumeration/remote/aws_route53_scanner_test.go +++ b/enumeration/remote/aws_route53_scanner_test.go @@ -6,7 +6,7 @@ import ( aws2 "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" terraform3 "github.com/snyk/driftctl/enumeration/terraform" "testing" @@ -64,7 +64,7 @@ func TestRoute53_HealthCheck(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllHealthChecks").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsRoute53HealthCheckResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRoute53HealthCheckResourceType, resourceaws.AwsRoute53HealthCheckResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsRoute53HealthCheckResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRoute53HealthCheckResourceType, resourceaws.AwsRoute53HealthCheckResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -85,7 +85,7 @@ func TestRoute53_HealthCheck(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -112,7 +112,7 @@ func TestRoute53_HealthCheck(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewRoute53HealthCheckEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsRoute53HealthCheckResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsRoute53HealthCheckResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsRoute53HealthCheckResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsRoute53HealthCheckResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -199,7 +199,7 @@ func TestRoute53_Zone(t *testing.T) { awsError, ) - alerter.On("SendAlert", resourceaws.AwsRoute53ZoneResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRoute53ZoneResourceType, resourceaws.AwsRoute53ZoneResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsRoute53ZoneResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRoute53ZoneResourceType, resourceaws.AwsRoute53ZoneResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -220,7 +220,7 @@ func TestRoute53_Zone(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -247,7 +247,7 @@ func TestRoute53_Zone(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewRoute53ZoneEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsRoute53ZoneResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsRoute53ZoneResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsRoute53ZoneResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsRoute53ZoneResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -389,7 +389,7 @@ func TestRoute53_Record(t *testing.T) { []*route53.HostedZone{}, awsError) - alerter.On("SendAlert", resourceaws.AwsRoute53RecordResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRoute53RecordResourceType, resourceaws.AwsRoute53ZoneResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsRoute53RecordResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRoute53RecordResourceType, resourceaws.AwsRoute53ZoneResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -409,7 +409,7 @@ func TestRoute53_Record(t *testing.T) { client.On("ListRecordsForZone", "Z06486383UC8WYSBZTWFM").Return( []*route53.ResourceRecordSet{}, awsError) - alerter.On("SendAlert", resourceaws.AwsRoute53RecordResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRoute53RecordResourceType, resourceaws.AwsRoute53RecordResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsRoute53RecordResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsRoute53RecordResourceType, resourceaws.AwsRoute53RecordResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -430,7 +430,7 @@ func TestRoute53_Record(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -457,7 +457,7 @@ func TestRoute53_Record(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewRoute53RecordEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsRoute53RecordResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsRoute53RecordResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsRoute53RecordResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsRoute53RecordResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) diff --git a/enumeration/remote/aws_s3_scanner_test.go b/enumeration/remote/aws_s3_scanner_test.go index d9f15c025..295c2a41b 100644 --- a/enumeration/remote/aws_s3_scanner_test.go +++ b/enumeration/remote/aws_s3_scanner_test.go @@ -9,7 +9,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/aws/client" "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" tf "github.com/snyk/driftctl/enumeration/remote/terraform" terraform3 "github.com/snyk/driftctl/enumeration/terraform" @@ -83,7 +83,7 @@ func TestS3Bucket(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllBuckets").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsS3BucketResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketResourceType, resourceaws.AwsS3BucketResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsS3BucketResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketResourceType, resourceaws.AwsS3BucketResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -104,7 +104,7 @@ func TestS3Bucket(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -133,7 +133,7 @@ func TestS3Bucket(t *testing.T) { Name: "test", DefaultAlias: "eu-west-3", }, alerter)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsS3BucketResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsS3BucketResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -213,7 +213,7 @@ func TestS3BucketInventory(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllBuckets").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsS3BucketInventoryResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketInventoryResourceType, resourceaws.AwsS3BucketResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsS3BucketInventoryResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketInventoryResourceType, resourceaws.AwsS3BucketResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -243,7 +243,7 @@ func TestS3BucketInventory(t *testing.T) { awsError, ) - alerter.On("SendAlert", resourceaws.AwsS3BucketInventoryResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketInventoryResourceType, resourceaws.AwsS3BucketInventoryResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsS3BucketInventoryResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketInventoryResourceType, resourceaws.AwsS3BucketInventoryResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -264,7 +264,7 @@ func TestS3BucketInventory(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -293,7 +293,7 @@ func TestS3BucketInventory(t *testing.T) { Name: "test", DefaultAlias: "eu-west-3", }, alerter)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketInventoryResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsS3BucketInventoryResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketInventoryResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsS3BucketInventoryResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -419,7 +419,7 @@ func TestS3BucketNotification(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("GetBucketNotification", "dritftctl-test-notifications-error", "eu-west-3").Return(nil, awsError) - alerter.On("SendAlert", "aws_s3_bucket_notification.dritftctl-test-notifications-error", alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, "aws_s3_bucket_notification.dritftctl-test-notifications-error", resourceaws.AwsS3BucketNotificationResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", "aws_s3_bucket_notification.dritftctl-test-notifications-error", alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, "aws_s3_bucket_notification.dritftctl-test-notifications-error", resourceaws.AwsS3BucketNotificationResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -429,7 +429,7 @@ func TestS3BucketNotification(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllBuckets").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsS3BucketNotificationResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketNotificationResourceType, resourceaws.AwsS3BucketResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsS3BucketNotificationResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketNotificationResourceType, resourceaws.AwsS3BucketResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -450,7 +450,7 @@ func TestS3BucketNotification(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -479,7 +479,7 @@ func TestS3BucketNotification(t *testing.T) { Name: "test", DefaultAlias: "eu-west-3", }, alerter)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketNotificationResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsS3BucketNotificationResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketNotificationResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsS3BucketNotificationResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -559,7 +559,7 @@ func TestS3BucketMetrics(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllBuckets").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsS3BucketMetricResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketMetricResourceType, resourceaws.AwsS3BucketResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsS3BucketMetricResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketMetricResourceType, resourceaws.AwsS3BucketResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -590,7 +590,7 @@ func TestS3BucketMetrics(t *testing.T) { awsError, ) - alerter.On("SendAlert", resourceaws.AwsS3BucketMetricResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketMetricResourceType, resourceaws.AwsS3BucketMetricResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsS3BucketMetricResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketMetricResourceType, resourceaws.AwsS3BucketMetricResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -611,7 +611,7 @@ func TestS3BucketMetrics(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -640,7 +640,7 @@ func TestS3BucketMetrics(t *testing.T) { Name: "test", DefaultAlias: "eu-west-3", }, alerter)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketMetricResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsS3BucketMetricResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketMetricResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsS3BucketMetricResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -748,7 +748,7 @@ func TestS3BucketPolicy(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllBuckets").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsS3BucketPolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketPolicyResourceType, resourceaws.AwsS3BucketResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsS3BucketPolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketPolicyResourceType, resourceaws.AwsS3BucketResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -769,7 +769,7 @@ func TestS3BucketPolicy(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -798,7 +798,7 @@ func TestS3BucketPolicy(t *testing.T) { Name: "test", DefaultAlias: "eu-west-3", }, alerter)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketPolicyResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsS3BucketPolicyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketPolicyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsS3BucketPolicyResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -872,7 +872,7 @@ func TestS3BucketPublicAccessBlock(t *testing.T) { repository.On("ListAllBuckets").Return([]*s3.Bucket{{Name: awssdk.String("foobar")}}, nil) repository.On("GetBucketLocation", "foobar").Return("us-east-1", nil) repository.On("GetBucketPublicAccessBlock", "foobar", "us-east-1").Return(nil, dummyError) - alerter.On("SendAlert", "aws_s3_bucket_public_access_block.foobar", alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceScanningError(dummyError, resourceaws.AwsS3BucketPublicAccessBlockResourceType, "foobar"), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", "aws_s3_bucket_public_access_block.foobar", alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceScanningError(dummyError, resourceaws.AwsS3BucketPublicAccessBlockResourceType, "foobar"), alerts.EnumerationPhase)).Return() }, assertExpected: func(t *testing.T, got []*resource.Resource) { assert.Len(t, got, 0) @@ -888,7 +888,7 @@ func TestS3BucketPublicAccessBlock(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -984,7 +984,7 @@ func TestS3BucketAnalytic(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") repository.On("ListAllBuckets").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsS3BucketAnalyticsConfigurationResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketAnalyticsConfigurationResourceType, resourceaws.AwsS3BucketResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsS3BucketAnalyticsConfigurationResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketAnalyticsConfigurationResourceType, resourceaws.AwsS3BucketResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -1015,7 +1015,7 @@ func TestS3BucketAnalytic(t *testing.T) { awsError, ) - alerter.On("SendAlert", resourceaws.AwsS3BucketAnalyticsConfigurationResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketAnalyticsConfigurationResourceType, resourceaws.AwsS3BucketAnalyticsConfigurationResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsS3BucketAnalyticsConfigurationResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsS3BucketAnalyticsConfigurationResourceType, resourceaws.AwsS3BucketAnalyticsConfigurationResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -1036,7 +1036,7 @@ func TestS3BucketAnalytic(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1065,7 +1065,7 @@ func TestS3BucketAnalytic(t *testing.T) { Name: "test", DefaultAlias: "eu-west-3", }, alerter)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketAnalyticsConfigurationResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsS3BucketAnalyticsConfigurationResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketAnalyticsConfigurationResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsS3BucketAnalyticsConfigurationResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) diff --git a/enumeration/remote/aws_sns_scanner_test.go b/enumeration/remote/aws_sns_scanner_test.go index ebe6741dc..c842f1291 100644 --- a/enumeration/remote/aws_sns_scanner_test.go +++ b/enumeration/remote/aws_sns_scanner_test.go @@ -8,7 +8,7 @@ import ( aws2 "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" terraform3 "github.com/snyk/driftctl/enumeration/terraform" @@ -66,7 +66,7 @@ func TestScanSNSTopic(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllTopics").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsSnsTopicResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSnsTopicResourceType, resourceaws.AwsSnsTopicResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsSnsTopicResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSnsTopicResourceType, resourceaws.AwsSnsTopicResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -87,7 +87,7 @@ func TestScanSNSTopic(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -114,7 +114,7 @@ func TestScanSNSTopic(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewSNSTopicEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsSnsTopicResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsSnsTopicResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsSnsTopicResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSnsTopicResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -166,7 +166,7 @@ func TestSNSTopicPolicyScan(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllTopics").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsSnsTopicPolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSnsTopicPolicyResourceType, resourceaws.AwsSnsTopicResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsSnsTopicPolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSnsTopicPolicyResourceType, resourceaws.AwsSnsTopicResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -187,7 +187,7 @@ func TestSNSTopicPolicyScan(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -214,7 +214,7 @@ func TestSNSTopicPolicyScan(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewSNSTopicPolicyEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsSnsTopicPolicyResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsSnsTopicPolicyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsSnsTopicPolicyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSnsTopicPolicyResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -283,7 +283,7 @@ func TestSNSTopicSubscriptionScan(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllSubscriptions").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsSnsTopicSubscriptionResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSnsTopicSubscriptionResourceType, resourceaws.AwsSnsTopicSubscriptionResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsSnsTopicSubscriptionResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSnsTopicSubscriptionResourceType, resourceaws.AwsSnsTopicSubscriptionResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -304,7 +304,7 @@ func TestSNSTopicSubscriptionScan(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -331,7 +331,7 @@ func TestSNSTopicSubscriptionScan(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewSNSTopicSubscriptionEnumerator(repo, factory, alerter)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsSnsTopicSubscriptionResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsSnsTopicSubscriptionResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsSnsTopicSubscriptionResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSnsTopicSubscriptionResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) diff --git a/enumeration/remote/aws_sqs_scanner_test.go b/enumeration/remote/aws_sqs_scanner_test.go index 14a009a54..b7ad002f9 100644 --- a/enumeration/remote/aws_sqs_scanner_test.go +++ b/enumeration/remote/aws_sqs_scanner_test.go @@ -8,7 +8,7 @@ import ( aws2 "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" terraform3 "github.com/snyk/driftctl/enumeration/terraform" @@ -62,7 +62,7 @@ func TestSQSQueue(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllQueues").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsSqsQueueResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSqsQueueResourceType, resourceaws.AwsSqsQueueResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsSqsQueueResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSqsQueueResourceType, resourceaws.AwsSqsQueueResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -83,7 +83,7 @@ func TestSQSQueue(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -189,7 +189,7 @@ func TestSQSQueuePolicy(t *testing.T) { awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "") client.On("ListAllQueues").Return(nil, awsError) - alerter.On("SendAlert", resourceaws.AwsSqsQueuePolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSqsQueuePolicyResourceType, resourceaws.AwsSqsQueueResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", resourceaws.AwsSqsQueuePolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsSqsQueuePolicyResourceType, resourceaws.AwsSqsQueueResourceType), alerts.EnumerationPhase)).Return() }, wantErr: nil, }, @@ -210,7 +210,7 @@ func TestSQSQueuePolicy(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -236,7 +236,7 @@ func TestSQSQueuePolicy(t *testing.T) { } remoteLibrary.AddEnumerator(aws2.NewSQSQueuePolicyEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsSqsQueuePolicyResourceType, common2.NewGenericDetailsFetcher(resourceaws.AwsSqsQueuePolicyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsSqsQueuePolicyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSqsQueuePolicyResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) diff --git a/enumeration/remote/azurerm/init.go b/enumeration/remote/azurerm/init.go index f74b8e58f..e42344a80 100644 --- a/enumeration/remote/azurerm/init.go +++ b/enumeration/remote/azurerm/init.go @@ -7,7 +7,7 @@ import ( "github.com/snyk/driftctl/enumeration/alerter" "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/enumeration/resource/azurerm" "github.com/snyk/driftctl/enumeration/terraform" @@ -17,7 +17,7 @@ func Init( version string, alerter *alerter.Alerter, providerLibrary *terraform.ProviderLibrary, - remoteLibrary *common2.RemoteLibrary, + remoteLibrary *common.RemoteLibrary, progress enumeration.ProgressCounter, resourceSchemaRepository *resource.SchemaRepository, factory resource.ResourceFactory, @@ -69,31 +69,31 @@ func Init( remoteLibrary.AddEnumerator(NewAzurermPublicIPEnumerator(networkRepo, factory)) remoteLibrary.AddEnumerator(NewAzurermPostgresqlDatabaseEnumerator(postgresqlRepo, factory)) remoteLibrary.AddEnumerator(NewAzurermNetworkSecurityGroupEnumerator(networkRepo, factory)) - remoteLibrary.AddDetailsFetcher(azurerm.AzureNetworkSecurityGroupResourceType, common2.NewGenericDetailsFetcher(azurerm.AzureNetworkSecurityGroupResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(azurerm.AzureNetworkSecurityGroupResourceType, common.NewGenericDetailsFetcher(azurerm.AzureNetworkSecurityGroupResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewAzurermLoadBalancerEnumerator(networkRepo, factory)) remoteLibrary.AddEnumerator(NewAzurermLoadBalancerRuleEnumerator(networkRepo, factory)) - remoteLibrary.AddDetailsFetcher(azurerm.AzureLoadBalancerRuleResourceType, common2.NewGenericDetailsFetcher(azurerm.AzureLoadBalancerRuleResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(azurerm.AzureLoadBalancerRuleResourceType, common.NewGenericDetailsFetcher(azurerm.AzureLoadBalancerRuleResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewAzurermPrivateDNSZoneEnumerator(privateDNSRepo, factory)) - remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSZoneResourceType, common2.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSZoneResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSZoneResourceType, common.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSZoneResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewAzurermPrivateDNSARecordEnumerator(privateDNSRepo, factory)) - remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSARecordResourceType, common2.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSARecordResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSARecordResourceType, common.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSARecordResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewAzurermPrivateDNSAAAARecordEnumerator(privateDNSRepo, factory)) - remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSAAAARecordResourceType, common2.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSAAAARecordResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSAAAARecordResourceType, common.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSAAAARecordResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewAzurermPrivateDNSMXRecordEnumerator(privateDNSRepo, factory)) - remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSMXRecordResourceType, common2.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSMXRecordResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSMXRecordResourceType, common.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSMXRecordResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewAzurermPrivateDNSCNameRecordEnumerator(privateDNSRepo, factory)) - remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSCNameRecordResourceType, common2.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSCNameRecordResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSCNameRecordResourceType, common.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSCNameRecordResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewAzurermPrivateDNSPTRRecordEnumerator(privateDNSRepo, factory)) - remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSPTRRecordResourceType, common2.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSPTRRecordResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSPTRRecordResourceType, common.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSPTRRecordResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewAzurermPrivateDNSSRVRecordEnumerator(privateDNSRepo, factory)) - remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSSRVRecordResourceType, common2.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSSRVRecordResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSSRVRecordResourceType, common.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSSRVRecordResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewAzurermPrivateDNSTXTRecordEnumerator(privateDNSRepo, factory)) - remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSTXTRecordResourceType, common2.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSTXTRecordResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(azurerm.AzurePrivateDNSTXTRecordResourceType, common.NewGenericDetailsFetcher(azurerm.AzurePrivateDNSTXTRecordResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewAzurermImageEnumerator(computeRepo, factory)) remoteLibrary.AddEnumerator(NewAzurermSSHPublicKeyEnumerator(computeRepo, factory)) - remoteLibrary.AddDetailsFetcher(azurerm.AzureSSHPublicKeyResourceType, common2.NewGenericDetailsFetcher(azurerm.AzureSSHPublicKeyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(azurerm.AzureSSHPublicKeyResourceType, common.NewGenericDetailsFetcher(azurerm.AzureSSHPublicKeyResourceType, provider, deserializer)) err = resourceSchemaRepository.Init(terraform.AZURE, provider.Version(), provider.Schema()) if err != nil { diff --git a/enumeration/remote/azurerm_compute_scanner_test.go b/enumeration/remote/azurerm_compute_scanner_test.go index 65bfdad6b..70fa2aceb 100644 --- a/enumeration/remote/azurerm_compute_scanner_test.go +++ b/enumeration/remote/azurerm_compute_scanner_test.go @@ -7,7 +7,7 @@ import ( azurerm2 "github.com/snyk/driftctl/enumeration/remote/azurerm" "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" terraform3 "github.com/snyk/driftctl/enumeration/terraform" @@ -98,7 +98,7 @@ func TestAzurermCompute_Image(t *testing.T) { for _, c := range tests { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -183,7 +183,7 @@ func TestAzurermCompute_SSHPublicKey(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -215,7 +215,7 @@ func TestAzurermCompute_SSHPublicKey(t *testing.T) { } remoteLibrary.AddEnumerator(azurerm2.NewAzurermSSHPublicKeyEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceazure.AzureSSHPublicKeyResourceType, common2.NewGenericDetailsFetcher(resourceazure.AzureSSHPublicKeyResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceazure.AzureSSHPublicKeyResourceType, common.NewGenericDetailsFetcher(resourceazure.AzureSSHPublicKeyResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) diff --git a/enumeration/remote/azurerm_network_scanner_test.go b/enumeration/remote/azurerm_network_scanner_test.go index 0197872ec..a14040ffc 100644 --- a/enumeration/remote/azurerm_network_scanner_test.go +++ b/enumeration/remote/azurerm_network_scanner_test.go @@ -7,7 +7,7 @@ import ( azurerm2 "github.com/snyk/driftctl/enumeration/remote/azurerm" "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" error2 "github.com/snyk/driftctl/enumeration/remote/error" terraform3 "github.com/snyk/driftctl/enumeration/terraform" @@ -93,7 +93,7 @@ func TestAzurermVirtualNetwork(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -186,7 +186,7 @@ func TestAzurermRouteTables(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -335,7 +335,7 @@ func TestAzurermRoutes(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -468,7 +468,7 @@ func TestAzurermSubnets(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -561,7 +561,7 @@ func TestAzurermFirewalls(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -654,7 +654,7 @@ func TestAzurermPublicIP(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -741,7 +741,7 @@ func TestAzurermSecurityGroups(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -773,7 +773,7 @@ func TestAzurermSecurityGroups(t *testing.T) { } remoteLibrary.AddEnumerator(azurerm2.NewAzurermNetworkSecurityGroupEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceazure.AzureNetworkSecurityGroupResourceType, common2.NewGenericDetailsFetcher(resourceazure.AzureNetworkSecurityGroupResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceazure.AzureNetworkSecurityGroupResourceType, common.NewGenericDetailsFetcher(resourceazure.AzureNetworkSecurityGroupResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -857,7 +857,7 @@ func TestAzurermLoadBalancers(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -962,7 +962,7 @@ func TestAzurermLoadBalancerRules(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -994,7 +994,7 @@ func TestAzurermLoadBalancerRules(t *testing.T) { } remoteLibrary.AddEnumerator(azurerm2.NewAzurermLoadBalancerRuleEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceazure.AzureLoadBalancerRuleResourceType, common2.NewGenericDetailsFetcher(resourceazure.AzureLoadBalancerRuleResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceazure.AzureLoadBalancerRuleResourceType, common.NewGenericDetailsFetcher(resourceazure.AzureLoadBalancerRuleResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) diff --git a/enumeration/remote/azurerm_privatedns_scanner_test.go b/enumeration/remote/azurerm_privatedns_scanner_test.go index 3f39b8b1f..67d755fab 100644 --- a/enumeration/remote/azurerm_privatedns_scanner_test.go +++ b/enumeration/remote/azurerm_privatedns_scanner_test.go @@ -7,7 +7,7 @@ import ( azurerm2 "github.com/snyk/driftctl/enumeration/remote/azurerm" "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" terraform2 "github.com/snyk/driftctl/enumeration/terraform" @@ -99,7 +99,7 @@ func TestAzurermPrivateDNSZone(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform2.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -131,7 +131,7 @@ func TestAzurermPrivateDNSZone(t *testing.T) { } remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSZoneEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSZoneResourceType, common2.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSZoneResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSZoneResourceType, common.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSZoneResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -253,7 +253,7 @@ func TestAzurermPrivateDNSARecord(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform2.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -285,7 +285,7 @@ func TestAzurermPrivateDNSARecord(t *testing.T) { } remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSARecordEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSARecordResourceType, common2.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSARecordResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSARecordResourceType, common.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSARecordResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -408,7 +408,7 @@ func TestAzurermPrivateDNSAAAARecord(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform2.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -440,7 +440,7 @@ func TestAzurermPrivateDNSAAAARecord(t *testing.T) { } remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSAAAARecordEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSAAAARecordResourceType, common2.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSAAAARecordResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSAAAARecordResourceType, common.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSAAAARecordResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -551,7 +551,7 @@ func TestAzurermPrivateDNSCNAMERecord(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform2.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -583,7 +583,7 @@ func TestAzurermPrivateDNSCNAMERecord(t *testing.T) { } remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSCNameRecordEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSCNameRecordResourceType, common2.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSCNameRecordResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSCNameRecordResourceType, common.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSCNameRecordResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -705,7 +705,7 @@ func TestAzurermPrivateDNSPTRRecord(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform2.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -737,7 +737,7 @@ func TestAzurermPrivateDNSPTRRecord(t *testing.T) { } remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSPTRRecordEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSPTRRecordResourceType, common2.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSPTRRecordResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSPTRRecordResourceType, common.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSPTRRecordResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -860,7 +860,7 @@ func TestAzurermPrivateDNSMXRecord(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform2.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -892,7 +892,7 @@ func TestAzurermPrivateDNSMXRecord(t *testing.T) { } remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSMXRecordEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSMXRecordResourceType, common2.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSMXRecordResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSMXRecordResourceType, common.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSMXRecordResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1014,7 +1014,7 @@ func TestAzurermPrivateDNSSRVRecord(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform2.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1046,7 +1046,7 @@ func TestAzurermPrivateDNSSRVRecord(t *testing.T) { } remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSSRVRecordEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSSRVRecordResourceType, common2.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSSRVRecordResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSSRVRecordResourceType, common.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSSRVRecordResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1168,7 +1168,7 @@ func TestAzurermPrivateDNSTXTRecord(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform2.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1200,7 +1200,7 @@ func TestAzurermPrivateDNSTXTRecord(t *testing.T) { } remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSTXTRecordEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSTXTRecordResourceType, common2.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSTXTRecordResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSTXTRecordResourceType, common.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSTXTRecordResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) diff --git a/enumeration/remote/github/init.go b/enumeration/remote/github/init.go index 64a978519..c2b016e2d 100644 --- a/enumeration/remote/github/init.go +++ b/enumeration/remote/github/init.go @@ -4,7 +4,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/alerter" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/enumeration/resource/github" "github.com/snyk/driftctl/enumeration/terraform" @@ -17,7 +17,7 @@ import ( func Init(version string, alerter *alerter.Alerter, providerLibrary *terraform.ProviderLibrary, - remoteLibrary *common2.RemoteLibrary, + remoteLibrary *common.RemoteLibrary, progress enumeration.ProgressCounter, resourceSchemaRepository *resource.SchemaRepository, factory resource.ResourceFactory, @@ -39,19 +39,19 @@ func Init(version string, alerter *alerter.Alerter, providerLibrary.AddProvider(terraform.GITHUB, provider) remoteLibrary.AddEnumerator(NewGithubTeamEnumerator(repository, factory)) - remoteLibrary.AddDetailsFetcher(github.GithubTeamResourceType, common2.NewGenericDetailsFetcher(github.GithubTeamResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(github.GithubTeamResourceType, common.NewGenericDetailsFetcher(github.GithubTeamResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewGithubRepositoryEnumerator(repository, factory)) - remoteLibrary.AddDetailsFetcher(github.GithubRepositoryResourceType, common2.NewGenericDetailsFetcher(github.GithubRepositoryResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(github.GithubRepositoryResourceType, common.NewGenericDetailsFetcher(github.GithubRepositoryResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewGithubMembershipEnumerator(repository, factory)) - remoteLibrary.AddDetailsFetcher(github.GithubMembershipResourceType, common2.NewGenericDetailsFetcher(github.GithubMembershipResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(github.GithubMembershipResourceType, common.NewGenericDetailsFetcher(github.GithubMembershipResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewGithubTeamMembershipEnumerator(repository, factory)) - remoteLibrary.AddDetailsFetcher(github.GithubTeamMembershipResourceType, common2.NewGenericDetailsFetcher(github.GithubTeamMembershipResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(github.GithubTeamMembershipResourceType, common.NewGenericDetailsFetcher(github.GithubTeamMembershipResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewGithubBranchProtectionEnumerator(repository, factory)) - remoteLibrary.AddDetailsFetcher(github.GithubBranchProtectionResourceType, common2.NewGenericDetailsFetcher(github.GithubBranchProtectionResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(github.GithubBranchProtectionResourceType, common.NewGenericDetailsFetcher(github.GithubBranchProtectionResourceType, provider, deserializer)) err = resourceSchemaRepository.Init(terraform.GITHUB, provider.Version(), provider.Schema()) if err != nil { diff --git a/enumeration/remote/github_branch_protection_scanner_test.go b/enumeration/remote/github_branch_protection_scanner_test.go index e28012856..ae97cd252 100644 --- a/enumeration/remote/github_branch_protection_scanner_test.go +++ b/enumeration/remote/github_branch_protection_scanner_test.go @@ -6,7 +6,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" github2 "github.com/snyk/driftctl/enumeration/remote/github" terraform2 "github.com/snyk/driftctl/enumeration/terraform" @@ -62,7 +62,7 @@ func TestScanGithubBranchProtection(t *testing.T) { mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListBranchProtection").Return(nil, errors.New("Your token has not been granted the required scopes to execute this query.")) - alerter.On("SendAlert", githubres.GithubBranchProtectionResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), githubres.GithubBranchProtectionResourceType, githubres.GithubBranchProtectionResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", githubres.GithubBranchProtectionResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), githubres.GithubBranchProtectionResourceType, githubres.GithubBranchProtectionResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -80,7 +80,7 @@ func TestScanGithubBranchProtection(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform2.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -106,7 +106,7 @@ func TestScanGithubBranchProtection(t *testing.T) { } remoteLibrary.AddEnumerator(github2.NewGithubBranchProtectionEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(githubres.GithubBranchProtectionResourceType, common2.NewGenericDetailsFetcher(githubres.GithubBranchProtectionResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(githubres.GithubBranchProtectionResourceType, common.NewGenericDetailsFetcher(githubres.GithubBranchProtectionResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) diff --git a/enumeration/remote/github_membership_scanner_test.go b/enumeration/remote/github_membership_scanner_test.go index acb9a6871..cf9e399d1 100644 --- a/enumeration/remote/github_membership_scanner_test.go +++ b/enumeration/remote/github_membership_scanner_test.go @@ -7,7 +7,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" github2 "github.com/snyk/driftctl/enumeration/remote/github" terraform2 "github.com/snyk/driftctl/enumeration/terraform" @@ -58,7 +58,7 @@ func TestScanGithubMembership(t *testing.T) { mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListMembership").Return(nil, errors.New("Your token has not been granted the required scopes to execute this query.")) - alerter.On("SendAlert", githubres.GithubMembershipResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), githubres.GithubMembershipResourceType, githubres.GithubMembershipResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", githubres.GithubMembershipResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), githubres.GithubMembershipResourceType, githubres.GithubMembershipResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -76,7 +76,7 @@ func TestScanGithubMembership(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform2.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -102,7 +102,7 @@ func TestScanGithubMembership(t *testing.T) { } remoteLibrary.AddEnumerator(github2.NewGithubMembershipEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(githubres.GithubMembershipResourceType, common2.NewGenericDetailsFetcher(githubres.GithubMembershipResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(githubres.GithubMembershipResourceType, common.NewGenericDetailsFetcher(githubres.GithubMembershipResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) diff --git a/enumeration/remote/github_repository_scanner_test.go b/enumeration/remote/github_repository_scanner_test.go index 14bac7c47..0369813ac 100644 --- a/enumeration/remote/github_repository_scanner_test.go +++ b/enumeration/remote/github_repository_scanner_test.go @@ -7,7 +7,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" github2 "github.com/snyk/driftctl/enumeration/remote/github" terraform2 "github.com/snyk/driftctl/enumeration/terraform" @@ -58,7 +58,7 @@ func TestScanGithubRepository(t *testing.T) { mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListRepositories").Return(nil, errors.New("Your token has not been granted the required scopes to execute this query.")) - alerter.On("SendAlert", githubres.GithubRepositoryResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), githubres.GithubRepositoryResourceType, githubres.GithubRepositoryResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", githubres.GithubRepositoryResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), githubres.GithubRepositoryResourceType, githubres.GithubRepositoryResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -76,7 +76,7 @@ func TestScanGithubRepository(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform2.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -102,7 +102,7 @@ func TestScanGithubRepository(t *testing.T) { } remoteLibrary.AddEnumerator(github2.NewGithubRepositoryEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(githubres.GithubRepositoryResourceType, common2.NewGenericDetailsFetcher(githubres.GithubRepositoryResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(githubres.GithubRepositoryResourceType, common.NewGenericDetailsFetcher(githubres.GithubRepositoryResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) diff --git a/enumeration/remote/github_team_membership_scanner_test.go b/enumeration/remote/github_team_membership_scanner_test.go index 5bb078e75..9ae59036a 100644 --- a/enumeration/remote/github_team_membership_scanner_test.go +++ b/enumeration/remote/github_team_membership_scanner_test.go @@ -7,7 +7,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" github2 "github.com/snyk/driftctl/enumeration/remote/github" terraform2 "github.com/snyk/driftctl/enumeration/terraform" @@ -58,7 +58,7 @@ func TestScanGithubTeamMembership(t *testing.T) { mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListTeamMemberships").Return(nil, errors.New("Your token has not been granted the required scopes to execute this query.")) - alerter.On("SendAlert", githubres.GithubTeamMembershipResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), githubres.GithubTeamMembershipResourceType, githubres.GithubTeamMembershipResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", githubres.GithubTeamMembershipResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), githubres.GithubTeamMembershipResourceType, githubres.GithubTeamMembershipResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -76,7 +76,7 @@ func TestScanGithubTeamMembership(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform2.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -102,7 +102,7 @@ func TestScanGithubTeamMembership(t *testing.T) { } remoteLibrary.AddEnumerator(github2.NewGithubTeamMembershipEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(githubres.GithubTeamMembershipResourceType, common2.NewGenericDetailsFetcher(githubres.GithubTeamMembershipResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(githubres.GithubTeamMembershipResourceType, common.NewGenericDetailsFetcher(githubres.GithubTeamMembershipResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) diff --git a/enumeration/remote/github_team_scanner_test.go b/enumeration/remote/github_team_scanner_test.go index f99f3c2d2..3619f305a 100644 --- a/enumeration/remote/github_team_scanner_test.go +++ b/enumeration/remote/github_team_scanner_test.go @@ -7,7 +7,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" github2 "github.com/snyk/driftctl/enumeration/remote/github" terraform2 "github.com/snyk/driftctl/enumeration/terraform" @@ -59,7 +59,7 @@ func TestScanGithubTeam(t *testing.T) { mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListTeams").Return(nil, errors.New("Your token has not been granted the required scopes to execute this query.")) - alerter.On("SendAlert", githubres.GithubTeamResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), githubres.GithubTeamResourceType, githubres.GithubTeamResourceType), alerts.EnumerationPhase)).Return() + alerter.On("SendAlert", githubres.GithubTeamResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), githubres.GithubTeamResourceType, githubres.GithubTeamResourceType), alerts.EnumerationPhase)).Return() }, err: nil, }, @@ -77,7 +77,7 @@ func TestScanGithubTeam(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform2.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -103,7 +103,7 @@ func TestScanGithubTeam(t *testing.T) { } remoteLibrary.AddEnumerator(github2.NewGithubTeamEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(githubres.GithubTeamResourceType, common2.NewGenericDetailsFetcher(githubres.GithubTeamResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(githubres.GithubTeamResourceType, common.NewGenericDetailsFetcher(githubres.GithubTeamResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) diff --git a/enumeration/remote/google/init.go b/enumeration/remote/google/init.go index 99e9deae8..0bb89a3e3 100644 --- a/enumeration/remote/google/init.go +++ b/enumeration/remote/google/init.go @@ -7,7 +7,7 @@ import ( "github.com/snyk/driftctl/enumeration/alerter" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" "github.com/snyk/driftctl/enumeration/remote/google/repository" "github.com/snyk/driftctl/enumeration/terraform" @@ -20,7 +20,7 @@ import ( func Init(version string, alerter *alerter.Alerter, providerLibrary *terraform.ProviderLibrary, - remoteLibrary *common2.RemoteLibrary, + remoteLibrary *common.RemoteLibrary, progress enumeration.ProgressCounter, resourceSchemaRepository *resource.SchemaRepository, factory resource.ResourceFactory, @@ -67,31 +67,31 @@ func Init(version string, alerter *alerter.Alerter, deserializer := resource.NewDeserializer(factory) remoteLibrary.AddEnumerator(NewGoogleStorageBucketEnumerator(assetRepository, factory)) - remoteLibrary.AddDetailsFetcher(google.GoogleStorageBucketResourceType, common2.NewGenericDetailsFetcher(google.GoogleStorageBucketResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(google.GoogleStorageBucketResourceType, common.NewGenericDetailsFetcher(google.GoogleStorageBucketResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewGoogleComputeFirewallEnumerator(assetRepository, factory)) - remoteLibrary.AddDetailsFetcher(google.GoogleComputeFirewallResourceType, common2.NewGenericDetailsFetcher(google.GoogleComputeFirewallResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(google.GoogleComputeFirewallResourceType, common.NewGenericDetailsFetcher(google.GoogleComputeFirewallResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewGoogleComputeRouterEnumerator(assetRepository, factory)) remoteLibrary.AddEnumerator(NewGoogleComputeInstanceEnumerator(assetRepository, factory)) remoteLibrary.AddEnumerator(NewGoogleProjectIamMemberEnumerator(iamRepository, factory)) - remoteLibrary.AddDetailsFetcher(google.GoogleProjectIamMemberResourceType, common2.NewGenericDetailsFetcher(google.GoogleProjectIamMemberResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(google.GoogleProjectIamMemberResourceType, common.NewGenericDetailsFetcher(google.GoogleProjectIamMemberResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewGoogleStorageBucketIamMemberEnumerator(assetRepository, storageRepository, factory)) - remoteLibrary.AddDetailsFetcher(google.GoogleStorageBucketIamMemberResourceType, common2.NewGenericDetailsFetcher(google.GoogleStorageBucketIamMemberResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(google.GoogleStorageBucketIamMemberResourceType, common.NewGenericDetailsFetcher(google.GoogleStorageBucketIamMemberResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewGoogleComputeNetworkEnumerator(assetRepository, factory)) - remoteLibrary.AddDetailsFetcher(google.GoogleComputeNetworkResourceType, common2.NewGenericDetailsFetcher(google.GoogleComputeNetworkResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(google.GoogleComputeNetworkResourceType, common.NewGenericDetailsFetcher(google.GoogleComputeNetworkResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewGoogleComputeSubnetworkEnumerator(assetRepository, factory)) - remoteLibrary.AddDetailsFetcher(google.GoogleComputeSubnetworkResourceType, common2.NewGenericDetailsFetcher(google.GoogleComputeSubnetworkResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(google.GoogleComputeSubnetworkResourceType, common.NewGenericDetailsFetcher(google.GoogleComputeSubnetworkResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewGoogleDNSManagedZoneEnumerator(assetRepository, factory)) remoteLibrary.AddEnumerator(NewGoogleComputeInstanceGroupEnumerator(assetRepository, factory)) - remoteLibrary.AddDetailsFetcher(google.GoogleComputeInstanceGroupResourceType, common2.NewGenericDetailsFetcher(google.GoogleComputeInstanceGroupResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(google.GoogleComputeInstanceGroupResourceType, common.NewGenericDetailsFetcher(google.GoogleComputeInstanceGroupResourceType, provider, deserializer)) remoteLibrary.AddEnumerator(NewGoogleBigqueryDatasetEnumerator(assetRepository, factory)) remoteLibrary.AddEnumerator(NewGoogleBigqueryTableEnumerator(assetRepository, factory)) diff --git a/enumeration/remote/google_bigquery_scanner_test.go b/enumeration/remote/google_bigquery_scanner_test.go index 6f8b754e3..4ac6493d1 100644 --- a/enumeration/remote/google_bigquery_scanner_test.go +++ b/enumeration/remote/google_bigquery_scanner_test.go @@ -6,7 +6,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" google2 "github.com/snyk/driftctl/enumeration/remote/google" "github.com/snyk/driftctl/enumeration/remote/google/repository" @@ -68,7 +68,7 @@ func TestGoogleBigqueryDataset(t *testing.T) { "SendAlert", "google_bigquery_dataset", alerts.NewRemoteAccessDeniedAlert( - common2.RemoteGoogleTerraform, + common.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_bigquery_dataset", @@ -89,7 +89,7 @@ func TestGoogleBigqueryDataset(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -171,7 +171,7 @@ func TestGoogleBigqueryTable(t *testing.T) { "SendAlert", "google_bigquery_table", alerts.NewRemoteAccessDeniedAlert( - common2.RemoteGoogleTerraform, + common.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_bigquery_table", @@ -192,7 +192,7 @@ func TestGoogleBigqueryTable(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} diff --git a/enumeration/remote/google_bigtable_scanner_test.go b/enumeration/remote/google_bigtable_scanner_test.go index 3bec37acb..dd0ef2703 100644 --- a/enumeration/remote/google_bigtable_scanner_test.go +++ b/enumeration/remote/google_bigtable_scanner_test.go @@ -6,7 +6,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" google2 "github.com/snyk/driftctl/enumeration/remote/google" "github.com/snyk/driftctl/enumeration/remote/google/repository" @@ -105,7 +105,7 @@ func TestGoogleBigtableInstance(t *testing.T) { "SendAlert", "google_bigtable_instance", alerts.NewRemoteAccessDeniedAlert( - common2.RemoteGoogleTerraform, + common.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_bigtable_instance", @@ -126,7 +126,7 @@ func TestGoogleBigtableInstance(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -231,7 +231,7 @@ func TestGoogleBigtableTable(t *testing.T) { "SendAlert", "google_bigtable_table", alerts.NewRemoteAccessDeniedAlert( - common2.RemoteGoogleTerraform, + common.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_bigtable_table", @@ -252,7 +252,7 @@ func TestGoogleBigtableTable(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} diff --git a/enumeration/remote/google_cloudfunctions_scanner_test.go b/enumeration/remote/google_cloudfunctions_scanner_test.go index a0b631703..ccdd2d3d7 100644 --- a/enumeration/remote/google_cloudfunctions_scanner_test.go +++ b/enumeration/remote/google_cloudfunctions_scanner_test.go @@ -6,7 +6,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/remote/google" "github.com/snyk/driftctl/enumeration/remote/google/repository" @@ -92,7 +92,7 @@ func TestGoogleCloudFunctionsFunction(t *testing.T) { "SendAlert", "google_cloudfunctions_function", alerts.NewRemoteAccessDeniedAlert( - common2.RemoteGoogleTerraform, + common.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_cloudfunctions_function", @@ -113,7 +113,7 @@ func TestGoogleCloudFunctionsFunction(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} diff --git a/enumeration/remote/google_cloudrun_scanner_test.go b/enumeration/remote/google_cloudrun_scanner_test.go index 51c7a0f5a..3bb778400 100644 --- a/enumeration/remote/google_cloudrun_scanner_test.go +++ b/enumeration/remote/google_cloudrun_scanner_test.go @@ -6,7 +6,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/remote/google" "github.com/snyk/driftctl/enumeration/remote/google/repository" @@ -84,7 +84,7 @@ func TestGoogleCloudRunService(t *testing.T) { "SendAlert", googleresource.GoogleCloudRunServiceResourceType, alerts.NewRemoteAccessDeniedAlert( - common2.RemoteGoogleTerraform, + common.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), googleresource.GoogleCloudRunServiceResourceType, @@ -108,7 +108,7 @@ func TestGoogleCloudRunService(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} diff --git a/enumeration/remote/google_compute_scanner_test.go b/enumeration/remote/google_compute_scanner_test.go index 27651c6bd..2d937d8f3 100644 --- a/enumeration/remote/google_compute_scanner_test.go +++ b/enumeration/remote/google_compute_scanner_test.go @@ -6,7 +6,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" google2 "github.com/snyk/driftctl/enumeration/remote/google" "github.com/snyk/driftctl/enumeration/remote/google/repository" @@ -76,7 +76,7 @@ func TestGoogleComputeFirewall(t *testing.T) { "SendAlert", "google_compute_firewall", alerts.NewRemoteAccessDeniedAlert( - common2.RemoteGoogleTerraform, + common.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_compute_firewall", @@ -102,7 +102,7 @@ func TestGoogleComputeFirewall(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -134,7 +134,7 @@ func TestGoogleComputeFirewall(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) remoteLibrary.AddEnumerator(google2.NewGoogleComputeFirewallEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resType, common2.NewGenericDetailsFetcher(resType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resType, common.NewGenericDetailsFetcher(resType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -212,7 +212,7 @@ func TestGoogleComputeRouter(t *testing.T) { "SendAlert", googleresource.GoogleComputeRouterResourceType, alerts.NewRemoteAccessDeniedAlert( - common2.RemoteGoogleTerraform, + common.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), googleresource.GoogleComputeRouterResourceType, @@ -236,7 +236,7 @@ func TestGoogleComputeRouter(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -319,7 +319,7 @@ func TestGoogleComputeInstance(t *testing.T) { "SendAlert", "google_compute_instance", alerts.NewRemoteAccessDeniedAlert( - common2.RemoteGoogleTerraform, + common.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_compute_instance", @@ -340,7 +340,7 @@ func TestGoogleComputeInstance(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -427,7 +427,7 @@ func TestGoogleComputeNetwork(t *testing.T) { "SendAlert", "google_compute_network", alerts.NewRemoteAccessDeniedAlert( - common2.RemoteGoogleTerraform, + common.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_compute_network", @@ -453,7 +453,7 @@ func TestGoogleComputeNetwork(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -485,7 +485,7 @@ func TestGoogleComputeNetwork(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) remoteLibrary.AddEnumerator(google2.NewGoogleComputeNetworkEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resType, common2.NewGenericDetailsFetcher(resType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resType, common.NewGenericDetailsFetcher(resType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -549,7 +549,7 @@ func TestGoogleComputeInstanceGroup(t *testing.T) { "SendAlert", "google_compute_instance_group", alerts.NewRemoteAccessDeniedAlert( - common2.RemoteGoogleTerraform, + common.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_compute_instance_group", @@ -575,7 +575,7 @@ func TestGoogleComputeInstanceGroup(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -607,7 +607,7 @@ func TestGoogleComputeInstanceGroup(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) remoteLibrary.AddEnumerator(google2.NewGoogleComputeInstanceGroupEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(googleresource.GoogleComputeInstanceGroupResourceType, common2.NewGenericDetailsFetcher(googleresource.GoogleComputeInstanceGroupResourceType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(googleresource.GoogleComputeInstanceGroupResourceType, common.NewGenericDetailsFetcher(googleresource.GoogleComputeInstanceGroupResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -686,7 +686,7 @@ func TestGoogleComputeAddress(t *testing.T) { "SendAlert", "google_compute_address", alerts.NewRemoteAccessDeniedAlert( - common2.RemoteGoogleTerraform, + common.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_compute_address", @@ -707,7 +707,7 @@ func TestGoogleComputeAddress(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -812,7 +812,7 @@ func TestGoogleComputeGlobalAddress(t *testing.T) { "SendAlert", "google_compute_global_address", alerts.NewRemoteAccessDeniedAlert( - common2.RemoteGoogleTerraform, + common.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_compute_global_address", @@ -833,7 +833,7 @@ func TestGoogleComputeGlobalAddress(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -920,7 +920,7 @@ func TestGoogleComputeSubnetwork(t *testing.T) { "SendAlert", "google_compute_subnetwork", alerts.NewRemoteAccessDeniedAlert( - common2.RemoteGoogleTerraform, + common.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_compute_subnetwork", @@ -946,7 +946,7 @@ func TestGoogleComputeSubnetwork(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -978,7 +978,7 @@ func TestGoogleComputeSubnetwork(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) remoteLibrary.AddEnumerator(google2.NewGoogleComputeSubnetworkEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resType, common2.NewGenericDetailsFetcher(resType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resType, common.NewGenericDetailsFetcher(resType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1045,7 +1045,7 @@ func TestGoogleComputeDisk(t *testing.T) { "SendAlert", "google_compute_disk", alerts.NewRemoteAccessDeniedAlert( - common2.RemoteGoogleTerraform, + common.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_compute_disk", @@ -1066,7 +1066,7 @@ func TestGoogleComputeDisk(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1155,7 +1155,7 @@ func TestGoogleComputeImage(t *testing.T) { "SendAlert", "google_compute_image", alerts.NewRemoteAccessDeniedAlert( - common2.RemoteGoogleTerraform, + common.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_compute_image", @@ -1176,7 +1176,7 @@ func TestGoogleComputeImage(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1265,7 +1265,7 @@ func TestGoogleComputeHealthCheck(t *testing.T) { "SendAlert", "google_compute_health_check", alerts.NewRemoteAccessDeniedAlert( - common2.RemoteGoogleTerraform, + common.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_compute_health_check", @@ -1286,7 +1286,7 @@ func TestGoogleComputeHealthCheck(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1375,7 +1375,7 @@ func TestGoogleComputeNodeGroup(t *testing.T) { "SendAlert", "google_compute_node_group", alerts.NewRemoteAccessDeniedAlert( - common2.RemoteGoogleTerraform, + common.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_compute_node_group", @@ -1396,7 +1396,7 @@ func TestGoogleComputeNodeGroup(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1484,7 +1484,7 @@ func TestGoogleComputeForwardingRule(t *testing.T) { "SendAlert", "google_compute_forwarding_rule", alerts.NewRemoteAccessDeniedAlert( - common2.RemoteGoogleTerraform, + common.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_compute_forwarding_rule", @@ -1505,7 +1505,7 @@ func TestGoogleComputeForwardingRule(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1594,7 +1594,7 @@ func TestGoogleComputeInstanceGroupManager(t *testing.T) { "SendAlert", "google_compute_instance_group_manager", alerts.NewRemoteAccessDeniedAlert( - common2.RemoteGoogleTerraform, + common.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_compute_instance_group_manager", @@ -1615,7 +1615,7 @@ func TestGoogleComputeInstanceGroupManager(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -1703,7 +1703,7 @@ func TestGoogleComputeGlobalForwardingRule(t *testing.T) { "SendAlert", "google_compute_global_forwarding_rule", alerts.NewRemoteAccessDeniedAlert( - common2.RemoteGoogleTerraform, + common.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_compute_global_forwarding_rule", @@ -1724,7 +1724,7 @@ func TestGoogleComputeGlobalForwardingRule(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} diff --git a/enumeration/remote/google_network_scanner_test.go b/enumeration/remote/google_network_scanner_test.go index 2956c0041..ced0a8e2f 100644 --- a/enumeration/remote/google_network_scanner_test.go +++ b/enumeration/remote/google_network_scanner_test.go @@ -6,7 +6,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/remote/google" "github.com/snyk/driftctl/enumeration/remote/google/repository" @@ -90,7 +90,7 @@ func TestGoogleDNSNanagedZone(t *testing.T) { "SendAlert", googleresource.GoogleDNSManagedZoneResourceType, alerts.NewRemoteAccessDeniedAlert( - common2.RemoteGoogleTerraform, + common.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), googleresource.GoogleDNSManagedZoneResourceType, @@ -114,7 +114,7 @@ func TestGoogleDNSNanagedZone(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} diff --git a/enumeration/remote/google_project_scanner_test.go b/enumeration/remote/google_project_scanner_test.go index c839dc941..76be2a13b 100644 --- a/enumeration/remote/google_project_scanner_test.go +++ b/enumeration/remote/google_project_scanner_test.go @@ -5,7 +5,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/remote/google" "github.com/snyk/driftctl/enumeration/remote/google/repository" @@ -55,7 +55,7 @@ func TestGoogleProjectIAMMember(t *testing.T) { "SendAlert", "google_project_iam_member", alerts.NewRemoteAccessDeniedAlert( - common2.RemoteGoogleTerraform, + common.RemoteGoogleTerraform, remoteerr.NewResourceListingError( errors.New("googleapi: Error 403: driftctl-acc-circle@driftctl-qa-1.iam.gserviceaccount.com does not have project.getIamPolicy access., forbidden"), "google_project_iam_member", @@ -101,7 +101,7 @@ func TestGoogleProjectIAMMember(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} diff --git a/enumeration/remote/google_sql_scanner_test.go b/enumeration/remote/google_sql_scanner_test.go index bcb05499a..d617ae995 100644 --- a/enumeration/remote/google_sql_scanner_test.go +++ b/enumeration/remote/google_sql_scanner_test.go @@ -6,7 +6,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/remote/google" "github.com/snyk/driftctl/enumeration/remote/google/repository" @@ -90,7 +90,7 @@ func TestGoogleSQLDatabaseInstance(t *testing.T) { "SendAlert", "google_sql_database_instance", alerts.NewRemoteAccessDeniedAlert( - common2.RemoteGoogleTerraform, + common.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_sql_database_instance", @@ -111,7 +111,7 @@ func TestGoogleSQLDatabaseInstance(t *testing.T) { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} diff --git a/enumeration/remote/google_storage_scanner_test.go b/enumeration/remote/google_storage_scanner_test.go index 75027fb7c..ce5fe2386 100644 --- a/enumeration/remote/google_storage_scanner_test.go +++ b/enumeration/remote/google_storage_scanner_test.go @@ -7,7 +7,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" "github.com/snyk/driftctl/enumeration/remote/cache" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" google2 "github.com/snyk/driftctl/enumeration/remote/google" "github.com/snyk/driftctl/enumeration/remote/google/repository" @@ -76,7 +76,7 @@ func TestGoogleStorageBucket(t *testing.T) { "SendAlert", "google_storage_bucket", alerts.NewRemoteAccessDeniedAlert( - common2.RemoteGoogleTerraform, + common.RemoteGoogleTerraform, remoteerr.NewResourceListingError( status.Error(codes.PermissionDenied, "The caller does not have permission"), "google_storage_bucket", @@ -102,7 +102,7 @@ func TestGoogleStorageBucket(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} @@ -143,7 +143,7 @@ func TestGoogleStorageBucket(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) remoteLibrary.AddEnumerator(google2.NewGoogleStorageBucketEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resType, common2.NewGenericDetailsFetcher(resType, provider, deserializer)) + remoteLibrary.AddDetailsFetcher(resType, common.NewGenericDetailsFetcher(resType, provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -222,7 +222,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { "SendAlert", "google_storage_bucket_iam_member", alerts.NewRemoteAccessDeniedAlert( - common2.RemoteGoogleTerraform, + common.RemoteGoogleTerraform, remoteerr.NewResourceListingError( errors.New("googleapi: Error 403: driftctl-acc-circle@driftctl-qa-1.iam.gserviceaccount.com does not have storage.buckets.getIamPolicy access to the Google Cloud Storage bucket., forbidden"), "google_storage_bucket_iam_member", @@ -278,7 +278,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { scanOptions := ScannerOptions{Deep: true} providerLibrary := terraform3.NewProviderLibrary() - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} diff --git a/enumeration/remote/remote.go b/enumeration/remote/remote.go index eb2f38162..0025d8533 100644 --- a/enumeration/remote/remote.go +++ b/enumeration/remote/remote.go @@ -6,7 +6,7 @@ import ( "github.com/snyk/driftctl/enumeration/alerter" "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/azurerm" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" "github.com/snyk/driftctl/enumeration/remote/github" "github.com/snyk/driftctl/enumeration/remote/google" "github.com/snyk/driftctl/enumeration/resource" @@ -14,10 +14,10 @@ import ( ) var supportedRemotes = []string{ - common2.RemoteAWSTerraform, - common2.RemoteGithubTerraform, - common2.RemoteGoogleTerraform, - common2.RemoteAzureTerraform, + common.RemoteAWSTerraform, + common.RemoteGithubTerraform, + common.RemoteGoogleTerraform, + common.RemoteAzureTerraform, } func IsSupported(remote string) bool { @@ -31,19 +31,19 @@ func IsSupported(remote string) bool { func Activate(remote, version string, alerter *alerter.Alerter, providerLibrary *terraform.ProviderLibrary, - remoteLibrary *common2.RemoteLibrary, + remoteLibrary *common.RemoteLibrary, progress enumeration.ProgressCounter, resourceSchemaRepository *resource.SchemaRepository, factory resource.ResourceFactory, configDir string) error { switch remote { - case common2.RemoteAWSTerraform: + case common.RemoteAWSTerraform: return aws.Init(version, alerter, providerLibrary, remoteLibrary, progress, resourceSchemaRepository, factory, configDir) - case common2.RemoteGithubTerraform: + case common.RemoteGithubTerraform: return github.Init(version, alerter, providerLibrary, remoteLibrary, progress, resourceSchemaRepository, factory, configDir) - case common2.RemoteGoogleTerraform: + case common.RemoteGoogleTerraform: return google.Init(version, alerter, providerLibrary, remoteLibrary, progress, resourceSchemaRepository, factory, configDir) - case common2.RemoteAzureTerraform: + case common.RemoteAzureTerraform: return azurerm.Init(version, alerter, providerLibrary, remoteLibrary, progress, resourceSchemaRepository, factory, configDir) default: diff --git a/enumeration/remote/scanner_test.go b/enumeration/remote/scanner_test.go index 5e14f1da7..b99657ea7 100644 --- a/enumeration/remote/scanner_test.go +++ b/enumeration/remote/scanner_test.go @@ -5,7 +5,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/alerter" - common2 "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/remote/common" "github.com/snyk/driftctl/enumeration/resource" @@ -16,11 +16,11 @@ func TestScannerShouldIgnoreType(t *testing.T) { // Initialize mocks alerter := alerter.NewAlerter() - fakeEnumerator := &common2.MockEnumerator{} + fakeEnumerator := &common.MockEnumerator{} fakeEnumerator.On("SupportedType").Return(resource.ResourceType("FakeType")) fakeEnumerator.AssertNotCalled(t, "Enumerate") - remoteLibrary := common2.NewRemoteLibrary() + remoteLibrary := common.NewRemoteLibrary() remoteLibrary.AddEnumerator(fakeEnumerator) testFilter := &enumeration.MockFilter{} From 066aed978572f489ab05ae67dac0e22bcc616eaf Mon Sep 17 00:00:00 2001 From: Elie CHARRA Date: Wed, 6 Jul 2022 10:58:36 +0200 Subject: [PATCH 05/12] chore: fix mess with terraform2 imports --- enumeration/remote/azurerm/provider.go | 6 +-- .../remote/azurerm_privatedns_scanner_test.go | 34 +++++++-------- enumeration/remote/github/provider.go | 4 +- .../github_branch_protection_scanner_test.go | 6 +-- .../remote/github_membership_scanner_test.go | 24 +++++------ .../remote/github_repository_scanner_test.go | 24 +++++------ .../github_team_membership_scanner_test.go | 24 +++++------ .../remote/github_team_scanner_test.go | 28 ++++++------- enumeration/remote/google/provider.go | 6 +-- enumeration/remote/terraform/provider.go | 10 ++--- pkg/driftctl_test.go | 42 +++++++++---------- pkg/iac/supplier/supplier_test.go | 6 +-- 12 files changed, 107 insertions(+), 107 deletions(-) diff --git a/enumeration/remote/azurerm/provider.go b/enumeration/remote/azurerm/provider.go index f516fa49b..a22ff3d16 100644 --- a/enumeration/remote/azurerm/provider.go +++ b/enumeration/remote/azurerm/provider.go @@ -10,7 +10,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/azurerm/common" "github.com/snyk/driftctl/enumeration/remote/terraform" - terraform2 "github.com/snyk/driftctl/enumeration/terraform" + tf "github.com/snyk/driftctl/enumeration/terraform" ) type AzureTerraformProvider struct { @@ -26,10 +26,10 @@ func NewAzureTerraformProvider(version string, progress enumeration.ProgressCoun // Just pass your version and name p := &AzureTerraformProvider{ version: version, - name: terraform2.AZURE, + name: tf.AZURE, } // Use TerraformProviderInstaller to retrieve the provider if needed - installer, err := terraform2.NewProviderInstaller(terraform2.ProviderConfig{ + installer, err := tf.NewProviderInstaller(tf.ProviderConfig{ Key: p.name, Version: version, ConfigDir: configDir, diff --git a/enumeration/remote/azurerm_privatedns_scanner_test.go b/enumeration/remote/azurerm_privatedns_scanner_test.go index 67d755fab..b3125a65c 100644 --- a/enumeration/remote/azurerm_privatedns_scanner_test.go +++ b/enumeration/remote/azurerm_privatedns_scanner_test.go @@ -9,7 +9,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" - terraform2 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" @@ -90,7 +90,7 @@ func TestAzurermPrivateDNSZone(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform2.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -98,7 +98,7 @@ func TestAzurermPrivateDNSZone(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform2.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -244,7 +244,7 @@ func TestAzurermPrivateDNSARecord(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform2.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -252,7 +252,7 @@ func TestAzurermPrivateDNSARecord(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform2.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -399,7 +399,7 @@ func TestAzurermPrivateDNSAAAARecord(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform2.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -407,7 +407,7 @@ func TestAzurermPrivateDNSAAAARecord(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform2.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -542,7 +542,7 @@ func TestAzurermPrivateDNSCNAMERecord(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform2.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -550,7 +550,7 @@ func TestAzurermPrivateDNSCNAMERecord(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform2.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -696,7 +696,7 @@ func TestAzurermPrivateDNSPTRRecord(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform2.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -704,7 +704,7 @@ func TestAzurermPrivateDNSPTRRecord(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform2.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -851,7 +851,7 @@ func TestAzurermPrivateDNSMXRecord(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform2.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -859,7 +859,7 @@ func TestAzurermPrivateDNSMXRecord(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform2.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -1005,7 +1005,7 @@ func TestAzurermPrivateDNSSRVRecord(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform2.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1013,7 +1013,7 @@ func TestAzurermPrivateDNSSRVRecord(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform2.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -1159,7 +1159,7 @@ func TestAzurermPrivateDNSTXTRecord(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform2.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1167,7 +1167,7 @@ func TestAzurermPrivateDNSTXTRecord(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform2.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks diff --git a/enumeration/remote/github/provider.go b/enumeration/remote/github/provider.go index b2b595ad6..c3dc4bf39 100644 --- a/enumeration/remote/github/provider.go +++ b/enumeration/remote/github/provider.go @@ -5,7 +5,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/terraform" - terraform2 "github.com/snyk/driftctl/enumeration/terraform" + tf "github.com/snyk/driftctl/enumeration/terraform" ) type GithubTerraformProvider struct { @@ -28,7 +28,7 @@ func NewGithubTerraformProvider(version string, progress enumeration.ProgressCou version: version, name: "github", } - installer, err := terraform2.NewProviderInstaller(terraform2.ProviderConfig{ + installer, err := tf.NewProviderInstaller(tf.ProviderConfig{ Key: p.name, Version: version, ConfigDir: configDir, diff --git a/enumeration/remote/github_branch_protection_scanner_test.go b/enumeration/remote/github_branch_protection_scanner_test.go index ae97cd252..71f9b3806 100644 --- a/enumeration/remote/github_branch_protection_scanner_test.go +++ b/enumeration/remote/github_branch_protection_scanner_test.go @@ -9,7 +9,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" github2 "github.com/snyk/driftctl/enumeration/remote/github" - terraform2 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform" "github.com/pkg/errors" githubres "github.com/snyk/driftctl/enumeration/resource/github" @@ -70,7 +70,7 @@ func TestScanGithubBranchProtection(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("github", "4.4.0") githubres.InitResourcesMetadata(schemaRepository) - factory := terraform2.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -79,7 +79,7 @@ func TestScanGithubBranchProtection(t *testing.T) { scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform2.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks diff --git a/enumeration/remote/github_membership_scanner_test.go b/enumeration/remote/github_membership_scanner_test.go index cf9e399d1..7cfcb5239 100644 --- a/enumeration/remote/github_membership_scanner_test.go +++ b/enumeration/remote/github_membership_scanner_test.go @@ -9,8 +9,8 @@ import ( "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" - github2 "github.com/snyk/driftctl/enumeration/remote/github" - terraform2 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/remote/github" + "github.com/snyk/driftctl/enumeration/terraform" githubres "github.com/snyk/driftctl/enumeration/resource/github" "github.com/snyk/driftctl/mocks" @@ -30,13 +30,13 @@ func TestScanGithubMembership(t *testing.T) { cases := []struct { test string dirName string - mocks func(*github2.MockGithubRepository, *mocks.AlerterInterface) + mocks func(*github.MockGithubRepository, *mocks.AlerterInterface) err error }{ { test: "no members", dirName: "github_membership_empty", - mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListMembership").Return([]string{}, nil) }, err: nil, @@ -44,7 +44,7 @@ func TestScanGithubMembership(t *testing.T) { { test: "Multiple membership with admin and member roles", dirName: "github_membership_multiple", - mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListMembership").Return([]string{ "driftctl-test:driftctl-acceptance-tester", "driftctl-test:eliecharra", @@ -55,7 +55,7 @@ func TestScanGithubMembership(t *testing.T) { { test: "cannot list membership", dirName: "github_membership_empty", - mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListMembership").Return(nil, errors.New("Your token has not been granted the required scopes to execute this query.")) alerter.On("SendAlert", githubres.GithubMembershipResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), githubres.GithubMembershipResourceType, githubres.GithubMembershipResourceType), alerts.EnumerationPhase)).Return() @@ -66,7 +66,7 @@ func TestScanGithubMembership(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("github", "4.4.0") githubres.InitResourcesMetadata(schemaRepository) - factory := terraform2.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -75,15 +75,15 @@ func TestScanGithubMembership(t *testing.T) { scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform2.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - mockedRepo := github2.MockGithubRepository{} + mockedRepo := github.MockGithubRepository{} c.mocks(&mockedRepo, alerter) - var repo github2.GithubRepository = &mockedRepo + var repo github.GithubRepository = &mockedRepo realProvider, err := tftest.InitTestGithubProvider(providerLibrary, "4.4.0") if err != nil { @@ -98,10 +98,10 @@ func TestScanGithubMembership(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = github2.NewGithubRepository(realProvider.GetConfig(), cache.New(0)) + repo = github.NewGithubRepository(realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(github2.NewGithubMembershipEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(github.NewGithubMembershipEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(githubres.GithubMembershipResourceType, common.NewGenericDetailsFetcher(githubres.GithubMembershipResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} diff --git a/enumeration/remote/github_repository_scanner_test.go b/enumeration/remote/github_repository_scanner_test.go index 0369813ac..ad93d598b 100644 --- a/enumeration/remote/github_repository_scanner_test.go +++ b/enumeration/remote/github_repository_scanner_test.go @@ -9,8 +9,8 @@ import ( "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" - github2 "github.com/snyk/driftctl/enumeration/remote/github" - terraform2 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/remote/github" + "github.com/snyk/driftctl/enumeration/terraform" githubres "github.com/snyk/driftctl/enumeration/resource/github" "github.com/snyk/driftctl/mocks" @@ -30,13 +30,13 @@ func TestScanGithubRepository(t *testing.T) { tests := []struct { test string dirName string - mocks func(*github2.MockGithubRepository, *mocks.AlerterInterface) + mocks func(*github.MockGithubRepository, *mocks.AlerterInterface) err error }{ { test: "no github repos", dirName: "github_repository_empty", - mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListRepositories").Return([]string{}, nil) }, err: nil, @@ -44,7 +44,7 @@ func TestScanGithubRepository(t *testing.T) { { test: "Multiple github repos Table", dirName: "github_repository_multiple", - mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListRepositories").Return([]string{ "driftctl", "driftctl-demos", @@ -55,7 +55,7 @@ func TestScanGithubRepository(t *testing.T) { { test: "cannot list repositories", dirName: "github_repository_empty", - mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListRepositories").Return(nil, errors.New("Your token has not been granted the required scopes to execute this query.")) alerter.On("SendAlert", githubres.GithubRepositoryResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), githubres.GithubRepositoryResourceType, githubres.GithubRepositoryResourceType), alerts.EnumerationPhase)).Return() @@ -66,7 +66,7 @@ func TestScanGithubRepository(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("github", "4.4.0") githubres.InitResourcesMetadata(schemaRepository) - factory := terraform2.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -75,15 +75,15 @@ func TestScanGithubRepository(t *testing.T) { scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform2.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - mockedRepo := github2.MockGithubRepository{} + mockedRepo := github.MockGithubRepository{} c.mocks(&mockedRepo, alerter) - var repo github2.GithubRepository = &mockedRepo + var repo github.GithubRepository = &mockedRepo realProvider, err := tftest.InitTestGithubProvider(providerLibrary, "4.4.0") if err != nil { @@ -98,10 +98,10 @@ func TestScanGithubRepository(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = github2.NewGithubRepository(realProvider.GetConfig(), cache.New(0)) + repo = github.NewGithubRepository(realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(github2.NewGithubRepositoryEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(github.NewGithubRepositoryEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(githubres.GithubRepositoryResourceType, common.NewGenericDetailsFetcher(githubres.GithubRepositoryResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} diff --git a/enumeration/remote/github_team_membership_scanner_test.go b/enumeration/remote/github_team_membership_scanner_test.go index 9ae59036a..a3cc733eb 100644 --- a/enumeration/remote/github_team_membership_scanner_test.go +++ b/enumeration/remote/github_team_membership_scanner_test.go @@ -9,8 +9,8 @@ import ( "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" - github2 "github.com/snyk/driftctl/enumeration/remote/github" - terraform2 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/remote/github" + "github.com/snyk/driftctl/enumeration/terraform" githubres "github.com/snyk/driftctl/enumeration/resource/github" "github.com/snyk/driftctl/mocks" @@ -30,13 +30,13 @@ func TestScanGithubTeamMembership(t *testing.T) { cases := []struct { test string dirName string - mocks func(*github2.MockGithubRepository, *mocks.AlerterInterface) + mocks func(*github.MockGithubRepository, *mocks.AlerterInterface) err error }{ { test: "no github team memberships", dirName: "github_team_membership_empty", - mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListTeamMemberships").Return([]string{}, nil) }, err: nil, @@ -44,7 +44,7 @@ func TestScanGithubTeamMembership(t *testing.T) { { test: "multiple github team memberships", dirName: "github_team_membership_multiple", - mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListTeamMemberships").Return([]string{ "4570529:driftctl-acceptance-tester", "4570529:wbeuil", @@ -55,7 +55,7 @@ func TestScanGithubTeamMembership(t *testing.T) { { test: "cannot list team membership", dirName: "github_team_membership_empty", - mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListTeamMemberships").Return(nil, errors.New("Your token has not been granted the required scopes to execute this query.")) alerter.On("SendAlert", githubres.GithubTeamMembershipResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), githubres.GithubTeamMembershipResourceType, githubres.GithubTeamMembershipResourceType), alerts.EnumerationPhase)).Return() @@ -66,7 +66,7 @@ func TestScanGithubTeamMembership(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("github", "4.4.0") githubres.InitResourcesMetadata(schemaRepository) - factory := terraform2.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -75,15 +75,15 @@ func TestScanGithubTeamMembership(t *testing.T) { scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform2.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - mockedRepo := github2.MockGithubRepository{} + mockedRepo := github.MockGithubRepository{} c.mocks(&mockedRepo, alerter) - var repo github2.GithubRepository = &mockedRepo + var repo github.GithubRepository = &mockedRepo realProvider, err := tftest.InitTestGithubProvider(providerLibrary, "4.4.0") if err != nil { @@ -98,10 +98,10 @@ func TestScanGithubTeamMembership(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = github2.NewGithubRepository(realProvider.GetConfig(), cache.New(0)) + repo = github.NewGithubRepository(realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(github2.NewGithubTeamMembershipEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(github.NewGithubTeamMembershipEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(githubres.GithubTeamMembershipResourceType, common.NewGenericDetailsFetcher(githubres.GithubTeamMembershipResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} diff --git a/enumeration/remote/github_team_scanner_test.go b/enumeration/remote/github_team_scanner_test.go index 3619f305a..958e6c890 100644 --- a/enumeration/remote/github_team_scanner_test.go +++ b/enumeration/remote/github_team_scanner_test.go @@ -9,8 +9,8 @@ import ( "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" - github2 "github.com/snyk/driftctl/enumeration/remote/github" - terraform2 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/remote/github" + "github.com/snyk/driftctl/enumeration/terraform" githubres "github.com/snyk/driftctl/enumeration/resource/github" "github.com/snyk/driftctl/mocks" @@ -30,22 +30,22 @@ func TestScanGithubTeam(t *testing.T) { tests := []struct { test string dirName string - mocks func(*github2.MockGithubRepository, *mocks.AlerterInterface) + mocks func(*github.MockGithubRepository, *mocks.AlerterInterface) err error }{ { test: "no github teams", dirName: "github_teams_empty", - mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { - client.On("ListTeams").Return([]github2.Team{}, nil) + mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { + client.On("ListTeams").Return([]github.Team{}, nil) }, err: nil, }, { test: "Multiple github teams with parent", dirName: "github_teams_multiple", - mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { - client.On("ListTeams").Return([]github2.Team{ + mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { + client.On("ListTeams").Return([]github.Team{ {DatabaseId: 4556811}, // github_team.team1 {DatabaseId: 4556812}, // github_team.team2 {DatabaseId: 4556814}, // github_team.with_parent @@ -56,7 +56,7 @@ func TestScanGithubTeam(t *testing.T) { { test: "cannot list teams", dirName: "github_teams_empty", - mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListTeams").Return(nil, errors.New("Your token has not been granted the required scopes to execute this query.")) alerter.On("SendAlert", githubres.GithubTeamResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), githubres.GithubTeamResourceType, githubres.GithubTeamResourceType), alerts.EnumerationPhase)).Return() @@ -67,7 +67,7 @@ func TestScanGithubTeam(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("github", "4.4.0") githubres.InitResourcesMetadata(schemaRepository) - factory := terraform2.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -76,15 +76,15 @@ func TestScanGithubTeam(t *testing.T) { scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform2.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks alerter := &mocks.AlerterInterface{} - mockedRepo := github2.MockGithubRepository{} + mockedRepo := github.MockGithubRepository{} c.mocks(&mockedRepo, alerter) - var repo github2.GithubRepository = &mockedRepo + var repo github.GithubRepository = &mockedRepo realProvider, err := tftest.InitTestGithubProvider(providerLibrary, "4.4.0") if err != nil { @@ -99,10 +99,10 @@ func TestScanGithubTeam(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = github2.NewGithubRepository(realProvider.GetConfig(), cache.New(0)) + repo = github.NewGithubRepository(realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(github2.NewGithubTeamEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(github.NewGithubTeamEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(githubres.GithubTeamResourceType, common.NewGenericDetailsFetcher(githubres.GithubTeamResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} diff --git a/enumeration/remote/google/provider.go b/enumeration/remote/google/provider.go index 276634b24..8b92ece99 100644 --- a/enumeration/remote/google/provider.go +++ b/enumeration/remote/google/provider.go @@ -8,7 +8,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/google/config" "github.com/snyk/driftctl/enumeration/remote/terraform" - terraform2 "github.com/snyk/driftctl/enumeration/terraform" + tf "github.com/snyk/driftctl/enumeration/terraform" asset "cloud.google.com/go/asset/apiv1" ) @@ -25,9 +25,9 @@ func NewGCPTerraformProvider(version string, progress enumeration.ProgressCounte } p := &GCPTerraformProvider{ version: version, - name: terraform2.GOOGLE, + name: tf.GOOGLE, } - installer, err := terraform2.NewProviderInstaller(terraform2.ProviderConfig{ + installer, err := tf.NewProviderInstaller(tf.ProviderConfig{ Key: p.name, Version: version, ConfigDir: configDir, diff --git a/enumeration/remote/terraform/provider.go b/enumeration/remote/terraform/provider.go index 28c913f75..7aee61592 100644 --- a/enumeration/remote/terraform/provider.go +++ b/enumeration/remote/terraform/provider.go @@ -17,7 +17,7 @@ import ( "github.com/sirupsen/logrus" progress2 "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/parallel" - terraform2 "github.com/snyk/driftctl/enumeration/terraform" + tf "github.com/snyk/driftctl/enumeration/terraform" "github.com/zclconf/go-cty/cty" "github.com/zclconf/go-cty/cty/gocty" ) @@ -36,7 +36,7 @@ type TerraformProviderConfig struct { type TerraformProvider struct { lock sync.Mutex - providerInstaller *terraform2.ProviderInstaller + providerInstaller *tf.ProviderInstaller grpcProviders map[string]*plugin.GRPCProvider schemas map[string]providers.Schema Config TerraformProviderConfig @@ -44,7 +44,7 @@ type TerraformProvider struct { progress progress2.ProgressCounter } -func NewTerraformProvider(installer *terraform2.ProviderInstaller, config TerraformProviderConfig, progress progress2.ProgressCounter) (*TerraformProvider, error) { +func NewTerraformProvider(installer *tf.ProviderInstaller, config TerraformProviderConfig, progress progress2.ProgressCounter) (*TerraformProvider, error) { p := TerraformProvider{ providerInstaller: installer, runner: parallel.NewParallelRunner(context.TODO(), 10), @@ -97,7 +97,7 @@ func (p *TerraformProvider) configure(alias string) error { logrus.WithFields(logrus.Fields{ "alias": alias, }).Debug("Starting gRPC client") - GRPCProvider, err := terraform2.NewGRPCProvider(discovery.PluginMeta{ + GRPCProvider, err := tf.NewGRPCProvider(discovery.PluginMeta{ Path: providerPath, }) @@ -142,7 +142,7 @@ func (p *TerraformProvider) configure(alias string) error { return nil } -func (p *TerraformProvider) ReadResource(args terraform2.ReadResourceArgs) (*cty.Value, error) { +func (p *TerraformProvider) ReadResource(args tf.ReadResourceArgs) (*cty.Value, error) { logrus.WithFields(logrus.Fields{ "id": args.ID, diff --git a/pkg/driftctl_test.go b/pkg/driftctl_test.go index 6a8576511..ce6d974a5 100644 --- a/pkg/driftctl_test.go +++ b/pkg/driftctl_test.go @@ -1,7 +1,7 @@ package pkg_test import ( - terraform2 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform" resource2 "github.com/snyk/driftctl/pkg/resource" "reflect" @@ -79,10 +79,10 @@ func runTest(t *testing.T, cases TestCases) { remoteSupplier := &resource.MockSupplier{} remoteSupplier.On("Resources").Return(c.remoteResources, nil) - var resourceFactory resource.ResourceFactory = terraform2.NewTerraformResourceFactory(repo) + var resourceFactory resource.ResourceFactory = terraform.NewTerraformResourceFactory(repo) if c.mocks != nil { - resourceFactory = &terraform2.MockResourceFactory{} + resourceFactory = &terraform.MockResourceFactory{} c.mocks(resourceFactory, repo) } @@ -366,7 +366,7 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) { { name: "we should ignore default AWS IAM role when strict mode is disabled", mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { - factory.(*terraform2.MockResourceFactory).On( + factory.(*terraform.MockResourceFactory).On( "CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "role-test-1-policy-test-1", @@ -464,7 +464,7 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) { { name: "we should not ignore default AWS IAM role when strict mode is enabled", mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { - factory.(*terraform2.MockResourceFactory).On( + factory.(*terraform.MockResourceFactory).On( "CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "role-test-1-policy-test-1", @@ -562,7 +562,7 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) { { name: "we should not ignore default AWS IAM role when strict mode is enabled and a filter is specified", mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { - factory.(*terraform2.MockResourceFactory).On( + factory.(*terraform.MockResourceFactory).On( "CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "role-test-1-policy-test-1", @@ -793,7 +793,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, }, mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { - factory.(*terraform2.MockResourceFactory).On( + factory.(*terraform.MockResourceFactory).On( "CreateAbstractResource", aws.AwsS3BucketPolicyResourceType, "foo", @@ -890,7 +890,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, Sch: getSchema(repo, "aws_ebs_volume"), } - factory.(*terraform2.MockResourceFactory).On("CreateAbstractResource", "aws_ebs_volume", mock.Anything, mock.MatchedBy(func(input map[string]interface{}) bool { + factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_ebs_volume", mock.Anything, mock.MatchedBy(func(input map[string]interface{}) bool { return matchByAttributes(input, map[string]interface{}{ "id": "vol-018c5ae89895aca4c", "availability_zone": "us-east-1", @@ -909,7 +909,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, Sch: getSchema(repo, "aws_ebs_volume"), } - factory.(*terraform2.MockResourceFactory).On("CreateAbstractResource", "aws_ebs_volume", mock.Anything, mock.MatchedBy(func(input map[string]interface{}) bool { + factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_ebs_volume", mock.Anything, mock.MatchedBy(func(input map[string]interface{}) bool { return matchByAttributes(input, map[string]interface{}{ "id": "vol-02862d9b39045a3a4", "availability_zone": "us-east-1", @@ -995,7 +995,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, }, mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { - factory.(*terraform2.MockResourceFactory).On("CreateAbstractResource", "aws_route", "r-table1080289494", mock.MatchedBy(func(input map[string]interface{}) bool { + factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_route", "r-table1080289494", mock.MatchedBy(func(input map[string]interface{}) bool { return matchByAttributes(input, map[string]interface{}{ "destination_cidr_block": "0.0.0.0/0", "gateway_id": "igw-07b7844a8fd17a638", @@ -1014,7 +1014,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "state": "active", }, }, nil) - factory.(*terraform2.MockResourceFactory).On("CreateAbstractResource", "aws_route", "r-table2750132062", mock.MatchedBy(func(input map[string]interface{}) bool { + factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_route", "r-table2750132062", mock.MatchedBy(func(input map[string]interface{}) bool { return matchByAttributes(input, map[string]interface{}{ "destination_ipv6_cidr_block": "::/0", "gateway_id": "igw-07b7844a8fd17a638", @@ -1073,7 +1073,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, }, mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { - factory.(*terraform2.MockResourceFactory).On("CreateAbstractResource", "aws_sns_topic_policy", "foo", map[string]interface{}{ + factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_sns_topic_policy", "foo", map[string]interface{}{ "id": "foo", "arn": "arn", "policy": "{\"policy\":\"bar\"}", @@ -1135,7 +1135,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, }, mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { - factory.(*terraform2.MockResourceFactory).On("CreateAbstractResource", "aws_sqs_queue_policy", "foo", map[string]interface{}{ + factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_sqs_queue_policy", "foo", map[string]interface{}{ "id": "foo", "queue_url": "foo", "policy": "{\"policy\":\"bar\"}", @@ -1364,7 +1364,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "prefix_list_ids": []interface{}{}, }, } - factory.(*terraform2.MockResourceFactory).On("CreateAbstractResource", "aws_security_group_rule", rule1.Id, + factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_security_group_rule", rule1.Id, mock.MatchedBy(func(input map[string]interface{}) bool { return matchByAttributes(input, map[string]interface{}{ "id": "sgrule-1707973622", @@ -1396,7 +1396,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "prefix_list_ids": []interface{}{}, }, } - factory.(*terraform2.MockResourceFactory).On("CreateAbstractResource", "aws_security_group_rule", rule2.Id, + factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_security_group_rule", rule2.Id, mock.MatchedBy(func(input map[string]interface{}) bool { return matchByAttributes(input, map[string]interface{}{ "id": "sgrule-2821752134", @@ -1428,7 +1428,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "prefix_list_ids": []interface{}{}, }, } - factory.(*terraform2.MockResourceFactory).On("CreateAbstractResource", "aws_security_group_rule", rule3.Id, + factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_security_group_rule", rule3.Id, mock.MatchedBy(func(input map[string]interface{}) bool { return matchByAttributes(input, map[string]interface{}{ "id": "sgrule-2165103420", @@ -1460,7 +1460,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "prefix_list_ids": []interface{}{}, }, } - factory.(*terraform2.MockResourceFactory).On("CreateAbstractResource", "aws_security_group_rule", rule4.Id, + factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_security_group_rule", rule4.Id, mock.MatchedBy(func(input map[string]interface{}) bool { return matchByAttributes(input, map[string]interface{}{ "id": "sgrule-2582518759", @@ -1556,7 +1556,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, }, mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { - factory.(*terraform2.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "iduser1", map[string]interface{}{ + factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "iduser1", map[string]interface{}{ "id": "iduser1", "policy_arn": "policy_arn1", "users": []interface{}{"user1"}, @@ -1573,7 +1573,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "roles": []interface{}{}, }, }, nil) - factory.(*terraform2.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "user1-policy_arn1", map[string]interface{}{ + factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "user1-policy_arn1", map[string]interface{}{ "policy_arn": "policy_arn1", "users": []interface{}{"user1"}, }).Twice().Return(&resource.Resource{ @@ -1584,7 +1584,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "users": []interface{}{"user1"}, }, }, nil) - factory.(*terraform2.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "idrole1", map[string]interface{}{ + factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "idrole1", map[string]interface{}{ "id": "idrole1", "policy_arn": "policy_arn1", "users": []interface{}{}, @@ -1601,7 +1601,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "roles": []interface{}{"role1"}, }, }, nil) - factory.(*terraform2.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "role1-policy_arn1", map[string]interface{}{ + factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "role1-policy_arn1", map[string]interface{}{ "policy_arn": "policy_arn1", "roles": []interface{}{"role1"}, }).Twice().Return(&resource.Resource{ diff --git a/pkg/iac/supplier/supplier_test.go b/pkg/iac/supplier/supplier_test.go index 615e77b1b..da8396c6c 100644 --- a/pkg/iac/supplier/supplier_test.go +++ b/pkg/iac/supplier/supplier_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/snyk/driftctl/enumeration/alerter" - terraform2 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform" "github.com/snyk/driftctl/pkg/filter" "github.com/snyk/driftctl/pkg/iac/config" @@ -91,12 +91,12 @@ func TestGetIACSupplier(t *testing.T) { progress.On("Start").Return().Times(1) repo := resource.InitFakeSchemaRepository("aws", "3.19.0") - factory := terraform2.NewTerraformResourceFactory(repo) + factory := terraform.NewTerraformResourceFactory(repo) alerter := alerter.NewAlerter() testFilter := &filter.MockFilter{} - _, err := GetIACSupplier(tt.args.config, terraform2.NewProviderLibrary(), tt.args.options, progress, alerter, factory, testFilter) + _, err := GetIACSupplier(tt.args.config, terraform.NewProviderLibrary(), tt.args.options, progress, alerter, factory, testFilter) if tt.wantErr != nil && err.Error() != tt.wantErr.Error() { t.Errorf("GetIACSupplier() error = %v, wantErr %v", err, tt.wantErr) From 26fd9aa21ea9d110a629f817ceaf0a41202a4f7a Mon Sep 17 00:00:00 2001 From: Elie CHARRA Date: Wed, 6 Jul 2022 16:36:32 +0200 Subject: [PATCH 06/12] chore: fix mess with aws2 imports --- .../remote/aws_api_gateway_scanner_test.go | 38 +++++++------- .../remote/aws_apigatewayv2_scanner_test.go | 26 +++++----- ...aws_applicationautoscaling_scanner_test.go | 8 +-- enumeration/remote/aws_ec2_scanner_test.go | 52 +++++++++---------- enumeration/remote/aws_ecr_scanner_test.go | 6 +-- enumeration/remote/aws_elbv2_scanner_test.go | 6 +-- enumeration/remote/aws_kms_scanner_test.go | 6 +-- enumeration/remote/aws_lambda_scanner_test.go | 6 +-- enumeration/remote/aws_rds_scanner_test.go | 8 +-- .../remote/aws_route53_scanner_test.go | 8 +-- enumeration/remote/aws_s3_scanner_test.go | 46 ++++++++-------- enumeration/remote/aws_sns_scanner_test.go | 12 ++--- enumeration/remote/aws_sqs_scanner_test.go | 8 +-- 13 files changed, 115 insertions(+), 115 deletions(-) diff --git a/enumeration/remote/aws_api_gateway_scanner_test.go b/enumeration/remote/aws_api_gateway_scanner_test.go index 0545f8946..bc6c1d5d4 100644 --- a/enumeration/remote/aws_api_gateway_scanner_test.go +++ b/enumeration/remote/aws_api_gateway_scanner_test.go @@ -8,7 +8,7 @@ import ( "github.com/pkg/errors" "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" - aws2 "github.com/snyk/driftctl/enumeration/remote/aws" + "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" @@ -86,7 +86,7 @@ func TestApiGatewayRestApi(t *testing.T) { var repo repository.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayRestApiEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayRestApiEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -163,7 +163,7 @@ func TestApiGatewayAccount(t *testing.T) { var repo repository.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayAccountEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayAccountEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -246,7 +246,7 @@ func TestApiGatewayApiKey(t *testing.T) { var repo repository.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayApiKeyEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayApiKeyEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -347,7 +347,7 @@ func TestApiGatewayAuthorizer(t *testing.T) { var repo repository.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayAuthorizerEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayAuthorizerEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -444,7 +444,7 @@ func TestApiGatewayStage(t *testing.T) { var repo repository.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayStageEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayStageEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -541,7 +541,7 @@ func TestApiGatewayResource(t *testing.T) { var repo repository.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayResourceEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayResourceEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -620,7 +620,7 @@ func TestApiGatewayDomainName(t *testing.T) { var repo repository.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayDomainNameEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayDomainNameEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -699,7 +699,7 @@ func TestApiGatewayVpcLink(t *testing.T) { var repo repository.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayVpcLinkEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayVpcLinkEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -796,7 +796,7 @@ func TestApiGatewayRequestValidator(t *testing.T) { var repo repository.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayRequestValidatorEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayRequestValidatorEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -882,7 +882,7 @@ func TestApiGatewayRestApiPolicy(t *testing.T) { var repo repository.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayRestApiPolicyEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayRestApiPolicyEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -979,7 +979,7 @@ func TestApiGatewayBasePathMapping(t *testing.T) { var repo repository.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayBasePathMappingEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayBasePathMappingEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1084,7 +1084,7 @@ func TestApiGatewayMethod(t *testing.T) { var repo repository.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayMethodEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayMethodEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1181,7 +1181,7 @@ func TestApiGatewayModel(t *testing.T) { var repo repository.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayModelEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayModelEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1290,7 +1290,7 @@ func TestApiGatewayMethodResponse(t *testing.T) { var repo repository.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayMethodResponseEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayMethodResponseEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1387,7 +1387,7 @@ func TestApiGatewayGatewayResponse(t *testing.T) { var repo repository.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayGatewayResponseEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayGatewayResponseEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1492,7 +1492,7 @@ func TestApiGatewayMethodSettings(t *testing.T) { var repo repository.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayMethodSettingsEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayMethodSettingsEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1597,7 +1597,7 @@ func TestApiGatewayIntegration(t *testing.T) { var repo repository.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayIntegrationEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayIntegrationEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1706,7 +1706,7 @@ func TestApiGatewayIntegrationResponse(t *testing.T) { var repo repository.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayIntegrationResponseEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayIntegrationResponseEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) diff --git a/enumeration/remote/aws_apigatewayv2_scanner_test.go b/enumeration/remote/aws_apigatewayv2_scanner_test.go index 2b87b96a9..dc86cede1 100644 --- a/enumeration/remote/aws_apigatewayv2_scanner_test.go +++ b/enumeration/remote/aws_apigatewayv2_scanner_test.go @@ -5,7 +5,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" - aws2 "github.com/snyk/driftctl/enumeration/remote/aws" + "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" @@ -83,7 +83,7 @@ func TestApiGatewayV2Api(t *testing.T) { var repo repository.ApiGatewayV2Repository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2ApiEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayV2ApiEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -172,7 +172,7 @@ func TestApiGatewayV2Route(t *testing.T) { var repo repository.ApiGatewayV2Repository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2RouteEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayV2RouteEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -281,7 +281,7 @@ func TestApiGatewayV2Deployment(t *testing.T) { var repo repository.ApiGatewayV2Repository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2DeploymentEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayV2DeploymentEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -360,7 +360,7 @@ func TestApiGatewayV2VpcLink(t *testing.T) { var repo repository.ApiGatewayV2Repository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2VpcLinkEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayV2VpcLinkEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -462,7 +462,7 @@ func TestApiGatewayV2Authorizer(t *testing.T) { var repo repository.ApiGatewayV2Repository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2AuthorizerEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayV2AuthorizerEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -570,7 +570,7 @@ func TestApiGatewayV2Integration(t *testing.T) { var repo repository.ApiGatewayV2Repository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2IntegrationEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayV2IntegrationEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -681,7 +681,7 @@ func TestApiGatewayV2Model(t *testing.T) { var repo repository.ApiGatewayV2Repository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2ModelEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayV2ModelEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -764,7 +764,7 @@ func TestApiGatewayV2Stage(t *testing.T) { var repo repository.ApiGatewayV2Repository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2StageEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayV2StageEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -885,7 +885,7 @@ func TestApiGatewayV2RouteResponse(t *testing.T) { var repo repository.ApiGatewayV2Repository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2RouteResponseEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayV2RouteResponseEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1009,7 +1009,7 @@ func TestApiGatewayV2Mapping(t *testing.T) { fakeRepo := &repository.MockApiGatewayV2Repository{} c.mocks(fakeRepoV1, fakeRepo, alerter) - remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2MappingEnumerator(fakeRepo, fakeRepoV1, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayV2MappingEnumerator(fakeRepo, fakeRepoV1, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1089,7 +1089,7 @@ func TestApiGatewayV2DomainName(t *testing.T) { var repo repository.ApiGatewayRepository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2DomainNameEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayV2DomainNameEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1210,7 +1210,7 @@ func TestApiGatewayV2IntegrationResponse(t *testing.T) { var repo repository.ApiGatewayV2Repository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2IntegrationResponseEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewApiGatewayV2IntegrationResponseEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) diff --git a/enumeration/remote/aws_applicationautoscaling_scanner_test.go b/enumeration/remote/aws_applicationautoscaling_scanner_test.go index 265139deb..3e896e741 100644 --- a/enumeration/remote/aws_applicationautoscaling_scanner_test.go +++ b/enumeration/remote/aws_applicationautoscaling_scanner_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/snyk/driftctl/enumeration" - aws2 "github.com/snyk/driftctl/enumeration/remote/aws" + "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" @@ -108,7 +108,7 @@ func TestAppAutoScalingTarget(t *testing.T) { repo = repository.NewAppAutoScalingRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewAppAutoscalingTargetEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewAppAutoscalingTargetEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsAppAutoscalingTargetResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsAppAutoscalingTargetResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -211,7 +211,7 @@ func TestAppAutoScalingPolicy(t *testing.T) { repo = repository.NewAppAutoScalingRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewAppAutoscalingPolicyEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewAppAutoscalingPolicyEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsAppAutoscalingPolicyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsAppAutoscalingPolicyResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -307,7 +307,7 @@ func TestAppAutoScalingScheduledAction(t *testing.T) { var repo repository.AppAutoScalingRepository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewAppAutoscalingScheduledActionEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewAppAutoscalingScheduledActionEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) diff --git a/enumeration/remote/aws_ec2_scanner_test.go b/enumeration/remote/aws_ec2_scanner_test.go index fbdd11fd8..bc495a04a 100644 --- a/enumeration/remote/aws_ec2_scanner_test.go +++ b/enumeration/remote/aws_ec2_scanner_test.go @@ -5,7 +5,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" - aws2 "github.com/snyk/driftctl/enumeration/remote/aws" + "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" @@ -107,7 +107,7 @@ func TestEC2EbsVolume(t *testing.T) { repo = repository.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewEC2EbsVolumeEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewEC2EbsVolumeEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsEbsVolumeResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEbsVolumeResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -204,7 +204,7 @@ func TestEC2EbsSnapshot(t *testing.T) { repo = repository.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewEC2EbsSnapshotEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewEC2EbsSnapshotEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsEbsSnapshotResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEbsSnapshotResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -303,7 +303,7 @@ func TestEC2Eip(t *testing.T) { repo = repository.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewEC2EipEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewEC2EipEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsEipResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEipResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -400,7 +400,7 @@ func TestEC2Ami(t *testing.T) { repo = repository.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewEC2AmiEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewEC2AmiEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsAmiResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsAmiResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -497,7 +497,7 @@ func TestEC2KeyPair(t *testing.T) { repo = repository.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewEC2KeyPairEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewEC2KeyPairEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsKeyPairResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsKeyPairResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -596,7 +596,7 @@ func TestEC2EipAssociation(t *testing.T) { repo = repository.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewEC2EipAssociationEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewEC2EipAssociationEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsEipAssociationResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEipAssociationResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -703,7 +703,7 @@ func TestEC2Instance(t *testing.T) { repo = repository.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewEC2InstanceEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewEC2InstanceEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsInstanceResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsInstanceResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -800,7 +800,7 @@ func TestEC2InternetGateway(t *testing.T) { repo = repository.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewEC2InternetGatewayEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewEC2InternetGatewayEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsInternetGatewayResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsInternetGatewayResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -914,7 +914,7 @@ func TestVPC(t *testing.T) { repo = repository.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewVPCEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewVPCEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsVpcResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsVpcResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -1025,7 +1025,7 @@ func TestDefaultVPC(t *testing.T) { repo = repository.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewDefaultVPCEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewDefaultVPCEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultVpcResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDefaultVpcResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -1191,7 +1191,7 @@ func TestEC2RouteTableAssociation(t *testing.T) { repo = repository.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewEC2RouteTableAssociationEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewEC2RouteTableAssociationEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsRouteTableAssociationResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsRouteTableAssociationResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -1311,7 +1311,7 @@ func TestEC2Subnet(t *testing.T) { repo = repository.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewEC2SubnetEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewEC2SubnetEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsSubnetResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSubnetResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -1431,7 +1431,7 @@ func TestEC2DefaultSubnet(t *testing.T) { repo = repository.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewEC2DefaultSubnetEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewEC2DefaultSubnetEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultSubnetResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDefaultSubnetResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -1538,7 +1538,7 @@ func TestEC2RouteTable(t *testing.T) { repo = repository.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewEC2RouteTableEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewEC2RouteTableEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsRouteTableResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsRouteTableResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -1645,7 +1645,7 @@ func TestEC2DefaultRouteTable(t *testing.T) { repo = repository.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewEC2DefaultRouteTableEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewEC2DefaultRouteTableEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultRouteTableResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDefaultRouteTableResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -1752,7 +1752,7 @@ func TestVpcSecurityGroup(t *testing.T) { repo = repository.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewVPCSecurityGroupEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewVPCSecurityGroupEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsSecurityGroupResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSecurityGroupResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -1859,7 +1859,7 @@ func TestVpcDefaultSecurityGroup(t *testing.T) { repo = repository.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewVPCDefaultSecurityGroupEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewVPCDefaultSecurityGroupEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultSecurityGroupResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDefaultSecurityGroupResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -1955,7 +1955,7 @@ func TestEC2NatGateway(t *testing.T) { repo = repository.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewEC2NatGatewayEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewEC2NatGatewayEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsNatGatewayResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsNatGatewayResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -2073,7 +2073,7 @@ func TestEC2NetworkACL(t *testing.T) { repo = repository.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewEC2NetworkACLEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewEC2NetworkACLEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsNetworkACLResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsNetworkACLResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -2222,7 +2222,7 @@ func TestEC2NetworkACLRule(t *testing.T) { provider.ShouldUpdate() } - remoteLibrary.AddEnumerator(aws2.NewEC2NetworkACLRuleEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewEC2NetworkACLRuleEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsNetworkACLRuleResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsNetworkACLRuleResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -2340,7 +2340,7 @@ func TestEC2DefaultNetworkACL(t *testing.T) { repo = repository.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewEC2DefaultNetworkACLEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewEC2DefaultNetworkACLEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultNetworkACLResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDefaultNetworkACLResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -2509,7 +2509,7 @@ func TestEC2Route(t *testing.T) { repo = repository.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewEC2RouteEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewEC2RouteEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsRouteResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsRouteResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -2700,7 +2700,7 @@ func TestVpcSecurityGroupRule(t *testing.T) { repo = repository.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewVPCSecurityGroupRuleEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewVPCSecurityGroupRuleEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsSecurityGroupRuleResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSecurityGroupRuleResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -2799,7 +2799,7 @@ func TestEC2LaunchTemplate(t *testing.T) { repo = repository.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewLaunchTemplateEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewLaunchTemplateEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsLaunchTemplateResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsLaunchTemplateResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -2887,7 +2887,7 @@ func TestEC2EbsEncryptionByDefault(t *testing.T) { repo = repository.NewEC2Repository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewEC2EbsEncryptionByDefaultEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewEC2EbsEncryptionByDefaultEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsEbsEncryptionByDefaultResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEbsEncryptionByDefaultResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} diff --git a/enumeration/remote/aws_ecr_scanner_test.go b/enumeration/remote/aws_ecr_scanner_test.go index 4cc44eb05..08f42dd1d 100644 --- a/enumeration/remote/aws_ecr_scanner_test.go +++ b/enumeration/remote/aws_ecr_scanner_test.go @@ -5,7 +5,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" - aws2 "github.com/snyk/driftctl/enumeration/remote/aws" + "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" @@ -109,7 +109,7 @@ func TestECRRepository(t *testing.T) { repo = repository.NewECRRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewECRRepositoryEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewECRRepositoryEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsEcrRepositoryResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEcrRepositoryResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -178,7 +178,7 @@ func TestECRRepositoryPolicy(t *testing.T) { var repo repository.ECRRepository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewECRRepositoryPolicyEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewECRRepositoryPolicyEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) diff --git a/enumeration/remote/aws_elbv2_scanner_test.go b/enumeration/remote/aws_elbv2_scanner_test.go index 954e645ae..c16e79ecc 100644 --- a/enumeration/remote/aws_elbv2_scanner_test.go +++ b/enumeration/remote/aws_elbv2_scanner_test.go @@ -6,7 +6,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" - aws2 "github.com/snyk/driftctl/enumeration/remote/aws" + "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" @@ -99,7 +99,7 @@ func TestELBV2_LoadBalancer(t *testing.T) { var repo repository.ELBV2Repository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewLoadBalancerEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewLoadBalancerEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -227,7 +227,7 @@ func TestELBV2_LoadBalancerListener(t *testing.T) { var repo repository.ELBV2Repository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewLoadBalancerListenerEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewLoadBalancerListenerEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) diff --git a/enumeration/remote/aws_kms_scanner_test.go b/enumeration/remote/aws_kms_scanner_test.go index 909be64dd..a935f1d29 100644 --- a/enumeration/remote/aws_kms_scanner_test.go +++ b/enumeration/remote/aws_kms_scanner_test.go @@ -5,7 +5,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" - aws2 "github.com/snyk/driftctl/enumeration/remote/aws" + "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" @@ -108,7 +108,7 @@ func TestKMSKey(t *testing.T) { repo = repository.NewKMSRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewKMSKeyEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewKMSKeyEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsKmsKeyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsKmsKeyResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -206,7 +206,7 @@ func TestKMSAlias(t *testing.T) { repo = repository.NewKMSRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewKMSAliasEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewKMSAliasEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsKmsAliasResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsKmsAliasResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} diff --git a/enumeration/remote/aws_lambda_scanner_test.go b/enumeration/remote/aws_lambda_scanner_test.go index 6f6bfea56..c6dd5c04c 100644 --- a/enumeration/remote/aws_lambda_scanner_test.go +++ b/enumeration/remote/aws_lambda_scanner_test.go @@ -5,7 +5,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" - aws2 "github.com/snyk/driftctl/enumeration/remote/aws" + "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" @@ -128,7 +128,7 @@ func TestScanLambdaFunction(t *testing.T) { repo = repository.NewLambdaRepository(session, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewLambdaFunctionEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewLambdaFunctionEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsLambdaFunctionResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsLambdaFunctionResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -244,7 +244,7 @@ func TestScanLambdaEventSourceMapping(t *testing.T) { repo = repository.NewLambdaRepository(session, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewLambdaEventSourceMappingEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewLambdaEventSourceMappingEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsLambdaEventSourceMappingResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsLambdaEventSourceMappingResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} diff --git a/enumeration/remote/aws_rds_scanner_test.go b/enumeration/remote/aws_rds_scanner_test.go index 278b547cb..131da7ded 100644 --- a/enumeration/remote/aws_rds_scanner_test.go +++ b/enumeration/remote/aws_rds_scanner_test.go @@ -5,7 +5,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" - aws2 "github.com/snyk/driftctl/enumeration/remote/aws" + "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" @@ -116,7 +116,7 @@ func TestRDSDBInstance(t *testing.T) { repo = repository.NewRDSRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewRDSDBInstanceEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewRDSDBInstanceEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsDbInstanceResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDbInstanceResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -213,7 +213,7 @@ func TestRDSDBSubnetGroup(t *testing.T) { repo = repository.NewRDSRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewRDSDBSubnetGroupEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewRDSDBSubnetGroupEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsDbSubnetGroupResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDbSubnetGroupResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -315,7 +315,7 @@ func TestRDSCluster(t *testing.T) { repo = repository.NewRDSRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewRDSClusterEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewRDSClusterEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsRDSClusterResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsRDSClusterResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} diff --git a/enumeration/remote/aws_route53_scanner_test.go b/enumeration/remote/aws_route53_scanner_test.go index 781801424..087a4a9be 100644 --- a/enumeration/remote/aws_route53_scanner_test.go +++ b/enumeration/remote/aws_route53_scanner_test.go @@ -3,7 +3,7 @@ package remote import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" - aws2 "github.com/snyk/driftctl/enumeration/remote/aws" + "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" @@ -111,7 +111,7 @@ func TestRoute53_HealthCheck(t *testing.T) { repo = repository.NewRoute53Repository(session, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewRoute53HealthCheckEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewRoute53HealthCheckEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsRoute53HealthCheckResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsRoute53HealthCheckResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -246,7 +246,7 @@ func TestRoute53_Zone(t *testing.T) { repo = repository.NewRoute53Repository(session, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewRoute53ZoneEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewRoute53ZoneEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsRoute53ZoneResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsRoute53ZoneResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -456,7 +456,7 @@ func TestRoute53_Record(t *testing.T) { repo = repository.NewRoute53Repository(session, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewRoute53RecordEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewRoute53RecordEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsRoute53RecordResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsRoute53RecordResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} diff --git a/enumeration/remote/aws_s3_scanner_test.go b/enumeration/remote/aws_s3_scanner_test.go index 295c2a41b..28cf65da8 100644 --- a/enumeration/remote/aws_s3_scanner_test.go +++ b/enumeration/remote/aws_s3_scanner_test.go @@ -5,15 +5,15 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" - aws2 "github.com/snyk/driftctl/enumeration/remote/aws" + "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/client" "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" tf "github.com/snyk/driftctl/enumeration/remote/terraform" - terraform3 "github.com/snyk/driftctl/enumeration/terraform" - + "github.com/snyk/driftctl/enumeration/terraform" + awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/session" @@ -91,7 +91,7 @@ func TestS3Bucket(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -103,7 +103,7 @@ func TestS3Bucket(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -129,7 +129,7 @@ func TestS3Bucket(t *testing.T) { repo = repository.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewS3BucketEnumerator(repo, factory, tf.TerraformProviderConfig{ + remoteLibrary.AddEnumerator(aws.NewS3BucketEnumerator(repo, factory, tf.TerraformProviderConfig{ Name: "test", DefaultAlias: "eu-west-3", }, alerter)) @@ -251,7 +251,7 @@ func TestS3BucketInventory(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -263,7 +263,7 @@ func TestS3BucketInventory(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -289,7 +289,7 @@ func TestS3BucketInventory(t *testing.T) { repo = repository.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewS3BucketInventoryEnumerator(repo, factory, tf.TerraformProviderConfig{ + remoteLibrary.AddEnumerator(aws.NewS3BucketInventoryEnumerator(repo, factory, tf.TerraformProviderConfig{ Name: "test", DefaultAlias: "eu-west-3", }, alerter)) @@ -437,7 +437,7 @@ func TestS3BucketNotification(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -449,7 +449,7 @@ func TestS3BucketNotification(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -475,7 +475,7 @@ func TestS3BucketNotification(t *testing.T) { repo = repository.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewS3BucketNotificationEnumerator(repo, factory, tf.TerraformProviderConfig{ + remoteLibrary.AddEnumerator(aws.NewS3BucketNotificationEnumerator(repo, factory, tf.TerraformProviderConfig{ Name: "test", DefaultAlias: "eu-west-3", }, alerter)) @@ -598,7 +598,7 @@ func TestS3BucketMetrics(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -610,7 +610,7 @@ func TestS3BucketMetrics(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -636,7 +636,7 @@ func TestS3BucketMetrics(t *testing.T) { repo = repository.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewS3BucketMetricsEnumerator(repo, factory, tf.TerraformProviderConfig{ + remoteLibrary.AddEnumerator(aws.NewS3BucketMetricsEnumerator(repo, factory, tf.TerraformProviderConfig{ Name: "test", DefaultAlias: "eu-west-3", }, alerter)) @@ -756,7 +756,7 @@ func TestS3BucketPolicy(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -768,7 +768,7 @@ func TestS3BucketPolicy(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -794,7 +794,7 @@ func TestS3BucketPolicy(t *testing.T) { repo = repository.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewS3BucketPolicyEnumerator(repo, factory, tf.TerraformProviderConfig{ + remoteLibrary.AddEnumerator(aws.NewS3BucketPolicyEnumerator(repo, factory, tf.TerraformProviderConfig{ Name: "test", DefaultAlias: "eu-west-3", }, alerter)) @@ -883,7 +883,7 @@ func TestS3BucketPublicAccessBlock(t *testing.T) { providerVersion := "3.19.0" schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -897,7 +897,7 @@ func TestS3BucketPublicAccessBlock(t *testing.T) { var repo repository.S3Repository = fakeRepo - remoteLibrary.AddEnumerator(aws2.NewS3BucketPublicAccessBlockEnumerator( + remoteLibrary.AddEnumerator(aws.NewS3BucketPublicAccessBlockEnumerator( repo, factory, tf.TerraformProviderConfig{DefaultAlias: "us-east-1"}, alerter, @@ -1023,7 +1023,7 @@ func TestS3BucketAnalytic(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1035,7 +1035,7 @@ func TestS3BucketAnalytic(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -1061,7 +1061,7 @@ func TestS3BucketAnalytic(t *testing.T) { repo = repository.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewS3BucketAnalyticEnumerator(repo, factory, tf.TerraformProviderConfig{ + remoteLibrary.AddEnumerator(aws.NewS3BucketAnalyticEnumerator(repo, factory, tf.TerraformProviderConfig{ Name: "test", DefaultAlias: "eu-west-3", }, alerter)) diff --git a/enumeration/remote/aws_sns_scanner_test.go b/enumeration/remote/aws_sns_scanner_test.go index c842f1291..1cbe757ee 100644 --- a/enumeration/remote/aws_sns_scanner_test.go +++ b/enumeration/remote/aws_sns_scanner_test.go @@ -5,7 +5,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" - aws2 "github.com/snyk/driftctl/enumeration/remote/aws" + "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" @@ -113,7 +113,7 @@ func TestScanSNSTopic(t *testing.T) { repo = repository.NewSNSRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewSNSTopicEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewSNSTopicEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsSnsTopicResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSnsTopicResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -213,7 +213,7 @@ func TestSNSTopicPolicyScan(t *testing.T) { repo = repository.NewSNSRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewSNSTopicPolicyEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewSNSTopicPolicyEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsSnsTopicPolicyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSnsTopicPolicyResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -270,9 +270,9 @@ func TestSNSTopicSubscriptionScan(t *testing.T) { {SubscriptionArn: awssdk.String("arn:aws:sns:us-east-1:526954929923:user-updates-topic:b6e66147-2b31-4486-8d4b-2a2272264c8e")}, }, nil) - alerter.On("SendAlert", "aws_sns_topic_subscription.PendingConfirmation", aws2.NewWrongArnTopicAlert("PendingConfirmation", awssdk.String("TEST"))).Return() + alerter.On("SendAlert", "aws_sns_topic_subscription.PendingConfirmation", aws.NewWrongArnTopicAlert("PendingConfirmation", awssdk.String("TEST"))).Return() - alerter.On("SendAlert", "aws_sns_topic_subscription.Incorrect", aws2.NewWrongArnTopicAlert("Incorrect", awssdk.String("INCORRECT"))).Return() + alerter.On("SendAlert", "aws_sns_topic_subscription.Incorrect", aws.NewWrongArnTopicAlert("Incorrect", awssdk.String("INCORRECT"))).Return() }, err: nil, }, @@ -330,7 +330,7 @@ func TestSNSTopicSubscriptionScan(t *testing.T) { repo = repository.NewSNSRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewSNSTopicSubscriptionEnumerator(repo, factory, alerter)) + remoteLibrary.AddEnumerator(aws.NewSNSTopicSubscriptionEnumerator(repo, factory, alerter)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsSnsTopicSubscriptionResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSnsTopicSubscriptionResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} diff --git a/enumeration/remote/aws_sqs_scanner_test.go b/enumeration/remote/aws_sqs_scanner_test.go index b7ad002f9..10359cf18 100644 --- a/enumeration/remote/aws_sqs_scanner_test.go +++ b/enumeration/remote/aws_sqs_scanner_test.go @@ -5,7 +5,7 @@ import ( "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" - aws2 "github.com/snyk/driftctl/enumeration/remote/aws" + "github.com/snyk/driftctl/enumeration/remote/aws" "github.com/snyk/driftctl/enumeration/remote/aws/repository" "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" @@ -108,8 +108,8 @@ func TestSQSQueue(t *testing.T) { repo = repository.NewSQSRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewSQSQueueEnumerator(repo, factory)) - remoteLibrary.AddDetailsFetcher(resourceaws.AwsSqsQueueResourceType, aws2.NewSQSQueueDetailsFetcher(provider, deserializer)) + remoteLibrary.AddEnumerator(aws.NewSQSQueueEnumerator(repo, factory)) + remoteLibrary.AddDetailsFetcher(resourceaws.AwsSqsQueueResourceType, aws.NewSQSQueueDetailsFetcher(provider, deserializer)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -235,7 +235,7 @@ func TestSQSQueuePolicy(t *testing.T) { repo = repository.NewSQSRepository(sess, cache.New(0)) } - remoteLibrary.AddEnumerator(aws2.NewSQSQueuePolicyEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(aws.NewSQSQueuePolicyEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsSqsQueuePolicyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSqsQueuePolicyResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} From 81f2efb96b1e3cad4132c31030519b3877acc465 Mon Sep 17 00:00:00 2001 From: Elie CHARRA Date: Wed, 6 Jul 2022 16:38:03 +0200 Subject: [PATCH 07/12] chore: fix mess with terraform3 imports --- ...aws_applicationautoscaling_scanner_test.go | 12 +-- .../remote/aws_cloudformation_scanner_test.go | 6 +- .../remote/aws_cloudfront_scanner_test.go | 6 +- .../remote/aws_dynamodb_scanner_test.go | 6 +- enumeration/remote/aws_ec2_scanner_test.go | 102 +++++++++--------- enumeration/remote/aws_ecr_scanner_test.go | 8 +- enumeration/remote/aws_iam_scanner_test.go | 38 +++---- enumeration/remote/aws_kms_scanner_test.go | 10 +- enumeration/remote/aws_lambda_scanner_test.go | 10 +- enumeration/remote/aws_rds_scanner_test.go | 14 +-- .../remote/aws_route53_scanner_test.go | 14 +-- enumeration/remote/aws_s3_scanner_test.go | 2 +- enumeration/remote/aws_sns_scanner_test.go | 14 +-- enumeration/remote/aws_sqs_scanner_test.go | 10 +- .../remote/azurerm_compute_scanner_test.go | 8 +- .../remote/azurerm_network_scanner_test.go | 24 ++--- .../remote/google_bigquery_scanner_test.go | 10 +- .../remote/google_bigtable_scanner_test.go | 10 +- .../google_cloudfunctions_scanner_test.go | 6 +- .../remote/google_cloudrun_scanner_test.go | 6 +- .../remote/google_compute_scanner_test.go | 72 ++++++------- .../remote/google_network_scanner_test.go | 6 +- .../remote/google_project_scanner_test.go | 6 +- enumeration/remote/google_sql_scanner_test.go | 6 +- .../remote/google_storage_scanner_test.go | 10 +- 25 files changed, 208 insertions(+), 208 deletions(-) diff --git a/enumeration/remote/aws_applicationautoscaling_scanner_test.go b/enumeration/remote/aws_applicationautoscaling_scanner_test.go index 3e896e741..8fea7dfe8 100644 --- a/enumeration/remote/aws_applicationautoscaling_scanner_test.go +++ b/enumeration/remote/aws_applicationautoscaling_scanner_test.go @@ -9,7 +9,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" remoteerror "github.com/snyk/driftctl/enumeration/remote/error" - terraform3 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform" awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" @@ -69,7 +69,7 @@ func TestAppAutoScalingTarget(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -81,7 +81,7 @@ func TestAppAutoScalingTarget(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -172,7 +172,7 @@ func TestAppAutoScalingPolicy(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -184,7 +184,7 @@ func TestAppAutoScalingPolicy(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -293,7 +293,7 @@ func TestAppAutoScalingScheduledAction(t *testing.T) { providerVersion := "3.19.0" schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range tests { t.Run(c.test, func(tt *testing.T) { diff --git a/enumeration/remote/aws_cloudformation_scanner_test.go b/enumeration/remote/aws_cloudformation_scanner_test.go index 778fd7dc0..4fd7ba82c 100644 --- a/enumeration/remote/aws_cloudformation_scanner_test.go +++ b/enumeration/remote/aws_cloudformation_scanner_test.go @@ -11,7 +11,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" - terraform3 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform" awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" @@ -68,7 +68,7 @@ func TestCloudformationStack(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -80,7 +80,7 @@ func TestCloudformationStack(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks diff --git a/enumeration/remote/aws_cloudfront_scanner_test.go b/enumeration/remote/aws_cloudfront_scanner_test.go index 81c9549c3..84a2731b4 100644 --- a/enumeration/remote/aws_cloudfront_scanner_test.go +++ b/enumeration/remote/aws_cloudfront_scanner_test.go @@ -10,7 +10,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" - terraform3 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform" awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" @@ -67,7 +67,7 @@ func TestCloudfrontDistribution(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -79,7 +79,7 @@ func TestCloudfrontDistribution(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks diff --git a/enumeration/remote/aws_dynamodb_scanner_test.go b/enumeration/remote/aws_dynamodb_scanner_test.go index 3a19dec2b..454c1fbb9 100644 --- a/enumeration/remote/aws_dynamodb_scanner_test.go +++ b/enumeration/remote/aws_dynamodb_scanner_test.go @@ -11,7 +11,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" - terraform3 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform" awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" @@ -69,7 +69,7 @@ func TestDynamoDBTable(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -81,7 +81,7 @@ func TestDynamoDBTable(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks diff --git a/enumeration/remote/aws_ec2_scanner_test.go b/enumeration/remote/aws_ec2_scanner_test.go index bc495a04a..426d09514 100644 --- a/enumeration/remote/aws_ec2_scanner_test.go +++ b/enumeration/remote/aws_ec2_scanner_test.go @@ -10,7 +10,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" - terraform3 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform" awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" @@ -68,7 +68,7 @@ func TestEC2EbsVolume(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -80,7 +80,7 @@ func TestEC2EbsVolume(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -165,7 +165,7 @@ func TestEC2EbsSnapshot(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -177,7 +177,7 @@ func TestEC2EbsSnapshot(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -264,7 +264,7 @@ func TestEC2Eip(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -276,7 +276,7 @@ func TestEC2Eip(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -361,7 +361,7 @@ func TestEC2Ami(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -373,7 +373,7 @@ func TestEC2Ami(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -458,7 +458,7 @@ func TestEC2KeyPair(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -470,7 +470,7 @@ func TestEC2KeyPair(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -557,7 +557,7 @@ func TestEC2EipAssociation(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -569,7 +569,7 @@ func TestEC2EipAssociation(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -664,7 +664,7 @@ func TestEC2Instance(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -676,7 +676,7 @@ func TestEC2Instance(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -761,7 +761,7 @@ func TestEC2InternetGateway(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -773,7 +773,7 @@ func TestEC2InternetGateway(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -875,7 +875,7 @@ func TestVPC(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -887,7 +887,7 @@ func TestVPC(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -986,7 +986,7 @@ func TestDefaultVPC(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -998,7 +998,7 @@ func TestDefaultVPC(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -1152,7 +1152,7 @@ func TestEC2RouteTableAssociation(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1164,7 +1164,7 @@ func TestEC2RouteTableAssociation(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -1272,7 +1272,7 @@ func TestEC2Subnet(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1284,7 +1284,7 @@ func TestEC2Subnet(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -1392,7 +1392,7 @@ func TestEC2DefaultSubnet(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1404,7 +1404,7 @@ func TestEC2DefaultSubnet(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -1499,7 +1499,7 @@ func TestEC2RouteTable(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1511,7 +1511,7 @@ func TestEC2RouteTable(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -1606,7 +1606,7 @@ func TestEC2DefaultRouteTable(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1618,7 +1618,7 @@ func TestEC2DefaultRouteTable(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -1713,7 +1713,7 @@ func TestVpcSecurityGroup(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1725,7 +1725,7 @@ func TestVpcSecurityGroup(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -1820,7 +1820,7 @@ func TestVpcDefaultSecurityGroup(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1832,7 +1832,7 @@ func TestVpcDefaultSecurityGroup(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -1916,7 +1916,7 @@ func TestEC2NatGateway(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1928,7 +1928,7 @@ func TestEC2NatGateway(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -2034,7 +2034,7 @@ func TestEC2NetworkACL(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -2046,7 +2046,7 @@ func TestEC2NetworkACL(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -2188,7 +2188,7 @@ func TestEC2NetworkACLRule(t *testing.T) { version := "3.19.0" schemaRepository := testresource.InitFakeSchemaRepository("aws", version) resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -2196,7 +2196,7 @@ func TestEC2NetworkACLRule(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -2301,7 +2301,7 @@ func TestEC2DefaultNetworkACL(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -2313,7 +2313,7 @@ func TestEC2DefaultNetworkACL(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -2470,7 +2470,7 @@ func TestEC2Route(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -2482,7 +2482,7 @@ func TestEC2Route(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -2661,7 +2661,7 @@ func TestVpcSecurityGroupRule(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -2673,7 +2673,7 @@ func TestVpcSecurityGroupRule(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -2760,7 +2760,7 @@ func TestEC2LaunchTemplate(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -2772,7 +2772,7 @@ func TestEC2LaunchTemplate(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -2848,7 +2848,7 @@ func TestEC2EbsEncryptionByDefault(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -2860,7 +2860,7 @@ func TestEC2EbsEncryptionByDefault(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks diff --git a/enumeration/remote/aws_ecr_scanner_test.go b/enumeration/remote/aws_ecr_scanner_test.go index 08f42dd1d..60fd9f534 100644 --- a/enumeration/remote/aws_ecr_scanner_test.go +++ b/enumeration/remote/aws_ecr_scanner_test.go @@ -10,7 +10,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" - terraform3 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform" awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" @@ -70,7 +70,7 @@ func TestECRRepository(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -82,7 +82,7 @@ func TestECRRepository(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -164,7 +164,7 @@ func TestECRRepositoryPolicy(t *testing.T) { providerVersion := "3.19.0" schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range tests { t.Run(c.test, func(tt *testing.T) { diff --git a/enumeration/remote/aws_iam_scanner_test.go b/enumeration/remote/aws_iam_scanner_test.go index 69959959a..07a9e22cd 100644 --- a/enumeration/remote/aws_iam_scanner_test.go +++ b/enumeration/remote/aws_iam_scanner_test.go @@ -10,7 +10,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" - terraform3 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" @@ -77,7 +77,7 @@ func TestIamUser(t *testing.T) { } schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -89,7 +89,7 @@ func TestIamUser(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -216,7 +216,7 @@ func TestIamUserPolicy(t *testing.T) { } schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -228,7 +228,7 @@ func TestIamUserPolicy(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -323,7 +323,7 @@ func TestIamPolicy(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -335,7 +335,7 @@ func TestIamPolicy(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -443,7 +443,7 @@ func TestIamRole(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -455,7 +455,7 @@ func TestIamRole(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -626,7 +626,7 @@ func TestIamRolePolicyAttachment(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -638,7 +638,7 @@ func TestIamRolePolicyAttachment(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -764,7 +764,7 @@ func TestIamAccessKey(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -776,7 +776,7 @@ func TestIamAccessKey(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -977,7 +977,7 @@ func TestIamUserPolicyAttachment(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -989,7 +989,7 @@ func TestIamUserPolicyAttachment(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -1108,7 +1108,7 @@ func TestIamRolePolicy(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -1120,7 +1120,7 @@ func TestIamRolePolicy(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -1210,7 +1210,7 @@ func TestIamGroupPolicy(t *testing.T) { providerVersion := "3.19.0" schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -1287,7 +1287,7 @@ func TestIamGroup(t *testing.T) { providerVersion := "3.19.0" schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range tests { t.Run(c.test, func(tt *testing.T) { diff --git a/enumeration/remote/aws_kms_scanner_test.go b/enumeration/remote/aws_kms_scanner_test.go index a935f1d29..fa0bf8e2b 100644 --- a/enumeration/remote/aws_kms_scanner_test.go +++ b/enumeration/remote/aws_kms_scanner_test.go @@ -10,7 +10,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" - terraform3 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform" awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" @@ -69,7 +69,7 @@ func TestKMSKey(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -81,7 +81,7 @@ func TestKMSKey(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -167,7 +167,7 @@ func TestKMSAlias(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -179,7 +179,7 @@ func TestKMSAlias(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks diff --git a/enumeration/remote/aws_lambda_scanner_test.go b/enumeration/remote/aws_lambda_scanner_test.go index c6dd5c04c..89fea5adb 100644 --- a/enumeration/remote/aws_lambda_scanner_test.go +++ b/enumeration/remote/aws_lambda_scanner_test.go @@ -10,7 +10,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" - terraform3 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform" awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" @@ -89,7 +89,7 @@ func TestScanLambdaFunction(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -101,7 +101,7 @@ func TestScanLambdaFunction(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -205,7 +205,7 @@ func TestScanLambdaEventSourceMapping(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -217,7 +217,7 @@ func TestScanLambdaEventSourceMapping(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks diff --git a/enumeration/remote/aws_rds_scanner_test.go b/enumeration/remote/aws_rds_scanner_test.go index 131da7ded..64eeb627e 100644 --- a/enumeration/remote/aws_rds_scanner_test.go +++ b/enumeration/remote/aws_rds_scanner_test.go @@ -10,7 +10,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" - terraform3 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform" awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" @@ -77,7 +77,7 @@ func TestRDSDBInstance(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -89,7 +89,7 @@ func TestRDSDBInstance(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -174,7 +174,7 @@ func TestRDSDBSubnetGroup(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -186,7 +186,7 @@ func TestRDSDBSubnetGroup(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -276,7 +276,7 @@ func TestRDSCluster(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -288,7 +288,7 @@ func TestRDSCluster(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks diff --git a/enumeration/remote/aws_route53_scanner_test.go b/enumeration/remote/aws_route53_scanner_test.go index 087a4a9be..e7354dff4 100644 --- a/enumeration/remote/aws_route53_scanner_test.go +++ b/enumeration/remote/aws_route53_scanner_test.go @@ -8,7 +8,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" - terraform3 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform" "testing" awssdk "github.com/aws/aws-sdk-go/aws" @@ -72,7 +72,7 @@ func TestRoute53_HealthCheck(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -84,7 +84,7 @@ func TestRoute53_HealthCheck(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -207,7 +207,7 @@ func TestRoute53_Zone(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -219,7 +219,7 @@ func TestRoute53_Zone(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -417,7 +417,7 @@ func TestRoute53_Record(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -429,7 +429,7 @@ func TestRoute53_Record(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks diff --git a/enumeration/remote/aws_s3_scanner_test.go b/enumeration/remote/aws_s3_scanner_test.go index 28cf65da8..114543982 100644 --- a/enumeration/remote/aws_s3_scanner_test.go +++ b/enumeration/remote/aws_s3_scanner_test.go @@ -13,7 +13,7 @@ import ( remoteerr "github.com/snyk/driftctl/enumeration/remote/error" tf "github.com/snyk/driftctl/enumeration/remote/terraform" "github.com/snyk/driftctl/enumeration/terraform" - + awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/session" diff --git a/enumeration/remote/aws_sns_scanner_test.go b/enumeration/remote/aws_sns_scanner_test.go index 1cbe757ee..67c0d0522 100644 --- a/enumeration/remote/aws_sns_scanner_test.go +++ b/enumeration/remote/aws_sns_scanner_test.go @@ -10,7 +10,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" - terraform3 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform" awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" @@ -74,7 +74,7 @@ func TestScanSNSTopic(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -86,7 +86,7 @@ func TestScanSNSTopic(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -174,7 +174,7 @@ func TestSNSTopicPolicyScan(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -186,7 +186,7 @@ func TestSNSTopicPolicyScan(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -291,7 +291,7 @@ func TestSNSTopicSubscriptionScan(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -303,7 +303,7 @@ func TestSNSTopicSubscriptionScan(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks diff --git a/enumeration/remote/aws_sqs_scanner_test.go b/enumeration/remote/aws_sqs_scanner_test.go index 10359cf18..0fed8535b 100644 --- a/enumeration/remote/aws_sqs_scanner_test.go +++ b/enumeration/remote/aws_sqs_scanner_test.go @@ -10,7 +10,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" - terraform3 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform" awssdk "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" @@ -70,7 +70,7 @@ func TestSQSQueue(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -82,7 +82,7 @@ func TestSQSQueue(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -197,7 +197,7 @@ func TestSQSQueuePolicy(t *testing.T) { schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -209,7 +209,7 @@ func TestSQSQueuePolicy(t *testing.T) { })) scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks diff --git a/enumeration/remote/azurerm_compute_scanner_test.go b/enumeration/remote/azurerm_compute_scanner_test.go index 70fa2aceb..91059ce95 100644 --- a/enumeration/remote/azurerm_compute_scanner_test.go +++ b/enumeration/remote/azurerm_compute_scanner_test.go @@ -9,7 +9,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" - terraform3 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" @@ -93,7 +93,7 @@ func TestAzurermCompute_Image(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -174,7 +174,7 @@ func TestAzurermCompute_SSHPublicKey(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -182,7 +182,7 @@ func TestAzurermCompute_SSHPublicKey(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks diff --git a/enumeration/remote/azurerm_network_scanner_test.go b/enumeration/remote/azurerm_network_scanner_test.go index a14040ffc..c22fd8bd3 100644 --- a/enumeration/remote/azurerm_network_scanner_test.go +++ b/enumeration/remote/azurerm_network_scanner_test.go @@ -9,7 +9,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" error2 "github.com/snyk/driftctl/enumeration/remote/error" - terraform3 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" @@ -87,7 +87,7 @@ func TestAzurermVirtualNetwork(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -180,7 +180,7 @@ func TestAzurermRouteTables(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -329,7 +329,7 @@ func TestAzurermRoutes(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -462,7 +462,7 @@ func TestAzurermSubnets(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -555,7 +555,7 @@ func TestAzurermFirewalls(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -648,7 +648,7 @@ func TestAzurermPublicIP(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -732,7 +732,7 @@ func TestAzurermSecurityGroups(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -740,7 +740,7 @@ func TestAzurermSecurityGroups(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -851,7 +851,7 @@ func TestAzurermLoadBalancers(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -953,7 +953,7 @@ func TestAzurermLoadBalancerRules(t *testing.T) { providerVersion := "2.71.0" schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -961,7 +961,7 @@ func TestAzurermLoadBalancerRules(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks diff --git a/enumeration/remote/google_bigquery_scanner_test.go b/enumeration/remote/google_bigquery_scanner_test.go index 4ac6493d1..1f900cc90 100644 --- a/enumeration/remote/google_bigquery_scanner_test.go +++ b/enumeration/remote/google_bigquery_scanner_test.go @@ -10,7 +10,7 @@ import ( remoteerr "github.com/snyk/driftctl/enumeration/remote/error" google2 "github.com/snyk/driftctl/enumeration/remote/google" "github.com/snyk/driftctl/enumeration/remote/google/repository" - terraform3 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform" "github.com/snyk/driftctl/enumeration/resource" googleresource "github.com/snyk/driftctl/enumeration/resource/google" @@ -83,12 +83,12 @@ func TestGoogleBigqueryDataset(t *testing.T) { providerVersion := "3.78.0" schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -186,12 +186,12 @@ func TestGoogleBigqueryTable(t *testing.T) { providerVersion := "3.78.0" schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks diff --git a/enumeration/remote/google_bigtable_scanner_test.go b/enumeration/remote/google_bigtable_scanner_test.go index dd0ef2703..d60db6a0c 100644 --- a/enumeration/remote/google_bigtable_scanner_test.go +++ b/enumeration/remote/google_bigtable_scanner_test.go @@ -10,7 +10,7 @@ import ( remoteerr "github.com/snyk/driftctl/enumeration/remote/error" google2 "github.com/snyk/driftctl/enumeration/remote/google" "github.com/snyk/driftctl/enumeration/remote/google/repository" - terraform3 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform" "github.com/snyk/driftctl/enumeration/resource" googleresource "github.com/snyk/driftctl/enumeration/resource/google" @@ -120,12 +120,12 @@ func TestGoogleBigtableInstance(t *testing.T) { providerVersion := "3.78.0" schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -246,12 +246,12 @@ func TestGoogleBigtableTable(t *testing.T) { providerVersion := "3.78.0" schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks diff --git a/enumeration/remote/google_cloudfunctions_scanner_test.go b/enumeration/remote/google_cloudfunctions_scanner_test.go index ccdd2d3d7..4e9cb9bc8 100644 --- a/enumeration/remote/google_cloudfunctions_scanner_test.go +++ b/enumeration/remote/google_cloudfunctions_scanner_test.go @@ -10,7 +10,7 @@ import ( remoteerr "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/remote/google" "github.com/snyk/driftctl/enumeration/remote/google/repository" - terraform3 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform" "github.com/snyk/driftctl/enumeration/resource" googleresource "github.com/snyk/driftctl/enumeration/resource/google" @@ -107,12 +107,12 @@ func TestGoogleCloudFunctionsFunction(t *testing.T) { providerVersion := "3.78.0" schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks diff --git a/enumeration/remote/google_cloudrun_scanner_test.go b/enumeration/remote/google_cloudrun_scanner_test.go index 3bb778400..84afa4f1f 100644 --- a/enumeration/remote/google_cloudrun_scanner_test.go +++ b/enumeration/remote/google_cloudrun_scanner_test.go @@ -10,7 +10,7 @@ import ( remoteerr "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/remote/google" "github.com/snyk/driftctl/enumeration/remote/google/repository" - terraform3 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform" "github.com/snyk/driftctl/enumeration/resource" googleresource "github.com/snyk/driftctl/enumeration/resource/google" @@ -102,12 +102,12 @@ func TestGoogleCloudRunService(t *testing.T) { providerVersion := "3.78.0" schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks diff --git a/enumeration/remote/google_compute_scanner_test.go b/enumeration/remote/google_compute_scanner_test.go index 2d937d8f3..33be9ed80 100644 --- a/enumeration/remote/google_compute_scanner_test.go +++ b/enumeration/remote/google_compute_scanner_test.go @@ -10,7 +10,7 @@ import ( remoteerr "github.com/snyk/driftctl/enumeration/remote/error" google2 "github.com/snyk/driftctl/enumeration/remote/google" "github.com/snyk/driftctl/enumeration/remote/google/repository" - terraform3 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform" "github.com/snyk/driftctl/enumeration/resource" googleresource "github.com/snyk/driftctl/enumeration/resource/google" @@ -93,7 +93,7 @@ func TestGoogleComputeFirewall(t *testing.T) { resType := resource.ResourceType(googleresource.GoogleComputeFirewallResourceType) schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -101,7 +101,7 @@ func TestGoogleComputeFirewall(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -230,12 +230,12 @@ func TestGoogleComputeRouter(t *testing.T) { providerVersion := "3.78.0" schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -334,12 +334,12 @@ func TestGoogleComputeInstance(t *testing.T) { providerVersion := "3.78.0" schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -444,7 +444,7 @@ func TestGoogleComputeNetwork(t *testing.T) { resType := resource.ResourceType(googleresource.GoogleComputeNetworkResourceType) schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -452,7 +452,7 @@ func TestGoogleComputeNetwork(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -566,7 +566,7 @@ func TestGoogleComputeInstanceGroup(t *testing.T) { resType := resource.ResourceType(googleresource.GoogleComputeInstanceGroupResourceType) schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -574,7 +574,7 @@ func TestGoogleComputeInstanceGroup(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -701,12 +701,12 @@ func TestGoogleComputeAddress(t *testing.T) { providerVersion := "3.78.0" schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -827,12 +827,12 @@ func TestGoogleComputeGlobalAddress(t *testing.T) { providerVersion := "3.78.0" schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -937,7 +937,7 @@ func TestGoogleComputeSubnetwork(t *testing.T) { resType := resource.ResourceType(googleresource.GoogleComputeSubnetworkResourceType) schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -945,7 +945,7 @@ func TestGoogleComputeSubnetwork(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -1060,12 +1060,12 @@ func TestGoogleComputeDisk(t *testing.T) { providerVersion := "3.78.0" schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -1170,12 +1170,12 @@ func TestGoogleComputeImage(t *testing.T) { providerVersion := "3.78.0" schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -1278,14 +1278,14 @@ func TestGoogleComputeHealthCheck(t *testing.T) { } providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository(terraform3.GOOGLE, providerVersion) + schemaRepository := testresource.InitFakeSchemaRepository(terraform.GOOGLE, providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -1388,14 +1388,14 @@ func TestGoogleComputeNodeGroup(t *testing.T) { } providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository(terraform3.GOOGLE, providerVersion) + schemaRepository := testresource.InitFakeSchemaRepository(terraform.GOOGLE, providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -1497,14 +1497,14 @@ func TestGoogleComputeForwardingRule(t *testing.T) { } providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository(terraform3.GOOGLE, providerVersion) + schemaRepository := testresource.InitFakeSchemaRepository(terraform.GOOGLE, providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -1607,14 +1607,14 @@ func TestGoogleComputeInstanceGroupManager(t *testing.T) { } providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository(terraform3.GOOGLE, providerVersion) + schemaRepository := testresource.InitFakeSchemaRepository(terraform.GOOGLE, providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -1716,14 +1716,14 @@ func TestGoogleComputeGlobalForwardingRule(t *testing.T) { } providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository(terraform3.GOOGLE, providerVersion) + schemaRepository := testresource.InitFakeSchemaRepository(terraform.GOOGLE, providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks diff --git a/enumeration/remote/google_network_scanner_test.go b/enumeration/remote/google_network_scanner_test.go index ced0a8e2f..338290198 100644 --- a/enumeration/remote/google_network_scanner_test.go +++ b/enumeration/remote/google_network_scanner_test.go @@ -10,7 +10,7 @@ import ( remoteerr "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/remote/google" "github.com/snyk/driftctl/enumeration/remote/google/repository" - terraform3 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform" "github.com/snyk/driftctl/enumeration/resource" googleresource "github.com/snyk/driftctl/enumeration/resource/google" @@ -108,12 +108,12 @@ func TestGoogleDNSNanagedZone(t *testing.T) { providerVersion := "3.78.0" schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks diff --git a/enumeration/remote/google_project_scanner_test.go b/enumeration/remote/google_project_scanner_test.go index 76be2a13b..a28f9acfe 100644 --- a/enumeration/remote/google_project_scanner_test.go +++ b/enumeration/remote/google_project_scanner_test.go @@ -9,7 +9,7 @@ import ( remoteerr "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/remote/google" "github.com/snyk/driftctl/enumeration/remote/google/repository" - terraform3 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform" "github.com/pkg/errors" "github.com/snyk/driftctl/enumeration/resource" @@ -91,7 +91,7 @@ func TestGoogleProjectIAMMember(t *testing.T) { resType := resource.ResourceType(googleresource.GoogleProjectIamMemberResourceType) schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -100,7 +100,7 @@ func TestGoogleProjectIAMMember(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks diff --git a/enumeration/remote/google_sql_scanner_test.go b/enumeration/remote/google_sql_scanner_test.go index d617ae995..66167ed49 100644 --- a/enumeration/remote/google_sql_scanner_test.go +++ b/enumeration/remote/google_sql_scanner_test.go @@ -10,7 +10,7 @@ import ( remoteerr "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/remote/google" "github.com/snyk/driftctl/enumeration/remote/google/repository" - terraform3 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform" "github.com/snyk/driftctl/enumeration/resource" googleresource "github.com/snyk/driftctl/enumeration/resource/google" @@ -105,12 +105,12 @@ func TestGoogleSQLDatabaseInstance(t *testing.T) { providerVersion := "3.78.0" schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) for _, c := range cases { t.Run(c.test, func(tt *testing.T) { scanOptions := ScannerOptions{} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks diff --git a/enumeration/remote/google_storage_scanner_test.go b/enumeration/remote/google_storage_scanner_test.go index ce5fe2386..3fc7c7f41 100644 --- a/enumeration/remote/google_storage_scanner_test.go +++ b/enumeration/remote/google_storage_scanner_test.go @@ -11,7 +11,7 @@ import ( remoteerr "github.com/snyk/driftctl/enumeration/remote/error" google2 "github.com/snyk/driftctl/enumeration/remote/google" "github.com/snyk/driftctl/enumeration/remote/google/repository" - terraform3 "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/enumeration/terraform" asset "cloud.google.com/go/asset/apiv1" "cloud.google.com/go/storage" @@ -93,7 +93,7 @@ func TestGoogleStorageBucket(t *testing.T) { resType := resource.ResourceType(googleresource.GoogleStorageBucketResourceType) schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -101,7 +101,7 @@ func TestGoogleStorageBucket(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks @@ -267,7 +267,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { resType := resource.ResourceType(googleresource.GoogleStorageBucketIamMemberResourceType) schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform3.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory(schemaRepository) deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -277,7 +277,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { shouldUpdate := c.dirName == *goldenfile.Update scanOptions := ScannerOptions{Deep: true} - providerLibrary := terraform3.NewProviderLibrary() + providerLibrary := terraform.NewProviderLibrary() remoteLibrary := common.NewRemoteLibrary() // Initialize mocks From 83be84efb43ca5e7bd7adee936e3566170e72758 Mon Sep 17 00:00:00 2001 From: Elie CHARRA Date: Wed, 6 Jul 2022 16:42:49 +0200 Subject: [PATCH 08/12] chore: fix mess with azurerm2 imports --- .../remote/azurerm_compute_scanner_test.go | 6 +++--- .../remote/azurerm_network_scanner_test.go | 20 +++++++++---------- .../remote/azurerm_postgresql_scanner_test.go | 6 +++--- .../remote/azurerm_privatedns_scanner_test.go | 18 ++++++++--------- .../remote/azurerm_storage_scanner_test.go | 6 +++--- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/enumeration/remote/azurerm_compute_scanner_test.go b/enumeration/remote/azurerm_compute_scanner_test.go index 91059ce95..55a67355b 100644 --- a/enumeration/remote/azurerm_compute_scanner_test.go +++ b/enumeration/remote/azurerm_compute_scanner_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/snyk/driftctl/enumeration" - azurerm2 "github.com/snyk/driftctl/enumeration/remote/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm" "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" @@ -105,7 +105,7 @@ func TestAzurermCompute_Image(t *testing.T) { fakeRepo := &repository.MockComputeRepository{} c.mocks(fakeRepo, alerter) - remoteLibrary.AddEnumerator(azurerm2.NewAzurermImageEnumerator(fakeRepo, factory)) + remoteLibrary.AddEnumerator(azurerm.NewAzurermImageEnumerator(fakeRepo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -214,7 +214,7 @@ func TestAzurermCompute_SSHPublicKey(t *testing.T) { repo = repository.NewComputeRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(azurerm2.NewAzurermSSHPublicKeyEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm.NewAzurermSSHPublicKeyEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceazure.AzureSSHPublicKeyResourceType, common.NewGenericDetailsFetcher(resourceazure.AzureSSHPublicKeyResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} diff --git a/enumeration/remote/azurerm_network_scanner_test.go b/enumeration/remote/azurerm_network_scanner_test.go index c22fd8bd3..3c74afee2 100644 --- a/enumeration/remote/azurerm_network_scanner_test.go +++ b/enumeration/remote/azurerm_network_scanner_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/snyk/driftctl/enumeration" - azurerm2 "github.com/snyk/driftctl/enumeration/remote/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm" "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" @@ -102,7 +102,7 @@ func TestAzurermVirtualNetwork(t *testing.T) { var repo repository.NetworkRepository = fakeRepo - remoteLibrary.AddEnumerator(azurerm2.NewAzurermVirtualNetworkEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm.NewAzurermVirtualNetworkEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -195,7 +195,7 @@ func TestAzurermRouteTables(t *testing.T) { var repo repository.NetworkRepository = fakeRepo - remoteLibrary.AddEnumerator(azurerm2.NewAzurermRouteTableEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm.NewAzurermRouteTableEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -344,7 +344,7 @@ func TestAzurermRoutes(t *testing.T) { var repo repository.NetworkRepository = fakeRepo - remoteLibrary.AddEnumerator(azurerm2.NewAzurermRouteEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm.NewAzurermRouteEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -477,7 +477,7 @@ func TestAzurermSubnets(t *testing.T) { var repo repository.NetworkRepository = fakeRepo - remoteLibrary.AddEnumerator(azurerm2.NewAzurermSubnetEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm.NewAzurermSubnetEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -570,7 +570,7 @@ func TestAzurermFirewalls(t *testing.T) { var repo repository.NetworkRepository = fakeRepo - remoteLibrary.AddEnumerator(azurerm2.NewAzurermFirewallsEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm.NewAzurermFirewallsEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -663,7 +663,7 @@ func TestAzurermPublicIP(t *testing.T) { var repo repository.NetworkRepository = fakeRepo - remoteLibrary.AddEnumerator(azurerm2.NewAzurermPublicIPEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm.NewAzurermPublicIPEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -772,7 +772,7 @@ func TestAzurermSecurityGroups(t *testing.T) { repo = repository.NewNetworkRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(azurerm2.NewAzurermNetworkSecurityGroupEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm.NewAzurermNetworkSecurityGroupEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceazure.AzureNetworkSecurityGroupResourceType, common.NewGenericDetailsFetcher(resourceazure.AzureNetworkSecurityGroupResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -866,7 +866,7 @@ func TestAzurermLoadBalancers(t *testing.T) { var repo repository.NetworkRepository = fakeRepo - remoteLibrary.AddEnumerator(azurerm2.NewAzurermLoadBalancerEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm.NewAzurermLoadBalancerEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -993,7 +993,7 @@ func TestAzurermLoadBalancerRules(t *testing.T) { repo = repository.NewNetworkRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(azurerm2.NewAzurermLoadBalancerRuleEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm.NewAzurermLoadBalancerRuleEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceazure.AzureLoadBalancerRuleResourceType, common.NewGenericDetailsFetcher(resourceazure.AzureLoadBalancerRuleResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} diff --git a/enumeration/remote/azurerm_postgresql_scanner_test.go b/enumeration/remote/azurerm_postgresql_scanner_test.go index 8887b29ea..7a6b57143 100644 --- a/enumeration/remote/azurerm_postgresql_scanner_test.go +++ b/enumeration/remote/azurerm_postgresql_scanner_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/snyk/driftctl/enumeration" - azurerm2 "github.com/snyk/driftctl/enumeration/remote/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm" "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" @@ -100,7 +100,7 @@ func TestAzurermPostgresqlServer(t *testing.T) { var repo repository.PostgresqlRespository = fakeRepo - remoteLibrary.AddEnumerator(azurerm2.NewAzurermPostgresqlServerEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm.NewAzurermPostgresqlServerEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -226,7 +226,7 @@ func TestAzurermPostgresqlDatabase(t *testing.T) { var repo repository.PostgresqlRespository = fakeRepo - remoteLibrary.AddEnumerator(azurerm2.NewAzurermPostgresqlDatabaseEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm.NewAzurermPostgresqlDatabaseEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) diff --git a/enumeration/remote/azurerm_privatedns_scanner_test.go b/enumeration/remote/azurerm_privatedns_scanner_test.go index b3125a65c..f6da66cad 100644 --- a/enumeration/remote/azurerm_privatedns_scanner_test.go +++ b/enumeration/remote/azurerm_privatedns_scanner_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/snyk/driftctl/enumeration" - azurerm2 "github.com/snyk/driftctl/enumeration/remote/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm" "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" @@ -130,7 +130,7 @@ func TestAzurermPrivateDNSZone(t *testing.T) { repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSZoneEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm.NewAzurermPrivateDNSZoneEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSZoneResourceType, common.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSZoneResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -284,7 +284,7 @@ func TestAzurermPrivateDNSARecord(t *testing.T) { repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSARecordEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm.NewAzurermPrivateDNSARecordEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSARecordResourceType, common.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSARecordResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -439,7 +439,7 @@ func TestAzurermPrivateDNSAAAARecord(t *testing.T) { repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSAAAARecordEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm.NewAzurermPrivateDNSAAAARecordEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSAAAARecordResourceType, common.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSAAAARecordResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -582,7 +582,7 @@ func TestAzurermPrivateDNSCNAMERecord(t *testing.T) { repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSCNameRecordEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm.NewAzurermPrivateDNSCNameRecordEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSCNameRecordResourceType, common.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSCNameRecordResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -736,7 +736,7 @@ func TestAzurermPrivateDNSPTRRecord(t *testing.T) { repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSPTRRecordEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm.NewAzurermPrivateDNSPTRRecordEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSPTRRecordResourceType, common.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSPTRRecordResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -891,7 +891,7 @@ func TestAzurermPrivateDNSMXRecord(t *testing.T) { repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSMXRecordEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm.NewAzurermPrivateDNSMXRecordEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSMXRecordResourceType, common.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSMXRecordResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -1045,7 +1045,7 @@ func TestAzurermPrivateDNSSRVRecord(t *testing.T) { repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSSRVRecordEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm.NewAzurermPrivateDNSSRVRecordEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSSRVRecordResourceType, common.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSSRVRecordResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -1199,7 +1199,7 @@ func TestAzurermPrivateDNSTXTRecord(t *testing.T) { repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSTXTRecordEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm.NewAzurermPrivateDNSTXTRecordEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resourceazure.AzurePrivateDNSTXTRecordResourceType, common.NewGenericDetailsFetcher(resourceazure.AzurePrivateDNSTXTRecordResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} diff --git a/enumeration/remote/azurerm_storage_scanner_test.go b/enumeration/remote/azurerm_storage_scanner_test.go index be7d56944..588f65f4d 100644 --- a/enumeration/remote/azurerm_storage_scanner_test.go +++ b/enumeration/remote/azurerm_storage_scanner_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/snyk/driftctl/enumeration" - azurerm2 "github.com/snyk/driftctl/enumeration/remote/azurerm" + "github.com/snyk/driftctl/enumeration/remote/azurerm" "github.com/snyk/driftctl/enumeration/remote/azurerm/repository" "github.com/snyk/driftctl/enumeration/remote/common" error2 "github.com/snyk/driftctl/enumeration/remote/error" @@ -97,7 +97,7 @@ func TestAzurermStorageAccount(t *testing.T) { var repo repository.StorageRespository = fakeRepo - remoteLibrary.AddEnumerator(azurerm2.NewAzurermStorageAccountEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm.NewAzurermStorageAccountEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -242,7 +242,7 @@ func TestAzurermStorageContainer(t *testing.T) { var repo repository.StorageRespository = fakeRepo - remoteLibrary.AddEnumerator(azurerm2.NewAzurermStorageContainerEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(azurerm.NewAzurermStorageContainerEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) From 034b82e2e97d774f7da3970f53ae906c21e4b63c Mon Sep 17 00:00:00 2001 From: Elie CHARRA Date: Wed, 6 Jul 2022 16:45:43 +0200 Subject: [PATCH 09/12] chore: fix mess with github2 imports --- .../github_branch_protection_scanner_test.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/enumeration/remote/github_branch_protection_scanner_test.go b/enumeration/remote/github_branch_protection_scanner_test.go index 71f9b3806..1fa3c7388 100644 --- a/enumeration/remote/github_branch_protection_scanner_test.go +++ b/enumeration/remote/github_branch_protection_scanner_test.go @@ -8,7 +8,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" - github2 "github.com/snyk/driftctl/enumeration/remote/github" + "github.com/snyk/driftctl/enumeration/remote/github" "github.com/snyk/driftctl/enumeration/terraform" "github.com/pkg/errors" @@ -30,13 +30,13 @@ func TestScanGithubBranchProtection(t *testing.T) { cases := []struct { test string dirName string - mocks func(*github2.MockGithubRepository, *mocks.AlerterInterface) + mocks func(*github.MockGithubRepository, *mocks.AlerterInterface) err error }{ { test: "no branch protection", dirName: "github_branch_protection_empty", - mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListBranchProtection").Return([]string{}, nil) }, err: nil, @@ -44,7 +44,7 @@ func TestScanGithubBranchProtection(t *testing.T) { { test: "Multiple branch protections", dirName: "github_branch_protection_multiples", - mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListBranchProtection").Return([]string{ "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzI=", // "repo0:main" "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0Nzg=", // "repo0:toto" @@ -59,7 +59,7 @@ func TestScanGithubBranchProtection(t *testing.T) { { test: "cannot list branch protections", dirName: "github_branch_protection_empty", - mocks: func(client *github2.MockGithubRepository, alerter *mocks.AlerterInterface) { + mocks: func(client *github.MockGithubRepository, alerter *mocks.AlerterInterface) { client.On("ListBranchProtection").Return(nil, errors.New("Your token has not been granted the required scopes to execute this query.")) alerter.On("SendAlert", githubres.GithubBranchProtectionResourceType, alerts.NewRemoteAccessDeniedAlert(common.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), githubres.GithubBranchProtectionResourceType, githubres.GithubBranchProtectionResourceType), alerts.EnumerationPhase)).Return() @@ -84,10 +84,10 @@ func TestScanGithubBranchProtection(t *testing.T) { // Initialize mocks alerter := &mocks.AlerterInterface{} - mockedRepo := github2.MockGithubRepository{} + mockedRepo := github.MockGithubRepository{} c.mocks(&mockedRepo, alerter) - var repo github2.GithubRepository = &mockedRepo + var repo github.GithubRepository = &mockedRepo realProvider, err := tftest.InitTestGithubProvider(providerLibrary, "4.4.0") if err != nil { @@ -102,10 +102,10 @@ func TestScanGithubBranchProtection(t *testing.T) { t.Fatal(err) } provider.ShouldUpdate() - repo = github2.NewGithubRepository(realProvider.GetConfig(), cache.New(0)) + repo = github.NewGithubRepository(realProvider.GetConfig(), cache.New(0)) } - remoteLibrary.AddEnumerator(github2.NewGithubBranchProtectionEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(github.NewGithubBranchProtectionEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(githubres.GithubBranchProtectionResourceType, common.NewGenericDetailsFetcher(githubres.GithubBranchProtectionResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} From 2aa8d7305e52e002f928a53ee3b0104b76a373b2 Mon Sep 17 00:00:00 2001 From: Elie CHARRA Date: Wed, 6 Jul 2022 16:54:46 +0200 Subject: [PATCH 10/12] chore: fix mess in GCP repos imports --- enumeration/remote/google/repository/asset.go | 4 ++-- enumeration/remote/google/repository/asset_test.go | 4 ++-- enumeration/remote/google/repository/storage.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/enumeration/remote/google/repository/asset.go b/enumeration/remote/google/repository/asset.go index 153d0d468..953e4f117 100644 --- a/enumeration/remote/google/repository/asset.go +++ b/enumeration/remote/google/repository/asset.go @@ -3,10 +3,10 @@ package repository import ( "context" "fmt" - "github.com/snyk/driftctl/enumeration/remote/cache" - "github.com/snyk/driftctl/enumeration/remote/google/config" asset "cloud.google.com/go/asset/apiv1" + "github.com/snyk/driftctl/enumeration/remote/cache" + "github.com/snyk/driftctl/enumeration/remote/google/config" "google.golang.org/api/iterator" assetpb "google.golang.org/genproto/googleapis/cloud/asset/v1" ) diff --git a/enumeration/remote/google/repository/asset_test.go b/enumeration/remote/google/repository/asset_test.go index b831a1773..8c5ec92dd 100644 --- a/enumeration/remote/google/repository/asset_test.go +++ b/enumeration/remote/google/repository/asset_test.go @@ -1,10 +1,10 @@ package repository import ( - "github.com/snyk/driftctl/enumeration/remote/cache" - "github.com/snyk/driftctl/enumeration/remote/google/config" "testing" + "github.com/snyk/driftctl/enumeration/remote/cache" + "github.com/snyk/driftctl/enumeration/remote/google/config" "github.com/snyk/driftctl/test/google" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" diff --git a/enumeration/remote/google/repository/storage.go b/enumeration/remote/google/repository/storage.go index ae33bc101..bbd186d9a 100644 --- a/enumeration/remote/google/repository/storage.go +++ b/enumeration/remote/google/repository/storage.go @@ -3,10 +3,10 @@ package repository import ( "context" "fmt" - "github.com/snyk/driftctl/enumeration/remote/cache" "sync" "cloud.google.com/go/storage" + "github.com/snyk/driftctl/enumeration/remote/cache" ) type StorageRepository interface { From 5659a8ee4b51d1e2d1e59376f83910e0e714fe40 Mon Sep 17 00:00:00 2001 From: Elie CHARRA Date: Wed, 6 Jul 2022 16:56:35 +0200 Subject: [PATCH 11/12] chore: fix mess with google2 imports --- .../remote/google_bigquery_scanner_test.go | 6 ++-- .../remote/google_bigtable_scanner_test.go | 6 ++-- .../remote/google_compute_scanner_test.go | 32 +++++++++---------- .../remote/google_storage_scanner_test.go | 6 ++-- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/enumeration/remote/google_bigquery_scanner_test.go b/enumeration/remote/google_bigquery_scanner_test.go index 1f900cc90..b43a0e826 100644 --- a/enumeration/remote/google_bigquery_scanner_test.go +++ b/enumeration/remote/google_bigquery_scanner_test.go @@ -8,7 +8,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" - google2 "github.com/snyk/driftctl/enumeration/remote/google" + "github.com/snyk/driftctl/enumeration/remote/google" "github.com/snyk/driftctl/enumeration/remote/google/repository" "github.com/snyk/driftctl/enumeration/terraform" @@ -109,7 +109,7 @@ func TestGoogleBigqueryDataset(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google2.NewGoogleBigqueryDatasetEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google.NewGoogleBigqueryDatasetEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -212,7 +212,7 @@ func TestGoogleBigqueryTable(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google2.NewGoogleBigqueryTableEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google.NewGoogleBigqueryTableEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) diff --git a/enumeration/remote/google_bigtable_scanner_test.go b/enumeration/remote/google_bigtable_scanner_test.go index d60db6a0c..cf4daa63e 100644 --- a/enumeration/remote/google_bigtable_scanner_test.go +++ b/enumeration/remote/google_bigtable_scanner_test.go @@ -8,7 +8,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" - google2 "github.com/snyk/driftctl/enumeration/remote/google" + "github.com/snyk/driftctl/enumeration/remote/google" "github.com/snyk/driftctl/enumeration/remote/google/repository" "github.com/snyk/driftctl/enumeration/terraform" @@ -146,7 +146,7 @@ func TestGoogleBigtableInstance(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google2.NewGoogleBigTableInstanceEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google.NewGoogleBigTableInstanceEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -272,7 +272,7 @@ func TestGoogleBigtableTable(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google2.NewGoogleBigtableTableEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google.NewGoogleBigtableTableEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) diff --git a/enumeration/remote/google_compute_scanner_test.go b/enumeration/remote/google_compute_scanner_test.go index 33be9ed80..ff3e01dfe 100644 --- a/enumeration/remote/google_compute_scanner_test.go +++ b/enumeration/remote/google_compute_scanner_test.go @@ -8,7 +8,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" - google2 "github.com/snyk/driftctl/enumeration/remote/google" + "github.com/snyk/driftctl/enumeration/remote/google" "github.com/snyk/driftctl/enumeration/remote/google/repository" "github.com/snyk/driftctl/enumeration/terraform" @@ -133,7 +133,7 @@ func TestGoogleComputeFirewall(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google2.NewGoogleComputeFirewallEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google.NewGoogleComputeFirewallEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resType, common.NewGenericDetailsFetcher(resType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -256,7 +256,7 @@ func TestGoogleComputeRouter(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google2.NewGoogleComputeRouterEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google.NewGoogleComputeRouterEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -360,7 +360,7 @@ func TestGoogleComputeInstance(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google2.NewGoogleComputeInstanceEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google.NewGoogleComputeInstanceEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -484,7 +484,7 @@ func TestGoogleComputeNetwork(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google2.NewGoogleComputeNetworkEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google.NewGoogleComputeNetworkEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resType, common.NewGenericDetailsFetcher(resType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -606,7 +606,7 @@ func TestGoogleComputeInstanceGroup(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google2.NewGoogleComputeInstanceGroupEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google.NewGoogleComputeInstanceGroupEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(googleresource.GoogleComputeInstanceGroupResourceType, common.NewGenericDetailsFetcher(googleresource.GoogleComputeInstanceGroupResourceType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -727,7 +727,7 @@ func TestGoogleComputeAddress(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google2.NewGoogleComputeAddressEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google.NewGoogleComputeAddressEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -853,7 +853,7 @@ func TestGoogleComputeGlobalAddress(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google2.NewGoogleComputeGlobalAddressEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google.NewGoogleComputeGlobalAddressEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -977,7 +977,7 @@ func TestGoogleComputeSubnetwork(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google2.NewGoogleComputeSubnetworkEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google.NewGoogleComputeSubnetworkEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resType, common.NewGenericDetailsFetcher(resType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -1086,7 +1086,7 @@ func TestGoogleComputeDisk(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google2.NewGoogleComputeDiskEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google.NewGoogleComputeDiskEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1196,7 +1196,7 @@ func TestGoogleComputeImage(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google2.NewGoogleComputeImageEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google.NewGoogleComputeImageEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1306,7 +1306,7 @@ func TestGoogleComputeHealthCheck(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google2.NewGoogleComputeHealthCheckEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google.NewGoogleComputeHealthCheckEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1416,7 +1416,7 @@ func TestGoogleComputeNodeGroup(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google2.NewGoogleComputeNodeGroupEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google.NewGoogleComputeNodeGroupEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1525,7 +1525,7 @@ func TestGoogleComputeForwardingRule(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google2.NewGoogleComputeForwardingRuleEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google.NewGoogleComputeForwardingRuleEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1635,7 +1635,7 @@ func TestGoogleComputeInstanceGroupManager(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google2.NewGoogleComputeInstanceGroupManagerEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google.NewGoogleComputeInstanceGroupManagerEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) @@ -1744,7 +1744,7 @@ func TestGoogleComputeGlobalForwardingRule(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google2.NewGoogleComputeGlobalForwardingRuleEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google.NewGoogleComputeGlobalForwardingRuleEnumerator(repo, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) diff --git a/enumeration/remote/google_storage_scanner_test.go b/enumeration/remote/google_storage_scanner_test.go index 3fc7c7f41..d1277199e 100644 --- a/enumeration/remote/google_storage_scanner_test.go +++ b/enumeration/remote/google_storage_scanner_test.go @@ -9,7 +9,7 @@ import ( "github.com/snyk/driftctl/enumeration/remote/cache" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" - google2 "github.com/snyk/driftctl/enumeration/remote/google" + "github.com/snyk/driftctl/enumeration/remote/google" "github.com/snyk/driftctl/enumeration/remote/google/repository" "github.com/snyk/driftctl/enumeration/terraform" @@ -142,7 +142,7 @@ func TestGoogleStorageBucket(t *testing.T) { repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0)) - remoteLibrary.AddEnumerator(google2.NewGoogleStorageBucketEnumerator(repo, factory)) + remoteLibrary.AddEnumerator(google.NewGoogleStorageBucketEnumerator(repo, factory)) remoteLibrary.AddDetailsFetcher(resType, common.NewGenericDetailsFetcher(resType, provider, deserializer)) testFilter := &enumeration.MockFilter{} @@ -312,7 +312,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { provider := terraform2.NewFakeTerraformProvider(realProvider) provider.WithResponse(c.dirName) - remoteLibrary.AddEnumerator(google2.NewGoogleStorageBucketIamMemberEnumerator(assetRepository, storageRepository, factory)) + remoteLibrary.AddEnumerator(google.NewGoogleStorageBucketIamMemberEnumerator(assetRepository, storageRepository, factory)) testFilter := &enumeration.MockFilter{} testFilter.On("IsTypeIgnored", mock.Anything).Return(false) From 3c7a52b13ca619919aaca2b8cdedffc562e02c31 Mon Sep 17 00:00:00 2001 From: Elie CHARRA Date: Wed, 6 Jul 2022 17:16:09 +0200 Subject: [PATCH 12/12] chore: fix mess with alerter2 imports --- ...resource_enumeration_error_handler_test.go | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/enumeration/remote/resource_enumeration_error_handler_test.go b/enumeration/remote/resource_enumeration_error_handler_test.go index fcf3162f4..b84101e15 100644 --- a/enumeration/remote/resource_enumeration_error_handler_test.go +++ b/enumeration/remote/resource_enumeration_error_handler_test.go @@ -4,7 +4,7 @@ import ( "errors" "testing" - alerter2 "github.com/snyk/driftctl/enumeration/alerter" + "github.com/snyk/driftctl/enumeration/alerter" "github.com/snyk/driftctl/enumeration/remote/alerts" "github.com/snyk/driftctl/enumeration/remote/common" remoteerr "github.com/snyk/driftctl/enumeration/remote/error" @@ -24,55 +24,55 @@ func TestHandleAwsEnumerationErrors(t *testing.T) { tests := []struct { name string err error - wantAlerts alerter2.Alerts + wantAlerts alerter.Alerts wantErr bool }{ { name: "Handled error 403", err: remoteerr.NewResourceListingError(awserr.NewRequestFailure(awserr.New("", "", errors.New("")), 403, ""), resourceaws.AwsVpcResourceType), - wantAlerts: alerter2.Alerts{"aws_vpc": []alerter2.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awserr.NewRequestFailure(awserr.New("", "", errors.New("")), 403, ""), "aws_vpc", "aws_vpc"), alerts.EnumerationPhase)}}, + wantAlerts: alerter.Alerts{"aws_vpc": []alerter.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awserr.NewRequestFailure(awserr.New("", "", errors.New("")), 403, ""), "aws_vpc", "aws_vpc"), alerts.EnumerationPhase)}}, wantErr: false, }, { name: "Handled error AccessDenied", err: remoteerr.NewResourceListingError(awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, ""), resourceaws.AwsDynamodbTableResourceType), - wantAlerts: alerter2.Alerts{"aws_dynamodb_table": []alerter2.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, ""), "aws_dynamodb_table", "aws_dynamodb_table"), alerts.EnumerationPhase)}}, + wantAlerts: alerter.Alerts{"aws_dynamodb_table": []alerter.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, ""), "aws_dynamodb_table", "aws_dynamodb_table"), alerts.EnumerationPhase)}}, wantErr: false, }, { name: "Not Handled error code", err: remoteerr.NewResourceListingError(awserr.NewRequestFailure(awserr.New("", "", errors.New("")), 404, ""), resourceaws.AwsVpcResourceType), - wantAlerts: map[string][]alerter2.Alert{}, + wantAlerts: map[string][]alerter.Alert{}, wantErr: true, }, { name: "Not Handled error type", err: errors.New("error"), - wantAlerts: map[string][]alerter2.Alert{}, + wantAlerts: map[string][]alerter.Alert{}, wantErr: true, }, { name: "Not Handled root error type", err: remoteerr.NewResourceListingError(errors.New("error"), resourceaws.AwsVpcResourceType), - wantAlerts: map[string][]alerter2.Alert{}, + wantAlerts: map[string][]alerter.Alert{}, wantErr: true, }, { name: "Handle AccessDenied error", err: remoteerr.NewResourceListingError(errors.New("an error occured: AccessDenied: 403"), resourceaws.AwsVpcResourceType), - wantAlerts: alerter2.Alerts{"aws_vpc": []alerter2.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("an error occured: AccessDenied: 403"), "aws_vpc", "aws_vpc"), alerts.EnumerationPhase)}}, + wantAlerts: alerter.Alerts{"aws_vpc": []alerter.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("an error occured: AccessDenied: 403"), "aws_vpc", "aws_vpc"), alerts.EnumerationPhase)}}, wantErr: false, }, { name: "Access denied error on a single resource", err: remoteerr.NewResourceScanningError(errors.New("Error: AccessDenied: 403 ..."), resourceaws.AwsS3BucketResourceType, "my-bucket"), - wantAlerts: alerter2.Alerts{"aws_s3_bucket.my-bucket": []alerter2.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Error: AccessDenied: 403 ..."), "aws_s3_bucket.my-bucket", "aws_s3_bucket"), alerts.EnumerationPhase)}}, + wantAlerts: alerter.Alerts{"aws_s3_bucket.my-bucket": []alerter.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Error: AccessDenied: 403 ..."), "aws_s3_bucket.my-bucket", "aws_s3_bucket"), alerts.EnumerationPhase)}}, wantErr: false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - alertr := alerter2.NewAlerter() + alertr := alerter.NewAlerter() gotErr := HandleResourceEnumerationError(tt.err, alertr) assert.Equal(t, tt.wantErr, gotErr != nil) @@ -88,31 +88,31 @@ func TestHandleGithubEnumerationErrors(t *testing.T) { tests := []struct { name string err error - wantAlerts alerter2.Alerts + wantAlerts alerter.Alerts wantErr bool }{ { name: "Handled graphql error", err: remoteerr.NewResourceListingError(errors.New("Your token has not been granted the required scopes to execute this query."), resourcegithub.GithubTeamResourceType), - wantAlerts: alerter2.Alerts{"github_team": []alerter2.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), "github_team", "github_team"), alerts.EnumerationPhase)}}, + wantAlerts: alerter.Alerts{"github_team": []alerter.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteGithubTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Your token has not been granted the required scopes to execute this query."), "github_team", "github_team"), alerts.EnumerationPhase)}}, wantErr: false, }, { name: "Not handled graphql error", err: remoteerr.NewResourceListingError(errors.New("This is a not handler graphql error"), resourcegithub.GithubTeamResourceType), - wantAlerts: map[string][]alerter2.Alert{}, + wantAlerts: map[string][]alerter.Alert{}, wantErr: true, }, { name: "Not Handled error type", err: errors.New("error"), - wantAlerts: map[string][]alerter2.Alert{}, + wantAlerts: map[string][]alerter.Alert{}, wantErr: true, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - alertr := alerter2.NewAlerter() + alertr := alerter.NewAlerter() gotErr := HandleResourceEnumerationError(tt.err, alertr) assert.Equal(t, tt.wantErr, gotErr != nil) @@ -127,31 +127,31 @@ func TestHandleGoogleEnumerationErrors(t *testing.T) { tests := []struct { name string err error - wantAlerts alerter2.Alerts + wantAlerts alerter.Alerts wantErr bool }{ { name: "Handled 403 error", err: remoteerr.NewResourceListingError(status.Error(codes.PermissionDenied, "useless message"), "google_type"), - wantAlerts: alerter2.Alerts{"google_type": []alerter2.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteGoogleTerraform, remoteerr.NewResourceListingErrorWithType(status.Error(codes.PermissionDenied, "useless message"), "google_type", "google_type"), alerts.EnumerationPhase)}}, + wantAlerts: alerter.Alerts{"google_type": []alerter.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteGoogleTerraform, remoteerr.NewResourceListingErrorWithType(status.Error(codes.PermissionDenied, "useless message"), "google_type", "google_type"), alerts.EnumerationPhase)}}, wantErr: false, }, { name: "Not handled non 403 error", err: status.Error(codes.Unknown, ""), - wantAlerts: map[string][]alerter2.Alert{}, + wantAlerts: map[string][]alerter.Alert{}, wantErr: true, }, { name: "Not Handled error type", err: errors.New("error"), - wantAlerts: map[string][]alerter2.Alert{}, + wantAlerts: map[string][]alerter.Alert{}, wantErr: true, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - alertr := alerter2.NewAlerter() + alertr := alerter.NewAlerter() gotErr := HandleResourceEnumerationError(tt.err, alertr) assert.Equal(t, tt.wantErr, gotErr != nil) @@ -167,43 +167,43 @@ func TestHandleAwsDetailsFetchingErrors(t *testing.T) { tests := []struct { name string err error - wantAlerts alerter2.Alerts + wantAlerts alerter.Alerts wantErr bool }{ { name: "Handle AccessDeniedException error", err: remoteerr.NewResourceListingError(awserr.NewRequestFailure(awserr.New("AccessDeniedException", "test", errors.New("")), 403, ""), resourceaws.AwsVpcResourceType), - wantAlerts: alerter2.Alerts{"aws_vpc": []alerter2.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awserr.NewRequestFailure(awserr.New("AccessDeniedException", "test", errors.New("")), 403, ""), "aws_vpc", "aws_vpc"), alerts.DetailsFetchingPhase)}}, + wantAlerts: alerter.Alerts{"aws_vpc": []alerter.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awserr.NewRequestFailure(awserr.New("AccessDeniedException", "test", errors.New("")), 403, ""), "aws_vpc", "aws_vpc"), alerts.DetailsFetchingPhase)}}, wantErr: false, }, { name: "Handle AccessDenied error", err: remoteerr.NewResourceListingError(awserr.NewRequestFailure(awserr.New("test", "error: AccessDenied", errors.New("")), 403, ""), resourceaws.AwsVpcResourceType), - wantAlerts: alerter2.Alerts{"aws_vpc": []alerter2.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awserr.NewRequestFailure(awserr.New("test", "error: AccessDenied", errors.New("")), 403, ""), "aws_vpc", "aws_vpc"), alerts.DetailsFetchingPhase)}}, + wantAlerts: alerter.Alerts{"aws_vpc": []alerter.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awserr.NewRequestFailure(awserr.New("test", "error: AccessDenied", errors.New("")), 403, ""), "aws_vpc", "aws_vpc"), alerts.DetailsFetchingPhase)}}, wantErr: false, }, { name: "Handle AuthorizationError error", err: remoteerr.NewResourceListingError(awserr.NewRequestFailure(awserr.New("test", "error: AuthorizationError", errors.New("")), 403, ""), resourceaws.AwsVpcResourceType), - wantAlerts: alerter2.Alerts{"aws_vpc": []alerter2.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awserr.NewRequestFailure(awserr.New("test", "error: AuthorizationError", errors.New("")), 403, ""), "aws_vpc", "aws_vpc"), alerts.DetailsFetchingPhase)}}, + wantAlerts: alerter.Alerts{"aws_vpc": []alerter.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awserr.NewRequestFailure(awserr.New("test", "error: AuthorizationError", errors.New("")), 403, ""), "aws_vpc", "aws_vpc"), alerts.DetailsFetchingPhase)}}, wantErr: false, }, { name: "Unhandled error", err: remoteerr.NewResourceListingError(awserr.NewRequestFailure(awserr.New("test", "error: dummy error", errors.New("")), 403, ""), resourceaws.AwsVpcResourceType), - wantAlerts: alerter2.Alerts{}, + wantAlerts: alerter.Alerts{}, wantErr: true, }, { name: "Not Handled error type", err: errors.New("error"), - wantAlerts: map[string][]alerter2.Alert{}, + wantAlerts: map[string][]alerter.Alert{}, wantErr: true, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - alertr := alerter2.NewAlerter() + alertr := alerter.NewAlerter() gotErr := HandleResourceDetailsFetchingError(tt.err, alertr) assert.Equal(t, tt.wantErr, gotErr != nil) @@ -219,7 +219,7 @@ func TestHandleGoogleDetailsFetchingErrors(t *testing.T) { tests := []struct { name string err error - wantAlerts alerter2.Alerts + wantAlerts alerter.Alerts wantErr bool }{ { @@ -229,7 +229,7 @@ func TestHandleGoogleDetailsFetchingErrors(t *testing.T) { "google_type", "resource_id", ), - wantAlerts: alerter2.Alerts{"google_type.resource_id": []alerter2.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteGoogleTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Error when reading or editing Storage Bucket \"driftctl-unittest-1\": googleapi: Error 403: driftctl@elie-dev.iam.gserviceaccount.com does not have storage.buckets.get access to the Google Cloud Storage bucket., forbidden"), "google_type.resource_id", "google_type"), alerts.DetailsFetchingPhase)}}, + wantAlerts: alerter.Alerts{"google_type.resource_id": []alerter.Alert{alerts.NewRemoteAccessDeniedAlert(common.RemoteGoogleTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("Error when reading or editing Storage Bucket \"driftctl-unittest-1\": googleapi: Error 403: driftctl@elie-dev.iam.gserviceaccount.com does not have storage.buckets.get access to the Google Cloud Storage bucket., forbidden"), "google_type.resource_id", "google_type"), alerts.DetailsFetchingPhase)}}, wantErr: false, }, { @@ -238,7 +238,7 @@ func TestHandleGoogleDetailsFetchingErrors(t *testing.T) { errors.New("this string does not contains g o o g l e a p i string and thus should not be matched"), "google_type", "resource_id", - ), wantAlerts: alerter2.Alerts{}, + ), wantAlerts: alerter.Alerts{}, wantErr: true, }, { @@ -247,19 +247,19 @@ func TestHandleGoogleDetailsFetchingErrors(t *testing.T) { errors.New("Error when reading or editing Storage Bucket \"driftctl-unittest-1\": googleapi: Error 404: not found"), "google_type", "resource_id", - ), wantAlerts: alerter2.Alerts{}, + ), wantAlerts: alerter.Alerts{}, wantErr: true, }, { name: "Not Handled error type", err: errors.New("error"), - wantAlerts: map[string][]alerter2.Alert{}, + wantAlerts: map[string][]alerter.Alert{}, wantErr: true, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - alertr := alerter2.NewAlerter() + alertr := alerter.NewAlerter() gotErr := HandleResourceDetailsFetchingError(tt.err, alertr) assert.Equal(t, tt.wantErr, gotErr != nil)