Merge branch 'prowler-cloud:master' into master

This commit is contained in:
Greg Hendrickson
2024-03-12 02:15:46 -07:00
committed by GitHub
2 changed files with 37 additions and 21 deletions

View File

@@ -2,6 +2,8 @@ from unittest import mock
from prowler.providers.aws.services.glue.glue_service import CatalogEncryptionSetting from prowler.providers.aws.services.glue.glue_service import CatalogEncryptionSetting
from tests.providers.aws.audit_info_utils import ( from tests.providers.aws.audit_info_utils import (
AWS_ACCOUNT_NUMBER,
AWS_COMMERCIAL_PARTITION,
AWS_REGION_US_EAST_1, AWS_REGION_US_EAST_1,
set_mocked_aws_audit_info, set_mocked_aws_audit_info,
) )
@@ -40,8 +42,8 @@ class Test_glue_data_catalogs_connection_passwords_encryption_enabled:
password_kms_id=None, password_kms_id=None,
) )
] ]
glue_client.audited_account = "12345678912" glue_client.audited_account = AWS_ACCOUNT_NUMBER
glue_client.audited_partition = "aws" glue_client.audited_partition = AWS_COMMERCIAL_PARTITION
glue_client.region = AWS_REGION_US_EAST_1 glue_client.region = AWS_REGION_US_EAST_1
glue_client.data_catalog_arn_template = f"arn:{glue_client.audited_partition}:glue:{glue_client.region}:{glue_client.audited_account}:data-catalog" glue_client.data_catalog_arn_template = f"arn:{glue_client.audited_partition}:glue:{glue_client.region}:{glue_client.audited_account}:data-catalog"
glue_client.__get_data_catalog_arn_template__ = mock.MagicMock( glue_client.__get_data_catalog_arn_template__ = mock.MagicMock(
@@ -65,7 +67,8 @@ class Test_glue_data_catalogs_connection_passwords_encryption_enabled:
result[0].status_extended result[0].status_extended
== "Glue data catalog connection password is not encrypted." == "Glue data catalog connection password is not encrypted."
) )
assert result[0].resource_id == "12345678912" assert result[0].resource_id == AWS_ACCOUNT_NUMBER
assert result[0].resource_arn == glue_client.data_catalog_arn_template
assert result[0].region == AWS_REGION_US_EAST_1 assert result[0].region == AWS_REGION_US_EAST_1
def test_glue_catalog_password_unencrypted_ignoring(self): def test_glue_catalog_password_unencrypted_ignoring(self):
@@ -81,8 +84,8 @@ class Test_glue_data_catalogs_connection_passwords_encryption_enabled:
password_kms_id=None, password_kms_id=None,
) )
] ]
glue_client.audited_account = "12345678912" glue_client.audited_account = AWS_ACCOUNT_NUMBER
glue_client.audited_partition = "aws" glue_client.audited_partition = AWS_COMMERCIAL_PARTITION
glue_client.region = AWS_REGION_US_EAST_1 glue_client.region = AWS_REGION_US_EAST_1
glue_client.data_catalog_arn_template = f"arn:{glue_client.audited_partition}:glue:{glue_client.region}:{glue_client.audited_account}:data-catalog" glue_client.data_catalog_arn_template = f"arn:{glue_client.audited_partition}:glue:{glue_client.region}:{glue_client.audited_account}:data-catalog"
glue_client.__get_data_catalog_arn_template__ = mock.MagicMock( glue_client.__get_data_catalog_arn_template__ = mock.MagicMock(
@@ -116,9 +119,9 @@ class Test_glue_data_catalogs_connection_passwords_encryption_enabled:
password_kms_id=None, password_kms_id=None,
) )
] ]
glue_client.audited_account = "12345678912" glue_client.audited_partition = AWS_COMMERCIAL_PARTITION
glue_client.audited_partition = "aws"
glue_client.region = AWS_REGION_US_EAST_1 glue_client.region = AWS_REGION_US_EAST_1
glue_client.audited_account = AWS_ACCOUNT_NUMBER
glue_client.data_catalog_arn_template = f"arn:{glue_client.audited_partition}:glue:{glue_client.region}:{glue_client.audited_account}:data-catalog" glue_client.data_catalog_arn_template = f"arn:{glue_client.audited_partition}:glue:{glue_client.region}:{glue_client.audited_account}:data-catalog"
glue_client.__get_data_catalog_arn_template__ = mock.MagicMock( glue_client.__get_data_catalog_arn_template__ = mock.MagicMock(
return_value=glue_client.data_catalog_arn_template return_value=glue_client.data_catalog_arn_template
@@ -142,7 +145,8 @@ class Test_glue_data_catalogs_connection_passwords_encryption_enabled:
result[0].status_extended result[0].status_extended
== "Glue data catalog connection password is not encrypted." == "Glue data catalog connection password is not encrypted."
) )
assert result[0].resource_id == "12345678912" assert result[0].resource_id == AWS_ACCOUNT_NUMBER
assert result[0].resource_arn == glue_client.data_catalog_arn_template
assert result[0].region == AWS_REGION_US_EAST_1 assert result[0].region == AWS_REGION_US_EAST_1
def test_glue_catalog_encrypted(self): def test_glue_catalog_encrypted(self):
@@ -157,7 +161,13 @@ class Test_glue_data_catalogs_connection_passwords_encryption_enabled:
password_kms_id="kms-key", password_kms_id="kms-key",
) )
] ]
glue_client.audited_account = "12345678912" glue_client.audited_partition = AWS_COMMERCIAL_PARTITION
glue_client.region = AWS_REGION_US_EAST_1
glue_client.audited_account = AWS_ACCOUNT_NUMBER
glue_client.data_catalog_arn_template = f"arn:{glue_client.audited_partition}:glue:{glue_client.region}:{glue_client.audited_account}:data-catalog"
glue_client.__get_data_catalog_arn_template__ = mock.MagicMock(
return_value=glue_client.data_catalog_arn_template
)
with mock.patch( with mock.patch(
"prowler.providers.aws.services.glue.glue_service.Glue", "prowler.providers.aws.services.glue.glue_service.Glue",
@@ -177,5 +187,6 @@ class Test_glue_data_catalogs_connection_passwords_encryption_enabled:
result[0].status_extended result[0].status_extended
== "Glue data catalog connection password is encrypted with KMS key kms-key." == "Glue data catalog connection password is encrypted with KMS key kms-key."
) )
assert result[0].resource_id == "12345678912" assert result[0].resource_id == AWS_ACCOUNT_NUMBER
assert result[0].resource_arn == glue_client.data_catalog_arn_template
assert result[0].region == AWS_REGION_US_EAST_1 assert result[0].region == AWS_REGION_US_EAST_1

