Commit 9be178b0 authored by dockx thibault's avatar dockx thibault
Browse files

Merge branch...

Merge branch '6336-audit-tasks-within-audit-tasks-new-functionnality-allowing-export-of-audit-log-to-syslog' into 'dev'

Resolve "[Audit] - Tasks - Within audit tasks - new functionnality allowing export of audit log to syslog format automatically."

See merge request fusiondirectory/fd-plugins!1094
Showing with 52 additions and 11 deletions
+52 -11
...@@ -72,6 +72,12 @@ attributetype ( 1.3.6.1.4.1.38414.60.1.10 NAME 'fdAuditTasksRetention' ...@@ -72,6 +72,12 @@ attributetype ( 1.3.6.1.4.1.38414.60.1.10 NAME 'fdAuditTasksRetention'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
SINGLE-VALUE ) SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.38414.60.1.11 NAME 'fdAuditSyslogEnabled'
DESC 'FusionDirectory - enable syslog transformation for audit logs'
EQUALITY booleanMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
SINGLE-VALUE )
# Object Class # Object Class
objectclass (1.3.6.1.4.1.38414.60.2.1 NAME 'fdAuditEvent' objectclass (1.3.6.1.4.1.38414.60.2.1 NAME 'fdAuditEvent'
DESC 'FusionDirectory - audit event' DESC 'FusionDirectory - audit event'
...@@ -81,5 +87,4 @@ objectclass (1.3.6.1.4.1.38414.60.2.1 NAME 'fdAuditEvent' ...@@ -81,5 +87,4 @@ objectclass (1.3.6.1.4.1.38414.60.2.1 NAME 'fdAuditEvent'
objectclass (1.3.6.1.4.1.38414.60.2.2 NAME 'fdAuditTasks' objectclass (1.3.6.1.4.1.38414.60.2.2 NAME 'fdAuditTasks'
DESC 'FusionDirectory - audit tasks' DESC 'FusionDirectory - audit tasks'
SUP top AUXILIARY SUP top AUXILIARY
MUST ( fdAuditTasksRetention ) MAY ( fdAuditTasksRetention $ fdAuditSyslogEnabled ) )
MAY ()) \ No newline at end of file
\ No newline at end of file
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
class auditTask extends simplePlugin class auditTask extends simplePlugin
{ {
protected $displayHeader = TRUE; protected $displayHeader = TRUE;
// To understand the last Exec mechanism, reference yourself to Notifications tasks.
protected $lastExec = NULL;
static function plInfo (): array static function plInfo (): array
{ {
...@@ -36,7 +34,7 @@ class auditTask extends simplePlugin ...@@ -36,7 +34,7 @@ class auditTask extends simplePlugin
'plFilter' => '(objectClass=fdAuditTasks)', 'plFilter' => '(objectClass=fdAuditTasks)',
'plObjectType' => ['tasks'], 'plObjectType' => ['tasks'],
// plConflicts take the name of the object class without the 'fd' in front. // plConflicts take the name of the object class without the 'fd' in front.
'plConflicts' => ['tasksMail', 'tasksLifeCycle', 'tasksNotifications'], 'plConflicts' => ['tasksMail', 'tasksLifeCycle', 'tasksNotifications', 'tasksArchive', 'tasksReminder'],
'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()), 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()),
'plForeignKeys' => [], 'plForeignKeys' => [],
]; ];
...@@ -45,7 +43,7 @@ class auditTask extends simplePlugin ...@@ -45,7 +43,7 @@ class auditTask extends simplePlugin
static function getAttributesInfo (): array static function getAttributesInfo (): array
{ {
return [ return [
'section1' => [ 'section1' => [
'name' => _('Schedule Audit Retention'), 'name' => _('Schedule Audit Retention'),
'attrs' => [ 'attrs' => [
new IntAttribute( new IntAttribute(
...@@ -54,15 +52,37 @@ class auditTask extends simplePlugin ...@@ -54,15 +52,37 @@ class auditTask extends simplePlugin
), ),
] ]
], ],
'section2' => [
'name' => _('Syslog Transformation'),
'attrs' => [
new BooleanAttribute(
_('Enable Syslog Transformation'), _('Enable transformation of audit logs into syslog format'),
'fdAuditSyslogEnabled', FALSE, FALSE
),
]
],
]; ];
} }
function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE) function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
{ {
parent::__construct($dn, $object, $parent, $mainTab); parent::__construct($dn, $object, $parent, $mainTab);
// Set the list of available attributes to follow in the set selection // Dynamically disable "Retaining days" if Syslog Transformation is enabled
$this->attributesAccess['fdAuditTasksRetention']->setDisabled(
$this->attributesAccess['fdAuditSyslogEnabled']->getValue()
);
// Add a listener to update the state dynamically when Syslog Transformation is toggled
$this->attributesAccess['fdAuditSyslogEnabled']->setSubmitForm('updateFieldsState');
}
function updateFieldsState ()
{
// Disable "Retaining days" if Syslog Transformation is enabled
$this->attributesAccess['fdAuditTasksRetention']->setDisabled(
$this->attributesAccess['fdAuditSyslogEnabled']->getValue()
);
} }
/** /**
...@@ -71,11 +91,19 @@ class auditTask extends simplePlugin ...@@ -71,11 +91,19 @@ class auditTask extends simplePlugin
*/ */
function generateSlaveTasks () function generateSlaveTasks ()
{ {
// The attribute required to be search in createSlaveTasks // Check if syslog transformation is enabled
$syslogEnabled = $this->attributesAccess['fdAuditSyslogEnabled']->getValue();
// The attribute required to be searched in createSlaveTasks
$attributeType = 'fdTasksGranularDN'; $attributeType = 'fdTasksGranularDN';
// Call the method from parent tasks object (first tab) to create sub-tasks. if ($syslogEnabled) {
$this->parent->getBaseObject()->createSlaveTasks(['auditRetentionTask'], $attributeType, NULL, 'Audit'); // Create sub-tasks for audit syslog transformation
$this->parent->getBaseObject()->createSlaveTasks(['auditSyslogTask'], $attributeType, NULL, 'Audit-Syslog');
} else {
// Create sub-tasks for audit deletion
$this->parent->getBaseObject()->createSlaveTasks(['auditRetentionTask'], $attributeType, NULL, 'Audit');
}
} }
/** /**
...@@ -83,6 +111,14 @@ class auditTask extends simplePlugin ...@@ -83,6 +111,14 @@ class auditTask extends simplePlugin
*/ */
function update (): bool function update (): bool
{ {
// Ensure that both "deletion" and "syslog" are not activated at the same time
$syslogEnabled = $this->attributesAccess['fdAuditSyslogEnabled']->getValue();
$retentionDays = $this->attributesAccess['fdAuditTasksRetention']->getValue();
if ($syslogEnabled && $retentionDays > 0) {
throw new Exception(_('Audit deletion and syslog transformation cannot be activated at the same time.'));
}
parent::update(); parent::update();
return TRUE; return TRUE;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment