diff --git a/plugins/tasks/Audit.php b/plugins/tasks/Audit.php index 94818316140c49b7b8f0ed19d0a8373639baa358..ed529f33d5afcdd5f6376ab6797fd7871f2e86c9 100644 --- a/plugins/tasks/Audit.php +++ b/plugins/tasks/Audit.php @@ -2,14 +2,11 @@ class Audit implements EndpointInterface { - private TaskGateway $gateway; - private Utils $utils; public function __construct (TaskGateway $gateway) { $this->gateway = $gateway; - $this->utils = new Utils(); } /** @@ -46,15 +43,28 @@ class Audit implements EndpointInterface */ public function processEndPointPatch (array $data = NULL): array { - $result = $this->processAuditDeletion($this->gateway->getObjectTypeTask('Audit')); + // Check if audit type is specified in data + $auditType = $data['type'] ?? 'standard'; // Default to standard audit + + if ($auditType === 'syslog') { + // Process syslog audit + $result = $this->processSyslogAuditTransformation($this->gateway->getObjectTypeTask('Audit-Syslog')); + } else { + // Process standard audit + $result = $this->processAuditDeletion($this->gateway->getObjectTypeTask('Audit')); + } // Recursive function to filter out empty arrays at any depth - $nonEmptyResults = $this->utils->recursiveArrayFilter($result); + $nonEmptyResults = $this->recursiveArrayFilter($result); if (!empty($nonEmptyResults)) { return $nonEmptyResults; } else { - return ['No audit requiring removal']; + if ($auditType === 'syslog') { + return ['No syslog audit entries requiring removal']; + } else { + return ['No standard audit entries requiring removal']; + } } } @@ -85,6 +95,26 @@ class Audit implements EndpointInterface return $result; } + /** + * @param array $syslogAuditSubTasks + * @return array + * @throws Exception + */ + public function processSyslogAuditTransformation (array $syslogAuditSubTasks): array + { + $result = []; + + print_r($syslogAuditSubTasks); + exit; + + foreach ($syslogAuditSubTasks as $task) { + // Similar to processAuditDeletion but for syslog + // ... + } + + return $result; + } + /** * @param string $mainTaskDn * @return array @@ -121,4 +151,19 @@ class Audit implements EndpointInterface return $audit; } + + /** + * @param array $array + * @return array + * Note : Recursively filters out empty values and arrays at any depth. + */ + public function recursiveArrayFilter (array $array): array + { + return array_filter($array, function ($item) { + if (is_array($item)) { + $item = $this->recursiveArrayFilter($item); + } + return !empty($item); + }); + } } \ No newline at end of file