View File

@@ -3,6 +3,8 @@ from unittest import mock
from prowler.providers.aws.services.glue.glue_service import CatalogEncryptionSetting from prowler.providers.aws.services.glue.glue_service import CatalogEncryptionSetting
from tests.providers.aws.audit_info_utils import ( from tests.providers.aws.audit_info_utils import (
AWS_ACCOUNT_NUMBER,
AWS_COMMERCIAL_PARTITION,
AWS_REGION_US_EAST_1, AWS_REGION_US_EAST_1,
set_mocked_aws_audit_info, set_mocked_aws_audit_info,
) )
@@ -41,9 +43,9 @@ class Test_glue_data_catalogs_metadata_encryption_enabled:
password_kms_id=None, password_kms_id=None,
) )
] ]
glue_client.audited_account = "12345678912"
glue_client.audited_partition = "aws"
glue_client.region = AWS_REGION_US_EAST_1 glue_client.region = AWS_REGION_US_EAST_1
glue_client.audited_account = AWS_ACCOUNT_NUMBER
glue_client.audited_partition = AWS_COMMERCIAL_PARTITION
glue_client.data_catalog_arn_template = f"arn:{glue_client.audited_partition}:glue:{glue_client.region}:{glue_client.audited_account}:data-catalog" glue_client.data_catalog_arn_template = f"arn:{glue_client.audited_partition}:glue:{glue_client.region}:{glue_client.audited_account}:data-catalog"
glue_client.__get_data_catalog_arn_template__ = mock.MagicMock( glue_client.__get_data_catalog_arn_template__ = mock.MagicMock(
return_value=glue_client.data_catalog_arn_template return_value=glue_client.data_catalog_arn_template
@@ -66,7 +68,8 @@ class Test_glue_data_catalogs_metadata_encryption_enabled:
result[0].status_extended result[0].status_extended
== "Glue data catalog settings have metadata encryption disabled." == "Glue data catalog settings have metadata encryption disabled."
) )
assert result[0].resource_id == "12345678912" assert result[0].resource_id == AWS_ACCOUNT_NUMBER
assert result[0].resource_arn == glue_client.data_catalog_arn_template
assert result[0].region == AWS_REGION_US_EAST_1 assert result[0].region == AWS_REGION_US_EAST_1
def test_glue_catalog_unencrypted_ignoring(self): def test_glue_catalog_unencrypted_ignoring(self):
@@ -82,10 +85,10 @@ class Test_glue_data_catalogs_metadata_encryption_enabled:
password_kms_id=None, password_kms_id=None,
) )
] ]
glue_client.audited_account = "12345678912"
glue_client.audit_info.ignore_unused_services = True glue_client.audit_info.ignore_unused_services = True
glue_client.audited_partition = "aws"
glue_client.region = AWS_REGION_US_EAST_1 glue_client.region = AWS_REGION_US_EAST_1
glue_client.audited_account = AWS_ACCOUNT_NUMBER
glue_client.audited_partition = AWS_COMMERCIAL_PARTITION
glue_client.data_catalog_arn_template = f"arn:{glue_client.audited_partition}:glue:{glue_client.region}:{glue_client.audited_account}:data-catalog" glue_client.data_catalog_arn_template = f"arn:{glue_client.audited_partition}:glue:{glue_client.region}:{glue_client.audited_account}:data-catalog"
glue_client.__get_data_catalog_arn_template__ = mock.MagicMock( glue_client.__get_data_catalog_arn_template__ = mock.MagicMock(
return_value=glue_client.data_catalog_arn_template return_value=glue_client.data_catalog_arn_template
@@ -117,10 +120,10 @@ class Test_glue_data_catalogs_metadata_encryption_enabled:
password_kms_id=None, password_kms_id=None,
) )
] ]
glue_client.audited_account = "12345678912"
glue_client.audit_info.ignore_unused_services = True glue_client.audit_info.ignore_unused_services = True
glue_client.audited_partition = "aws"
glue_client.region = AWS_REGION_US_EAST_1 glue_client.region = AWS_REGION_US_EAST_1
glue_client.audited_account = AWS_ACCOUNT_NUMBER
glue_client.audited_partition = AWS_COMMERCIAL_PARTITION
glue_client.data_catalog_arn_template = f"arn:{glue_client.audited_partition}:glue:{glue_client.region}:{glue_client.audited_account}:data-catalog" glue_client.data_catalog_arn_template = f"arn:{glue_client.audited_partition}:glue:{glue_client.region}:{glue_client.audited_account}:data-catalog"
glue_client.__get_data_catalog_arn_template__ = mock.MagicMock( glue_client.__get_data_catalog_arn_template__ = mock.MagicMock(
return_value=glue_client.data_catalog_arn_template return_value=glue_client.data_catalog_arn_template
@@ -143,7 +146,8 @@ class Test_glue_data_catalogs_metadata_encryption_enabled:
"Glue data catalog settings have metadata encryption disabled.", "Glue data catalog settings have metadata encryption disabled.",
result[0].status_extended, result[0].status_extended,
) )
assert result[0].resource_id == "12345678912" assert result[0].resource_id == AWS_ACCOUNT_NUMBER
assert result[0].resource_arn == glue_client.data_catalog_arn_template
assert result[0].region == AWS_REGION_US_EAST_1 assert result[0].region == AWS_REGION_US_EAST_1
def test_glue_catalog_encrypted(self): def test_glue_catalog_encrypted(self):
@@ -159,9 +163,9 @@ class Test_glue_data_catalogs_metadata_encryption_enabled:
password_kms_id=None, password_kms_id=None,
) )
] ]
glue_client.audited_account = "12345678912"
glue_client.audited_partition = "aws"
glue_client.region = AWS_REGION_US_EAST_1 glue_client.region = AWS_REGION_US_EAST_1
glue_client.audited_account = AWS_ACCOUNT_NUMBER
glue_client.audited_partition = AWS_COMMERCIAL_PARTITION
glue_client.data_catalog_arn_template = f"arn:{glue_client.audited_partition}:glue:{glue_client.region}:{glue_client.audited_account}:data-catalog" glue_client.data_catalog_arn_template = f"arn:{glue_client.audited_partition}:glue:{glue_client.region}:{glue_client.audited_account}:data-catalog"
glue_client.__get_data_catalog_arn_template__ = mock.MagicMock( glue_client.__get_data_catalog_arn_template__ = mock.MagicMock(
return_value=glue_client.data_catalog_arn_template return_value=glue_client.data_catalog_arn_template
@@ -184,5 +188,6 @@ class Test_glue_data_catalogs_metadata_encryption_enabled:
result[0].status_extended result[0].status_extended
== "Glue data catalog settings have metadata encryption enabled with KMS key kms-key." == "Glue data catalog settings have metadata encryption enabled with KMS key kms-key."
) )
assert result[0].resource_id == "12345678912" assert result[0].resource_id == AWS_ACCOUNT_NUMBER
assert result[0].resource_arn == glue_client.data_catalog_arn_template
assert result[0].region == AWS_REGION_US_EAST_1 assert result[0].region == AWS_REGION_US_EAST_1