From dd181a0a295622d982a2555c1c7751b1c6223f31 Mon Sep 17 00:00:00 2001 From: Nikita Melkozerov Date: Tue, 8 Oct 2024 13:58:09 +0000 Subject: [PATCH] remove default arn --- plugins/aws/fix_plugin_aws/resource/backup.py | 4 ++-- plugins/aws/fix_plugin_aws/resource/dynamodb.py | 8 ++++---- plugins/aws/fix_plugin_aws/resource/efs.py | 4 ++-- plugins/aws/fix_plugin_aws/resource/kms.py | 4 ++-- plugins/aws/fix_plugin_aws/resource/lambda_.py | 4 ++-- plugins/aws/fix_plugin_aws/resource/secretsmanager.py | 4 ++-- plugins/aws/fix_plugin_aws/resource/sns.py | 4 ++-- plugins/aws/fix_plugin_aws/resource/sqs.py | 4 ++-- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/plugins/aws/fix_plugin_aws/resource/backup.py b/plugins/aws/fix_plugin_aws/resource/backup.py index 0e52e23fb5..cbb18e9834 100644 --- a/plugins/aws/fix_plugin_aws/resource/backup.py +++ b/plugins/aws/fix_plugin_aws/resource/backup.py @@ -342,10 +342,10 @@ class AwsBackupVault(BackupResourceTaggable, AwsResource, HasResourcePolicy): vault_policy: Optional[Json] = field(default=None) def resource_policy(self, builder: Any) -> List[Tuple[PolicySource, Dict[str, Any]]]: - if not self.vault_policy: + if not self.vault_policy or not self.arn: return [] - return [(PolicySource(PolicySourceKind.resource, uri=self.arn or ""), self.vault_policy or {})] + return [(PolicySource(PolicySourceKind.resource, uri=self.arn), self.vault_policy)] @classmethod def called_collect_apis(cls) -> List[AwsApiSpec]: diff --git a/plugins/aws/fix_plugin_aws/resource/dynamodb.py b/plugins/aws/fix_plugin_aws/resource/dynamodb.py index 9b3f00f209..c7bbfbf4fb 100644 --- a/plugins/aws/fix_plugin_aws/resource/dynamodb.py +++ b/plugins/aws/fix_plugin_aws/resource/dynamodb.py @@ -420,9 +420,9 @@ class AwsDynamoDbTable(DynamoDbTaggable, AwsResource, HasResourcePolicy): dynamodb_policy: Optional[Json] = field(default=None) def resource_policy(self, builder: Any) -> List[Tuple[PolicySource, Dict[str, Any]]]: - if not self.dynamodb_policy: + if not self.dynamodb_policy or not self.arn: return [] - return [(PolicySource(PolicySourceKind.resource, self.arn or ""), self.dynamodb_policy)] + return [(PolicySource(PolicySourceKind.resource, self.arn), self.dynamodb_policy)] @classmethod def called_collect_apis(cls) -> List[AwsApiSpec]: @@ -531,10 +531,10 @@ class AwsDynamoDbGlobalTable(DynamoDbTaggable, AwsResource, HasResourcePolicy): dynamodb_policy: Optional[Json] = field(default=None) def resource_policy(self, builder: Any) -> List[Tuple[PolicySource, Dict[str, Any]]]: - if not self.dynamodb_policy: + if not self.dynamodb_policy or not self.arn: return [] - return [(PolicySource(PolicySourceKind.resource, self.arn or ""), self.dynamodb_policy)] + return [(PolicySource(PolicySourceKind.resource, self.arn), self.dynamodb_policy)] @classmethod def called_collect_apis(cls) -> List[AwsApiSpec]: diff --git a/plugins/aws/fix_plugin_aws/resource/efs.py b/plugins/aws/fix_plugin_aws/resource/efs.py index 927b5c7c5a..50c7fc10b5 100644 --- a/plugins/aws/fix_plugin_aws/resource/efs.py +++ b/plugins/aws/fix_plugin_aws/resource/efs.py @@ -117,10 +117,10 @@ class AwsEfsFileSystem(EfsTaggable, AwsResource, BaseNetworkShare, HasResourcePo file_system_policy: Optional[Json] = field(default=None) def resource_policy(self, builder: Any) -> List[Tuple[PolicySource, Dict[str, Any]]]: - if not self.file_system_policy: + if not self.file_system_policy or not self.arn: return [] - return [(PolicySource(PolicySourceKind.resource, self.arn or ""), self.file_system_policy or {})] + return [(PolicySource(PolicySourceKind.resource, self.arn), self.file_system_policy)] @classmethod def called_collect_apis(cls) -> List[AwsApiSpec]: diff --git a/plugins/aws/fix_plugin_aws/resource/kms.py b/plugins/aws/fix_plugin_aws/resource/kms.py index fea96b5b14..34db963bd9 100644 --- a/plugins/aws/fix_plugin_aws/resource/kms.py +++ b/plugins/aws/fix_plugin_aws/resource/kms.py @@ -122,9 +122,9 @@ class AwsKmsKey(AwsResource, BaseAccessKey, HasResourcePolicy): kms_key_policy: Optional[Json] = field(default=None) def resource_policy(self, builder: Any) -> List[Tuple[PolicySource, Dict[str, Any]]]: - if not self.kms_key_policy: + if not self.kms_key_policy or not self.arn: return [] - return [(PolicySource(PolicySourceKind.resource, self.arn or ""), self.kms_key_policy or {})] + return [(PolicySource(PolicySourceKind.resource, self.arn), self.kms_key_policy)] @classmethod def called_collect_apis(cls) -> List[AwsApiSpec]: diff --git a/plugins/aws/fix_plugin_aws/resource/lambda_.py b/plugins/aws/fix_plugin_aws/resource/lambda_.py index 3ff2445b09..caa2da3f6b 100644 --- a/plugins/aws/fix_plugin_aws/resource/lambda_.py +++ b/plugins/aws/fix_plugin_aws/resource/lambda_.py @@ -284,10 +284,10 @@ class AwsLambdaFunction(AwsResource, BaseServerlessFunction, HasResourcePolicy): function_url_config: Optional[AwsLambdaFunctionUrlConfig] = field(default=None) def resource_policy(self, builder: Any) -> List[Tuple[PolicySource, Dict[str, Any]]]: - if not self.function_policy: + if not self.function_policy or not self.arn: return [] - return [(PolicySource(PolicySourceKind.resource, self.arn or ""), self.function_policy)] + return [(PolicySource(PolicySourceKind.resource, self.arn), self.function_policy)] @classmethod def called_collect_apis(cls) -> List[AwsApiSpec]: diff --git a/plugins/aws/fix_plugin_aws/resource/secretsmanager.py b/plugins/aws/fix_plugin_aws/resource/secretsmanager.py index 632d8dc220..e79f52a172 100644 --- a/plugins/aws/fix_plugin_aws/resource/secretsmanager.py +++ b/plugins/aws/fix_plugin_aws/resource/secretsmanager.py @@ -77,10 +77,10 @@ class AwsSecretsManagerSecret(HasResourcePolicy, AwsResource): policy: Optional[Json] = field(default=None) def resource_policy(self, builder: Any) -> List[Tuple[PolicySource, Dict[str, Any]]]: - if not self.policy: + if not self.policy or not self.arn: return [] - return [(PolicySource(PolicySourceKind.resource, self.arn or ""), self.policy)] + return [(PolicySource(PolicySourceKind.resource, self.arn), self.policy)] @classmethod def called_collect_apis(cls) -> List[AwsApiSpec]: diff --git a/plugins/aws/fix_plugin_aws/resource/sns.py b/plugins/aws/fix_plugin_aws/resource/sns.py index 6b6448e590..6a22292149 100644 --- a/plugins/aws/fix_plugin_aws/resource/sns.py +++ b/plugins/aws/fix_plugin_aws/resource/sns.py @@ -59,10 +59,10 @@ class AwsSnsTopic(AwsResource, HasResourcePolicy): topic_content_based_deduplication: Optional[bool] = field(default=None) def resource_policy(self, builder: Any) -> List[Tuple[PolicySource, Dict[str, Any]]]: - if not self.topic_policy: + if not self.topic_policy or not self.arn: return [] - return [(PolicySource(PolicySourceKind.resource, self.arn or ""), self.topic_policy)] + return [(PolicySource(PolicySourceKind.resource, self.arn), self.topic_policy)] @classmethod def called_collect_apis(cls) -> List[AwsApiSpec]: diff --git a/plugins/aws/fix_plugin_aws/resource/sqs.py b/plugins/aws/fix_plugin_aws/resource/sqs.py index 9495fd5487..ebaa8923be 100644 --- a/plugins/aws/fix_plugin_aws/resource/sqs.py +++ b/plugins/aws/fix_plugin_aws/resource/sqs.py @@ -104,10 +104,10 @@ class AwsSqsQueue(AwsResource, BaseQueue, HasResourcePolicy): sqs_managed_sse_enabled: Optional[bool] = field(default=None) def resource_policy(self, builder: Any) -> List[Tuple[PolicySource, Dict[str, Any]]]: - if not self.sqs_policy: + if not self.sqs_policy or not self.arn: return [] - return [(PolicySource(PolicySourceKind.resource, self.arn or ""), self.sqs_policy)] + return [(PolicySource(PolicySourceKind.resource, self.arn), self.sqs_policy)] @classmethod def called_collect_apis(cls) -> List[AwsApiSpec]: