mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-10-31 07:44:21 +00:00
Merge branch 'master' into PRWLR-7300-create-ia-c-provider
This commit is contained in:
36 files changed
+31779
-281
No files matched your search
@@ -37,7 +37,7 @@ mock_metadata_lambda = CheckMetadata(
|
||||
CheckID="awslambda_function_url_public",
|
||||
CheckTitle="Check 1",
|
||||
CheckType=["type1"],
|
||||
ServiceName="lambda",
|
||||
ServiceName="awslambda",
|
||||
SubServiceName="subservice1",
|
||||
ResourceIdTemplate="template1",
|
||||
Severity="high",
|
||||
|
||||
@@ -857,7 +857,6 @@ KISA_ISMSP_AWS = Compliance(
|
||||
],
|
||||
)
|
||||
|
||||
PROWLER_THREATSCORE_AWS_NAME = "prowler_threatscore_aws"
|
||||
PROWLER_THREATSCORE_AWS = Compliance(
|
||||
Framework="ProwlerThreatScore",
|
||||
Version="1.0",
|
||||
@@ -901,7 +900,6 @@ PROWLER_THREATSCORE_AWS = Compliance(
|
||||
],
|
||||
)
|
||||
|
||||
PROWLER_THREATSCORE_AZURE_NAME = "prowler_threatscore_azure"
|
||||
PROWLER_THREATSCORE_AZURE = Compliance(
|
||||
Framework="ProwlerThreatScore",
|
||||
Version="1.0",
|
||||
@@ -945,7 +943,6 @@ PROWLER_THREATSCORE_AZURE = Compliance(
|
||||
],
|
||||
)
|
||||
|
||||
PROWLER_THREATSCORE_GCP_NAME = "prowler_threatscore_gcp"
|
||||
PROWLER_THREATSCORE_GCP = Compliance(
|
||||
Framework="ProwlerThreatScore",
|
||||
Version="1.0",
|
||||
@@ -989,7 +986,6 @@ PROWLER_THREATSCORE_GCP = Compliance(
|
||||
],
|
||||
)
|
||||
|
||||
PROWLER_THREATSCORE_M365_NAME = "prowler_threatscore_m365"
|
||||
PROWLER_THREATSCORE_M365 = Compliance(
|
||||
Framework="ProwlerThreatScore",
|
||||
Version="1.0",
|
||||
|
||||
@@ -10,10 +10,7 @@ from prowler.lib.outputs.compliance.prowler_threatscore.models import (
|
||||
from prowler.lib.outputs.compliance.prowler_threatscore.prowler_threatscore_aws import (
|
||||
ProwlerThreatScoreAWS,
|
||||
)
|
||||
from tests.lib.outputs.compliance.fixtures import (
|
||||
PROWLER_THREATSCORE_AWS,
|
||||
PROWLER_THREATSCORE_AWS_NAME,
|
||||
)
|
||||
from tests.lib.outputs.compliance.fixtures import PROWLER_THREATSCORE_AWS
|
||||
from tests.lib.outputs.fixtures.fixtures import generate_finding_output
|
||||
from tests.providers.aws.utils import AWS_ACCOUNT_NUMBER, AWS_REGION_EU_WEST_1
|
||||
|
||||
@@ -24,9 +21,7 @@ class TestProwlerThreatScoreAWS:
|
||||
generate_finding_output(compliance={"ProwlerThreatScore-1.0": "1.1.1"})
|
||||
]
|
||||
|
||||
output = ProwlerThreatScoreAWS(
|
||||
findings, PROWLER_THREATSCORE_AWS, PROWLER_THREATSCORE_AWS_NAME
|
||||
)
|
||||
output = ProwlerThreatScoreAWS(findings, PROWLER_THREATSCORE_AWS)
|
||||
output_data = output.data[0]
|
||||
assert isinstance(output_data, ProwlerThreatScoreAWSModel)
|
||||
assert output_data.Provider == "aws"
|
||||
@@ -134,9 +129,7 @@ class TestProwlerThreatScoreAWS:
|
||||
findings = [
|
||||
generate_finding_output(compliance={"ProwlerThreatScore-1.0": "1.1.1"})
|
||||
]
|
||||
output = ProwlerThreatScoreAWS(
|
||||
findings, PROWLER_THREATSCORE_AWS, PROWLER_THREATSCORE_AWS_NAME
|
||||
)
|
||||
output = ProwlerThreatScoreAWS(findings, PROWLER_THREATSCORE_AWS)
|
||||
output._file_descriptor = mock_file
|
||||
|
||||
with patch.object(mock_file, "close", return_value=None):
|
||||
|
||||
@@ -10,10 +10,7 @@ from prowler.lib.outputs.compliance.prowler_threatscore.models import (
|
||||
from prowler.lib.outputs.compliance.prowler_threatscore.prowler_threatscore_azure import (
|
||||
ProwlerThreatScoreAzure,
|
||||
)
|
||||
from tests.lib.outputs.compliance.fixtures import (
|
||||
PROWLER_THREATSCORE_AZURE,
|
||||
PROWLER_THREATSCORE_AZURE_NAME,
|
||||
)
|
||||
from tests.lib.outputs.compliance.fixtures import PROWLER_THREATSCORE_AZURE
|
||||
from tests.lib.outputs.fixtures.fixtures import generate_finding_output
|
||||
from tests.providers.azure.azure_fixtures import (
|
||||
AZURE_SUBSCRIPTION_ID,
|
||||
@@ -33,9 +30,7 @@ class TestProwlerThreatScoreAzure:
|
||||
)
|
||||
]
|
||||
|
||||
output = ProwlerThreatScoreAzure(
|
||||
findings, PROWLER_THREATSCORE_AZURE, PROWLER_THREATSCORE_AZURE_NAME
|
||||
)
|
||||
output = ProwlerThreatScoreAzure(findings, PROWLER_THREATSCORE_AZURE)
|
||||
output_data = output.data[0]
|
||||
assert isinstance(output_data, ProwlerThreatScoreAzureModel)
|
||||
assert output_data.Provider == "azure"
|
||||
@@ -144,9 +139,7 @@ class TestProwlerThreatScoreAzure:
|
||||
findings = [
|
||||
generate_finding_output(compliance={"ProwlerThreatScore-1.0": "1.1.1"})
|
||||
]
|
||||
output = ProwlerThreatScoreAzure(
|
||||
findings, PROWLER_THREATSCORE_AZURE, PROWLER_THREATSCORE_AZURE_NAME
|
||||
)
|
||||
output = ProwlerThreatScoreAzure(findings, PROWLER_THREATSCORE_AZURE)
|
||||
output._file_descriptor = mock_file
|
||||
|
||||
with patch.object(mock_file, "close", return_value=None):
|
||||
|
||||
@@ -10,10 +10,7 @@ from prowler.lib.outputs.compliance.prowler_threatscore.models import (
|
||||
from prowler.lib.outputs.compliance.prowler_threatscore.prowler_threatscore_gcp import (
|
||||
ProwlerThreatScoreGCP,
|
||||
)
|
||||
from tests.lib.outputs.compliance.fixtures import (
|
||||
PROWLER_THREATSCORE_GCP,
|
||||
PROWLER_THREATSCORE_GCP_NAME,
|
||||
)
|
||||
from tests.lib.outputs.compliance.fixtures import PROWLER_THREATSCORE_GCP
|
||||
from tests.lib.outputs.fixtures.fixtures import generate_finding_output
|
||||
from tests.providers.gcp.gcp_fixtures import GCP_PROJECT_ID
|
||||
|
||||
@@ -30,9 +27,7 @@ class TestProwlerThreatScoreGCP:
|
||||
)
|
||||
]
|
||||
|
||||
output = ProwlerThreatScoreGCP(
|
||||
findings, PROWLER_THREATSCORE_GCP, PROWLER_THREATSCORE_GCP_NAME
|
||||
)
|
||||
output = ProwlerThreatScoreGCP(findings, PROWLER_THREATSCORE_GCP)
|
||||
output_data = output.data[0]
|
||||
assert isinstance(output_data, ProwlerThreatScoreGCPModel)
|
||||
assert output_data.Provider == "gcp"
|
||||
@@ -140,9 +135,7 @@ class TestProwlerThreatScoreGCP:
|
||||
findings = [
|
||||
generate_finding_output(compliance={"ProwlerThreatScore-1.0": "1.1.1"})
|
||||
]
|
||||
output = ProwlerThreatScoreGCP(
|
||||
findings, PROWLER_THREATSCORE_GCP, PROWLER_THREATSCORE_GCP_NAME
|
||||
)
|
||||
output = ProwlerThreatScoreGCP(findings, PROWLER_THREATSCORE_GCP)
|
||||
output._file_descriptor = mock_file
|
||||
|
||||
with patch.object(mock_file, "close", return_value=None):
|
||||
|
||||
@@ -10,10 +10,7 @@ from prowler.lib.outputs.compliance.prowler_threatscore.models import (
|
||||
from prowler.lib.outputs.compliance.prowler_threatscore.prowler_threatscore_m365 import (
|
||||
ProwlerThreatScoreM365,
|
||||
)
|
||||
from tests.lib.outputs.compliance.fixtures import (
|
||||
PROWLER_THREATSCORE_M365,
|
||||
PROWLER_THREATSCORE_M365_NAME,
|
||||
)
|
||||
from tests.lib.outputs.compliance.fixtures import PROWLER_THREATSCORE_M365
|
||||
from tests.lib.outputs.fixtures.fixtures import generate_finding_output
|
||||
from tests.providers.m365.m365_fixtures import TENANT_ID
|
||||
|
||||
@@ -30,9 +27,7 @@ class TestProwlerThreatScoreM365:
|
||||
)
|
||||
]
|
||||
|
||||
output = ProwlerThreatScoreM365(
|
||||
findings, PROWLER_THREATSCORE_M365, PROWLER_THREATSCORE_M365_NAME
|
||||
)
|
||||
output = ProwlerThreatScoreM365(findings, PROWLER_THREATSCORE_M365)
|
||||
output_data = output.data[0]
|
||||
assert isinstance(output_data, ProwlerThreatScoreM365Model)
|
||||
assert output_data.Provider == "m365"
|
||||
@@ -142,9 +137,7 @@ class TestProwlerThreatScoreM365:
|
||||
findings = [
|
||||
generate_finding_output(compliance={"ProwlerThreatScore-1.0": "1.1.1"})
|
||||
]
|
||||
output = ProwlerThreatScoreM365(
|
||||
findings, PROWLER_THREATSCORE_M365, PROWLER_THREATSCORE_M365_NAME
|
||||
)
|
||||
output = ProwlerThreatScoreM365(findings, PROWLER_THREATSCORE_M365)
|
||||
output._file_descriptor = mock_file
|
||||
|
||||
with patch.object(mock_file, "close", return_value=None):
|
||||
|
||||
+49
-5
@@ -31,7 +31,7 @@ class Test_defender_ensure_notify_alerts_severity_is_high:
|
||||
result = check.execute()
|
||||
assert len(result) == 0
|
||||
|
||||
def test_defender_severity_alerts_low(self):
|
||||
def test_defender_severity_alerts_critical(self):
|
||||
resource_id = str(uuid4())
|
||||
defender_client = mock.MagicMock
|
||||
defender_client.security_contacts = {
|
||||
@@ -41,7 +41,7 @@ class Test_defender_ensure_notify_alerts_severity_is_high:
|
||||
name="default",
|
||||
emails="",
|
||||
phone="",
|
||||
alert_notifications_minimal_severity="Low",
|
||||
alert_notifications_minimal_severity="Critical",
|
||||
alert_notifications_state="On",
|
||||
notified_roles=["Contributor"],
|
||||
notified_roles_state="On",
|
||||
@@ -69,7 +69,7 @@ class Test_defender_ensure_notify_alerts_severity_is_high:
|
||||
assert result[0].status == "FAIL"
|
||||
assert (
|
||||
result[0].status_extended
|
||||
== f"Notifiy alerts are not enabled for severity high in subscription {AZURE_SUBSCRIPTION_ID}."
|
||||
== f"Notifications are not enabled for alerts with a minimum severity of high or lower in subscription {AZURE_SUBSCRIPTION_ID}."
|
||||
)
|
||||
assert result[0].subscription == AZURE_SUBSCRIPTION_ID
|
||||
assert result[0].resource_name == "default"
|
||||
@@ -113,7 +113,51 @@ class Test_defender_ensure_notify_alerts_severity_is_high:
|
||||
assert result[0].status == "PASS"
|
||||
assert (
|
||||
result[0].status_extended
|
||||
== f"Notifiy alerts are enabled for severity high in subscription {AZURE_SUBSCRIPTION_ID}."
|
||||
== f"Notifications are enabled for alerts with a minimum severity of high or lower (High) in subscription {AZURE_SUBSCRIPTION_ID}."
|
||||
)
|
||||
assert result[0].subscription == AZURE_SUBSCRIPTION_ID
|
||||
assert result[0].resource_name == "default"
|
||||
assert result[0].resource_id == resource_id
|
||||
|
||||
def test_defender_severity_alerts_low(self):
|
||||
resource_id = str(uuid4())
|
||||
defender_client = mock.MagicMock
|
||||
defender_client.security_contacts = {
|
||||
AZURE_SUBSCRIPTION_ID: {
|
||||
resource_id: SecurityContacts(
|
||||
resource_id=resource_id,
|
||||
name="default",
|
||||
emails="",
|
||||
phone="",
|
||||
alert_notifications_minimal_severity="Low",
|
||||
alert_notifications_state="On",
|
||||
notified_roles=["Contributor"],
|
||||
notified_roles_state="On",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
with (
|
||||
mock.patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=set_mocked_azure_provider(),
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.azure.services.defender.defender_ensure_notify_alerts_severity_is_high.defender_ensure_notify_alerts_severity_is_high.defender_client",
|
||||
new=defender_client,
|
||||
),
|
||||
):
|
||||
from prowler.providers.azure.services.defender.defender_ensure_notify_alerts_severity_is_high.defender_ensure_notify_alerts_severity_is_high import (
|
||||
defender_ensure_notify_alerts_severity_is_high,
|
||||
)
|
||||
|
||||
check = defender_ensure_notify_alerts_severity_is_high()
|
||||
result = check.execute()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "PASS"
|
||||
assert (
|
||||
result[0].status_extended
|
||||
== f"Notifications are enabled for alerts with a minimum severity of high or lower (Low) in subscription {AZURE_SUBSCRIPTION_ID}."
|
||||
)
|
||||
assert result[0].subscription == AZURE_SUBSCRIPTION_ID
|
||||
assert result[0].resource_name == "default"
|
||||
@@ -156,7 +200,7 @@ class Test_defender_ensure_notify_alerts_severity_is_high:
|
||||
assert result[0].status == "FAIL"
|
||||
assert (
|
||||
result[0].status_extended
|
||||
== f"Notifiy alerts are not enabled for severity high in subscription {AZURE_SUBSCRIPTION_ID}."
|
||||
== f"Notifications are not enabled for alerts with a minimum severity of high or lower in subscription {AZURE_SUBSCRIPTION_ID}."
|
||||
)
|
||||
assert result[0].subscription == AZURE_SUBSCRIPTION_ID
|
||||
assert result[0].resource_name == "default"
|
||||
|
||||
@@ -93,7 +93,7 @@ async def mock_entra_get_conditional_access_policy(_):
|
||||
"include": ["797f4846-ba00-4fd7-ba43-dac1f8f63013"],
|
||||
"exclude": [],
|
||||
},
|
||||
access_controls={"grant": ["MFA"], "block": []},
|
||||
access_controls={"grant": ["MFA", "compliantDevice"], "block": []},
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -216,7 +216,7 @@ class Test_Entra_Service:
|
||||
)
|
||||
assert entra_client.conditional_access_policy[DOMAIN]["id-1"].access_controls[
|
||||
"grant"
|
||||
] == ["MFA"]
|
||||
] == ["MFA", "compliantDevice"]
|
||||
assert (
|
||||
entra_client.conditional_access_policy[DOMAIN]["id-1"].access_controls[
|
||||
"block"
|
||||
|
||||
+88
@@ -114,3 +114,91 @@ class Test_admincenter_groups_not_public_visibility:
|
||||
assert result[0].resource_name == "Group1"
|
||||
assert result[0].resource_id == id_group1
|
||||
assert result[0].location == "global"
|
||||
|
||||
def test_admincenter_group_public_visibility(self):
|
||||
admincenter_client = mock.MagicMock
|
||||
admincenter_client.audited_tenant = "audited_tenant"
|
||||
admincenter_client.audited_domain = DOMAIN
|
||||
|
||||
with (
|
||||
mock.patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=set_mocked_m365_provider(),
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.m365.lib.powershell.m365_powershell.M365PowerShell.connect_exchange_online"
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.m365.services.admincenter.admincenter_groups_not_public_visibility.admincenter_groups_not_public_visibility.admincenter_client",
|
||||
new=admincenter_client,
|
||||
),
|
||||
):
|
||||
from prowler.providers.m365.services.admincenter.admincenter_groups_not_public_visibility.admincenter_groups_not_public_visibility import (
|
||||
admincenter_groups_not_public_visibility,
|
||||
)
|
||||
from prowler.providers.m365.services.admincenter.admincenter_service import (
|
||||
Group,
|
||||
)
|
||||
|
||||
id_group1 = str(uuid4())
|
||||
|
||||
admincenter_client.groups = {
|
||||
id_group1: Group(id=id_group1, name="Group1", visibility="Public"),
|
||||
}
|
||||
|
||||
check = admincenter_groups_not_public_visibility()
|
||||
result = check.execute()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "FAIL"
|
||||
assert (
|
||||
result[0].status_extended
|
||||
== "Group Group1 has Public visibility and should be Private."
|
||||
)
|
||||
assert result[0].resource == admincenter_client.groups[id_group1].dict()
|
||||
assert result[0].resource_name == "Group1"
|
||||
assert result[0].resource_id == id_group1
|
||||
assert result[0].location == "global"
|
||||
|
||||
def test_admincenter_group_none_visibility(self):
|
||||
admincenter_client = mock.MagicMock
|
||||
admincenter_client.audited_tenant = "audited_tenant"
|
||||
admincenter_client.audited_domain = DOMAIN
|
||||
|
||||
with (
|
||||
mock.patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=set_mocked_m365_provider(),
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.m365.lib.powershell.m365_powershell.M365PowerShell.connect_exchange_online"
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.m365.services.admincenter.admincenter_groups_not_public_visibility.admincenter_groups_not_public_visibility.admincenter_client",
|
||||
new=admincenter_client,
|
||||
),
|
||||
):
|
||||
from prowler.providers.m365.services.admincenter.admincenter_groups_not_public_visibility.admincenter_groups_not_public_visibility import (
|
||||
admincenter_groups_not_public_visibility,
|
||||
)
|
||||
from prowler.providers.m365.services.admincenter.admincenter_service import (
|
||||
Group,
|
||||
)
|
||||
|
||||
id_group1 = str(uuid4())
|
||||
|
||||
admincenter_client.groups = {
|
||||
id_group1: Group(id=id_group1, name="Group1", visibility=None),
|
||||
}
|
||||
|
||||
check = admincenter_groups_not_public_visibility()
|
||||
result = check.execute()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "FAIL"
|
||||
assert (
|
||||
result[0].status_extended
|
||||
== "Group Group1 has None visibility and should be Private."
|
||||
)
|
||||
assert result[0].resource == admincenter_client.groups[id_group1].dict()
|
||||
assert result[0].resource_name == "Group1"
|
||||
assert result[0].resource_id == id_group1
|
||||
assert result[0].location == "global"
|
||||
@@ -68,7 +68,10 @@ async def mock_entra_get_conditional_access_policies(_):
|
||||
),
|
||||
),
|
||||
grant_controls=GrantControls(
|
||||
built_in_controls=[ConditionalAccessGrantControl.BLOCK],
|
||||
built_in_controls=[
|
||||
ConditionalAccessGrantControl.BLOCK,
|
||||
ConditionalAccessGrantControl.COMPLIANT_DEVICE,
|
||||
],
|
||||
operator=GrantControlOperator.OR,
|
||||
authentication_strength=AuthenticationStrength.PHISHING_RESISTANT_MFA,
|
||||
),
|
||||
@@ -211,7 +214,10 @@ class Test_Entra_Service:
|
||||
),
|
||||
),
|
||||
grant_controls=GrantControls(
|
||||
built_in_controls=[ConditionalAccessGrantControl.BLOCK],
|
||||
built_in_controls=[
|
||||
ConditionalAccessGrantControl.BLOCK,
|
||||
ConditionalAccessGrantControl.COMPLIANT_DEVICE,
|
||||
],
|
||||
operator=GrantControlOperator.OR,
|
||||
authentication_strength=AuthenticationStrength.PHISHING_RESISTANT_MFA,
|
||||
),
|
||||
|
||||
Reference in new issue
Block a user