diff options
-rw-r--r-- | apps/admin_audit/composer/composer/autoload_classmap.php | 1 | ||||
-rw-r--r-- | apps/admin_audit/composer/composer/autoload_static.php | 1 | ||||
-rw-r--r-- | apps/admin_audit/lib/Actions/Files.php | 30 | ||||
-rw-r--r-- | apps/admin_audit/lib/Actions/Sharing.php | 267 | ||||
-rw-r--r-- | apps/admin_audit/lib/Actions/UserManagement.php | 42 | ||||
-rw-r--r-- | apps/admin_audit/lib/Listener/FileEventListener.php | 38 |
6 files changed, 23 insertions, 356 deletions
diff --git a/apps/admin_audit/composer/composer/autoload_classmap.php b/apps/admin_audit/composer/composer/autoload_classmap.php index b73c4b9b3a5..b67d90e7689 100644 --- a/apps/admin_audit/composer/composer/autoload_classmap.php +++ b/apps/admin_audit/composer/composer/autoload_classmap.php @@ -12,7 +12,6 @@ return array( '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', 'OCA\\AdminAudit\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php', 'OCA\\AdminAudit\\AuditLogger' => $baseDir . '/../lib/AuditLogger.php', diff --git a/apps/admin_audit/composer/composer/autoload_static.php b/apps/admin_audit/composer/composer/autoload_static.php index ec5d6b67011..f8fd457edd8 100644 --- a/apps/admin_audit/composer/composer/autoload_static.php +++ b/apps/admin_audit/composer/composer/autoload_static.php @@ -27,7 +27,6 @@ class ComposerStaticInitAdminAudit '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', 'OCA\\AdminAudit\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php', 'OCA\\AdminAudit\\AuditLogger' => __DIR__ . '/..' . '/../lib/AuditLogger.php', diff --git a/apps/admin_audit/lib/Actions/Files.php b/apps/admin_audit/lib/Actions/Files.php index 50448e88f70..5c08640d2d2 100644 --- a/apps/admin_audit/lib/Actions/Files.php +++ b/apps/admin_audit/lib/Actions/Files.php @@ -18,7 +18,6 @@ use OCP\Files\Events\Node\NodeRenamedEvent; use OCP\Files\Events\Node\NodeWrittenEvent; use OCP\Files\InvalidPathException; use OCP\Files\NotFoundException; -use OCP\Preview\BeforePreviewFetchedEvent; use Psr\Log\LoggerInterface; /** @@ -229,33 +228,4 @@ class Files extends Action { array_keys($params) ); } - - /** - * Logs preview access to a file - * - * @param BeforePreviewFetchedEvent $event - */ - public function preview(BeforePreviewFetchedEvent $event): void { - try { - $file = $event->getNode(); - $params = [ - 'id' => $file->getId(), - 'width' => $event->getWidth(), - 'height' => $event->getHeight(), - 'crop' => $event->isCrop(), - 'mode' => $event->getMode(), - 'path' => mb_substr($file->getInternalPath(), 5) - ]; - } catch (InvalidPathException|NotFoundException $e) { - \OCP\Server::get(LoggerInterface::class)->error( - 'Exception thrown in file preview: '.$e->getMessage(), ['app' => 'admin_audit', 'exception' => $e] - ); - return; - } - $this->log( - 'Preview accessed: (id: "%s", width: "%s", height: "%s" crop: "%s", mode: "%s", path: "%s")', - $params, - array_keys($params) - ); - } } diff --git a/apps/admin_audit/lib/Actions/Sharing.php b/apps/admin_audit/lib/Actions/Sharing.php index bca2b6eecac..8f021d5f210 100644 --- a/apps/admin_audit/lib/Actions/Sharing.php +++ b/apps/admin_audit/lib/Actions/Sharing.php @@ -7,279 +7,12 @@ declare(strict_types=1); */ namespace OCA\AdminAudit\Actions; -use OCP\Share\IShare; - /** * Class Sharing logs the sharing actions * * @package OCA\AdminAudit\Actions */ class Sharing extends Action { - /** - * Logs sharing of data - * - * @param array $params - */ - public function shared(array $params): void { - if ($params['shareType'] === IShare::TYPE_LINK) { - $this->log( - 'The %s "%s" with ID "%s" has been shared via link with permissions "%s" (Share ID: %s)', - $params, - [ - 'itemType', - 'path', - 'itemSource', - 'permissions', - 'id', - ] - ); - } elseif ($params['shareType'] === IShare::TYPE_USER) { - $this->log( - 'The %s "%s" with ID "%s" has been shared to the user "%s" with permissions "%s" (Share ID: %s)', - $params, - [ - 'itemType', - 'path', - 'itemSource', - 'shareWith', - 'permissions', - 'id', - ] - ); - } elseif ($params['shareType'] === IShare::TYPE_GROUP) { - $this->log( - 'The %s "%s" with ID "%s" has been shared to the group "%s" with permissions "%s" (Share ID: %s)', - $params, - [ - 'itemType', - 'path', - 'itemSource', - 'shareWith', - 'permissions', - 'id', - ] - ); - } elseif ($params['shareType'] === IShare::TYPE_ROOM) { - $this->log( - 'The %s "%s" with ID "%s" has been shared to the room "%s" with permissions "%s" (Share ID: %s)', - $params, - [ - 'itemType', - 'path', - 'itemSource', - 'shareWith', - 'permissions', - 'id', - ] - ); - } elseif ($params['shareType'] === IShare::TYPE_EMAIL) { - $this->log( - 'The %s "%s" with ID "%s" has been shared to the email recipient "%s" with permissions "%s" (Share ID: %s)', - $params, - [ - 'itemType', - 'path', - 'itemSource', - 'shareWith', - 'permissions', - 'id', - ] - ); - } elseif ($params['shareType'] === IShare::TYPE_CIRCLE) { - $this->log( - 'The %s "%s" with ID "%s" has been shared to the circle "%s" with permissions "%s" (Share ID: %s)', - $params, - [ - 'itemType', - 'path', - 'itemSource', - 'shareWith', - 'permissions', - 'id', - ] - ); - } elseif ($params['shareType'] === IShare::TYPE_REMOTE) { - $this->log( - 'The %s "%s" with ID "%s" has been shared to the remote user "%s" with permissions "%s" (Share ID: %s)', - $params, - [ - 'itemType', - 'path', - 'itemSource', - 'shareWith', - 'permissions', - 'id', - ] - ); - } elseif ($params['shareType'] === IShare::TYPE_REMOTE_GROUP) { - $this->log( - 'The %s "%s" with ID "%s" has been shared to the remote group "%s" with permissions "%s" (Share ID: %s)', - $params, - [ - 'itemType', - 'path', - 'itemSource', - 'shareWith', - 'permissions', - 'id', - ] - ); - } elseif ($params['shareType'] === IShare::TYPE_DECK) { - $this->log( - 'The %s "%s" with ID "%s" has been shared to the deck card "%s" with permissions "%s" (Share ID: %s)', - $params, - [ - 'itemType', - 'path', - 'itemSource', - 'shareWith', - 'permissions', - 'id', - ] - ); - } elseif ($params['shareType'] === IShare::TYPE_SCIENCEMESH) { - $this->log( - 'The %s "%s" with ID "%s" has been shared to the ScienceMesh user "%s" with permissions "%s" (Share ID: %s)', - $params, - [ - 'itemType', - 'path', - 'itemSource', - 'shareWith', - 'permissions', - 'id', - ] - ); - } - } - - /** - * Logs unsharing of data - * - * @param array $params - */ - public function unshare(array $params): void { - if ($params['shareType'] === IShare::TYPE_LINK) { - $this->log( - 'The %s "%s" with ID "%s" has been unshared (Share ID: %s)', - $params, - [ - 'itemType', - 'fileTarget', - 'itemSource', - 'id', - ] - ); - } elseif ($params['shareType'] === IShare::TYPE_USER) { - $this->log( - 'The %s "%s" with ID "%s" has been unshared from the user "%s" (Share ID: %s)', - $params, - [ - 'itemType', - 'fileTarget', - 'itemSource', - 'shareWith', - 'id', - ] - ); - } elseif ($params['shareType'] === IShare::TYPE_GROUP) { - $this->log( - 'The %s "%s" with ID "%s" has been unshared from the group "%s" (Share ID: %s)', - $params, - [ - 'itemType', - 'fileTarget', - 'itemSource', - 'shareWith', - 'id', - ] - ); - } elseif ($params['shareType'] === IShare::TYPE_ROOM) { - $this->log( - 'The %s "%s" with ID "%s" has been unshared from the room "%s" (Share ID: %s)', - $params, - [ - 'itemType', - 'fileTarget', - 'itemSource', - 'shareWith', - 'id', - ] - ); - } elseif ($params['shareType'] === IShare::TYPE_EMAIL) { - $this->log( - 'The %s "%s" with ID "%s" has been unshared from the email recipient "%s" (Share ID: %s)', - $params, - [ - 'itemType', - 'fileTarget', - 'itemSource', - 'shareWith', - 'id', - ] - ); - } elseif ($params['shareType'] === IShare::TYPE_CIRCLE) { - $this->log( - 'The %s "%s" with ID "%s" has been unshared from the circle "%s" (Share ID: %s)', - $params, - [ - 'itemType', - 'fileTarget', - 'itemSource', - 'shareWith', - 'id', - ] - ); - } elseif ($params['shareType'] === IShare::TYPE_REMOTE) { - $this->log( - 'The %s "%s" with ID "%s" has been unshared from the remote user "%s" (Share ID: %s)', - $params, - [ - 'itemType', - 'fileTarget', - 'itemSource', - 'shareWith', - 'id', - ] - ); - } elseif ($params['shareType'] === IShare::TYPE_REMOTE_GROUP) { - $this->log( - 'The %s "%s" with ID "%s" has been unshared from the remote group "%s" (Share ID: %s)', - $params, - [ - 'itemType', - 'fileTarget', - 'itemSource', - 'shareWith', - 'id', - ] - ); - } elseif ($params['shareType'] === IShare::TYPE_DECK) { - $this->log( - 'The %s "%s" with ID "%s" has been unshared from the deck card "%s" (Share ID: %s)', - $params, - [ - 'itemType', - 'fileTarget', - 'itemSource', - 'shareWith', - 'id', - ] - ); - } elseif ($params['shareType'] === IShare::TYPE_SCIENCEMESH) { - $this->log( - 'The %s "%s" with ID "%s" has been unshared from the ScienceMesh user "%s" (Share ID: %s)', - $params, - [ - 'itemType', - 'fileTarget', - 'itemSource', - 'shareWith', - 'id', - ] - ); - } - } /** * Logs the updating of permission changes for shares diff --git a/apps/admin_audit/lib/Actions/UserManagement.php b/apps/admin_audit/lib/Actions/UserManagement.php deleted file mode 100644 index 5b8b11f196b..00000000000 --- a/apps/admin_audit/lib/Actions/UserManagement.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php - -declare(strict_types=1); -/** - * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ -namespace OCA\AdminAudit\Actions; - -/** - * Class UserManagement logs all user management related actions. - * - * @package OCA\AdminAudit\Actions - */ -class UserManagement extends Action { - - /** - * Log assignments of users (typically user backends) - * - * @param string $uid - */ - public function assign(string $uid): void { - $this->log( - 'UserID assigned: "%s"', - [ 'uid' => $uid ], - [ 'uid' ] - ); - } - - /** - * Log unassignments of users (typically user backends, no data removed) - * - * @param string $uid - */ - public function unassign(string $uid): void { - $this->log( - 'UserID unassigned: "%s"', - [ 'uid' => $uid ], - [ 'uid' ] - ); - } -} diff --git a/apps/admin_audit/lib/Listener/FileEventListener.php b/apps/admin_audit/lib/Listener/FileEventListener.php index a931ef18241..74bb2ac836c 100644 --- a/apps/admin_audit/lib/Listener/FileEventListener.php +++ b/apps/admin_audit/lib/Listener/FileEventListener.php @@ -12,7 +12,10 @@ namespace OCA\AdminAudit\Listener; use OCA\AdminAudit\Actions\Action; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; +use OCP\Files\InvalidPathException; +use OCP\Files\NotFoundException; use OCP\Preview\BeforePreviewFetchedEvent; +use Psr\Log\LoggerInterface; /** * @template-implements IEventListener<BeforePreviewFetchedEvent> @@ -24,25 +27,30 @@ class FileEventListener extends Action implements IEventListener { } } + /** + * Logs preview access to a file + */ private function beforePreviewFetched(BeforePreviewFetchedEvent $event): void { - $file = $event->getNode(); - - $this->log( - 'Preview accessed: "%s" (width: "%s", height: "%s" crop: "%s", mode: "%s")', - [ - 'path' => mb_substr($file->getInternalPath(), 5), + try { + $file = $event->getNode(); + $params = [ + 'id' => $file->getId(), 'width' => $event->getWidth(), 'height' => $event->getHeight(), 'crop' => $event->isCrop(), 'mode' => $event->getMode(), - ], - [ - 'path', - 'width', - 'height', - 'crop', - 'mode' - ] - ); + 'path' => mb_substr($file->getInternalPath(), 5) + ]; + $this->log( + 'Preview accessed: (id: "%s", width: "%s", height: "%s" crop: "%s", mode: "%s", path: "%s")', + $params, + array_keys($params) + ); + } catch (InvalidPathException|NotFoundException $e) { + \OCP\Server::get(LoggerInterface::class)->error( + 'Exception thrown in file preview: '.$e->getMessage(), ['app' => 'admin_audit', 'exception' => $e] + ); + return; + } } } |