feat(ignore unused services): add --ignore-unused-services argument to ignore findings from services not in actual use (#2936)

This commit is contained in:
Sergio Garcia
2023-10-24 14:09:27 +02:00
committed by GitHub
parent 2aa3126eb0
commit b822c19d2c
89 changed files with 4587 additions and 1157 deletions

View File

@@ -15,6 +15,7 @@ class Test_backup_plans_exist:
backup_client.audited_account_arn = f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root"
backup_client.region = AWS_REGION
backup_client.backup_plans = []
backup_client.backup_vaults = ["vault"]
with mock.patch(
"prowler.providers.aws.services.backup.backup_service.Backup",
new=backup_client,
@@ -34,6 +35,27 @@ class Test_backup_plans_exist:
assert result[0].resource_arn == f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:root"
assert result[0].region == AWS_REGION
def test_no_backup_plans_not_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_plans = []
backup_client.backup_vaults = []
with mock.patch(
"prowler.providers.aws.services.backup.backup_service.Backup",
new=backup_client,
):
# Test Check
from prowler.providers.aws.services.backup.backup_plans_exist.backup_plans_exist import (
backup_plans_exist,
)
check = backup_plans_exist()
result = check.execute()
assert len(result) == 0
def test_one_backup_plan(self):
backup_client = mock.MagicMock
backup_client.audited_account = AWS_ACCOUNT_NUMBER
@@ -70,7 +92,7 @@ class Test_backup_plans_exist:
assert result[0].status == "PASS"
assert (
result[0].status_extended
== f"At least one backup plan exists: {result[0].resource_id}."
== f"At least one Backup Plan exists: {result[0].resource_id}."
)
assert result[0].resource_id == "MyBackupPlan"
assert (