feat(admin_audit): Audit the tag creation

Co-authored-by: greta <gretadoci@gmail.com>
Co-authored-by: Ferdinand Thiessen <opensource@fthiessen.de>
Signed-off-by: greta <gretadoci@gmail.com>
pull/40163/head
greta 1 year ago committed by Andy Scherzinger
parent 29661b045c
commit d590373ae7
  1. 1
      apps/admin_audit/composer/composer/autoload_classmap.php
  2. 1
      apps/admin_audit/composer/composer/autoload_static.php
  3. 27
      apps/admin_audit/lib/Actions/TagManagement.php
  4. 9
      apps/admin_audit/lib/AppInfo/Application.php

@ -15,6 +15,7 @@ return array(
'OCA\\AdminAudit\\Actions\\GroupManagement' => $baseDir . '/../lib/Actions/GroupManagement.php',
'OCA\\AdminAudit\\Actions\\Security' => $baseDir . '/../lib/Actions/Security.php',
'OCA\\AdminAudit\\Actions\\Sharing' => $baseDir . '/../lib/Actions/Sharing.php',
'OCA\\AdminAudit\\Actions\\TagManagement' => $baseDir . '/../lib/Actions/TagManagement.php',
'OCA\\AdminAudit\\Actions\\Trashbin' => $baseDir . '/../lib/Actions/Trashbin.php',
'OCA\\AdminAudit\\Actions\\UserManagement' => $baseDir . '/../lib/Actions/UserManagement.php',
'OCA\\AdminAudit\\Actions\\Versions' => $baseDir . '/../lib/Actions/Versions.php',

@ -30,6 +30,7 @@ class ComposerStaticInitAdminAudit
'OCA\\AdminAudit\\Actions\\GroupManagement' => __DIR__ . '/..' . '/../lib/Actions/GroupManagement.php',
'OCA\\AdminAudit\\Actions\\Security' => __DIR__ . '/..' . '/../lib/Actions/Security.php',
'OCA\\AdminAudit\\Actions\\Sharing' => __DIR__ . '/..' . '/../lib/Actions/Sharing.php',
'OCA\\AdminAudit\\Actions\\TagManagement' => __DIR__ . '/..' . '/../lib/Actions/TagManagement.php',
'OCA\\AdminAudit\\Actions\\Trashbin' => __DIR__ . '/..' . '/../lib/Actions/Trashbin.php',
'OCA\\AdminAudit\\Actions\\UserManagement' => __DIR__ . '/..' . '/../lib/Actions/UserManagement.php',
'OCA\\AdminAudit\\Actions\\Versions' => __DIR__ . '/..' . '/../lib/Actions/Versions.php',

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
/*!
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\AdminAudit\Actions;
use OCP\SystemTag\ISystemTag;
class TagManagement extends Action {
/**
* @param ISystemTag $tag newly created tag
*/
public function createTag(ISystemTag $tag): void {
$this->log('System tag "%s" (%s, %s) created',
[
'name' => $tag->getName(),
'visbility' => $tag->isUserVisible() ? 'visible' : 'invisible',
'assignable' => $tag->isUserAssignable() ? 'user assignable' : 'system only',
],
['name', 'visibility', 'assignable']
);
}
}

@ -16,6 +16,7 @@ use OCA\AdminAudit\Actions\Files;
use OCA\AdminAudit\Actions\GroupManagement;
use OCA\AdminAudit\Actions\Security;
use OCA\AdminAudit\Actions\Sharing;
use OCA\AdminAudit\Actions\TagManagement;
use OCA\AdminAudit\Actions\Trashbin;
use OCA\AdminAudit\Actions\UserManagement;
use OCA\AdminAudit\Actions\Versions;
@ -99,6 +100,7 @@ class Application extends App implements IBootstrap {
$this->versionsHooks($logger);
$this->securityHooks($logger, $eventDispatcher);
$this->tagHooks($logger, $eventDispatcher);
}
private function userManagementHooks(IAuditLogger $logger,
@ -169,6 +171,13 @@ class Application extends App implements IBootstrap {
$appActions->runCommand($event->getArguments());
});
}
private function tagHooks(IAuditLogger $logger,
IEventDispatcher $eventDispatcher): void {
$eventDispatcher->addListener(\OCP\SystemTag\ManagerEvent::EVENT_CREATE, function (\OCP\SystemTag\ManagerEvent $event) use ($logger) {
$tagActions = new TagManagement($logger);
$tagActions->createTag($event->getTag());
});
}
private function fileHooks(IAuditLogger $logger,
IEventDispatcher $eventDispatcher): void {

Loading…
Cancel
Save