mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-23 12:31:54 +00:00
fix(m365): handle tenant_id in mutelist (#8306)
Co-authored-by: Pepe Fagoaga <pepe@prowler.com>
This commit is contained in:
@@ -30,6 +30,7 @@ All notable changes to the **Prowler SDK** are documented in this file.
|
||||
- `ServiceName` field in Network Firewall checks metadata [(#8280)](https://github.com/prowler-cloud/prowler/pull/8280)
|
||||
- Update `entra_users_mfa_capable` check to use the correct resource name and ID [(#8288)](https://github.com/prowler-cloud/prowler/pull/8288)
|
||||
- Handle multiple services and severities while listing checks [(#8302)](https://github.com/prowler-cloud/prowler/pull/8302)
|
||||
- Handle `tenant_id` for M365 Mutelist [(#8306)](https://github.com/prowler-cloud/prowler/pull/8306)
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -635,6 +635,8 @@ def execute(
|
||||
is_finding_muted_args["account_name"] = (
|
||||
global_provider.identity.account_name
|
||||
)
|
||||
elif global_provider.type == "m365":
|
||||
is_finding_muted_args["tenant_id"] = global_provider.identity.tenant_id
|
||||
for finding in check_findings:
|
||||
if global_provider.type == "azure":
|
||||
is_finding_muted_args["subscription_id"] = (
|
||||
|
||||
@@ -7,9 +7,10 @@ class M365Mutelist(Mutelist):
|
||||
def is_finding_muted(
|
||||
self,
|
||||
finding: CheckReportM365,
|
||||
tenant_id: str,
|
||||
) -> bool:
|
||||
return self.is_muted(
|
||||
finding.tenant_id,
|
||||
tenant_id,
|
||||
finding.check_metadata.CheckID,
|
||||
finding.location,
|
||||
finding.resource_name,
|
||||
|
||||
@@ -56,7 +56,6 @@ class TestM365Mutelist:
|
||||
mutelist = M365Mutelist(mutelist_content=mutelist_content)
|
||||
|
||||
finding = MagicMock
|
||||
finding.tenant_id = "subscription_1"
|
||||
finding.check_metadata = MagicMock
|
||||
finding.check_metadata.CheckID = "check_test"
|
||||
finding.status = "FAIL"
|
||||
@@ -65,7 +64,35 @@ class TestM365Mutelist:
|
||||
finding.tenant_domain = "test_domain"
|
||||
finding.resource_tags = []
|
||||
|
||||
assert mutelist.is_finding_muted(finding)
|
||||
assert mutelist.is_finding_muted(finding, tenant_id="subscription_1")
|
||||
|
||||
def test_finding_is_not_muted(self):
|
||||
# Mutelist
|
||||
mutelist_content = {
|
||||
"Accounts": {
|
||||
"subscription_1": {
|
||||
"Checks": {
|
||||
"check_test": {
|
||||
"Regions": ["*"],
|
||||
"Resources": ["test_resource"],
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mutelist = M365Mutelist(mutelist_content=mutelist_content)
|
||||
|
||||
finding = MagicMock
|
||||
finding.check_metadata = MagicMock
|
||||
finding.check_metadata.CheckID = "check_test"
|
||||
finding.status = "FAIL"
|
||||
finding.location = "global"
|
||||
finding.resource_name = "test_resource"
|
||||
finding.tenant_domain = "test_domain"
|
||||
finding.resource_tags = []
|
||||
|
||||
assert not mutelist.is_finding_muted(finding, tenant_id="subscription_2")
|
||||
|
||||
def test_mute_finding(self):
|
||||
# Mutelist
|
||||
|
||||
Reference in New Issue
Block a user