-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dms): add new check
dms_replication_task_source_logging_enabled
(
#5627) Co-authored-by: Sergio <sergio@prowler.com>
- Loading branch information
1 parent
a2dba30
commit d5873c0
Showing
6 changed files
with
694 additions
and
1 deletion.
There are no files selected for viewing
Empty file.
32 changes: 32 additions & 0 deletions
32
...ion_task_source_logging_enabled/dms_replication_task_source_logging_enabled.metadata.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"Provider": "aws", | ||
"CheckID": "dms_replication_task_source_logging_enabled", | ||
"CheckTitle": "Check if DMS replication tasks for the source database have logging enabled.", | ||
"CheckType": [ | ||
"Software and Configuration Checks/AWS Security Best Practices" | ||
], | ||
"ServiceName": "dms", | ||
"SubServiceName": "", | ||
"ResourceIdTemplate": "arn:aws:dms:region:account-id:task/task-id", | ||
"Severity": "medium", | ||
"ResourceType": "AwsDmsReplicationTask", | ||
"Description": "This control checks whether logging is enabled with the minimum severity level of LOGGER_SEVERITY_DEFAULT for DMS replication tasks SOURCE_CAPTURE and SOURCE_UNLOAD. The control fails if logging isn't enabled for these tasks or if the minimum severity level is less than LOGGER_SEVERITY_DEFAULT.", | ||
"Risk": "Without logging enabled, issues in data migration may go undetected, affecting the integrity and compliance of replicated data.", | ||
"RelatedUrl": "https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Monitoring.html#CHAP_Monitoring.ManagingLogs", | ||
"Remediation": { | ||
"Code": { | ||
"CLI": "aws dms modify-replication-task --replication-task-arn <task-arn> --task-settings '{\"Logging\":{\"EnableLogging\":true,\"LogComponents\":[{\"Id\":\"SOURCE_CAPTURE\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"},{\"Id\":\"SOURCE_UNLOAD\",\"Severity\":\"LOGGER_SEVERITY_DEFAULT\"}]}}'", | ||
"NativeIaC": "", | ||
"Other": "https://docs.aws.amazon.com/securityhub/latest/userguide/dms-controls.html#dms-8", | ||
"Terraform": "" | ||
}, | ||
"Recommendation": { | ||
"Text": "Enable logging for source database DMS replication tasks with a minimum severity level of LOGGER_SEVERITY_DEFAULT.", | ||
"Url": "https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Tasks.CustomizingTasks.TaskSettings.Logging.html" | ||
} | ||
}, | ||
"Categories": [], | ||
"DependsOn": [], | ||
"RelatedTo": [], | ||
"Notes": "" | ||
} |
79 changes: 79 additions & 0 deletions
79
...ms_replication_task_source_logging_enabled/dms_replication_task_source_logging_enabled.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
from typing import List | ||
|
||
from prowler.lib.check.models import Check, Check_Report_AWS | ||
from prowler.providers.aws.services.dms.dms_client import dms_client | ||
|
||
|
||
class dms_replication_task_source_logging_enabled(Check): | ||
""" | ||
Check if AWS DMS replication tasks have logging enabled with the required | ||
logging components and severity levels. | ||
This class verifies that each DMS replication task has logging enabled | ||
and that the components SOURCE_CAPTURE and SOURCE_UNLOAD are configured with | ||
at least LOGGER_SEVERITY_DEFAULT severity level. If either component is missing | ||
or does not meet the minimum severity requirement, the check will fail. | ||
""" | ||
|
||
def execute(self) -> List[Check_Report_AWS]: | ||
""" | ||
Execute the DMS replication task logging requirements check. | ||
Iterates over all DMS replication tasks and generates a report indicating | ||
whether each task has logging enabled and meets the logging requirements | ||
for SOURCE_CAPTURE and SOURCE_UNLOAD components. | ||
Returns: | ||
List[Check_Report_AWS]: A list of report objects with the results of the check. | ||
""" | ||
MINIMUM_SEVERITY_LEVELS = [ | ||
"LOGGER_SEVERITY_DEFAULT", | ||
"LOGGER_SEVERITY_DEBUG", | ||
"LOGGER_SEVERITY_DETAILED_DEBUG", | ||
] | ||
findings = [] | ||
for ( | ||
replication_task_arn, | ||
replication_task, | ||
) in dms_client.replication_tasks.items(): | ||
report = Check_Report_AWS(self.metadata()) | ||
report.resource_id = replication_task.id | ||
report.resource_arn = replication_task_arn | ||
report.region = replication_task.region | ||
report.resource_tags = replication_task.tags | ||
|
||
if not replication_task.logging_enabled: | ||
report.status = "FAIL" | ||
report.status_extended = f"DMS Replication Task {replication_task.id} does not have logging enabled for source events." | ||
else: | ||
missing_components = [] | ||
source_capture_compliant = False | ||
source_unload_compliant = False | ||
|
||
for component in replication_task.log_components: | ||
if ( | ||
component["Id"] == "SOURCE_CAPTURE" | ||
and component["Severity"] in MINIMUM_SEVERITY_LEVELS | ||
): | ||
source_capture_compliant = True | ||
elif ( | ||
component["Id"] == "SOURCE_UNLOAD" | ||
and component["Severity"] in MINIMUM_SEVERITY_LEVELS | ||
): | ||
source_unload_compliant = True | ||
|
||
if not source_capture_compliant: | ||
missing_components.append("Source Capture") | ||
if not source_unload_compliant: | ||
missing_components.append("Source Unload") | ||
|
||
if source_capture_compliant and source_unload_compliant: | ||
report.status = "PASS" | ||
report.status_extended = f"DMS Replication Task {replication_task.id} has logging enabled with the minimum severity level in source events." | ||
else: | ||
report.status = "FAIL" | ||
report.status_extended = f"DMS Replication Task {replication_task.id} does not meet the minimum severity level of logging in {', '.join(missing_components)} events." | ||
|
||
findings.append(report) | ||
|
||
return findings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.