diff --git a/prowler/providers/aws/services/stepfunctions/stepfunctions_statemachine_logging_enabled/stepfunctions_statemachine_logging_enabled.py b/prowler/providers/aws/services/stepfunctions/stepfunctions_statemachine_logging_enabled/stepfunctions_statemachine_logging_enabled.py index f5dc00e121..328896c8e6 100644 --- a/prowler/providers/aws/services/stepfunctions/stepfunctions_statemachine_logging_enabled/stepfunctions_statemachine_logging_enabled.py +++ b/prowler/providers/aws/services/stepfunctions/stepfunctions_statemachine_logging_enabled/stepfunctions_statemachine_logging_enabled.py @@ -33,7 +33,10 @@ class stepfunctions_statemachine_logging_enabled(Check): report.status = "PASS" report.status_extended = f"Step Functions state machine {state_machine.name} has logging enabled." - if state_machine.logging_configuration.level == LoggingLevel.OFF: + if ( + not state_machine.logging_configuration + or state_machine.logging_configuration.level == LoggingLevel.OFF + ): report.status = "FAIL" report.status_extended = f"Step Functions state machine {state_machine.name} does not have logging enabled." findings.append(report) diff --git a/tests/providers/aws/services/stepfunctions/stepfunctions_statemachine_logging_enabled/stepfunctions_statemachine_logging_enabled_test.py b/tests/providers/aws/services/stepfunctions/stepfunctions_statemachine_logging_enabled/stepfunctions_statemachine_logging_enabled_test.py index 212267fdf3..801c045f5b 100644 --- a/tests/providers/aws/services/stepfunctions/stepfunctions_statemachine_logging_enabled/stepfunctions_statemachine_logging_enabled_test.py +++ b/tests/providers/aws/services/stepfunctions/stepfunctions_statemachine_logging_enabled/stepfunctions_statemachine_logging_enabled_test.py @@ -74,6 +74,15 @@ def create_state_machine(name, logging_configuration): }, 1, ), # Logging enabled + ( + { + STATE_MACHINE_ARN: create_state_machine( + "TestStateMachine", + None, + ) + }, + 1, + ), # Logging configuration is None ], ) @mock_aws(config={"stepfunctions": {"execute_state_machine": True}}) @@ -104,10 +113,9 @@ def test_stepfunctions_statemachine_logging(state_machines, expected_status): # Additional assertions for specific scenarios if expected_status == 1: - if ( - state_machines[STATE_MACHINE_ARN].logging_configuration.level - == LoggingLevel.OFF - ): + logging_conf = state_machines[STATE_MACHINE_ARN].logging_configuration + + if logging_conf is None or logging_conf.level == LoggingLevel.OFF: assert result[0].status == "FAIL" assert ( result[0].status_extended @@ -123,3 +131,4 @@ def test_stepfunctions_statemachine_logging(state_machines, expected_status): assert result[0].resource_id == STATE_MACHINE_ID assert result[0].resource_arn == STATE_MACHINE_ARN assert result[0].region == AWS_REGION_EU_WEST_1 + assert result[0].resource == state_machines[STATE_MACHINE_ARN]