From 2e58973abc083505f89065c55fefe1fd9d923fa3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 24 Aug 2024 02:19:20 +0000 Subject: [PATCH 1/2] Chore(deps-dev): Bump nextcloud/coding-standard from 1.2.1 to 1.2.3 Bumps [nextcloud/coding-standard](https://github.com/nextcloud/coding-standard) from 1.2.1 to 1.2.3. - [Release notes](https://github.com/nextcloud/coding-standard/releases) - [Changelog](https://github.com/nextcloud/coding-standard/blob/master/CHANGELOG.md) - [Commits](https://github.com/nextcloud/coding-standard/compare/v1.2.1...v1.2.3) --- updated-dependencies: - dependency-name: nextcloud/coding-standard dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- composer.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/composer.lock b/composer.lock index fde6af45..92325547 100644 --- a/composer.lock +++ b/composer.lock @@ -138,16 +138,16 @@ }, { "name": "nextcloud/coding-standard", - "version": "v1.2.1", + "version": "v1.2.3", "source": { "type": "git", "url": "https://github.com/nextcloud/coding-standard.git", - "reference": "cf5f18d989ec62fb4cdc7fc92a36baf34b3d829e" + "reference": "bc9c53a5306114b60c4363057aff9c2ed10a54da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nextcloud/coding-standard/zipball/cf5f18d989ec62fb4cdc7fc92a36baf34b3d829e", - "reference": "cf5f18d989ec62fb4cdc7fc92a36baf34b3d829e", + "url": "https://api.github.com/repos/nextcloud/coding-standard/zipball/bc9c53a5306114b60c4363057aff9c2ed10a54da", + "reference": "bc9c53a5306114b60c4363057aff9c2ed10a54da", "shasum": "" }, "require": { @@ -173,9 +173,9 @@ "description": "Nextcloud coding standards for the php cs fixer", "support": { "issues": "https://github.com/nextcloud/coding-standard/issues", - "source": "https://github.com/nextcloud/coding-standard/tree/v1.2.1" + "source": "https://github.com/nextcloud/coding-standard/tree/v1.2.3" }, - "time": "2024-02-01T14:54:37+00:00" + "time": "2024-08-23T14:32:32+00:00" }, { "name": "nextcloud/ocp", @@ -391,16 +391,16 @@ }, { "name": "php-cs-fixer/shim", - "version": "v3.59.3", + "version": "v3.62.0", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/shim.git", - "reference": "c855876e64de3431bc9279f27af7be40d11d7613" + "reference": "7a91d5ce45c486f5b445d95901228507a02f60ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/shim/zipball/c855876e64de3431bc9279f27af7be40d11d7613", - "reference": "c855876e64de3431bc9279f27af7be40d11d7613", + "url": "https://api.github.com/repos/PHP-CS-Fixer/shim/zipball/7a91d5ce45c486f5b445d95901228507a02f60ae", + "reference": "7a91d5ce45c486f5b445d95901228507a02f60ae", "shasum": "" }, "require": { @@ -437,9 +437,9 @@ "description": "A tool to automatically fix PHP code style", "support": { "issues": "https://github.com/PHP-CS-Fixer/shim/issues", - "source": "https://github.com/PHP-CS-Fixer/shim/tree/v3.59.3" + "source": "https://github.com/PHP-CS-Fixer/shim/tree/v3.62.0" }, - "time": "2024-06-16T14:17:34+00:00" + "time": "2024-08-07T17:03:46+00:00" }, { "name": "phpunit/php-code-coverage", From f55d2d599ab3f8fdbc18ac2cdfa5423f7f1f8d3f Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Mon, 26 Aug 2024 15:52:54 +0200 Subject: [PATCH 2/2] Run php linter Signed-off-by: Louis Chemineau --- lib/Connector/Sabre/LockPlugin.php | 2 +- lib/Controller/KeyController.php | 2 +- lib/E2EEPublicShareTemplateProvider.php | 12 +++---- lib/E2EEnabledPathCache.php | 2 +- lib/MetaDataStorage.php | 12 +++---- lib/MetaDataStorageV1.php | 4 +-- .../ClientHasCapabilityMiddleware.php | 2 +- lib/Middleware/UserAgentCheckMiddleware.php | 2 +- lib/Settings/Personal.php | 4 +-- tests/Unit/CapabilitiesTest.php | 6 ++-- .../Connector/Sabre/PropFindPluginTest.php | 12 +++---- tests/Unit/Controller/KeyControllerTest.php | 4 +-- tests/Unit/EncryptionManagerTest.php | 36 +++++++++---------- 13 files changed, 50 insertions(+), 50 deletions(-) diff --git a/lib/Connector/Sabre/LockPlugin.php b/lib/Connector/Sabre/LockPlugin.php index 2ad1680f..606d4887 100644 --- a/lib/Connector/Sabre/LockPlugin.php +++ b/lib/Connector/Sabre/LockPlugin.php @@ -87,7 +87,7 @@ public function checkLock(RequestInterface $request): void { if (!$this->isFile($url, $node)) { return; } - /** @var File|Directory|FutureFile $node*/ + /** @var File|Directory|FutureFile $node */ // We don't care if we are not inside an end to end encrypted folder if ($method === 'COPY' || $method === 'MOVE') { diff --git a/lib/Controller/KeyController.php b/lib/Controller/KeyController.php index 541bc45c..a214e397 100644 --- a/lib/Controller/KeyController.php +++ b/lib/Controller/KeyController.php @@ -218,7 +218,7 @@ public function setPublicKey(string $publicKey): DataResponse { } catch (KeyExistsException $e) { return new DataResponse([], Http::STATUS_CONFLICT); } catch (Exception $e) { - $this->logger->error("Fail to set user public key", ['exception' => $e, 'app' => $this->appName]); + $this->logger->error('Fail to set user public key', ['exception' => $e, 'app' => $this->appName]); throw new OCSBadRequestException($this->l10n->t('Internal error')); } diff --git a/lib/E2EEPublicShareTemplateProvider.php b/lib/E2EEPublicShareTemplateProvider.php index 44d4bc42..a1699700 100644 --- a/lib/E2EEPublicShareTemplateProvider.php +++ b/lib/E2EEPublicShareTemplateProvider.php @@ -75,17 +75,17 @@ function (array $acc, string $userId): array { $this->initialState->provideInitialState('encryptionVersion', $metadata['version']); // OpenGraph Support: http://ogp.me/ - Util::addHeader('meta', ['property' => "og:title", 'content' => $this->l10n->t("Encrypted share")]); - Util::addHeader('meta', ['property' => "og:description", 'content' => $this->defaults->getName() . ($this->defaults->getSlogan() !== '' ? ' - ' . $this->defaults->getSlogan() : '')]); - Util::addHeader('meta', ['property' => "og:site_name", 'content' => $this->defaults->getName()]); - Util::addHeader('meta', ['property' => "og:url", 'content' => $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.showShare', ['token' => $token])]); - Util::addHeader('meta', ['property' => "og:type", 'content' => "object"]); + Util::addHeader('meta', ['property' => 'og:title', 'content' => $this->l10n->t('Encrypted share')]); + Util::addHeader('meta', ['property' => 'og:description', 'content' => $this->defaults->getName() . ($this->defaults->getSlogan() !== '' ? ' - ' . $this->defaults->getSlogan() : '')]); + Util::addHeader('meta', ['property' => 'og:site_name', 'content' => $this->defaults->getName()]); + Util::addHeader('meta', ['property' => 'og:url', 'content' => $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.showShare', ['token' => $token])]); + Util::addHeader('meta', ['property' => 'og:type', 'content' => 'object']); $csp = new ContentSecurityPolicy(); $csp->addAllowedFrameDomain('\'self\''); $response = new PublicTemplateResponse(Application::APP_ID, 'filesdrop', []); - $response->setHeaderTitle($this->l10n->t("Encrypted share")); + $response->setHeaderTitle($this->l10n->t('Encrypted share')); $response->setContentSecurityPolicy($csp); return $response; diff --git a/lib/E2EEnabledPathCache.php b/lib/E2EEnabledPathCache.php index 1577eb26..f9d962a0 100644 --- a/lib/E2EEnabledPathCache.php +++ b/lib/E2EEnabledPathCache.php @@ -68,7 +68,7 @@ public function isE2EEnabledPath(Node $node): bool { } // walk path backwards while caching each node's state - return $this->getEncryptedStates((string) $storage->getCache()->getNumericStorageId(), $node); + return $this->getEncryptedStates((string)$storage->getCache()->getNumericStorageId(), $node); } /** diff --git a/lib/MetaDataStorage.php b/lib/MetaDataStorage.php index d18741da..d3b10998 100644 --- a/lib/MetaDataStorage.php +++ b/lib/MetaDataStorage.php @@ -241,16 +241,16 @@ public function readSignature(int $id): string { $metadata = $dir->getFile($this->metaDataFileName)->getContent(); $decodedMetadata = json_decode($metadata, true); - if ($decodedMetadata['metadata']['version'] === "1.2") { - return ""; + if ($decodedMetadata['metadata']['version'] === '1.2') { + return ''; } if ($decodedMetadata['metadata']['version'] === 1.2) { - return ""; + return ''; } if ($decodedMetadata['metadata']['version'] === 1) { - return ""; + return ''; } throw $ex; @@ -294,7 +294,7 @@ private function getFolderNameForFileId(int $id): string { protected function verifyOwner(string $userId, int $id): void { try { $userFolder = $this->rootFolder->getUserFolder($userId); - } catch (NoUserException | NotPermittedException $ex) { + } catch (NoUserException|NotPermittedException $ex) { throw new NotFoundException('No user-root for '. $userId); } @@ -349,7 +349,7 @@ protected function cleanupLegacyFile(string $userId, int $id): void { try { $legacyFolder = $this->appData->getFolder($this->metaDataRoot . '/' . $legacyOwnerPath); $legacyFolder->delete(); - } catch (NotFoundException | NotPermittedException $e) { + } catch (NotFoundException|NotPermittedException $e) { return; } } diff --git a/lib/MetaDataStorageV1.php b/lib/MetaDataStorageV1.php index 7a99cd5b..a926ecdc 100644 --- a/lib/MetaDataStorageV1.php +++ b/lib/MetaDataStorageV1.php @@ -227,7 +227,7 @@ private function getFolderNameForFileId(int $id): string { protected function verifyOwner(string $userId, int $id): void { try { $userFolder = $this->rootFolder->getUserFolder($userId); - } catch (NoUserException | NotPermittedException $ex) { + } catch (NoUserException|NotPermittedException $ex) { throw new NotFoundException('No user-root for '. $userId); } @@ -282,7 +282,7 @@ protected function cleanupLegacyFile(string $userId, int $id): void { try { $legacyFolder = $this->appData->getFolder($this->metaDataRoot . '/' . $legacyOwnerPath); $legacyFolder->delete(); - } catch (NotFoundException | NotPermittedException $e) { + } catch (NotFoundException|NotPermittedException $e) { return; } } diff --git a/lib/Middleware/ClientHasCapabilityMiddleware.php b/lib/Middleware/ClientHasCapabilityMiddleware.php index cea87dfc..d6ac7155 100644 --- a/lib/Middleware/ClientHasCapabilityMiddleware.php +++ b/lib/Middleware/ClientHasCapabilityMiddleware.php @@ -71,7 +71,7 @@ public function beforeController($controller, $methodName): void { return; } - if ($decodedMetadata['metadata']['version'] === "1.2") { + if ($decodedMetadata['metadata']['version'] === '1.2') { return; } diff --git a/lib/Middleware/UserAgentCheckMiddleware.php b/lib/Middleware/UserAgentCheckMiddleware.php index 8906785d..d71d7dea 100644 --- a/lib/Middleware/UserAgentCheckMiddleware.php +++ b/lib/Middleware/UserAgentCheckMiddleware.php @@ -69,7 +69,7 @@ public function beforeController($controller, $methodName): void { return; } - if ($this->request->getHeader('x-e2ee-supported') === "true") { + if ($this->request->getHeader('x-e2ee-supported') === 'true') { return; } diff --git a/lib/Settings/Personal.php b/lib/Settings/Personal.php index 4a800308..d2898394 100644 --- a/lib/Settings/Personal.php +++ b/lib/Settings/Personal.php @@ -31,7 +31,7 @@ public function __construct(IKeyStorage $keyStorage, IInitialState $initialState } public function getForm(): TemplateResponse { - assert($this->userId !== null, "We are always logged in inside the setting app"); + assert($this->userId !== null, 'We are always logged in inside the setting app'); $hasKey = $this->keyStorage->publicKeyExists($this->userId) && $this->keyStorage->privateKeyExists($this->userId); @@ -40,7 +40,7 @@ public function getForm(): TemplateResponse { return new TemplateResponse( Application::APP_ID, 'settings', - ["canUseApp" => !$this->config->isDisabledForUser($this->userSession->getUser())] + ['canUseApp' => !$this->config->isDisabledForUser($this->userSession->getUser())] ); } diff --git a/tests/Unit/CapabilitiesTest.php b/tests/Unit/CapabilitiesTest.php index 8405cafe..d43b6fc3 100644 --- a/tests/Unit/CapabilitiesTest.php +++ b/tests/Unit/CapabilitiesTest.php @@ -59,18 +59,18 @@ public function testGetCapabilities(): void { ->willReturn($user); $user ->method('getUID') - ->willReturn("test"); + ->willReturn('test'); $this->config->expects($this->once()) ->method('isDisabledForUser') ->with($user) ->willReturn(false); $this->keyStorage->expects($this->once()) ->method('publicKeyExists') - ->with("test") + ->with('test') ->willReturn(true); $this->keyStorage->expects($this->once()) ->method('privateKeyExists') - ->with("test") + ->with('test') ->willReturn(true); $this->assertEquals([ 'end-to-end-encryption' => [ diff --git a/tests/Unit/Connector/Sabre/PropFindPluginTest.php b/tests/Unit/Connector/Sabre/PropFindPluginTest.php index d839f97a..343768e2 100644 --- a/tests/Unit/Connector/Sabre/PropFindPluginTest.php +++ b/tests/Unit/Connector/Sabre/PropFindPluginTest.php @@ -49,7 +49,7 @@ class PropFindPluginTest extends TestCase { /** @var UserAgentManager|\PHPUnit\Framework\MockObject\MockObject */ private $userAgentManager; - /** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */ private $request; /** @var Server|\PHPUnit\Framework\MockObject\MockObject */ @@ -83,11 +83,11 @@ public function testInitialize(): void { $server = $this->createMock(Server::class); $server->expects($this->atLeast(2)) - ->method('on') - ->withConsecutive( - ['afterMethod:PROPFIND', [$this->plugin, 'checkAccess'], 50], - ['propFind', [$this->plugin, 'updateProperty'], 105], - ); + ->method('on') + ->withConsecutive( + ['afterMethod:PROPFIND', [$this->plugin, 'checkAccess'], 50], + ['propFind', [$this->plugin, 'updateProperty'], 105], + ); $this->plugin->initialize($server); } diff --git a/tests/Unit/Controller/KeyControllerTest.php b/tests/Unit/Controller/KeyControllerTest.php index 6c929aa0..f266719f 100644 --- a/tests/Unit/Controller/KeyControllerTest.php +++ b/tests/Unit/Controller/KeyControllerTest.php @@ -66,7 +66,7 @@ class KeyControllerTest extends TestCase { private $controller; /** @var string valid CSR (CN set to "admin") */ - private $validCSR = "-----BEGIN CERTIFICATE REQUEST----- + private $validCSR = '-----BEGIN CERTIFICATE REQUEST----- MIIC7jCCAdYCAQAwgagxCzAJBgNVBAYTAlVLMREwDwYDVQQIDAhTb21lcnNldDEU MBIGA1UEBwwLR2xhc3RvbmJ1cnkxHzAdBgNVBAoMFlRoZSBCcmFpbiBSb29tIExp bWl0ZWQxHzAdBgNVBAsMFlBIUCBEb2N1bWVudGF0aW9uIFRlYW0xDjAMBgNVBAMM @@ -84,7 +84,7 @@ class KeyControllerTest extends TestCase { w7829dr37SuA2kQb86aVpqdL50v3HjCclXd7PfWiYqajuHaIsokBV5ly2IdQo4Cz AYzYQFPtjsDZ4Tju4VZKM4YpF2GwQgT7zhzDBvywGPqvfw== -----END CERTIFICATE REQUEST----- -"; +'; /** @var string */ private $invalidCSR = "-----BEGIN CERTIFICATE REQUEST-----\nMIIC7jCCAdYCAQAwgag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IFICATE+REQUEST-----\n"; diff --git a/tests/Unit/EncryptionManagerTest.php b/tests/Unit/EncryptionManagerTest.php index 0d33ffc1..c4335e19 100644 --- a/tests/Unit/EncryptionManagerTest.php +++ b/tests/Unit/EncryptionManagerTest.php @@ -43,22 +43,22 @@ class EncryptionManagerTest extends TestCase { - /** @var IRootFolder|PHPUnit_Framework_MockObject_MockObject */ + /** @var IRootFolder|PHPUnit_Framework_MockObject_MockObject */ private $rootFolderInterface; - /** @var Folder|PHPUnit_Framework_MockObject_MockObject */ + /** @var Folder|PHPUnit_Framework_MockObject_MockObject */ private $rootFolder; - /** @var IStorage|PHPUnit_Framework_MockObject_MockObject */ + /** @var IStorage|PHPUnit_Framework_MockObject_MockObject */ private $storage; - /** @var ICache|PHPUnit_Framework_MockObject_MockObject */ + /** @var ICache|PHPUnit_Framework_MockObject_MockObject */ private $fileCache; - /** @var IUserSession|PHPUnit_Framework_MockObject_MockObject */ + /** @var IUserSession|PHPUnit_Framework_MockObject_MockObject */ private $userSession; - /** @var IManager|PHPUnit_Framework_MockObject_MockObject */ + /** @var IManager|PHPUnit_Framework_MockObject_MockObject */ private $shareManager; /** @var IDBConnection|PHPUnit_Framework_MockObject_MockObject */ @@ -213,18 +213,18 @@ public function testIsValidFolderSuccess():void { ->willReturn($user); $this->shareManager->method('getSharesBy') - ->willReturnMap([ - ['userId123', IShare::TYPE_USER, $node1, false, 1, []], - ['userId123', IShare::TYPE_GROUP, $node1, false, 1, []], - ['userId123', IShare::TYPE_USERGROUP, $node1, false, 1, []], - ['userId123', IShare::TYPE_LINK, $node1, false, 1, []], - ['userId123', IShare::TYPE_EMAIL, $node1, false, 1, []], - ['userId123', IShare::TYPE_REMOTE, $node1, false, 1, []], - ['userId123', IShare::TYPE_CIRCLE, $node1, false, 1, []], - ['userId123', IShare::TYPE_GUEST, $node1, false, 1, []], - ['userId123', IShare::TYPE_REMOTE_GROUP, $node1, false, 1, []], - ['userId123', IShare::TYPE_ROOM, $node1, false, 1, []], - ]); + ->willReturnMap([ + ['userId123', IShare::TYPE_USER, $node1, false, 1, []], + ['userId123', IShare::TYPE_GROUP, $node1, false, 1, []], + ['userId123', IShare::TYPE_USERGROUP, $node1, false, 1, []], + ['userId123', IShare::TYPE_LINK, $node1, false, 1, []], + ['userId123', IShare::TYPE_EMAIL, $node1, false, 1, []], + ['userId123', IShare::TYPE_REMOTE, $node1, false, 1, []], + ['userId123', IShare::TYPE_CIRCLE, $node1, false, 1, []], + ['userId123', IShare::TYPE_GUEST, $node1, false, 1, []], + ['userId123', IShare::TYPE_REMOTE_GROUP, $node1, false, 1, []], + ['userId123', IShare::TYPE_ROOM, $node1, false, 1, []], + ]); self::invokePrivate($instance, 'isValidFolder', [42]); }