diff options
Diffstat (limited to 'apps/workflowengine/lib/Check')
-rw-r--r-- | apps/workflowengine/lib/Check/AbstractStringCheck.php | 36 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/FileMimeType.php | 70 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/FileName.php | 36 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/FileSize.php | 37 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/FileSystemTags.php | 97 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/RequestRemoteAddress.php | 39 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/RequestTime.php | 40 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/RequestURL.php | 40 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/RequestUserAgent.php | 33 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/TFileCheck.php | 25 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/UserGroupMembership.php | 42 |
11 files changed, 121 insertions, 374 deletions
diff --git a/apps/workflowengine/lib/Check/AbstractStringCheck.php b/apps/workflowengine/lib/Check/AbstractStringCheck.php index 26047f90d50..d92e9901365 100644 --- a/apps/workflowengine/lib/Check/AbstractStringCheck.php +++ b/apps/workflowengine/lib/Check/AbstractStringCheck.php @@ -1,26 +1,8 @@ <?php + /** - * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com> - * - * @author Arthur Schiwon <blizzz@arthur-schiwon.de> - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Joas Schilling <coding@schilljs.com> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCA\WorkflowEngine\Check; @@ -33,14 +15,12 @@ abstract class AbstractStringCheck implements ICheck { /** @var array[] Nested array: [Pattern => [ActualValue => Regex Result]] */ protected $matches; - /** @var IL10N */ - protected $l; - /** * @param IL10N $l */ - public function __construct(IL10N $l) { - $this->l = $l; + public function __construct( + protected IL10N $l, + ) { } /** @@ -89,8 +69,8 @@ abstract class AbstractStringCheck implements ICheck { throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1); } - if (in_array($operator, ['matches', '!matches']) && - @preg_match($value, null) === false) { + if (in_array($operator, ['matches', '!matches']) + && @preg_match($value, null) === false) { throw new \UnexpectedValueException($this->l->t('The given regular expression is invalid'), 2); } } diff --git a/apps/workflowengine/lib/Check/FileMimeType.php b/apps/workflowengine/lib/Check/FileMimeType.php index 991d7ebc739..a8dfa64528e 100644 --- a/apps/workflowengine/lib/Check/FileMimeType.php +++ b/apps/workflowengine/lib/Check/FileMimeType.php @@ -1,28 +1,8 @@ <?php + /** - * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com> - * - * @author Arthur Schiwon <blizzz@arthur-schiwon.de> - * @author Joas Schilling <coding@schilljs.com> - * @author Julius Härtl <jus@bitgrid.net> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCA\WorkflowEngine\Check; @@ -42,21 +22,17 @@ class FileMimeType extends AbstractStringCheck implements IFileCheck { /** @var array */ protected $mimeType; - /** @var IRequest */ - protected $request; - - /** @var IMimeTypeDetector */ - protected $mimeTypeDetector; - /** * @param IL10N $l * @param IRequest $request * @param IMimeTypeDetector $mimeTypeDetector */ - public function __construct(IL10N $l, IRequest $request, IMimeTypeDetector $mimeTypeDetector) { + public function __construct( + IL10N $l, + protected IRequest $request, + protected IMimeTypeDetector $mimeTypeDetector, + ) { parent::__construct($l); - $this->request = $request; - $this->mimeTypeDetector = $mimeTypeDetector; } /** @@ -107,13 +83,7 @@ class FileMimeType extends AbstractStringCheck implements IFileCheck { * @return bool */ public function executeCheck($operator, $value) { - $actualValue = $this->getActualValue(); - $plainMimetypeResult = $this->executeStringCheck($operator, $value, $actualValue); - if ($actualValue === 'httpd/unix-directory') { - return $plainMimetypeResult; - } - $detectMimetypeBasedOnFilenameResult = $this->executeStringCheck($operator, $value, $this->mimeTypeDetector->detectPath($this->path)); - return $plainMimetypeResult || $detectMimetypeBasedOnFilenameResult; + return $this->executeStringCheck($operator, $value, $this->getActualValue()); } /** @@ -128,9 +98,9 @@ class FileMimeType extends AbstractStringCheck implements IFileCheck { return $this->cacheAndReturnMimeType($this->storage->getId(), $this->path, $cacheEntry->getMimeType()); } - if ($this->storage->file_exists($this->path) && - $this->storage->filesize($this->path) && - $this->storage->instanceOfStorage(Local::class) + if ($this->storage->file_exists($this->path) + && $this->storage->filesize($this->path) + && $this->storage->instanceOfStorage(Local::class) ) { $path = $this->storage->getLocalFile($this->path); $mimeType = $this->mimeTypeDetector->detectContent($path); @@ -156,12 +126,12 @@ class FileMimeType extends AbstractStringCheck implements IFileCheck { */ protected function isWebDAVRequest() { return substr($this->request->getScriptName(), 0 - strlen('/remote.php')) === '/remote.php' && ( - $this->request->getPathInfo() === '/webdav' || - strpos($this->request->getPathInfo(), '/webdav/') === 0 || - $this->request->getPathInfo() === '/dav/files' || - strpos($this->request->getPathInfo(), '/dav/files/') === 0 || - $this->request->getPathInfo() === '/dav/uploads' || - strpos($this->request->getPathInfo(), '/dav/uploads/') === 0 + $this->request->getPathInfo() === '/webdav' + || str_starts_with($this->request->getPathInfo() ?? '', '/webdav/') + || $this->request->getPathInfo() === '/dav/files' + || str_starts_with($this->request->getPathInfo() ?? '', '/dav/files/') + || $this->request->getPathInfo() === '/dav/uploads' + || str_starts_with($this->request->getPathInfo() ?? '', '/dav/uploads/') ); } @@ -170,8 +140,8 @@ class FileMimeType extends AbstractStringCheck implements IFileCheck { */ protected function isPublicWebDAVRequest() { return substr($this->request->getScriptName(), 0 - strlen('/public.php')) === '/public.php' && ( - $this->request->getPathInfo() === '/webdav' || - strpos($this->request->getPathInfo(), '/webdav/') === 0 + $this->request->getPathInfo() === '/webdav' + || str_starts_with($this->request->getPathInfo() ?? '', '/webdav/') ); } diff --git a/apps/workflowengine/lib/Check/FileName.php b/apps/workflowengine/lib/Check/FileName.php index 32df51ebfac..4a9d503018f 100644 --- a/apps/workflowengine/lib/Check/FileName.php +++ b/apps/workflowengine/lib/Check/FileName.php @@ -3,27 +3,8 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2018 Daniel Kesselberg <mail@danielkesselberg.de> - * - * @author Arthur Schiwon <blizzz@arthur-schiwon.de> - * @author Daniel Kesselberg <mail@danielkesselberg.de> - * @author szaimen <szaimen@e.mail.de> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCA\WorkflowEngine\Check; @@ -37,19 +18,16 @@ use OCP\WorkflowEngine\IFileCheck; class FileName extends AbstractStringCheck implements IFileCheck { use TFileCheck; - /** @var IRequest */ - protected $request; - /** @var IMountManager */ - private $mountManager; - /** * @param IL10N $l * @param IRequest $request */ - public function __construct(IL10N $l, IRequest $request, IMountManager $mountManager) { + public function __construct( + IL10N $l, + protected IRequest $request, + private IMountManager $mountManager, + ) { parent::__construct($l); - $this->request = $request; - $this->mountManager = $mountManager; } /** diff --git a/apps/workflowengine/lib/Check/FileSize.php b/apps/workflowengine/lib/Check/FileSize.php index 7271147e834..5ee03ccc9cf 100644 --- a/apps/workflowengine/lib/Check/FileSize.php +++ b/apps/workflowengine/lib/Check/FileSize.php @@ -1,26 +1,8 @@ <?php + /** - * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com> - * - * @author Arthur Schiwon <blizzz@arthur-schiwon.de> - * @author Joas Schilling <coding@schilljs.com> - * @author Morris Jobke <hey@morrisjobke.de> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCA\WorkflowEngine\Check; @@ -35,19 +17,14 @@ class FileSize implements ICheck { /** @var int */ protected $size; - /** @var IL10N */ - protected $l; - - /** @var IRequest */ - protected $request; - /** * @param IL10N $l * @param IRequest $request */ - public function __construct(IL10N $l, IRequest $request) { - $this->l = $l; - $this->request = $request; + public function __construct( + protected IL10N $l, + protected IRequest $request, + ) { } /** diff --git a/apps/workflowengine/lib/Check/FileSystemTags.php b/apps/workflowengine/lib/Check/FileSystemTags.php index 008f47eca78..811571f558a 100644 --- a/apps/workflowengine/lib/Check/FileSystemTags.php +++ b/apps/workflowengine/lib/Check/FileSystemTags.php @@ -1,42 +1,25 @@ <?php + /** - * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com> - * - * @author Arthur Schiwon <blizzz@arthur-schiwon.de> - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Joas Schilling <coding@schilljs.com> - * @author Julius Härtl <jus@bitgrid.net> - * @author Richard Steinmetz <richard@steinmetz.cloud> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCA\WorkflowEngine\Check; +use OC\Files\Storage\Wrapper\Jail; use OCA\Files_Sharing\SharedStorage; use OCA\WorkflowEngine\Entity\File; use OCP\Files\Cache\ICache; use OCP\Files\IHomeStorage; +use OCP\IGroupManager; use OCP\IL10N; +use OCP\IUser; +use OCP\IUserSession; use OCP\SystemTag\ISystemTagManager; use OCP\SystemTag\ISystemTagObjectMapper; use OCP\SystemTag\TagNotFoundException; use OCP\WorkflowEngine\ICheck; use OCP\WorkflowEngine\IFileCheck; -use OC\Files\Storage\Wrapper\Wrapper; class FileSystemTags implements ICheck, IFileCheck { use TFileCheck; @@ -47,24 +30,13 @@ class FileSystemTags implements ICheck, IFileCheck { /** @var array */ protected $fileSystemTags; - /** @var IL10N */ - protected $l; - - /** @var ISystemTagManager */ - protected $systemTagManager; - - /** @var ISystemTagObjectMapper */ - protected $systemTagObjectMapper; - - /** - * @param IL10N $l - * @param ISystemTagManager $systemTagManager - * @param ISystemTagObjectMapper $systemTagObjectMapper - */ - public function __construct(IL10N $l, ISystemTagManager $systemTagManager, ISystemTagObjectMapper $systemTagObjectMapper) { - $this->l = $l; - $this->systemTagManager = $systemTagManager; - $this->systemTagObjectMapper = $systemTagObjectMapper; + public function __construct( + protected IL10N $l, + protected ISystemTagManager $systemTagManager, + protected ISystemTagObjectMapper $systemTagObjectMapper, + protected IUserSession $userSession, + protected IGroupManager $groupManager, + ) { } /** @@ -88,7 +60,18 @@ class FileSystemTags implements ICheck, IFileCheck { } try { - $this->systemTagManager->getTagsByIds($value); + $tags = $this->systemTagManager->getTagsByIds($value); + + $user = $this->userSession->getUser(); + $isAdmin = $user instanceof IUser && $this->groupManager->isAdmin($user->getUID()); + + if (!$isAdmin) { + foreach ($tags as $tag) { + if (!$tag->isUserVisible()) { + throw new \UnexpectedValueException($this->l->t('The given tag id is invalid'), 4); + } + } + } } catch (TagNotFoundException $e) { throw new \UnexpectedValueException($this->l->t('The given tag id is invalid'), 2); } catch (\InvalidArgumentException $e) { @@ -133,27 +116,15 @@ class FileSystemTags implements ICheck, IFileCheck { * @return int[] */ protected function getFileIds(ICache $cache, $path, $isExternalStorage) { - /** @psalm-suppress InvalidArgument */ - if ($this->storage->instanceOfStorage(\OCA\GroupFolders\Mount\GroupFolderStorage::class)) { - // Special implementation for groupfolder since all groupfolders share the same storage - // id so add the group folder id in the cache key too. - $groupFolderStorage = $this->storage; - if ($this->storage instanceof Wrapper) { - $groupFolderStorage = $this->storage->getInstanceOfStorage(\OCA\GroupFolders\Mount\GroupFolderStorage::class); - } - if ($groupFolderStorage === null) { - throw new \LogicException('Should not happen: Storage is instance of GroupFolderStorage but no group folder storage found while unwrapping.'); - } - /** - * @psalm-suppress UndefinedDocblockClass - * @psalm-suppress UndefinedInterfaceMethod - */ - $cacheId = $cache->getNumericStorageId() . '/' . $groupFolderStorage->getFolderId(); + $cacheId = $cache->getNumericStorageId(); + if ($this->storage->instanceOfStorage(Jail::class)) { + $absolutePath = $this->storage->getUnjailedPath($path); } else { - $cacheId = $cache->getNumericStorageId(); + $absolutePath = $path; } - if (isset($this->fileIds[$cacheId][$path])) { - return $this->fileIds[$cacheId][$path]; + + if (isset($this->fileIds[$cacheId][$absolutePath])) { + return $this->fileIds[$cacheId][$absolutePath]; } $parentIds = []; @@ -168,7 +139,7 @@ class FileSystemTags implements ICheck, IFileCheck { $parentIds[] = $fileId; } - $this->fileIds[$cacheId][$path] = $parentIds; + $this->fileIds[$cacheId][$absolutePath] = $parentIds; return $parentIds; } diff --git a/apps/workflowengine/lib/Check/RequestRemoteAddress.php b/apps/workflowengine/lib/Check/RequestRemoteAddress.php index 474599a8642..b6f8fef5aed 100644 --- a/apps/workflowengine/lib/Check/RequestRemoteAddress.php +++ b/apps/workflowengine/lib/Check/RequestRemoteAddress.php @@ -1,28 +1,8 @@ <?php + /** - * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com> - * - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author J0WI <J0WI@users.noreply.github.com> - * @author Joas Schilling <coding@schilljs.com> - * @author Julius Härtl <jus@bitgrid.net> - * @author Morris Jobke <hey@morrisjobke.de> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCA\WorkflowEngine\Check; @@ -32,19 +12,14 @@ use OCP\WorkflowEngine\ICheck; class RequestRemoteAddress implements ICheck { - /** @var IL10N */ - protected $l; - - /** @var IRequest */ - protected $request; - /** * @param IL10N $l * @param IRequest $request */ - public function __construct(IL10N $l, IRequest $request) { - $this->l = $l; - $this->request = $request; + public function __construct( + protected IL10N $l, + protected IRequest $request, + ) { } /** diff --git a/apps/workflowengine/lib/Check/RequestTime.php b/apps/workflowengine/lib/Check/RequestTime.php index be28f8ead15..a49986652b8 100644 --- a/apps/workflowengine/lib/Check/RequestTime.php +++ b/apps/workflowengine/lib/Check/RequestTime.php @@ -1,27 +1,8 @@ <?php + /** - * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com> - * - * @author Arthur Schiwon <blizzz@arthur-schiwon.de> - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Joas Schilling <coding@schilljs.com> - * @author Julius Härtl <jus@bitgrid.net> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCA\WorkflowEngine\Check; @@ -36,18 +17,13 @@ class RequestTime implements ICheck { /** @var bool[] */ protected $cachedResults; - /** @var IL10N */ - protected $l; - - /** @var ITimeFactory */ - protected $timeFactory; - /** * @param ITimeFactory $timeFactory */ - public function __construct(IL10N $l, ITimeFactory $timeFactory) { - $this->l = $l; - $this->timeFactory = $timeFactory; + public function __construct( + protected IL10N $l, + protected ITimeFactory $timeFactory, + ) { } /** @@ -87,7 +63,7 @@ class RequestTime implements ICheck { [$hour1, $minute1] = explode(':', $time1); $date1 = new \DateTime('now', new \DateTimeZone($timezone1)); $date1->setTimestamp($currentTimestamp); - $date1->setTime($hour1, $minute1); + $date1->setTime((int)$hour1, (int)$minute1); return $date1->getTimestamp(); } diff --git a/apps/workflowengine/lib/Check/RequestURL.php b/apps/workflowengine/lib/Check/RequestURL.php index 73e6a2e6ce6..fb2ac7e8fd5 100644 --- a/apps/workflowengine/lib/Check/RequestURL.php +++ b/apps/workflowengine/lib/Check/RequestURL.php @@ -1,25 +1,8 @@ <?php + /** - * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com> - * - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Joas Schilling <coding@schilljs.com> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCA\WorkflowEngine\Check; @@ -32,16 +15,15 @@ class RequestURL extends AbstractStringCheck { /** @var ?string */ protected $url; - /** @var IRequest */ - protected $request; - /** * @param IL10N $l * @param IRequest $request */ - public function __construct(IL10N $l, IRequest $request) { + public function __construct( + IL10N $l, + protected IRequest $request, + ) { parent::__construct($l); - $this->request = $request; } /** @@ -89,10 +71,10 @@ class RequestURL extends AbstractStringCheck { return false; } return substr($this->request->getScriptName(), 0 - strlen('/remote.php')) === '/remote.php' && ( - $this->request->getPathInfo() === '/webdav' || - strpos($this->request->getPathInfo(), '/webdav/') === 0 || - $this->request->getPathInfo() === '/dav/files' || - strpos($this->request->getPathInfo(), '/dav/files/') === 0 + $this->request->getPathInfo() === '/webdav' + || str_starts_with($this->request->getPathInfo() ?? '', '/webdav/') + || $this->request->getPathInfo() === '/dav/files' + || str_starts_with($this->request->getPathInfo() ?? '', '/dav/files/') ); } } diff --git a/apps/workflowengine/lib/Check/RequestUserAgent.php b/apps/workflowengine/lib/Check/RequestUserAgent.php index e8ca3ddfbc9..572ef567074 100644 --- a/apps/workflowengine/lib/Check/RequestUserAgent.php +++ b/apps/workflowengine/lib/Check/RequestUserAgent.php @@ -1,26 +1,8 @@ <?php + /** - * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com> - * - * @author Arthur Schiwon <blizzz@arthur-schiwon.de> - * @author Joas Schilling <coding@schilljs.com> - * @author Morris Jobke <hey@morrisjobke.de> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCA\WorkflowEngine\Check; @@ -29,16 +11,15 @@ use OCP\IRequest; class RequestUserAgent extends AbstractStringCheck { - /** @var IRequest */ - protected $request; - /** * @param IL10N $l * @param IRequest $request */ - public function __construct(IL10N $l, IRequest $request) { + public function __construct( + IL10N $l, + protected IRequest $request, + ) { parent::__construct($l); - $this->request = $request; } /** diff --git a/apps/workflowengine/lib/Check/TFileCheck.php b/apps/workflowengine/lib/Check/TFileCheck.php index 561cf012ff7..a514352e047 100644 --- a/apps/workflowengine/lib/Check/TFileCheck.php +++ b/apps/workflowengine/lib/Check/TFileCheck.php @@ -3,32 +3,15 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2019 Arthur Schiwon <blizzz@arthur-schiwon.de> - * - * @author Arthur Schiwon <blizzz@arthur-schiwon.de> - * @author Joas Schilling <coding@schilljs.com> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCA\WorkflowEngine\Check; use OCA\WorkflowEngine\AppInfo\Application; use OCA\WorkflowEngine\Entity\File; use OCP\Files\Node; +use OCP\Files\NotFoundException; use OCP\Files\Storage\IStorage; use OCP\WorkflowEngine\IEntity; @@ -55,7 +38,7 @@ trait TFileCheck { } /** - * @throws \OCP\Files\NotFoundException + * @throws NotFoundException */ public function setEntitySubject(IEntity $entity, $subject): void { if ($entity instanceof File) { diff --git a/apps/workflowengine/lib/Check/UserGroupMembership.php b/apps/workflowengine/lib/Check/UserGroupMembership.php index 4ca073b8e5b..690f9974a49 100644 --- a/apps/workflowengine/lib/Check/UserGroupMembership.php +++ b/apps/workflowengine/lib/Check/UserGroupMembership.php @@ -1,26 +1,8 @@ <?php + /** - * @copyright Copyright (c) 2016 Morris Jobke <hey@morrisjobke.de> - * - * @author Joas Schilling <coding@schilljs.com> - * @author Julius Härtl <jus@bitgrid.net> - * @author Morris Jobke <hey@morrisjobke.de> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCA\WorkflowEngine\Check; @@ -39,24 +21,16 @@ class UserGroupMembership implements ICheck { /** @var string[] */ protected $cachedGroupMemberships; - /** @var IUserSession */ - protected $userSession; - - /** @var IGroupManager */ - protected $groupManager; - - /** @var IL10N */ - protected $l; - /** * @param IUserSession $userSession * @param IGroupManager $groupManager * @param IL10N $l */ - public function __construct(IUserSession $userSession, IGroupManager $groupManager, IL10N $l) { - $this->userSession = $userSession; - $this->groupManager = $groupManager; - $this->l = $l; + public function __construct( + protected IUserSession $userSession, + protected IGroupManager $groupManager, + protected IL10N $l, + ) { } /** |