diff options
Diffstat (limited to 'apps/admin_audit')
31 files changed, 133 insertions, 77 deletions
diff --git a/apps/admin_audit/appinfo/info.xml b/apps/admin_audit/appinfo/info.xml index cfdfebaacb4..6bdacf96a2c 100644 --- a/apps/admin_audit/appinfo/info.xml +++ b/apps/admin_audit/appinfo/info.xml @@ -10,7 +10,7 @@ <name>Auditing / Logging</name> <summary>Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions.</summary> <description>Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions.</description> - <version>1.21.0</version> + <version>1.22.0</version> <licence>agpl</licence> <author>Nextcloud</author> <namespace>AdminAudit</namespace> @@ -20,7 +20,7 @@ <category>monitoring</category> <bugs>https://github.com/nextcloud/server/issues</bugs> <dependencies> - <nextcloud min-version="31" max-version="31"/> + <nextcloud min-version="32" max-version="32"/> </dependencies> <background-jobs> <job>OCA\AdminAudit\BackgroundJobs\Rotate</job> diff --git a/apps/admin_audit/l10n/be.js b/apps/admin_audit/l10n/be.js new file mode 100644 index 00000000000..bb52accdf5c --- /dev/null +++ b/apps/admin_audit/l10n/be.js @@ -0,0 +1,7 @@ +OC.L10N.register( + "admin_audit", + { + "Auditing / Logging" : "Аўдыт / Журнал", + "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Прадастаўляе магчымасці вядзення журнала дзенняў для Nextcloud, такіх як доступ да файлаў або іншых канфідэнцыйных дзеянняў." +}, +"nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);"); diff --git a/apps/admin_audit/l10n/be.json b/apps/admin_audit/l10n/be.json new file mode 100644 index 00000000000..6b36dae579b --- /dev/null +++ b/apps/admin_audit/l10n/be.json @@ -0,0 +1,5 @@ +{ "translations": { + "Auditing / Logging" : "Аўдыт / Журнал", + "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Прадастаўляе магчымасці вядзення журнала дзенняў для Nextcloud, такіх як доступ да файлаў або іншых канфідэнцыйных дзеянняў." +},"pluralForm" :"nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);" +}
\ No newline at end of file diff --git a/apps/admin_audit/l10n/bg.js b/apps/admin_audit/l10n/bg.js index cd82e96ec73..2769c6899f8 100644 --- a/apps/admin_audit/l10n/bg.js +++ b/apps/admin_audit/l10n/bg.js @@ -1,7 +1,7 @@ OC.L10N.register( "admin_audit", { - "Auditing / Logging" : "Одитиране/създаване на регистри", - "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Предоставя възможности за регистриране в Nextcloud, като например достъп до файлове за регистриране или други чувствителни действия." + "Auditing / Logging" : "Одитиране / Регистри на действията", + "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Предоставя възможности за създаване на регистри на действията в \"Nextcloud\", като например кой е осъществил достъп до файл или други действия." }, "nplurals=2; plural=(n != 1);"); diff --git a/apps/admin_audit/l10n/bg.json b/apps/admin_audit/l10n/bg.json index 770ffcbf35a..4d3ac67c0a6 100644 --- a/apps/admin_audit/l10n/bg.json +++ b/apps/admin_audit/l10n/bg.json @@ -1,5 +1,5 @@ { "translations": { - "Auditing / Logging" : "Одитиране/създаване на регистри", - "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Предоставя възможности за регистриране в Nextcloud, като например достъп до файлове за регистриране или други чувствителни действия." + "Auditing / Logging" : "Одитиране / Регистри на действията", + "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Предоставя възможности за създаване на регистри на действията в \"Nextcloud\", като например кой е осъществил достъп до файл или други действия." },"pluralForm" :"nplurals=2; plural=(n != 1);" }
\ No newline at end of file diff --git a/apps/admin_audit/l10n/br.js b/apps/admin_audit/l10n/br.js new file mode 100644 index 00000000000..3190748725a --- /dev/null +++ b/apps/admin_audit/l10n/br.js @@ -0,0 +1,6 @@ +OC.L10N.register( + "admin_audit", + { + "Auditing / Logging" : "Aodit / Kerzhlevr" +}, +"nplurals=5; plural=((n%10 == 1) && (n%100 != 11) && (n%100 !=71) && (n%100 !=91) ? 0 :(n%10 == 2) && (n%100 != 12) && (n%100 !=72) && (n%100 !=92) ? 1 :(n%10 ==3 || n%10==4 || n%10==9) && (n%100 < 10 || n% 100 > 19) && (n%100 < 70 || n%100 > 79) && (n%100 < 90 || n%100 > 99) ? 2 :(n != 0 && n % 1000000 == 0) ? 3 : 4);"); diff --git a/apps/admin_audit/l10n/br.json b/apps/admin_audit/l10n/br.json new file mode 100644 index 00000000000..b70638a3de0 --- /dev/null +++ b/apps/admin_audit/l10n/br.json @@ -0,0 +1,4 @@ +{ "translations": { + "Auditing / Logging" : "Aodit / Kerzhlevr" +},"pluralForm" :"nplurals=5; plural=((n%10 == 1) && (n%100 != 11) && (n%100 !=71) && (n%100 !=91) ? 0 :(n%10 == 2) && (n%100 != 12) && (n%100 !=72) && (n%100 !=92) ? 1 :(n%10 ==3 || n%10==4 || n%10==9) && (n%100 < 10 || n% 100 > 19) && (n%100 < 70 || n%100 > 79) && (n%100 < 90 || n%100 > 99) ? 2 :(n != 0 && n % 1000000 == 0) ? 3 : 4);" +}
\ No newline at end of file diff --git a/apps/admin_audit/l10n/eo.js b/apps/admin_audit/l10n/eo.js index 3ab916b0b54..17becacc88e 100644 --- a/apps/admin_audit/l10n/eo.js +++ b/apps/admin_audit/l10n/eo.js @@ -2,6 +2,6 @@ OC.L10N.register( "admin_audit", { "Auditing / Logging" : "Ekzamenado / Protokolado", - "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Provizi protokolado-kapablojn por Nextcloud, kiel ekzemple protokolado de aliroj al dosieroj aŭ aliaj delikataj agoj." + "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Ebligas protokoladon, ekzemple protokolado de aliroj al dosieroj aŭ aliaj delikataj agoj." }, "nplurals=2; plural=(n != 1);"); diff --git a/apps/admin_audit/l10n/eo.json b/apps/admin_audit/l10n/eo.json index eef1c6821c5..293d8cce025 100644 --- a/apps/admin_audit/l10n/eo.json +++ b/apps/admin_audit/l10n/eo.json @@ -1,5 +1,5 @@ { "translations": { "Auditing / Logging" : "Ekzamenado / Protokolado", - "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Provizi protokolado-kapablojn por Nextcloud, kiel ekzemple protokolado de aliroj al dosieroj aŭ aliaj delikataj agoj." + "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Ebligas protokoladon, ekzemple protokolado de aliroj al dosieroj aŭ aliaj delikataj agoj." },"pluralForm" :"nplurals=2; plural=(n != 1);" }
\ No newline at end of file diff --git a/apps/admin_audit/l10n/es_CR.js b/apps/admin_audit/l10n/es_CR.js index 554f249b125..a051b8053d3 100644 --- a/apps/admin_audit/l10n/es_CR.js +++ b/apps/admin_audit/l10n/es_CR.js @@ -1,6 +1,7 @@ OC.L10N.register( "admin_audit", { - "Auditing / Logging" : "Auditoría / Registros" + "Auditing / Logging" : "Auditoría / Registros", + "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Proporciona capacidades de registro para Nextcloud, como el registro de accesos a archivos o acciones sensibles." }, "nplurals=3; plural=n == 1 ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;"); diff --git a/apps/admin_audit/l10n/es_CR.json b/apps/admin_audit/l10n/es_CR.json index 772c7486a7b..00a101b11b8 100644 --- a/apps/admin_audit/l10n/es_CR.json +++ b/apps/admin_audit/l10n/es_CR.json @@ -1,4 +1,5 @@ { "translations": { - "Auditing / Logging" : "Auditoría / Registros" + "Auditing / Logging" : "Auditoría / Registros", + "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Proporciona capacidades de registro para Nextcloud, como el registro de accesos a archivos o acciones sensibles." },"pluralForm" :"nplurals=3; plural=n == 1 ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;" }
\ No newline at end of file diff --git a/apps/admin_audit/l10n/id.js b/apps/admin_audit/l10n/id.js index 441f1940069..144a85299f1 100644 --- a/apps/admin_audit/l10n/id.js +++ b/apps/admin_audit/l10n/id.js @@ -1,7 +1,7 @@ OC.L10N.register( "admin_audit", { - "Auditing / Logging" : "Pemeriksaan / Pencatatan", - "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Menyediakan kemampuan pencatatan untuk Nextcloud seperti pencatatan akses berkas atau tindakan sensitif lainnya." + "Auditing / Logging" : "Pengauditan/Pencatatan", + "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Menyediakan kemampuan pencatatan untuk Nextcloud, misalnya pencatatan akses file atau tindakan sensitif lainnya." }, "nplurals=1; plural=0;"); diff --git a/apps/admin_audit/l10n/id.json b/apps/admin_audit/l10n/id.json index 91af029f895..868f7c94d32 100644 --- a/apps/admin_audit/l10n/id.json +++ b/apps/admin_audit/l10n/id.json @@ -1,5 +1,5 @@ { "translations": { - "Auditing / Logging" : "Pemeriksaan / Pencatatan", - "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Menyediakan kemampuan pencatatan untuk Nextcloud seperti pencatatan akses berkas atau tindakan sensitif lainnya." + "Auditing / Logging" : "Pengauditan/Pencatatan", + "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Menyediakan kemampuan pencatatan untuk Nextcloud, misalnya pencatatan akses file atau tindakan sensitif lainnya." },"pluralForm" :"nplurals=1; plural=0;" }
\ No newline at end of file diff --git a/apps/admin_audit/l10n/lv.js b/apps/admin_audit/l10n/lv.js index e583bce358a..9aba6a9da59 100644 --- a/apps/admin_audit/l10n/lv.js +++ b/apps/admin_audit/l10n/lv.js @@ -2,6 +2,6 @@ OC.L10N.register( "admin_audit", { "Auditing / Logging" : "Auditēšana / Žurnalizēšana", - "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Nodrošina Nextcloud žurnalizēšanas iespējas, piemēram, faila piekļuves žurnalizēšanu vai citas sensitīvas darbības." + "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Nodrošina Nextcloud žurnalēšanas spējas, piemēram, datņu piekļuves žurnalēšanu vai citas jūtīgas darbības." }, "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2);"); diff --git a/apps/admin_audit/l10n/lv.json b/apps/admin_audit/l10n/lv.json index 3bac82cde2a..8fa3c22ebd3 100644 --- a/apps/admin_audit/l10n/lv.json +++ b/apps/admin_audit/l10n/lv.json @@ -1,5 +1,5 @@ { "translations": { "Auditing / Logging" : "Auditēšana / Žurnalizēšana", - "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Nodrošina Nextcloud žurnalizēšanas iespējas, piemēram, faila piekļuves žurnalizēšanu vai citas sensitīvas darbības." + "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Nodrošina Nextcloud žurnalēšanas spējas, piemēram, datņu piekļuves žurnalēšanu vai citas jūtīgas darbības." },"pluralForm" :"nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2);" }
\ No newline at end of file diff --git a/apps/admin_audit/l10n/pt_BR.js b/apps/admin_audit/l10n/pt_BR.js index a706afdc942..67b7e27fad8 100644 --- a/apps/admin_audit/l10n/pt_BR.js +++ b/apps/admin_audit/l10n/pt_BR.js @@ -2,6 +2,6 @@ OC.L10N.register( "admin_audit", { "Auditing / Logging" : "Auditoria / Registro", - "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Fornece habilidades de registro para o NextCloud, como acessos de arquivo de log ou ações sensíveis." + "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Fornece recursos de registro para o Nextcloud, como acessos a arquivos de registro ou outras ações sensíveis." }, "nplurals=3; plural=(n == 0 || n == 1) ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;"); diff --git a/apps/admin_audit/l10n/pt_BR.json b/apps/admin_audit/l10n/pt_BR.json index befc0c2c900..2d745b9c979 100644 --- a/apps/admin_audit/l10n/pt_BR.json +++ b/apps/admin_audit/l10n/pt_BR.json @@ -1,5 +1,5 @@ { "translations": { "Auditing / Logging" : "Auditoria / Registro", - "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Fornece habilidades de registro para o NextCloud, como acessos de arquivo de log ou ações sensíveis." + "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Fornece recursos de registro para o Nextcloud, como acessos a arquivos de registro ou outras ações sensíveis." },"pluralForm" :"nplurals=3; plural=(n == 0 || n == 1) ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;" }
\ No newline at end of file diff --git a/apps/admin_audit/l10n/pt_PT.js b/apps/admin_audit/l10n/pt_PT.js index 72f6e8a62eb..2289d0fa8e7 100644 --- a/apps/admin_audit/l10n/pt_PT.js +++ b/apps/admin_audit/l10n/pt_PT.js @@ -1,7 +1,7 @@ OC.L10N.register( "admin_audit", { - "Auditing / Logging" : "Auditorias / Registos", - "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Fornece funcionalidades de registo para o Nextcloud como registar acessos a ficheiros ou demais ações sensíveis. " + "Auditing / Logging" : "Auditorias / registos", + "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Fornece funcionalidades de registo para o Nextcloud como registar acessos a ficheiros ou outras ações sensíveis. " }, "nplurals=3; plural=(n == 0 || n == 1) ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;"); diff --git a/apps/admin_audit/l10n/pt_PT.json b/apps/admin_audit/l10n/pt_PT.json index 19e9845c0f0..ba9810d585c 100644 --- a/apps/admin_audit/l10n/pt_PT.json +++ b/apps/admin_audit/l10n/pt_PT.json @@ -1,5 +1,5 @@ { "translations": { - "Auditing / Logging" : "Auditorias / Registos", - "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Fornece funcionalidades de registo para o Nextcloud como registar acessos a ficheiros ou demais ações sensíveis. " + "Auditing / Logging" : "Auditorias / registos", + "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Fornece funcionalidades de registo para o Nextcloud como registar acessos a ficheiros ou outras ações sensíveis. " },"pluralForm" :"nplurals=3; plural=(n == 0 || n == 1) ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;" }
\ No newline at end of file diff --git a/apps/admin_audit/l10n/sr@latin.js b/apps/admin_audit/l10n/sr@latin.js new file mode 100644 index 00000000000..bab487e832d --- /dev/null +++ b/apps/admin_audit/l10n/sr@latin.js @@ -0,0 +1,7 @@ +OC.L10N.register( + "admin_audit", + { + "Auditing / Logging" : "Praćenje / Beleženje", + "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Daje Nextcloudu mogućnost beleženja, poput pristupa fajlovima ili drugih osetljivih radnji." +}, +"nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);"); diff --git a/apps/admin_audit/l10n/sr@latin.json b/apps/admin_audit/l10n/sr@latin.json new file mode 100644 index 00000000000..a01ecd856c0 --- /dev/null +++ b/apps/admin_audit/l10n/sr@latin.json @@ -0,0 +1,5 @@ +{ "translations": { + "Auditing / Logging" : "Praćenje / Beleženje", + "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Daje Nextcloudu mogućnost beleženja, poput pristupa fajlovima ili drugih osetljivih radnji." +},"pluralForm" :"nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);" +}
\ No newline at end of file diff --git a/apps/admin_audit/l10n/sw.js b/apps/admin_audit/l10n/sw.js new file mode 100644 index 00000000000..58fd34da654 --- /dev/null +++ b/apps/admin_audit/l10n/sw.js @@ -0,0 +1,7 @@ +OC.L10N.register( + "admin_audit", + { + "Auditing / Logging" : "Ukaguzi/kuweka kumbukumbu", + "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Hutoa uwezo wa kuweka kumbukumbu kwa Nextcloud kama vile ufikiaji wa faili za kumbukumbu au vitendo nyeti." +}, +"nplurals=2; plural=(n != 1);"); diff --git a/apps/admin_audit/l10n/sw.json b/apps/admin_audit/l10n/sw.json new file mode 100644 index 00000000000..3775e3f2982 --- /dev/null +++ b/apps/admin_audit/l10n/sw.json @@ -0,0 +1,5 @@ +{ "translations": { + "Auditing / Logging" : "Ukaguzi/kuweka kumbukumbu", + "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Hutoa uwezo wa kuweka kumbukumbu kwa Nextcloud kama vile ufikiaji wa faili za kumbukumbu au vitendo nyeti." +},"pluralForm" :"nplurals=2; plural=(n != 1);" +}
\ No newline at end of file diff --git a/apps/admin_audit/l10n/uz.js b/apps/admin_audit/l10n/uz.js new file mode 100644 index 00000000000..007c8bb77e1 --- /dev/null +++ b/apps/admin_audit/l10n/uz.js @@ -0,0 +1,7 @@ +OC.L10N.register( + "admin_audit", + { + "Auditing / Logging" : "Audit / Kirish", + "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Next bulut uchun tizimga kirish qobiliyatini ta'minlaydi, masalan, faylga kirish yoki boshqa sezgir harakatlar." +}, +"nplurals=1; plural=0;"); diff --git a/apps/admin_audit/l10n/uz.json b/apps/admin_audit/l10n/uz.json new file mode 100644 index 00000000000..025df6c2786 --- /dev/null +++ b/apps/admin_audit/l10n/uz.json @@ -0,0 +1,5 @@ +{ "translations": { + "Auditing / Logging" : "Audit / Kirish", + "Provides logging abilities for Nextcloud such as logging file accesses or otherwise sensitive actions." : "Next bulut uchun tizimga kirish qobiliyatini ta'minlaydi, masalan, faylga kirish yoki boshqa sezgir harakatlar." +},"pluralForm" :"nplurals=1; plural=0;" +}
\ No newline at end of file diff --git a/apps/admin_audit/lib/Actions/Action.php b/apps/admin_audit/lib/Actions/Action.php index 2566025a8ce..acd415d82ea 100644 --- a/apps/admin_audit/lib/Actions/Action.php +++ b/apps/admin_audit/lib/Actions/Action.php @@ -37,11 +37,8 @@ class Action { ); } else { $this->logger->critical( - sprintf( - '$params["' . $element . '"] was missing. Transferred value: %s', - print_r($params, true) - ), - ['app' => 'admin_audit'] + '$params["' . $element . '"] was missing. Transferred value: {params}', + ['app' => 'admin_audit', 'params' => $params] ); } return; diff --git a/apps/admin_audit/lib/Actions/Files.php b/apps/admin_audit/lib/Actions/Files.php index 3993f1a76ee..7be4a7cd581 100644 --- a/apps/admin_audit/lib/Actions/Files.php +++ b/apps/admin_audit/lib/Actions/Files.php @@ -10,7 +10,6 @@ namespace OCA\AdminAudit\Actions; use OC\Files\Node\NonExistingFile; use OCP\Files\Events\Node\BeforeNodeDeletedEvent; use OCP\Files\Events\Node\BeforeNodeReadEvent; -use OCP\Files\Events\Node\BeforeNodeRenamedEvent; use OCP\Files\Events\Node\NodeCopiedEvent; use OCP\Files\Events\Node\NodeCreatedEvent; use OCP\Files\Events\Node\NodeRenamedEvent; @@ -26,9 +25,6 @@ use Psr\Log\LoggerInterface; * @package OCA\AdminAudit\Actions */ class Files extends Action { - - private array $renamedNodes = []; - /** * Logs file read actions */ @@ -37,7 +33,7 @@ class Files extends Action { $node = $event->getNode(); $params = [ 'id' => $node instanceof NonExistingFile ? null : $node->getId(), - 'path' => mb_substr($node->getInternalPath(), 5), + 'path' => $node->getPath(), ]; } catch (InvalidPathException|NotFoundException $e) { Server::get(LoggerInterface::class)->error( @@ -55,29 +51,14 @@ class Files extends Action { /** * Logs rename actions of files */ - public function beforeRename(BeforeNodeRenamedEvent $event): void { - try { - $source = $event->getSource(); - $this->renamedNodes[$source->getId()] = $source; - } catch (InvalidPathException|NotFoundException $e) { - Server::get(LoggerInterface::class)->error( - 'Exception thrown in file rename: ' . $e->getMessage(), ['app' => 'admin_audit', 'exception' => $e] - ); - return; - } - } - - /** - * Logs rename actions of files - */ public function afterRename(NodeRenamedEvent $event): void { try { $target = $event->getTarget(); - $originalSource = $this->renamedNodes[$target->getId()]; + $source = $event->getSource(); $params = [ 'newid' => $target->getId(), - 'oldpath' => mb_substr($originalSource->getInternalPath(), 5), - 'newpath' => mb_substr($target->getInternalPath(), 5), + 'oldpath' => $source->getPath(), + 'newpath' => $target->getPath(), ]; } catch (InvalidPathException|NotFoundException $e) { Server::get(LoggerInterface::class)->error( @@ -101,7 +82,7 @@ class Files extends Action { try { $params = [ 'id' => $event->getNode()->getId(), - 'path' => mb_substr($event->getNode()->getInternalPath(), 5), + 'path' => $event->getNode()->getPath(), ]; } catch (InvalidPathException|NotFoundException $e) { Server::get(LoggerInterface::class)->error( @@ -127,8 +108,8 @@ class Files extends Action { $params = [ 'oldid' => $event->getSource()->getId(), 'newid' => $event->getTarget()->getId(), - 'oldpath' => mb_substr($event->getSource()->getInternalPath(), 5), - 'newpath' => mb_substr($event->getTarget()->getInternalPath(), 5), + 'oldpath' => $event->getSource()->getPath(), + 'newpath' => $event->getTarget()->getPath(), ]; } catch (InvalidPathException|NotFoundException $e) { Server::get(LoggerInterface::class)->error( @@ -151,7 +132,7 @@ class Files extends Action { try { $params = [ 'id' => $node->getId(), - 'path' => mb_substr($node->getInternalPath(), 5), + 'path' => $node->getPath(), ]; } catch (InvalidPathException|NotFoundException $e) { Server::get(LoggerInterface::class)->error( @@ -177,7 +158,7 @@ class Files extends Action { try { $params = [ 'id' => $event->getNode()->getId(), - 'path' => mb_substr($event->getNode()->getInternalPath(), 5), + 'path' => $event->getNode()->getPath(), ]; } catch (InvalidPathException|NotFoundException $e) { Server::get(LoggerInterface::class)->error( diff --git a/apps/admin_audit/lib/Actions/Versions.php b/apps/admin_audit/lib/Actions/Versions.php index c856c994d3f..b3fdefd011d 100644 --- a/apps/admin_audit/lib/Actions/Versions.php +++ b/apps/admin_audit/lib/Actions/Versions.php @@ -8,16 +8,6 @@ declare(strict_types=1); namespace OCA\AdminAudit\Actions; class Versions extends Action { - public function rollback(array $params): void { - $this->log('Version "%s" of "%s" was restored.', - [ - 'version' => $params['revision'], - 'path' => $params['path'] - ], - ['version', 'path'] - ); - } - public function delete(array $params): void { $this->log('Version "%s" was deleted.', ['path' => $params['path']], diff --git a/apps/admin_audit/lib/AppInfo/Application.php b/apps/admin_audit/lib/AppInfo/Application.php index de45bb9bcdd..63a1d065bc8 100644 --- a/apps/admin_audit/lib/AppInfo/Application.php +++ b/apps/admin_audit/lib/AppInfo/Application.php @@ -27,6 +27,7 @@ use OCA\AdminAudit\Listener\GroupManagementEventListener; use OCA\AdminAudit\Listener\SecurityEventListener; use OCA\AdminAudit\Listener\SharingEventListener; use OCA\AdminAudit\Listener\UserManagementEventListener; +use OCA\Files_Versions\Events\VersionRestoredEvent; use OCP\App\Events\AppDisableEvent; use OCP\App\Events\AppEnableEvent; use OCP\App\Events\AppUpdateEvent; @@ -34,13 +35,13 @@ use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IRegistrationContext; +use OCP\Authentication\Events\AnyLoginFailedEvent; use OCP\Authentication\TwoFactorAuth\TwoFactorProviderChallengeFailed; use OCP\Authentication\TwoFactorAuth\TwoFactorProviderChallengePassed; use OCP\Console\ConsoleEvent; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Events\Node\BeforeNodeDeletedEvent; use OCP\Files\Events\Node\BeforeNodeReadEvent; -use OCP\Files\Events\Node\BeforeNodeRenamedEvent; use OCP\Files\Events\Node\NodeCopiedEvent; use OCP\Files\Events\Node\NodeCreatedEvent; use OCP\Files\Events\Node\NodeRenamedEvent; @@ -105,9 +106,11 @@ class Application extends App implements IBootstrap { $context->registerEventListener(UserLoggedInWithCookieEvent::class, AuthEventListener::class); $context->registerEventListener(UserLoggedInEvent::class, AuthEventListener::class); $context->registerEventListener(BeforeUserLoggedOutEvent::class, AuthEventListener::class); + $context->registerEventListener(AnyLoginFailedEvent::class, AuthEventListener::class); // File events $context->registerEventListener(BeforePreviewFetchedEvent::class, FileEventListener::class); + $context->registerEventListener(VersionRestoredEvent::class, FileEventListener::class); // Security events $context->registerEventListener(TwoFactorProviderChallengePassed::class, SecurityEventListener::class); @@ -167,13 +170,6 @@ class Application extends App implements IBootstrap { $fileActions = new Files($logger); $eventDispatcher->addListener( - BeforeNodeRenamedEvent::class, - function (BeforeNodeRenamedEvent $event) use ($fileActions): void { - $fileActions->beforeRename($event); - } - ); - - $eventDispatcher->addListener( NodeRenamedEvent::class, function (NodeRenamedEvent $event) use ($fileActions): void { $fileActions->afterRename($event); @@ -218,7 +214,6 @@ class Application extends App implements IBootstrap { private function versionsHooks(IAuditLogger $logger): void { $versionsActions = new Versions($logger); - Util::connectHook('\OCP\Versions', 'rollback', $versionsActions, 'rollback'); Util::connectHook('\OCP\Versions', 'delete', $versionsActions, 'delete'); } diff --git a/apps/admin_audit/lib/Listener/AuthEventListener.php b/apps/admin_audit/lib/Listener/AuthEventListener.php index 2b31a271d23..88be8555a4d 100644 --- a/apps/admin_audit/lib/Listener/AuthEventListener.php +++ b/apps/admin_audit/lib/Listener/AuthEventListener.php @@ -10,6 +10,7 @@ declare(strict_types=1); namespace OCA\AdminAudit\Listener; use OCA\AdminAudit\Actions\Action; +use OCP\Authentication\Events\AnyLoginFailedEvent; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; use OCP\User\Events\BeforeUserLoggedInEvent; @@ -18,7 +19,7 @@ use OCP\User\Events\UserLoggedInEvent; use OCP\User\Events\UserLoggedInWithCookieEvent; /** - * @template-implements IEventListener<BeforeUserLoggedInEvent|UserLoggedInWithCookieEvent|UserLoggedInEvent|BeforeUserLoggedOutEvent> + * @template-implements IEventListener<BeforeUserLoggedInEvent|UserLoggedInWithCookieEvent|UserLoggedInEvent|BeforeUserLoggedOutEvent|AnyLoginFailedEvent> */ class AuthEventListener extends Action implements IEventListener { public function handle(Event $event): void { @@ -28,6 +29,8 @@ class AuthEventListener extends Action implements IEventListener { $this->userLoggedIn($event); } elseif ($event instanceof BeforeUserLoggedOutEvent) { $this->beforeUserLogout($event); + } elseif ($event instanceof AnyLoginFailedEvent) { + $this->anyLoginFailed($event); } } @@ -64,4 +67,17 @@ class AuthEventListener extends Action implements IEventListener { [] ); } + + private function anyLoginFailed(AnyLoginFailedEvent $event): void { + $this->log( + 'Login failed: "%s"', + [ + 'loginName' => $event->getLoginName() + ], + [ + 'loginName', + ], + true + ); + } } diff --git a/apps/admin_audit/lib/Listener/FileEventListener.php b/apps/admin_audit/lib/Listener/FileEventListener.php index 4ea3db6aa7d..46a4962123b 100644 --- a/apps/admin_audit/lib/Listener/FileEventListener.php +++ b/apps/admin_audit/lib/Listener/FileEventListener.php @@ -10,6 +10,7 @@ declare(strict_types=1); namespace OCA\AdminAudit\Listener; use OCA\AdminAudit\Actions\Action; +use OCA\Files_Versions\Events\VersionRestoredEvent; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; use OCP\Files\InvalidPathException; @@ -19,12 +20,14 @@ use OCP\Server; use Psr\Log\LoggerInterface; /** - * @template-implements IEventListener<BeforePreviewFetchedEvent> + * @template-implements IEventListener<BeforePreviewFetchedEvent|VersionRestoredEvent> */ class FileEventListener extends Action implements IEventListener { public function handle(Event $event): void { if ($event instanceof BeforePreviewFetchedEvent) { $this->beforePreviewFetched($event); + } elseif ($event instanceof VersionRestoredEvent) { + $this->versionRestored($event); } } @@ -40,7 +43,7 @@ class FileEventListener extends Action implements IEventListener { 'height' => $event->getHeight(), 'crop' => $event->isCrop(), 'mode' => $event->getMode(), - 'path' => mb_substr($file->getInternalPath(), 5) + 'path' => $file->getPath(), ]; $this->log( 'Preview accessed: (id: "%s", width: "%s", height: "%s" crop: "%s", mode: "%s", path: "%s")', @@ -54,4 +57,18 @@ class FileEventListener extends Action implements IEventListener { return; } } + + /** + * Logs when a version is restored + */ + private function versionRestored(VersionRestoredEvent $event): void { + $version = $event->getVersion(); + $this->log('Version "%s" of "%s" was restored.', + [ + 'version' => $version->getRevisionId(), + 'path' => $version->getVersionPath() + ], + ['version', 'path'] + ); + } } |