Skip to content

Commit

Permalink
feat(admin_audit): Audit the tag creation
Browse files Browse the repository at this point in the history
Co-authored-by: greta <[email protected]>
Co-authored-by: Ferdinand Thiessen <[email protected]>
Signed-off-by: greta <[email protected]>
  • Loading branch information
GretaD and susnux committed Jul 10, 2024
1 parent e31f474 commit feb227f
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/admin_audit/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
'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',
Expand Down
1 change: 1 addition & 0 deletions apps/admin_audit/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
27 changes: 27 additions & 0 deletions apps/admin_audit/lib/Actions/TagManagement.php
Original file line number Diff line number Diff line change
@@ -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']
);
}
}
9 changes: 9 additions & 0 deletions apps/admin_audit/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
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;
Expand Down Expand Up @@ -99,6 +100,7 @@ private function registerHooks(IAuditLogger $logger,
$this->versionsHooks($logger);

$this->securityHooks($logger, $eventDispatcher);
$this->tagHooks($logger, $eventDispatcher);
}

private function userManagementHooks(IAuditLogger $logger,
Expand Down Expand Up @@ -169,6 +171,13 @@ private function consoleHooks(IAuditLogger $logger,
$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) {

Check notice

Code scanning / Psalm

DeprecatedConstant Note

Constant OCP\SystemTag\ManagerEvent::EVENT_CREATE is deprecated
$tagActions = new TagManagement($logger);
$tagActions->createTag($event->getTag());
});
}

private function fileHooks(IAuditLogger $logger,
IEventDispatcher $eventDispatcher): void {
Expand Down

0 comments on commit feb227f

Please sign in to comment.