diff options
Diffstat (limited to 'apps/workflowengine/lib')
-rw-r--r-- | apps/workflowengine/lib/AppInfo/Application.php | 1 | ||||
-rw-r--r-- | apps/workflowengine/lib/BackgroundJobs/Rotate.php | 1 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/AbstractStringCheck.php | 5 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/Directory.php | 58 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/FileMimeType.php | 23 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/FileSize.php | 1 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/FileSystemTags.php | 1 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/RequestRemoteAddress.php | 1 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/RequestTime.php | 1 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/RequestURL.php | 9 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/RequestUserAgent.php | 1 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/UserGroupMembership.php | 1 | ||||
-rw-r--r-- | apps/workflowengine/lib/Controller/RequestTimeController.php | 1 | ||||
-rw-r--r-- | apps/workflowengine/lib/Manager.php | 3 | ||||
-rw-r--r-- | apps/workflowengine/lib/Settings/Section.php | 1 |
15 files changed, 91 insertions, 17 deletions
diff --git a/apps/workflowengine/lib/AppInfo/Application.php b/apps/workflowengine/lib/AppInfo/Application.php index 09aa4ed3896..93b0ca49260 100644 --- a/apps/workflowengine/lib/AppInfo/Application.php +++ b/apps/workflowengine/lib/AppInfo/Application.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/apps/workflowengine/lib/BackgroundJobs/Rotate.php b/apps/workflowengine/lib/BackgroundJobs/Rotate.php index 66ac19f425a..d7984b1226a 100644 --- a/apps/workflowengine/lib/BackgroundJobs/Rotate.php +++ b/apps/workflowengine/lib/BackgroundJobs/Rotate.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/apps/workflowengine/lib/Check/AbstractStringCheck.php b/apps/workflowengine/lib/Check/AbstractStringCheck.php index 4e56cda377e..d92e9901365 100644 --- a/apps/workflowengine/lib/Check/AbstractStringCheck.php +++ b/apps/workflowengine/lib/Check/AbstractStringCheck.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later @@ -68,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/Directory.php b/apps/workflowengine/lib/Check/Directory.php new file mode 100644 index 00000000000..f7b856a95fe --- /dev/null +++ b/apps/workflowengine/lib/Check/Directory.php @@ -0,0 +1,58 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCA\WorkflowEngine\Check; + +use OCA\WorkflowEngine\Entity\File; +use OCP\IL10N; +use OCP\WorkflowEngine\IFileCheck; + +class Directory extends AbstractStringCheck implements IFileCheck { + use TFileCheck; + + /** + * @param IL10N $l + */ + public function __construct( + IL10N $l, + ) { + parent::__construct($l); + } + + /** + * @return string + */ + protected function getActualValue(): string { + if ($this->path === null) { + return ''; + } + // files/some/path -> some/path + return preg_replace('/^files\//', '', pathinfo($this->path, PATHINFO_DIRNAME)); + } + + /** + * @param string $operator + * @param string $checkValue + * @param string $actualValue + * @return bool + */ + protected function executeStringCheck($operator, $checkValue, $actualValue) { + if ($operator === 'is' || $operator === '!is') { + $checkValue = ltrim(rtrim($checkValue, '/'), '/'); + } + return parent::executeStringCheck($operator, $checkValue, $actualValue); + } + + public function supportedEntities(): array { + return [ File::class ]; + } + + public function isAvailableForScope(int $scope): bool { + return true; + } +} diff --git a/apps/workflowengine/lib/Check/FileMimeType.php b/apps/workflowengine/lib/Check/FileMimeType.php index 3062994c6ba..a8dfa64528e 100644 --- a/apps/workflowengine/lib/Check/FileMimeType.php +++ b/apps/workflowengine/lib/Check/FileMimeType.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later @@ -97,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); @@ -125,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' || - 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/') + $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/') ); } @@ -139,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' || - str_starts_with($this->request->getPathInfo() ?? '', '/webdav/') + $this->request->getPathInfo() === '/webdav' + || str_starts_with($this->request->getPathInfo() ?? '', '/webdav/') ); } diff --git a/apps/workflowengine/lib/Check/FileSize.php b/apps/workflowengine/lib/Check/FileSize.php index c1ee1d85ae9..5ee03ccc9cf 100644 --- a/apps/workflowengine/lib/Check/FileSize.php +++ b/apps/workflowengine/lib/Check/FileSize.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/apps/workflowengine/lib/Check/FileSystemTags.php b/apps/workflowengine/lib/Check/FileSystemTags.php index bd1609e9aff..811571f558a 100644 --- a/apps/workflowengine/lib/Check/FileSystemTags.php +++ b/apps/workflowengine/lib/Check/FileSystemTags.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/apps/workflowengine/lib/Check/RequestRemoteAddress.php b/apps/workflowengine/lib/Check/RequestRemoteAddress.php index 6fb5a3026d6..b6f8fef5aed 100644 --- a/apps/workflowengine/lib/Check/RequestRemoteAddress.php +++ b/apps/workflowengine/lib/Check/RequestRemoteAddress.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/apps/workflowengine/lib/Check/RequestTime.php b/apps/workflowengine/lib/Check/RequestTime.php index b6b4e9176c2..a49986652b8 100644 --- a/apps/workflowengine/lib/Check/RequestTime.php +++ b/apps/workflowengine/lib/Check/RequestTime.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/apps/workflowengine/lib/Check/RequestURL.php b/apps/workflowengine/lib/Check/RequestURL.php index 62d6dbc5c38..fb2ac7e8fd5 100644 --- a/apps/workflowengine/lib/Check/RequestURL.php +++ b/apps/workflowengine/lib/Check/RequestURL.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later @@ -70,10 +71,10 @@ class RequestURL extends AbstractStringCheck { return false; } return substr($this->request->getScriptName(), 0 - strlen('/remote.php')) === '/remote.php' && ( - $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() === '/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 47db1bb0c68..572ef567074 100644 --- a/apps/workflowengine/lib/Check/RequestUserAgent.php +++ b/apps/workflowengine/lib/Check/RequestUserAgent.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/apps/workflowengine/lib/Check/UserGroupMembership.php b/apps/workflowengine/lib/Check/UserGroupMembership.php index 215557a75a9..690f9974a49 100644 --- a/apps/workflowengine/lib/Check/UserGroupMembership.php +++ b/apps/workflowengine/lib/Check/UserGroupMembership.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/apps/workflowengine/lib/Controller/RequestTimeController.php b/apps/workflowengine/lib/Controller/RequestTimeController.php index 1aca5d92d2d..4b34f16ce0a 100644 --- a/apps/workflowengine/lib/Controller/RequestTimeController.php +++ b/apps/workflowengine/lib/Controller/RequestTimeController.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/apps/workflowengine/lib/Manager.php b/apps/workflowengine/lib/Manager.php index 7d14fc83449..27b25a2e752 100644 --- a/apps/workflowengine/lib/Manager.php +++ b/apps/workflowengine/lib/Manager.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later @@ -7,6 +8,7 @@ namespace OCA\WorkflowEngine; use Doctrine\DBAL\Exception; use OCA\WorkflowEngine\AppInfo\Application; +use OCA\WorkflowEngine\Check\Directory; use OCA\WorkflowEngine\Check\FileMimeType; use OCA\WorkflowEngine\Check\FileName; use OCA\WorkflowEngine\Check\FileSize; @@ -691,6 +693,7 @@ class Manager implements IManager { protected function getBuildInChecks(): array { try { return [ + $this->container->query(Directory::class), $this->container->query(FileMimeType::class), $this->container->query(FileName::class), $this->container->query(FileSize::class), diff --git a/apps/workflowengine/lib/Settings/Section.php b/apps/workflowengine/lib/Settings/Section.php index 5a13a9e4cec..aa790c9ddcc 100644 --- a/apps/workflowengine/lib/Settings/Section.php +++ b/apps/workflowengine/lib/Settings/Section.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later |