mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-10 06:45:08 +00:00
chore(arn): include ARN of AWS accounts (#2477)
Co-authored-by: Pepe Fagoaga <pepe@verica.io>
This commit is contained in:
@@ -18,6 +18,7 @@ current_audit_info = AWS_Audit_Info(
|
||||
user_agent_extra=boto3_user_agent_extra,
|
||||
),
|
||||
audited_account=None,
|
||||
audited_account_arn=None,
|
||||
audited_user_id=None,
|
||||
audited_partition=None,
|
||||
audited_identity_arn=None,
|
||||
|
||||
@@ -37,6 +37,7 @@ class AWS_Audit_Info:
|
||||
# https://boto3.amazonaws.com/v1/documentation/api/latest/guide/retries.html
|
||||
session_config: Config
|
||||
audited_account: int
|
||||
audited_account_arn: str
|
||||
audited_identity_arn: str
|
||||
audited_user_id: str
|
||||
audited_partition: str
|
||||
|
||||
@@ -9,6 +9,7 @@ class account_maintain_current_contact_details(Check):
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.region = account_client.region
|
||||
report.resource_id = account_client.audited_account
|
||||
report.resource_arn = account_client.audited_account_arn
|
||||
report.status = "INFO"
|
||||
report.status_extended = "Manual check: Login to the AWS Console. Choose your account name on the top right of the window -> My Account -> Contact Information."
|
||||
return [report]
|
||||
|
||||
@@ -9,6 +9,7 @@ class account_security_contact_information_is_registered(Check):
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.region = account_client.region
|
||||
report.resource_id = account_client.audited_account
|
||||
report.resource_arn = account_client.audited_account_arn
|
||||
report.status = "INFO"
|
||||
report.status_extended = "Manual check: Login to the AWS Console. Choose your account name on the top right of the window -> My Account -> Alternate Contacts -> Security Section."
|
||||
return [report]
|
||||
|
||||
@@ -9,6 +9,7 @@ class account_security_questions_are_registered_in_the_aws_account(Check):
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.region = account_client.region
|
||||
report.resource_id = account_client.audited_account
|
||||
report.resource_arn = account_client.audited_account_arn
|
||||
report.status = "INFO"
|
||||
report.status_extended = "Manual check: Login to the AWS Console as root. Choose your account name on the top right of the window -> My Account -> Configure Security Challenge Questions."
|
||||
return [report]
|
||||
|
||||
@@ -7,6 +7,8 @@ class Account:
|
||||
self.service = "account"
|
||||
self.session = audit_info.audit_session
|
||||
self.audited_account = audit_info.audited_account
|
||||
self.audited_partition = audit_info.audited_partition
|
||||
self.audited_account_arn = audit_info.audited_account_arn
|
||||
self.regional_clients = generate_regional_clients(self.service, audit_info)
|
||||
# If the region is not set in the audit profile,
|
||||
# we pick the first region from the regional clients list
|
||||
|
||||
@@ -8,8 +8,8 @@ class backup_plans_exist(Check):
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.status = "FAIL"
|
||||
report.status_extended = "No Backup Plan Exist"
|
||||
report.resource_arn = ""
|
||||
report.resource_id = "Backups"
|
||||
report.resource_arn = backup_client.audited_account_arn
|
||||
report.resource_id = backup_client.audited_account
|
||||
report.region = backup_client.region
|
||||
if backup_client.backup_plans:
|
||||
report.status = "PASS"
|
||||
|
||||
@@ -10,8 +10,8 @@ class backup_reportplans_exist(Check):
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.status = "FAIL"
|
||||
report.status_extended = "No Backup Report Plan Exist"
|
||||
report.resource_arn = ""
|
||||
report.resource_id = "Backups"
|
||||
report.resource_arn = backup_client.audited_account_arn
|
||||
report.resource_id = backup_client.audited_account
|
||||
report.region = backup_client.region
|
||||
if backup_client.backup_report_plans:
|
||||
report.status = "PASS"
|
||||
|
||||
@@ -15,6 +15,8 @@ class Backup:
|
||||
self.service = "backup"
|
||||
self.session = audit_info.audit_session
|
||||
self.audited_account = audit_info.audited_account
|
||||
self.audited_partition = audit_info.audited_partition
|
||||
self.audited_account_arn = audit_info.audited_account_arn
|
||||
self.audit_resources = audit_info.audit_resources
|
||||
self.regional_clients = generate_regional_clients(self.service, audit_info)
|
||||
# If the region is not set in the audit profile,
|
||||
|
||||
@@ -8,8 +8,8 @@ class backup_vaults_exist(Check):
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.status = "FAIL"
|
||||
report.status_extended = "No Backup Vault Exist"
|
||||
report.resource_arn = ""
|
||||
report.resource_id = "Backups"
|
||||
report.resource_arn = backup_client.audited_account_arn
|
||||
report.resource_id = backup_client.audited_account
|
||||
report.region = backup_client.region
|
||||
if backup_client.backup_vaults:
|
||||
report.status = "PASS"
|
||||
|
||||
@@ -32,8 +32,8 @@ class cloudtrail_multi_region_enabled(Check):
|
||||
report.status_extended = (
|
||||
"No CloudTrail trails enabled and logging were found"
|
||||
)
|
||||
report.resource_arn = "No trails"
|
||||
report.resource_id = "No trails"
|
||||
report.resource_arn = cloudtrail_client.audited_account_arn
|
||||
report.resource_id = cloudtrail_client.audited_account
|
||||
# If there are no trails logging it is needed to store the FAIL once all the trails have been checked
|
||||
if report.status == "FAIL":
|
||||
findings.append(report)
|
||||
|
||||
@@ -9,8 +9,8 @@ class cloudtrail_s3_dataevents_read_enabled(Check):
|
||||
findings = []
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.region = cloudtrail_client.region
|
||||
report.resource_id = "No trails"
|
||||
report.resource_arn = "No trails"
|
||||
report.resource_arn = cloudtrail_client.audited_account_arn
|
||||
report.resource_id = cloudtrail_client.audited_account
|
||||
report.status = "FAIL"
|
||||
report.status_extended = "No CloudTrail trails have a data event to record all S3 object-level API operations."
|
||||
for trail in cloudtrail_client.trails:
|
||||
|
||||
@@ -9,8 +9,8 @@ class cloudtrail_s3_dataevents_write_enabled(Check):
|
||||
findings = []
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.region = cloudtrail_client.region
|
||||
report.resource_id = "No trails"
|
||||
report.resource_arn = "No trails"
|
||||
report.resource_arn = cloudtrail_client.audited_account_arn
|
||||
report.resource_id = cloudtrail_client.audited_account
|
||||
report.status = "FAIL"
|
||||
report.status_extended = "No CloudTrail trails have a data event to record all S3 object-level API operations."
|
||||
for trail in cloudtrail_client.trails:
|
||||
|
||||
@@ -16,8 +16,9 @@ class Cloudtrail:
|
||||
self.service = "cloudtrail"
|
||||
self.session = audit_info.audit_session
|
||||
self.audited_account = audit_info.audited_account
|
||||
self.audit_resources = audit_info.audit_resources
|
||||
self.audited_partition = audit_info.audited_partition
|
||||
self.audited_account_arn = audit_info.audited_account_arn
|
||||
self.audit_resources = audit_info.audit_resources
|
||||
self.regional_clients = generate_regional_clients(self.service, audit_info)
|
||||
# If the region is not set in the audit profile,
|
||||
# we pick the first region from the regional clients list
|
||||
|
||||
@@ -21,6 +21,7 @@ class cloudwatch_changes_to_network_acls_alarm_configured(Check):
|
||||
)
|
||||
report.region = cloudwatch_client.region
|
||||
report.resource_id = cloudtrail_client.audited_account
|
||||
report.resource_arn = cloudtrail_client.audited_account_arn
|
||||
# 1. Iterate for CloudWatch Log Group in CloudTrail trails
|
||||
log_groups = []
|
||||
for trail in cloudtrail_client.trails:
|
||||
|
||||
@@ -21,6 +21,7 @@ class cloudwatch_changes_to_network_gateways_alarm_configured(Check):
|
||||
)
|
||||
report.region = cloudwatch_client.region
|
||||
report.resource_id = cloudtrail_client.audited_account
|
||||
report.resource_arn = cloudtrail_client.audited_account_arn
|
||||
# 1. Iterate for CloudWatch Log Group in CloudTrail trails
|
||||
log_groups = []
|
||||
for trail in cloudtrail_client.trails:
|
||||
|
||||
@@ -21,6 +21,7 @@ class cloudwatch_changes_to_network_route_tables_alarm_configured(Check):
|
||||
)
|
||||
report.region = cloudwatch_client.region
|
||||
report.resource_id = cloudtrail_client.audited_account
|
||||
report.resource_arn = cloudtrail_client.audited_account_arn
|
||||
# 1. Iterate for CloudWatch Log Group in CloudTrail trails
|
||||
log_groups = []
|
||||
for trail in cloudtrail_client.trails:
|
||||
|
||||
@@ -21,6 +21,7 @@ class cloudwatch_changes_to_vpcs_alarm_configured(Check):
|
||||
)
|
||||
report.region = cloudwatch_client.region
|
||||
report.resource_id = cloudtrail_client.audited_account
|
||||
report.resource_arn = cloudtrail_client.audited_account_arn
|
||||
# 1. Iterate for CloudWatch Log Group in CloudTrail trails
|
||||
log_groups = []
|
||||
for trail in cloudtrail_client.trails:
|
||||
|
||||
@@ -7,12 +7,14 @@ class cloudwatch_cross_account_sharing_disabled(Check):
|
||||
findings = []
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.status = "PASS"
|
||||
report.status_extended = "CloudWatch doesn't allows cross-account sharing"
|
||||
report.resource_id = "CloudWatch-CrossAccountSharingRole"
|
||||
report.status_extended = "CloudWatch doesn't allow cross-account sharing"
|
||||
report.resource_arn = iam_client.account_arn
|
||||
report.resource_id = iam_client.account
|
||||
report.region = iam_client.region
|
||||
for role in iam_client.roles:
|
||||
if role.name == "CloudWatch-CrossAccountSharingRole":
|
||||
report.resource_arn = role.arn
|
||||
report.resource_id = role.name
|
||||
report.status = "FAIL"
|
||||
report.status_extended = "CloudWatch has allowed cross-account sharing."
|
||||
findings.append(report)
|
||||
|
||||
@@ -23,6 +23,7 @@ class cloudwatch_log_metric_filter_and_alarm_for_aws_config_configuration_change
|
||||
)
|
||||
report.region = cloudwatch_client.region
|
||||
report.resource_id = cloudtrail_client.audited_account
|
||||
report.resource_arn = cloudtrail_client.audited_account_arn
|
||||
# 1. Iterate for CloudWatch Log Group in CloudTrail trails
|
||||
log_groups = []
|
||||
for trail in cloudtrail_client.trails:
|
||||
|
||||
@@ -23,6 +23,7 @@ class cloudwatch_log_metric_filter_and_alarm_for_cloudtrail_configuration_change
|
||||
)
|
||||
report.region = cloudwatch_client.region
|
||||
report.resource_id = cloudtrail_client.audited_account
|
||||
report.resource_arn = cloudtrail_client.audited_account_arn
|
||||
# 1. Iterate for CloudWatch Log Group in CloudTrail trails
|
||||
log_groups = []
|
||||
for trail in cloudtrail_client.trails:
|
||||
|
||||
@@ -21,6 +21,7 @@ class cloudwatch_log_metric_filter_authentication_failures(Check):
|
||||
)
|
||||
report.region = cloudwatch_client.region
|
||||
report.resource_id = cloudtrail_client.audited_account
|
||||
report.resource_arn = cloudtrail_client.audited_account_arn
|
||||
# 1. Iterate for CloudWatch Log Group in CloudTrail trails
|
||||
log_groups = []
|
||||
for trail in cloudtrail_client.trails:
|
||||
|
||||
@@ -21,6 +21,7 @@ class cloudwatch_log_metric_filter_aws_organizations_changes(Check):
|
||||
)
|
||||
report.region = cloudwatch_client.region
|
||||
report.resource_id = cloudtrail_client.audited_account
|
||||
report.resource_arn = cloudtrail_client.audited_account_arn
|
||||
# 1. Iterate for CloudWatch Log Group in CloudTrail trails
|
||||
log_groups = []
|
||||
for trail in cloudtrail_client.trails:
|
||||
|
||||
@@ -21,6 +21,7 @@ class cloudwatch_log_metric_filter_disable_or_scheduled_deletion_of_kms_cmk(Chec
|
||||
)
|
||||
report.region = cloudwatch_client.region
|
||||
report.resource_id = cloudtrail_client.audited_account
|
||||
report.resource_arn = cloudtrail_client.audited_account_arn
|
||||
# 1. Iterate for CloudWatch Log Group in CloudTrail trails
|
||||
log_groups = []
|
||||
for trail in cloudtrail_client.trails:
|
||||
|
||||
@@ -21,6 +21,7 @@ class cloudwatch_log_metric_filter_for_s3_bucket_policy_changes(Check):
|
||||
)
|
||||
report.region = cloudwatch_client.region
|
||||
report.resource_id = cloudtrail_client.audited_account
|
||||
report.resource_arn = cloudtrail_client.audited_account_arn
|
||||
# 1. Iterate for CloudWatch Log Group in CloudTrail trails
|
||||
log_groups = []
|
||||
for trail in cloudtrail_client.trails:
|
||||
|
||||
@@ -21,6 +21,7 @@ class cloudwatch_log_metric_filter_policy_changes(Check):
|
||||
)
|
||||
report.region = cloudwatch_client.region
|
||||
report.resource_id = cloudtrail_client.audited_account
|
||||
report.resource_arn = cloudtrail_client.audited_account_arn
|
||||
# 1. Iterate for CloudWatch Log Group in CloudTrail trails
|
||||
log_groups = []
|
||||
for trail in cloudtrail_client.trails:
|
||||
|
||||
@@ -21,6 +21,7 @@ class cloudwatch_log_metric_filter_root_usage(Check):
|
||||
)
|
||||
report.region = cloudwatch_client.region
|
||||
report.resource_id = cloudtrail_client.audited_account
|
||||
report.resource_arn = cloudtrail_client.audited_account_arn
|
||||
# 1. Iterate for CloudWatch Log Group in CloudTrail trails
|
||||
log_groups = []
|
||||
for trail in cloudtrail_client.trails:
|
||||
|
||||
@@ -21,6 +21,7 @@ class cloudwatch_log_metric_filter_security_group_changes(Check):
|
||||
)
|
||||
report.region = cloudwatch_client.region
|
||||
report.resource_id = cloudtrail_client.audited_account
|
||||
report.resource_arn = cloudtrail_client.audited_account_arn
|
||||
# 1. Iterate for CloudWatch Log Group in CloudTrail trails
|
||||
log_groups = []
|
||||
for trail in cloudtrail_client.trails:
|
||||
|
||||
@@ -21,6 +21,7 @@ class cloudwatch_log_metric_filter_sign_in_without_mfa(Check):
|
||||
)
|
||||
report.region = cloudwatch_client.region
|
||||
report.resource_id = cloudtrail_client.audited_account
|
||||
report.resource_arn = cloudtrail_client.audited_account_arn
|
||||
# 1. Iterate for CloudWatch Log Group in CloudTrail trails
|
||||
log_groups = []
|
||||
for trail in cloudtrail_client.trails:
|
||||
|
||||
@@ -21,6 +21,7 @@ class cloudwatch_log_metric_filter_unauthorized_api_calls(Check):
|
||||
)
|
||||
report.region = cloudwatch_client.region
|
||||
report.resource_id = cloudtrail_client.audited_account
|
||||
report.resource_arn = cloudtrail_client.audited_account_arn
|
||||
# 1. Iterate for CloudWatch Log Group in CloudTrail trails
|
||||
log_groups = []
|
||||
for trail in cloudtrail_client.trails:
|
||||
|
||||
@@ -8,7 +8,12 @@ class config_recorder_all_regions_enabled(Check):
|
||||
for recorder in config_client.recorders:
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.region = recorder.region
|
||||
report.resource_id = "" if not recorder.name else recorder.name
|
||||
report.resource_arn = (
|
||||
config_client.audited_account_arn
|
||||
) # Config Recorders do not have ARNs
|
||||
report.resource_id = (
|
||||
config_client.audited_account if not recorder.name else recorder.name
|
||||
)
|
||||
# Check if Config is enabled in region
|
||||
if not recorder.name:
|
||||
report.status = "FAIL"
|
||||
|
||||
@@ -14,6 +14,8 @@ class Config:
|
||||
self.service = "config"
|
||||
self.session = audit_info.audit_session
|
||||
self.audited_account = audit_info.audited_account
|
||||
self.audited_partition = audit_info.audited_partition
|
||||
self.audited_account_arn = audit_info.audited_account_arn
|
||||
self.audit_resources = audit_info.audit_resources
|
||||
self.regional_clients = generate_regional_clients(self.service, audit_info)
|
||||
self.recorders = []
|
||||
|
||||
@@ -9,10 +9,10 @@ class drs_job_exist(Check):
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.status = "FAIL"
|
||||
report.status_extended = "DRS is not enabled for this region."
|
||||
report.resource_id = drs.id
|
||||
report.region = drs.region
|
||||
report.resource_tags = []
|
||||
report.resource_arn = ""
|
||||
report.resource_arn = drs_client.audited_account_arn
|
||||
report.resource_id = drs_client.audited_account
|
||||
if drs.status == "ENABLED":
|
||||
report.status_extended = "DRS is enabled for this region without jobs."
|
||||
if drs.jobs:
|
||||
|
||||
@@ -16,6 +16,7 @@ class DRS:
|
||||
self.session = audit_info.audit_session
|
||||
self.audited_account = audit_info.audited_account
|
||||
self.audited_partition = audit_info.audited_partition
|
||||
self.audited_account_arn = audit_info.audited_account_arn
|
||||
self.audit_resources = audit_info.audit_resources
|
||||
self.regional_clients = generate_regional_clients(self.service, audit_info)
|
||||
# If the region is not set in the audit profile,
|
||||
|
||||
@@ -8,7 +8,8 @@ class ec2_ebs_default_encryption(Check):
|
||||
for ebs_encryption in ec2_client.ebs_encryption_by_default:
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.region = ebs_encryption.region
|
||||
report.resource_id = "EBS Default Encryption"
|
||||
report.resource_arn = ec2_client.audited_account_arn
|
||||
report.resource_id = ec2_client.audited_account
|
||||
report.status = "FAIL"
|
||||
report.status_extended = "EBS Default Encryption is not activated."
|
||||
if ebs_encryption.status:
|
||||
|
||||
@@ -17,6 +17,7 @@ class EC2:
|
||||
self.session = audit_info.audit_session
|
||||
self.audited_partition = audit_info.audited_partition
|
||||
self.audited_account = audit_info.audited_account
|
||||
self.audited_account_arn = audit_info.audited_account_arn
|
||||
self.audit_resources = audit_info.audit_resources
|
||||
self.regional_clients = generate_regional_clients(self.service, audit_info)
|
||||
self.instances = []
|
||||
|
||||
@@ -9,7 +9,7 @@ class emr_cluster_account_public_block_enabled(Check):
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.region = region
|
||||
report.resource_id = emr_client.audited_account
|
||||
|
||||
report.resource_arn = emr_client.audited_account_arn
|
||||
if emr_client.block_public_access_configuration[
|
||||
region
|
||||
].block_public_security_group_rules:
|
||||
|
||||
@@ -16,6 +16,8 @@ class EMR:
|
||||
self.service = "emr"
|
||||
self.session = audit_info.audit_session
|
||||
self.audited_account = audit_info.audited_account
|
||||
self.audited_partition = audit_info.audited_partition
|
||||
self.audited_account_arn = audit_info.audited_account_arn
|
||||
self.audit_resources = audit_info.audit_resources
|
||||
self.regional_clients = generate_regional_clients(self.service, audit_info)
|
||||
self.clusters = {}
|
||||
|
||||
@@ -7,8 +7,8 @@ class fms_policy_compliant(Check):
|
||||
findings = []
|
||||
if fms_client.fms_admin_account:
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.resource_id = "FMS"
|
||||
report.resource_arn = ""
|
||||
report.resource_arn = fms_client.audited_account_arn
|
||||
report.resource_id = fms_client.audited_account
|
||||
report.region = fms_client.region
|
||||
report.status = "PASS"
|
||||
report.status_extended = "FMS enabled with all compliant accounts"
|
||||
|
||||
@@ -13,6 +13,7 @@ class FMS:
|
||||
self.session = audit_info.audit_session
|
||||
self.audited_account = audit_info.audited_account
|
||||
self.audited_partition = audit_info.audited_partition
|
||||
self.audited_account_arn = audit_info.audited_account_arn
|
||||
self.audit_resources = audit_info.audit_resources
|
||||
global_client = generate_regional_clients(
|
||||
self.service, audit_info, global_service=True
|
||||
|
||||
@@ -8,6 +8,7 @@ class glue_data_catalogs_connection_passwords_encryption_enabled(Check):
|
||||
for encryption in glue_client.catalog_encryption_settings:
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.resource_id = glue_client.audited_account
|
||||
report.resource_arn = glue_client.audited_account_arn
|
||||
report.region = encryption.region
|
||||
report.status = "FAIL"
|
||||
report.status_extended = (
|
||||
|
||||
@@ -8,6 +8,7 @@ class glue_data_catalogs_metadata_encryption_enabled(Check):
|
||||
for encryption in glue_client.catalog_encryption_settings:
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.resource_id = glue_client.audited_account
|
||||
report.resource_arn = glue_client.audited_account_arn
|
||||
report.region = encryption.region
|
||||
report.status = "FAIL"
|
||||
report.status_extended = (
|
||||
|
||||
@@ -15,7 +15,8 @@ class Glue:
|
||||
self.session = audit_info.audit_session
|
||||
self.audited_account = audit_info.audited_account
|
||||
self.audit_resources = audit_info.audit_resources
|
||||
self.audited_partition = audit_info.audited_account
|
||||
self.audited_partition = audit_info.audited_partition
|
||||
self.audited_account_arn = audit_info.audited_account_arn
|
||||
self.regional_clients = generate_regional_clients(self.service, audit_info)
|
||||
self.connections = []
|
||||
self.__threading_call__(self.__get_connections__)
|
||||
|
||||
@@ -7,7 +7,8 @@ class iam_password_policy_expires_passwords_within_90_days_or_less(Check):
|
||||
findings = []
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.region = iam_client.region
|
||||
report.resource_id = "password_policy"
|
||||
report.resource_arn = iam_client.account_arn
|
||||
report.resource_id = iam_client.account
|
||||
# Check if password policy exists
|
||||
if iam_client.password_policy:
|
||||
# Check if password policy expiration exists
|
||||
|
||||
@@ -7,7 +7,8 @@ class iam_password_policy_lowercase(Check):
|
||||
findings = []
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.region = iam_client.region
|
||||
report.resource_id = "password_policy"
|
||||
report.resource_arn = iam_client.account_arn
|
||||
report.resource_id = iam_client.account
|
||||
# Check if password policy exists
|
||||
if iam_client.password_policy:
|
||||
# Check if lowercase flag is set
|
||||
|
||||
@@ -7,7 +7,8 @@ class iam_password_policy_minimum_length_14(Check):
|
||||
findings = []
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.region = iam_client.region
|
||||
report.resource_id = "password_policy"
|
||||
report.resource_arn = iam_client.account_arn
|
||||
report.resource_id = iam_client.account
|
||||
# Check if password policy exists
|
||||
if iam_client.password_policy:
|
||||
# Check password policy length
|
||||
|
||||
@@ -7,7 +7,8 @@ class iam_password_policy_number(Check):
|
||||
findings = []
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.region = iam_client.region
|
||||
report.resource_id = "password_policy"
|
||||
report.resource_arn = iam_client.account_arn
|
||||
report.resource_id = iam_client.account
|
||||
# Check if password policy exists
|
||||
if iam_client.password_policy:
|
||||
# Check if number flag is set
|
||||
|
||||
@@ -7,7 +7,8 @@ class iam_password_policy_reuse_24(Check):
|
||||
findings = []
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.region = iam_client.region
|
||||
report.resource_id = "password_policy"
|
||||
report.resource_arn = iam_client.account_arn
|
||||
report.resource_id = iam_client.account
|
||||
# Check if password policy exists
|
||||
if iam_client.password_policy:
|
||||
# Check if reuse prevention flag is set
|
||||
|
||||
@@ -7,7 +7,8 @@ class iam_password_policy_symbol(Check):
|
||||
findings = []
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.region = iam_client.region
|
||||
report.resource_id = "password_policy"
|
||||
report.resource_arn = iam_client.account_arn
|
||||
report.resource_id = iam_client.account
|
||||
# Check if password policy exists
|
||||
if iam_client.password_policy:
|
||||
# Check if symbol flag is set
|
||||
|
||||
@@ -7,7 +7,8 @@ class iam_password_policy_uppercase(Check):
|
||||
findings = []
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.region = iam_client.region
|
||||
report.resource_id = "password_policy"
|
||||
report.resource_arn = iam_client.account_arn
|
||||
report.resource_id = iam_client.account
|
||||
# Check if password policy exists
|
||||
if iam_client.password_policy:
|
||||
# Check if uppercase flag is set
|
||||
|
||||
@@ -11,8 +11,8 @@ class iam_root_hardware_mfa_enabled(Check):
|
||||
virtual_mfa = False
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.region = iam_client.region
|
||||
report.resource_id = "root"
|
||||
report.resource_arn = f"arn:aws:iam::{iam_client.account}:root"
|
||||
report.resource_id = "<root_account>"
|
||||
report.resource_arn = iam_client.account_arn
|
||||
|
||||
if iam_client.account_summary["SummaryMap"]["AccountMFAEnabled"] > 0:
|
||||
virtual_mfas = iam_client.virtual_mfa_devices
|
||||
|
||||
@@ -54,6 +54,7 @@ class IAM:
|
||||
self.account = audit_info.audited_account
|
||||
self.audit_resources = audit_info.audit_resources
|
||||
self.partition = audit_info.audited_partition
|
||||
self.account_arn = audit_info.audited_account_arn
|
||||
self.client = self.session.client(self.service)
|
||||
global_client = generate_regional_clients(
|
||||
self.service, audit_info, global_service=True
|
||||
|
||||
@@ -11,8 +11,8 @@ class inspector2_findings_exist(Check):
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.status = "FAIL"
|
||||
report.status_extended = "Inspector2 is not enabled."
|
||||
report.resource_id = inspector.id
|
||||
report.resource_arn = ""
|
||||
report.resource_id = inspector2_client.audited_account
|
||||
report.resource_arn = inspector2_client.audited_account_arn
|
||||
report.region = inspector.region
|
||||
if inspector.status == "ENABLED":
|
||||
active_findings = 0
|
||||
|
||||
@@ -13,8 +13,9 @@ class Inspector2:
|
||||
self.service = "inspector2"
|
||||
self.session = audit_info.audit_session
|
||||
self.audited_account = audit_info.audited_account
|
||||
self.audit_resources = audit_info.audit_resources
|
||||
self.audited_partition = audit_info.audited_partition
|
||||
self.audited_account_arn = audit_info.audited_account_arn
|
||||
self.audit_resources = audit_info.audit_resources
|
||||
self.regional_clients = generate_regional_clients(self.service, audit_info)
|
||||
# If the region is not set in the audit profile,
|
||||
# we pick the first region from the regional clients list
|
||||
|
||||
@@ -8,7 +8,8 @@ class macie_is_enabled(Check):
|
||||
for session in macie_client.sessions:
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.region = session.region
|
||||
report.resource_id = "Macie"
|
||||
report.resource_arn = macie_client.audited_account_arn
|
||||
report.resource_id = macie_client.audited_account
|
||||
if session.status == "ENABLED":
|
||||
report.status = "PASS"
|
||||
report.status_extended = "Macie is enabled."
|
||||
|
||||
@@ -12,6 +12,8 @@ class Macie:
|
||||
self.service = "macie2"
|
||||
self.session = audit_info.audit_session
|
||||
self.audited_account = audit_info.audited_account
|
||||
self.audited_partition = audit_info.audited_partition
|
||||
self.audited_account_arn = audit_info.audited_account_arn
|
||||
self.regional_clients = generate_regional_clients(self.service, audit_info)
|
||||
self.sessions = []
|
||||
self.__threading_call__(self.__get_macie_session__)
|
||||
|
||||
@@ -13,6 +13,7 @@ class resourceexplorer2_indexes_found(Check):
|
||||
report.region = resource_explorer_2_client.region
|
||||
report.resource_arn = "NoResourceExplorer"
|
||||
report.resource_id = resource_explorer_2_client.audited_account
|
||||
report.resource_arn = resource_explorer_2_client.audited_account_arn
|
||||
if resource_explorer_2_client.indexes:
|
||||
report.region = resource_explorer_2_client.indexes[0].region
|
||||
report.resource_arn = resource_explorer_2_client.indexes[0].arn
|
||||
|
||||
@@ -14,6 +14,8 @@ class ResourceExplorer2:
|
||||
self.session = audit_info.audit_session
|
||||
self.audit_resources = audit_info.audit_resources
|
||||
self.audited_account = audit_info.audited_account
|
||||
self.audited_partition = audit_info.audited_partition
|
||||
self.audited_account_arn = audit_info.audited_account_arn
|
||||
self.regional_clients = generate_regional_clients(self.service, audit_info)
|
||||
# If the region is not set in the audit profile,
|
||||
# we pick the first region from the regional clients list
|
||||
|
||||
@@ -11,6 +11,7 @@ class s3_account_level_public_access_blocks(Check):
|
||||
report.status_extended = f"Block Public Access is not configured for the account {s3_client.audited_account}."
|
||||
report.region = s3control_client.region
|
||||
report.resource_id = s3_client.audited_account
|
||||
report.resource_arn = s3_client.audited_account_arn
|
||||
if (
|
||||
s3control_client.account_public_access_block
|
||||
and s3control_client.account_public_access_block.ignore_public_acls
|
||||
|
||||
@@ -17,6 +17,7 @@ class s3_bucket_public_access(Check):
|
||||
report.status_extended = "All S3 public access blocked at account level."
|
||||
report.region = s3control_client.region
|
||||
report.resource_id = s3_client.audited_account
|
||||
report.resource_arn = s3_client.audited_account_arn
|
||||
findings.append(report)
|
||||
else:
|
||||
# 2. If public access is not blocked at account level, check it at each bucket level
|
||||
|
||||
@@ -19,6 +19,7 @@ class S3:
|
||||
self.audited_account = audit_info.audited_account
|
||||
self.audit_resources = audit_info.audit_resources
|
||||
self.audited_partition = audit_info.audited_partition
|
||||
self.audited_account_arn = audit_info.audited_account_arn
|
||||
self.regional_clients = generate_regional_clients(self.service, audit_info)
|
||||
self.buckets = self.__list_buckets__(audit_info)
|
||||
self.__threading_call__(self.__get_bucket_versioning__)
|
||||
|
||||
@@ -10,7 +10,8 @@ class ssmincidents_enabled_with_plans(Check):
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.status = "FAIL"
|
||||
report.status_extended = "No SSM Incidents replication set exists."
|
||||
report.resource_id = "SSMIncidents"
|
||||
report.resource_arn = ssmincidents_client.audited_account_arn
|
||||
report.resource_id = ssmincidents_client.audited_account
|
||||
report.region = ssmincidents_client.region
|
||||
if ssmincidents_client.replication_set:
|
||||
report.resource_arn = ssmincidents_client.replication_set[0].arn
|
||||
|
||||
@@ -21,6 +21,7 @@ class SSMIncidents:
|
||||
self.session = audit_info.audit_session
|
||||
self.audited_account = audit_info.audited_account
|
||||
self.audited_partition = audit_info.audited_partition
|
||||
self.audited_account_arn = audit_info.audited_account_arn
|
||||
self.audit_resources = audit_info.audit_resources
|
||||
self.regional_clients = generate_regional_clients(self.service, audit_info)
|
||||
# If the region is not set in the audit profile,
|
||||
|
||||
@@ -14,6 +14,7 @@ class vpc_different_regions(Check):
|
||||
# This is a global check under the vpc service: region, resource_id and tags are not relevant here but we keep them for consistency
|
||||
report.region = vpc_client.region
|
||||
report.resource_id = vpc_client.audited_account
|
||||
report.resource_arn = vpc_client.audited_account_arn
|
||||
report.status = "FAIL"
|
||||
report.status_extended = "VPCs found only in one region"
|
||||
if len(vpc_regions) > 1:
|
||||
|
||||
@@ -17,6 +17,7 @@ class VPC:
|
||||
self.audited_account = audit_info.audited_account
|
||||
self.audit_resources = audit_info.audit_resources
|
||||
self.audited_partition = audit_info.audited_partition
|
||||
self.audited_account_arn = audit_info.audited_account_arn
|
||||
self.regional_clients = generate_regional_clients(self.service, audit_info)
|
||||
self.vpcs = {}
|
||||
self.vpc_peering_connections = []
|
||||
|
||||
@@ -135,6 +135,7 @@ Azure Identity Type: {Fore.YELLOW}[{audit_info.identity.identity_type}]{Style.RE
|
||||
current_audit_info.audited_partition = parse_iam_credentials_arn(
|
||||
caller_identity["Arn"]
|
||||
).partition
|
||||
current_audit_info.audited_account_arn = f"arn:{current_audit_info.audited_partition}:iam::{current_audit_info.audited_account}:root"
|
||||
|
||||
logger.info("Checking if organizations role assumption is needed ...")
|
||||
if organizations_role_arn:
|
||||
@@ -214,6 +215,7 @@ Azure Identity Type: {Fore.YELLOW}[{audit_info.identity.identity_type}]{Style.RE
|
||||
current_audit_info.audit_session = assumed_session
|
||||
current_audit_info.audited_account = role_arn_parsed.account_id
|
||||
current_audit_info.audited_partition = role_arn_parsed.partition
|
||||
current_audit_info.audited_account_arn = f"arn:{current_audit_info.audited_partition}:iam::{current_audit_info.audited_account}:root"
|
||||
else:
|
||||
logger.info("Audit session is the original one")
|
||||
current_audit_info.audit_session = current_audit_info.original_session
|
||||
|
||||
@@ -146,6 +146,7 @@ class Test_Check:
|
||||
botocore_session=None,
|
||||
),
|
||||
audited_account=AWS_ACCOUNT_NUMBER,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root",
|
||||
audited_user_id=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
|
||||
@@ -83,6 +83,7 @@ class Test_Outputs:
|
||||
original_session=None,
|
||||
audit_session=None,
|
||||
audited_account=AWS_ACCOUNT_ID,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_ID}:root",
|
||||
audited_identity_arn="test-arn",
|
||||
audited_user_id="test",
|
||||
audited_partition="aws",
|
||||
@@ -355,6 +356,7 @@ class Test_Outputs:
|
||||
# original_session=None,
|
||||
# audit_session=None,
|
||||
# audited_account=AWS_ACCOUNT_ID,
|
||||
# audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_ID}:root",
|
||||
# audited_identity_arn="test-arn",
|
||||
# audited_user_id="test",
|
||||
# audited_partition="aws",
|
||||
@@ -400,6 +402,7 @@ class Test_Outputs:
|
||||
original_session=None,
|
||||
audit_session=None,
|
||||
audited_account=AWS_ACCOUNT_ID,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_ID}:root",
|
||||
audited_identity_arn="test-arn",
|
||||
audited_user_id="test",
|
||||
audited_partition="aws",
|
||||
@@ -475,6 +478,7 @@ class Test_Outputs:
|
||||
original_session=None,
|
||||
audit_session=session,
|
||||
audited_account=AWS_ACCOUNT_ID,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_ID}:root",
|
||||
audited_identity_arn="test-arn",
|
||||
audited_user_id="test",
|
||||
audited_partition="aws",
|
||||
@@ -524,6 +528,7 @@ class Test_Outputs:
|
||||
original_session=None,
|
||||
audit_session=session,
|
||||
audited_account=AWS_ACCOUNT_ID,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_ID}:root",
|
||||
audited_identity_arn="test-arn",
|
||||
audited_user_id="test",
|
||||
audited_partition="aws",
|
||||
@@ -580,6 +585,7 @@ class Test_Outputs:
|
||||
original_session=None,
|
||||
audit_session=session,
|
||||
audited_account=AWS_ACCOUNT_ID,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_ID}:root",
|
||||
audited_identity_arn="test-arn",
|
||||
audited_user_id="test",
|
||||
audited_partition="aws",
|
||||
@@ -687,6 +693,7 @@ class Test_Outputs:
|
||||
original_session=None,
|
||||
audit_session=session,
|
||||
audited_account=AWS_ACCOUNT_ID,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_ID}:root",
|
||||
audited_identity_arn="test-arn",
|
||||
audited_user_id="test",
|
||||
audited_partition="aws",
|
||||
|
||||
@@ -32,6 +32,7 @@ class Test_Slack_Integration:
|
||||
original_session=None,
|
||||
audit_session=None,
|
||||
audited_account=AWS_ACCOUNT_ID,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_ID}:root",
|
||||
audited_identity_arn="test-arn",
|
||||
audited_user_id="test",
|
||||
audited_partition="aws",
|
||||
|
||||
@@ -44,6 +44,7 @@ class Test_AWS_Provider:
|
||||
original_session=session,
|
||||
audit_session=None,
|
||||
audited_account=None,
|
||||
audited_account_arn=None,
|
||||
audited_partition=None,
|
||||
audited_identity_arn=None,
|
||||
audited_user_id=None,
|
||||
@@ -103,6 +104,7 @@ class Test_AWS_Provider:
|
||||
original_session=None,
|
||||
audit_session=session,
|
||||
audited_account=None,
|
||||
audited_account_arn=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
audited_user_id=None,
|
||||
@@ -133,6 +135,7 @@ class Test_AWS_Provider:
|
||||
original_session=None,
|
||||
audit_session=session,
|
||||
audited_account=None,
|
||||
audited_account_arn=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
audited_user_id=None,
|
||||
@@ -162,6 +165,7 @@ class Test_AWS_Provider:
|
||||
original_session=None,
|
||||
audit_session=session,
|
||||
audited_account=None,
|
||||
audited_account_arn=None,
|
||||
audited_partition="aws-cn",
|
||||
audited_identity_arn=None,
|
||||
audited_user_id=None,
|
||||
|
||||
@@ -26,6 +26,7 @@ class Test_Allowlist:
|
||||
botocore_session=None,
|
||||
),
|
||||
audited_account=AWS_ACCOUNT_NUMBER,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root",
|
||||
audited_user_id=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
|
||||
@@ -79,6 +79,7 @@ class Test_AccessAnalyzer_Service:
|
||||
botocore_session=None,
|
||||
),
|
||||
audited_account=AWS_ACCOUNT_NUMBER,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root",
|
||||
audited_user_id=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
|
||||
@@ -105,6 +105,7 @@ class Test_ACM_Service:
|
||||
botocore_session=None,
|
||||
),
|
||||
audited_account=AWS_ACCOUNT_NUMBER,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root",
|
||||
audited_user_id=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
|
||||
@@ -20,6 +20,7 @@ class Test_apigateway_authorizers_enabled:
|
||||
botocore_session=None,
|
||||
),
|
||||
audited_account=AWS_ACCOUNT_NUMBER,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root",
|
||||
audited_user_id=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
|
||||
@@ -20,6 +20,7 @@ class Test_apigateway_client_certificate_enabled:
|
||||
botocore_session=None,
|
||||
),
|
||||
audited_account=AWS_ACCOUNT_NUMBER,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root",
|
||||
audited_user_id=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
|
||||
@@ -19,6 +19,7 @@ class Test_apigateway_endpoint_public:
|
||||
botocore_session=None,
|
||||
),
|
||||
audited_account=AWS_ACCOUNT_NUMBER,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root",
|
||||
audited_user_id=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
|
||||
@@ -19,6 +19,7 @@ class Test_apigateway_logging_enabled:
|
||||
botocore_session=None,
|
||||
),
|
||||
audited_account=AWS_ACCOUNT_NUMBER,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root",
|
||||
audited_user_id=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
|
||||
@@ -19,6 +19,7 @@ class Test_APIGateway_Service:
|
||||
botocore_session=None,
|
||||
),
|
||||
audited_account=AWS_ACCOUNT_NUMBER,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root",
|
||||
audited_user_id=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
|
||||
@@ -19,6 +19,7 @@ class Test_apigateway_waf_acl_attached:
|
||||
botocore_session=None,
|
||||
),
|
||||
audited_account=AWS_ACCOUNT_NUMBER,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root",
|
||||
audited_user_id=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
|
||||
@@ -48,6 +48,7 @@ class Test_apigatewayv2_access_logging_enabled:
|
||||
botocore_session=None,
|
||||
),
|
||||
audited_account=AWS_ACCOUNT_NUMBER,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root",
|
||||
audited_user_id=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
|
||||
@@ -48,6 +48,7 @@ class Test_apigatewayv2_authorizers_enabled:
|
||||
botocore_session=None,
|
||||
),
|
||||
audited_account=AWS_ACCOUNT_NUMBER,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root",
|
||||
audited_user_id=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
|
||||
@@ -50,6 +50,7 @@ class Test_ApiGatewayV2_Service:
|
||||
botocore_session=None,
|
||||
),
|
||||
audited_account=AWS_ACCOUNT_NUMBER,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root",
|
||||
audited_user_id=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
|
||||
@@ -72,6 +72,7 @@ class Test_AppStream_Service:
|
||||
botocore_session=None,
|
||||
),
|
||||
audited_account=AWS_ACCOUNT_NUMBER,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root",
|
||||
audited_user_id=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
|
||||
@@ -19,6 +19,7 @@ class Test_autoscaling_find_secrets_ec2_launch_configuration:
|
||||
botocore_session=None,
|
||||
),
|
||||
audited_account=AWS_ACCOUNT_NUMBER,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root",
|
||||
audited_user_id=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
|
||||
@@ -19,6 +19,7 @@ class Test_autoscaling_group_multiple_az:
|
||||
botocore_session=None,
|
||||
),
|
||||
audited_account=AWS_ACCOUNT_NUMBER,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root",
|
||||
audited_user_id=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
|
||||
@@ -21,6 +21,7 @@ class Test_AutoScaling_Service:
|
||||
botocore_session=None,
|
||||
),
|
||||
audited_account=AWS_ACCOUNT_NUMBER,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root",
|
||||
audited_user_id=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
|
||||
@@ -34,6 +34,7 @@ class Test_awslambda_function_invoke_api_operations_cloudtrail_logging_enabled:
|
||||
botocore_session=None,
|
||||
),
|
||||
audited_account=None,
|
||||
audited_account_arn=None,
|
||||
audited_user_id=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
|
||||
@@ -76,6 +76,7 @@ class Test_Lambda_Service:
|
||||
botocore_session=None,
|
||||
),
|
||||
audited_account=DEFAULT_ACCOUNT_ID,
|
||||
audited_account_arn=f"arn:aws:iam::{DEFAULT_ACCOUNT_ID}:root",
|
||||
audited_user_id=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
|
||||
@@ -4,11 +4,14 @@ from unittest import mock
|
||||
from prowler.providers.aws.services.backup.backup_service import BackupPlan
|
||||
|
||||
AWS_REGION = "eu-west-1"
|
||||
AWS_ACCOUNT_NUMBER = "123456789012"
|
||||
|
||||
|
||||
class Test_backup_plans_exist:
|
||||
def test_no_backup_plans(self):
|
||||
backup_client = mock.MagicMock
|
||||
backup_client.audited_account = AWS_ACCOUNT_NUMBER
|
||||
backup_client.audited_account_arn = f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root"
|
||||
backup_client.region = AWS_REGION
|
||||
backup_client.backup_plans = []
|
||||
with mock.patch(
|
||||
@@ -26,12 +29,14 @@ class Test_backup_plans_exist:
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "FAIL"
|
||||
assert result[0].status_extended == "No Backup Plan Exist"
|
||||
assert result[0].resource_id == "Backups"
|
||||
assert result[0].resource_arn == ""
|
||||
assert result[0].resource_id == AWS_ACCOUNT_NUMBER
|
||||
assert result[0].resource_arn == f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root"
|
||||
assert result[0].region == AWS_REGION
|
||||
|
||||
def test_one_backup_plan(self):
|
||||
backup_client = mock.MagicMock
|
||||
backup_client.audited_account = AWS_ACCOUNT_NUMBER
|
||||
backup_client.audited_account_arn = f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root"
|
||||
backup_client.region = AWS_REGION
|
||||
backup_client.backup_plans = [
|
||||
BackupPlan(
|
||||
|
||||
@@ -7,6 +7,7 @@ from prowler.providers.aws.services.backup.backup_service import (
|
||||
)
|
||||
|
||||
AWS_REGION = "eu-west-1"
|
||||
AWS_ACCOUNT_NUMBER = "123456789012"
|
||||
|
||||
|
||||
class Test_backup_reportplans_exist:
|
||||
@@ -30,6 +31,8 @@ class Test_backup_reportplans_exist:
|
||||
|
||||
def test_no_backup_report_plans(self):
|
||||
backup_client = mock.MagicMock
|
||||
backup_client.audited_account = AWS_ACCOUNT_NUMBER
|
||||
backup_client.audited_account_arn = f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root"
|
||||
backup_client.region = AWS_REGION
|
||||
backup_client.backup_plans = [
|
||||
BackupPlan(
|
||||
@@ -58,12 +61,14 @@ class Test_backup_reportplans_exist:
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "FAIL"
|
||||
assert result[0].status_extended == "No Backup Report Plan Exist"
|
||||
assert result[0].resource_id == "Backups"
|
||||
assert result[0].resource_arn == ""
|
||||
assert result[0].resource_id == AWS_ACCOUNT_NUMBER
|
||||
assert result[0].resource_arn == f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root"
|
||||
assert result[0].region == AWS_REGION
|
||||
|
||||
def test_one_backup_report_plan(self):
|
||||
backup_client = mock.MagicMock
|
||||
backup_client.audited_account = AWS_ACCOUNT_NUMBER
|
||||
backup_client.audited_account_arn = f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root"
|
||||
backup_client.region = AWS_REGION
|
||||
backup_client.backup_plans = [
|
||||
BackupPlan(
|
||||
|
||||
@@ -72,7 +72,6 @@ def mock_generate_regional_clients(service, audit_info):
|
||||
new=mock_generate_regional_clients,
|
||||
)
|
||||
class Test_Backup_Service:
|
||||
|
||||
# Mocked Audit Info
|
||||
def set_mocked_audit_info(self):
|
||||
audit_info = AWS_Audit_Info(
|
||||
@@ -83,6 +82,7 @@ class Test_Backup_Service:
|
||||
botocore_session=None,
|
||||
),
|
||||
audited_account=None,
|
||||
audited_account_arn=None,
|
||||
audited_user_id=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
|
||||
@@ -3,11 +3,14 @@ from unittest import mock
|
||||
from prowler.providers.aws.services.backup.backup_service import BackupVault
|
||||
|
||||
AWS_REGION = "eu-west-1"
|
||||
AWS_ACCOUNT_NUMBER = "123456789012"
|
||||
|
||||
|
||||
class Test_backup_vaults_exist:
|
||||
def test_no_backup_vaults(self):
|
||||
backup_client = mock.MagicMock
|
||||
backup_client.audited_account = AWS_ACCOUNT_NUMBER
|
||||
backup_client.audited_account_arn = f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root"
|
||||
backup_client.region = AWS_REGION
|
||||
backup_client.backup_vaults = []
|
||||
with mock.patch(
|
||||
@@ -25,12 +28,14 @@ class Test_backup_vaults_exist:
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "FAIL"
|
||||
assert result[0].status_extended == "No Backup Vault Exist"
|
||||
assert result[0].resource_id == "Backups"
|
||||
assert result[0].resource_arn == ""
|
||||
assert result[0].resource_id == AWS_ACCOUNT_NUMBER
|
||||
assert result[0].resource_arn == f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root"
|
||||
assert result[0].region == AWS_REGION
|
||||
|
||||
def test_one_backup_vault(self):
|
||||
backup_client = mock.MagicMock
|
||||
backup_client.audited_account = AWS_ACCOUNT_NUMBER
|
||||
backup_client.audited_account_arn = f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root"
|
||||
backup_client.region = AWS_REGION
|
||||
backup_client.backup_vaults = [
|
||||
BackupVault(
|
||||
|
||||
@@ -143,6 +143,7 @@ class Test_CloudFormation_Service:
|
||||
botocore_session=None,
|
||||
),
|
||||
audited_account=None,
|
||||
audited_account_arn=None,
|
||||
audited_user_id=None,
|
||||
audited_partition=None,
|
||||
audited_identity_arn=None,
|
||||
|
||||
@@ -164,6 +164,7 @@ class Test_CloudFront_Service:
|
||||
region_name=AWS_REGION,
|
||||
),
|
||||
audited_account=DEFAULT_ACCOUNT_ID,
|
||||
audited_account_arn=f"arn:aws:iam::{DEFAULT_ACCOUNT_ID}:root",
|
||||
audited_user_id=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
|
||||
@@ -25,6 +25,7 @@ class Test_cloudtrail_bucket_requires_mfa_delete:
|
||||
botocore_session=None,
|
||||
),
|
||||
audited_account=AWS_ACCOUNT_NUMBER,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root",
|
||||
audited_user_id=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
|
||||
@@ -20,6 +20,7 @@ class Test_cloudtrail_cloudwatch_logging_enabled:
|
||||
botocore_session=None,
|
||||
),
|
||||
audited_account=AWS_ACCOUNT_NUMBER,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root",
|
||||
audited_user_id=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
|
||||
@@ -19,6 +19,7 @@ class Test_cloudtrail_insights_exist:
|
||||
botocore_session=None,
|
||||
),
|
||||
audited_account=AWS_ACCOUNT_NUMBER,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root",
|
||||
audited_user_id=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
|
||||
@@ -19,6 +19,7 @@ class Test_cloudtrail_kms_encryption_enabled:
|
||||
botocore_session=None,
|
||||
),
|
||||
audited_account=AWS_ACCOUNT_NUMBER,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root",
|
||||
audited_user_id=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
|
||||
@@ -19,6 +19,7 @@ class Test_cloudtrail_log_file_validation_enabled:
|
||||
botocore_session=None,
|
||||
),
|
||||
audited_account=AWS_ACCOUNT_NUMBER,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root",
|
||||
audited_user_id=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
|
||||
@@ -19,6 +19,7 @@ class Test_cloudtrail_logs_s3_bucket_access_logging_enabled:
|
||||
botocore_session=None,
|
||||
),
|
||||
audited_account=AWS_ACCOUNT_NUMBER,
|
||||
audited_account_arn=f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root",
|
||||
audited_user_id=None,
|
||||
audited_partition="aws",
|
||||
audited_identity_arn=None,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user