diff options
Diffstat (limited to 'apps/encryption')
39 files changed, 40 insertions, 165 deletions
diff --git a/apps/encryption/lib/AppInfo/Application.php b/apps/encryption/lib/AppInfo/Application.php index fcd7ef569b9..688564887d3 100644 --- a/apps/encryption/lib/AppInfo/Application.php +++ b/apps/encryption/lib/AppInfo/Application.php @@ -78,7 +78,6 @@ class Application extends \OCP\AppFramework\App { */ public function registerHooks() { if (!$this->config->getSystemValueBool('maintenance')) { - $container = $this->getContainer(); $server = $container->getServer(); // Register our hooks and fire them. @@ -97,7 +96,6 @@ class Application extends \OCP\AppFramework\App { ]); $hookManager->fireHooks(); - } else { // Logout user if we are in maintenance to force re-login $this->getContainer()->getServer()->getUserSession()->logout(); @@ -112,8 +110,7 @@ class Application extends \OCP\AppFramework\App { Encryption::ID, Encryption::DISPLAY_NAME, function () use ($container) { - - return new Encryption( + return new Encryption( $container->query('Crypt'), $container->query('KeyManager'), $container->query('Util'), @@ -123,8 +120,7 @@ class Application extends \OCP\AppFramework\App { $container->getServer()->getLogger(), $container->getServer()->getL10N($container->getAppName()) ); - }); - + }); } public function registerServices() { @@ -261,6 +257,5 @@ class Application extends \OCP\AppFramework\App { ); } ); - } } diff --git a/apps/encryption/lib/Command/DisableMasterKey.php b/apps/encryption/lib/Command/DisableMasterKey.php index 18bf0b3903d..d59e3b586c8 100644 --- a/apps/encryption/lib/Command/DisableMasterKey.php +++ b/apps/encryption/lib/Command/DisableMasterKey.php @@ -50,7 +50,6 @@ class DisableMasterKey extends Command { public function __construct(Util $util, IConfig $config, QuestionHelper $questionHelper) { - $this->util = $util; $this->config = $config; $this->questionHelper = $questionHelper; @@ -64,10 +63,9 @@ class DisableMasterKey extends Command { } protected function execute(InputInterface $input, OutputInterface $output) { - $isMasterKeyEnabled = $this->util->isMasterKeyEnabled(); - if(!$isMasterKeyEnabled) { + if (!$isMasterKeyEnabled) { $output->writeln('Master key already disabled'); } else { $question = new ConfirmationQuestion( @@ -83,7 +81,5 @@ class DisableMasterKey extends Command { $output->writeln('aborted.'); } } - } - } diff --git a/apps/encryption/lib/Command/EnableMasterKey.php b/apps/encryption/lib/Command/EnableMasterKey.php index d1148c88ccd..6c4645e7212 100644 --- a/apps/encryption/lib/Command/EnableMasterKey.php +++ b/apps/encryption/lib/Command/EnableMasterKey.php @@ -49,7 +49,6 @@ class EnableMasterKey extends Command { public function __construct(Util $util, IConfig $config, QuestionHelper $questionHelper) { - $this->util = $util; $this->config = $config; $this->questionHelper = $questionHelper; @@ -63,10 +62,9 @@ class EnableMasterKey extends Command { } protected function execute(InputInterface $input, OutputInterface $output) { - $isAlreadyEnabled = $this->util->isMasterKeyEnabled(); - if($isAlreadyEnabled) { + if ($isAlreadyEnabled) { $output->writeln('Master key already enabled'); } else { $question = new ConfirmationQuestion( @@ -79,7 +77,5 @@ class EnableMasterKey extends Command { $output->writeln('aborted.'); } } - } - } diff --git a/apps/encryption/lib/Command/RecoverUser.php b/apps/encryption/lib/Command/RecoverUser.php index 9d98b38de47..a4d7b2407d6 100644 --- a/apps/encryption/lib/Command/RecoverUser.php +++ b/apps/encryption/lib/Command/RecoverUser.php @@ -54,7 +54,6 @@ class RecoverUser extends Command { IConfig $config, IUserManager $userManager, QuestionHelper $questionHelper) { - $this->util = $util; $this->questionHelper = $questionHelper; $this->userManager = $userManager; @@ -74,10 +73,9 @@ class RecoverUser extends Command { } protected function execute(InputInterface $input, OutputInterface $output) { - $isMasterKeyEnabled = $this->util->isMasterKeyEnabled(); - if($isMasterKeyEnabled) { + if ($isMasterKeyEnabled) { $output->writeln('You use the master key, no individual user recovery needed.'); return; } @@ -90,7 +88,7 @@ class RecoverUser extends Command { } $recoveryKeyEnabled = $this->util->isRecoveryEnabledForUser($uid); - if($recoveryKeyEnabled === false) { + if ($recoveryKeyEnabled === false) { $output->writeln('Recovery key is not enabled for: ' . $uid); return; } @@ -108,7 +106,5 @@ class RecoverUser extends Command { $output->write('Start to recover users files... This can take some time...'); $this->userManager->get($uid)->setPassword($newLoginPassword, $recoveryPassword); $output->writeln('Done.'); - } - } diff --git a/apps/encryption/lib/Controller/RecoveryController.php b/apps/encryption/lib/Controller/RecoveryController.php index 534e00e1b2e..509ff2a0391 100644 --- a/apps/encryption/lib/Controller/RecoveryController.php +++ b/apps/encryption/lib/Controller/RecoveryController.php @@ -161,7 +161,6 @@ class RecoveryController extends Controller { */ public function userSetRecovery($userEnableRecovery) { if ($userEnableRecovery === '0' || $userEnableRecovery === '1') { - $result = $this->recovery->setRecoveryForUser($userEnableRecovery); if ($result) { @@ -180,7 +179,6 @@ class RecoveryController extends Controller { ] ); } - } return new DataResponse( [ @@ -189,5 +187,4 @@ class RecoveryController extends Controller { ] ], Http::STATUS_BAD_REQUEST); } - } diff --git a/apps/encryption/lib/Controller/SettingsController.php b/apps/encryption/lib/Controller/SettingsController.php index 545f544625b..f918f176767 100644 --- a/apps/encryption/lib/Controller/SettingsController.php +++ b/apps/encryption/lib/Controller/SettingsController.php @@ -150,7 +150,6 @@ class SettingsController extends Controller { Http::STATUS_BAD_REQUEST ); } - } /** diff --git a/apps/encryption/lib/Controller/StatusController.php b/apps/encryption/lib/Controller/StatusController.php index d3925e4482a..40159627b00 100644 --- a/apps/encryption/lib/Controller/StatusController.php +++ b/apps/encryption/lib/Controller/StatusController.php @@ -67,10 +67,9 @@ class StatusController extends Controller { * @return DataResponse */ public function getStatus() { - $status = 'error'; $message = 'no valid init status'; - switch($this->session->getStatus()) { + switch ($this->session->getStatus()) { case Session::INIT_EXECUTED: $status = 'interactionNeeded'; $message = (string)$this->l->t( @@ -102,5 +101,4 @@ class StatusController extends Controller { ] ); } - } diff --git a/apps/encryption/lib/Crypto/Crypt.php b/apps/encryption/lib/Crypto/Crypt.php index b8e7ebab85b..24b1f21ecd0 100644 --- a/apps/encryption/lib/Crypto/Crypt.php +++ b/apps/encryption/lib/Crypto/Crypt.php @@ -54,7 +54,6 @@ use OCP\IUserSession; * @package OCA\Encryption\Crypto */ class Crypt { - const DEFAULT_CIPHER = 'AES-256-CTR'; // default cipher from old Nextcloud versions const LEGACY_CIPHER = 'AES-128-CFB'; @@ -109,7 +108,6 @@ class Crypt { * @return array|bool */ public function createKeyPair() { - $log = $this->logger; $res = $this->getOpenSSLPKey(); @@ -176,7 +174,6 @@ class Crypt { * @throws EncryptionFailedException */ public function symmetricEncryptFileContent($plainContent, $passPhrase, $version, $position) { - if (!$plainContent) { $this->logger->error('Encryption Library, symmetrical encryption failed no content given', ['app' => 'encryption']); @@ -207,7 +204,6 @@ class Crypt { * @throws \InvalidArgumentException */ public function generateHeader($keyFormat = 'hash') { - if (in_array($keyFormat, $this->supportedKeyFormats, true) === false) { throw new \InvalidArgumentException('key format "' . $keyFormat . '" is not supported'); } @@ -267,8 +263,8 @@ class Crypt { } // Workaround for OpenSSL 0.9.8. Fallback to an old cipher that should work. - if(OPENSSL_VERSION_NUMBER < 0x1000101f) { - if($cipher === 'AES-256-CTR' || $cipher === 'AES-128-CTR') { + if (OPENSSL_VERSION_NUMBER < 0x1000101f) { + if ($cipher === 'AES-256-CTR' || $cipher === 'AES-128-CTR') { $cipher = self::LEGACY_CIPHER; } } @@ -284,7 +280,7 @@ class Crypt { * @throws \InvalidArgumentException */ protected function getKeySize($cipher) { - if(isset($this->supportedCiphersAndKeySize[$cipher])) { + if (isset($this->supportedCiphersAndKeySize[$cipher])) { return $this->supportedCiphersAndKeySize[$cipher]; } @@ -389,7 +385,6 @@ class Crypt { * @return false|string */ public function decryptPrivateKey($privateKey, $password = '', $uid = '') { - $header = $this->parseHeader($privateKey); if (isset($header['cipher'])) { diff --git a/apps/encryption/lib/Crypto/DecryptAll.php b/apps/encryption/lib/Crypto/DecryptAll.php index a488c726523..ed43bc75457 100644 --- a/apps/encryption/lib/Crypto/DecryptAll.php +++ b/apps/encryption/lib/Crypto/DecryptAll.php @@ -78,10 +78,9 @@ class DecryptAll { * @return bool */ public function prepare(InputInterface $input, OutputInterface $output, $user) { - $question = new Question('Please enter the recovery key password: '); - if($this->util->isMasterKeyEnabled()) { + if ($this->util->isMasterKeyEnabled()) { $output->writeln('Use master key to decrypt all files'); $user = $this->keyManager->getMasterKeyId(); $password =$this->keyManager->getMasterKeyPassword(); diff --git a/apps/encryption/lib/Crypto/EncryptAll.php b/apps/encryption/lib/Crypto/EncryptAll.php index d0aaafd0617..8fa2214234e 100644 --- a/apps/encryption/lib/Crypto/EncryptAll.php +++ b/apps/encryption/lib/Crypto/EncryptAll.php @@ -131,7 +131,6 @@ class EncryptAll { * @param OutputInterface $output */ public function encryptAll(InputInterface $input, OutputInterface $output) { - $this->input = $input; $this->output = $output; @@ -184,7 +183,7 @@ class EncryptAll { $progress->setFormat(" %message% \n [%bar%]"); $progress->start(); - foreach($this->userManager->getBackends() as $backend) { + foreach ($this->userManager->getBackends() as $backend) { $limit = 500; $offset = 0; do { @@ -203,7 +202,7 @@ class EncryptAll { } } $offset += $limit; - } while(count($users) >= $limit); + } while (count($users) >= $limit); } $progress->setMessage('Key-pair created for all users'); @@ -231,7 +230,6 @@ class EncryptAll { } $progress->setMessage("all files encrypted"); $progress->finish(); - } /** @@ -241,7 +239,7 @@ class EncryptAll { */ protected function encryptAllUserFilesWithMasterKey(ProgressBar $progress) { $userNo = 1; - foreach($this->userManager->getBackends() as $backend) { + foreach ($this->userManager->getBackends() as $backend) { $limit = 500; $offset = 0; do { @@ -252,7 +250,7 @@ class EncryptAll { $userNo++; } $offset += $limit; - } while(count($users) >= $limit); + } while (count($users) >= $limit); } } @@ -264,12 +262,11 @@ class EncryptAll { * @param string $userCount */ protected function encryptUsersFiles($uid, ProgressBar $progress, $userCount) { - $this->setupUserFS($uid); $directories = []; $directories[] = '/' . $uid . '/files'; - while($root = array_pop($directories)) { + while ($root = array_pop($directories)) { $content = $this->rootView->getDirectoryContent($root); foreach ($content as $file) { $path = $root . '/' . $file['name']; @@ -279,7 +276,7 @@ class EncryptAll { } else { $progress->setMessage("encrypt files for user $userCount: $path"); $progress->advance(); - if($this->encryptFile($path) === false) { + if ($this->encryptFile($path) === false) { $progress->setMessage("encrypt files for user $userCount: $path (already encrypted)"); $progress->advance(); } @@ -461,7 +458,6 @@ class EncryptAll { $table->setRows($rows); $table->render(); } - } /** @@ -471,7 +467,6 @@ class EncryptAll { * @return array an array of the html mail body and the plain text mail body */ protected function createMailBody($password) { - $html = new \OC_Template("encryption", "mail", ""); $html->assign('password', $password); $htmlMail = $html->fetchPage(); @@ -482,5 +477,4 @@ class EncryptAll { return [$htmlMail, $plainTextMail]; } - } diff --git a/apps/encryption/lib/Crypto/Encryption.php b/apps/encryption/lib/Crypto/Encryption.php index f976a0815db..57cf4e2edac 100644 --- a/apps/encryption/lib/Crypto/Encryption.php +++ b/apps/encryption/lib/Crypto/Encryption.php @@ -45,7 +45,6 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class Encryption implements IEncryptionModule { - const ID = 'OC_DEFAULT_MODULE'; const DISPLAY_NAME = 'Default encryption module'; @@ -184,7 +183,7 @@ class Encryption implements IEncryptionModule { $this->isWriteOperation = false; $this->writeCache = ''; - if($this->session->isReady() === false) { + if ($this->session->isReady() === false) { // if the master key is enabled we can initialize encryption // with a empty password and user name if ($this->util->isMasterKeyEnabled()) { @@ -221,7 +220,7 @@ class Encryption implements IEncryptionModule { // if we read a part file we need to increase the version by 1 // because the version number was also increased by writing // the part file - if(Scanner::isPartialFile($path)) { + if (Scanner::isPartialFile($path)) { $this->version = $this->version + 1; } } @@ -313,7 +312,6 @@ class Encryption implements IEncryptionModule { // Clear the write cache, ready for reuse - it has been // flushed and its old contents processed $this->writeCache = ''; - } $encrypted = ''; @@ -340,7 +338,6 @@ class Encryption implements IEncryptionModule { // Clear $data ready for next round $data = ''; - } else { // Read the chunk from the start of $data @@ -352,9 +349,7 @@ class Encryption implements IEncryptionModule { // $data, leaving only unprocessed data in $data // var, for handling on the next round $data = substr($data, $this->unencryptedBlockSizeSigned); - } - } return $encrypted; @@ -389,7 +384,6 @@ class Encryption implements IEncryptionModule { * @return boolean */ public function update($path, $uid, array $accessList) { - if (empty($accessList)) { if (isset(self::$rememberVersion[$path])) { $this->keyManager->setVersion($path, self::$rememberVersion[$path], new View()); @@ -401,7 +395,6 @@ class Encryption implements IEncryptionModule { $fileKey = $this->keyManager->getFileKey($path, $uid); if (!empty($fileKey)) { - $publicKeys = []; if ($this->useMasterPassword === true) { $publicKeys[$this->keyManager->getMasterKeyId()] = $this->keyManager->getPublicMasterKey(); @@ -422,7 +415,6 @@ class Encryption implements IEncryptionModule { $this->keyManager->deleteAllFileKeys($path); $this->keyManager->setAllFileKeys($path, $encryptedFileKey); - } else { $this->logger->debug('no file key found, we assume that the file "{file}" is not encrypted', ['file' => $path, 'app' => 'encryption']); diff --git a/apps/encryption/lib/Exceptions/MultiKeyDecryptException.php b/apps/encryption/lib/Exceptions/MultiKeyDecryptException.php index 9bb01249d94..79ec2c3c822 100644 --- a/apps/encryption/lib/Exceptions/MultiKeyDecryptException.php +++ b/apps/encryption/lib/Exceptions/MultiKeyDecryptException.php @@ -26,5 +26,4 @@ namespace OCA\Encryption\Exceptions; use OCP\Encryption\Exceptions\GenericEncryptionException; class MultiKeyDecryptException extends GenericEncryptionException { - } diff --git a/apps/encryption/lib/Exceptions/MultiKeyEncryptException.php b/apps/encryption/lib/Exceptions/MultiKeyEncryptException.php index f4a03d259ca..4916a4ceba5 100644 --- a/apps/encryption/lib/Exceptions/MultiKeyEncryptException.php +++ b/apps/encryption/lib/Exceptions/MultiKeyEncryptException.php @@ -26,5 +26,4 @@ namespace OCA\Encryption\Exceptions; use OCP\Encryption\Exceptions\GenericEncryptionException; class MultiKeyEncryptException extends GenericEncryptionException { - } diff --git a/apps/encryption/lib/Exceptions/PrivateKeyMissingException.php b/apps/encryption/lib/Exceptions/PrivateKeyMissingException.php index f7014fa2701..4d14b191ddc 100644 --- a/apps/encryption/lib/Exceptions/PrivateKeyMissingException.php +++ b/apps/encryption/lib/Exceptions/PrivateKeyMissingException.php @@ -32,10 +32,9 @@ class PrivateKeyMissingException extends GenericEncryptionException { * @param string $userId */ public function __construct($userId) { - if(empty($userId)) { + if (empty($userId)) { $userId = "<no-user-id-given>"; } parent::__construct("Private Key missing for user: $userId"); } - } diff --git a/apps/encryption/lib/Exceptions/PublicKeyMissingException.php b/apps/encryption/lib/Exceptions/PublicKeyMissingException.php index d6f12b3669e..e0667d42a20 100644 --- a/apps/encryption/lib/Exceptions/PublicKeyMissingException.php +++ b/apps/encryption/lib/Exceptions/PublicKeyMissingException.php @@ -31,10 +31,9 @@ class PublicKeyMissingException extends GenericEncryptionException { * @param string $userId */ public function __construct($userId) { - if(empty($userId)) { + if (empty($userId)) { $userId = "<no-user-id-given>"; } parent::__construct("Public Key missing for user: $userId"); } - } diff --git a/apps/encryption/lib/HookManager.php b/apps/encryption/lib/HookManager.php index a40f56fa373..324c0d718da 100644 --- a/apps/encryption/lib/HookManager.php +++ b/apps/encryption/lib/HookManager.php @@ -26,7 +26,6 @@ namespace OCA\Encryption; use OCA\Encryption\Hooks\Contracts\IHook; class HookManager { - private $hookInstances = []; /** @@ -42,7 +41,6 @@ class HookManager { } $this->hookInstances[] = $instance; } - } elseif ($instances instanceof IHook) { $this->hookInstances[] = $instances; } @@ -58,7 +56,5 @@ class HookManager { */ $instance->addHooks(); } - } - } diff --git a/apps/encryption/lib/Hooks/UserHooks.php b/apps/encryption/lib/Hooks/UserHooks.php index 16655dfe689..399e2865d03 100644 --- a/apps/encryption/lib/Hooks/UserHooks.php +++ b/apps/encryption/lib/Hooks/UserHooks.php @@ -109,7 +109,6 @@ class UserHooks implements IHook { Session $session, Crypt $crypt, Recovery $recovery) { - $this->keyManager = $keyManager; $this->userManager = $userManager; $this->logger = $logger; @@ -258,7 +257,6 @@ class UserHooks implements IHook { // current logged in user changes his own password if ($user && $params['uid'] === $user->getUID()) { - $privateKey = $this->session->getPrivateKey(); // Encrypt private key with new user pwd as passphrase diff --git a/apps/encryption/lib/KeyManager.php b/apps/encryption/lib/KeyManager.php index 8b286e00942..a62a4ca27f8 100644 --- a/apps/encryption/lib/KeyManager.php +++ b/apps/encryption/lib/KeyManager.php @@ -120,7 +120,6 @@ class KeyManager { ILogger $log, Util $util ) { - $this->util = $util; $this->session = $session; $this->keyStorage = $keyStorage; @@ -179,7 +178,6 @@ class KeyManager { * check if a key pair for the master key exists, if not we create one */ public function validateMasterKey() { - if ($this->util->isMasterKeyEnabled() === false) { return; } @@ -358,11 +356,10 @@ class KeyManager { * @return boolean */ public function init($uid, $passPhrase) { - $this->session->setStatus(Session::INIT_EXECUTED); try { - if($this->util->isMasterKeyEnabled()) { + if ($this->util->isMasterKeyEnabled()) { $uid = $this->getMasterKeyId(); $passPhrase = $this->getMasterKeyPassword(); $privateKey = $this->getSystemPrivateKey($uid); @@ -462,7 +459,7 @@ class KeyManager { */ public function getVersion($path, View $view) { $fileInfo = $view->getFileInfo($path); - if($fileInfo === false) { + if ($fileInfo === false) { return 0; } return $fileInfo->getEncryptedVersion(); @@ -478,7 +475,7 @@ class KeyManager { public function setVersion($path, $version, View $view) { $fileInfo= $view->getFileInfo($path); - if($fileInfo !== false) { + if ($fileInfo !== false) { $cache = $fileInfo->getStorage()->getCache(); $cache->update($fileInfo->getId(), ['encrypted' => $version, 'encryptedVersion' => $version]); } @@ -642,7 +639,6 @@ class KeyManager { } return $keys; - } /** @@ -685,7 +681,6 @@ class KeyManager { if ($this->recoveryKeyExists() && $this->util->isRecoveryEnabledForUser($uid)) { - $publicKeys[$this->getRecoveryKeyId()] = $this->getRecoveryKey(); } @@ -700,7 +695,7 @@ class KeyManager { */ public function getMasterKeyPassword() { $password = $this->config->getSystemValue('secret'); - if (empty($password)){ + if (empty($password)) { throw new \Exception('Can not get secret from Nextcloud instance'); } diff --git a/apps/encryption/lib/Migration/SetMasterKeyStatus.php b/apps/encryption/lib/Migration/SetMasterKeyStatus.php index ade393cede1..322b991ae97 100644 --- a/apps/encryption/lib/Migration/SetMasterKeyStatus.php +++ b/apps/encryption/lib/Migration/SetMasterKeyStatus.php @@ -73,5 +73,4 @@ class SetMasterKeyStatus implements IRepairStep { $appVersion = $this->config->getAppValue('encryption', 'installed_version', '0.0.0'); return version_compare($appVersion, '2.0.0', '<'); } - } diff --git a/apps/encryption/lib/Recovery.php b/apps/encryption/lib/Recovery.php index 657d41b61dd..7d7132999ea 100644 --- a/apps/encryption/lib/Recovery.php +++ b/apps/encryption/lib/Recovery.php @@ -95,7 +95,7 @@ class Recovery { if (!$keyManager->recoveryKeyExists()) { $keyPair = $this->crypt->createKeyPair(); - if(!is_array($keyPair)) { + if (!is_array($keyPair)) { return false; } @@ -120,7 +120,7 @@ class Recovery { public function changeRecoveryKeyPassword($newPassword, $oldPassword) { $recoveryKey = $this->keyManager->getSystemPrivateKey($this->keyManager->getRecoveryKeyId()); $decryptedRecoveryKey = $this->crypt->decryptPrivateKey($recoveryKey, $oldPassword); - if($decryptedRecoveryKey === false) { + if ($decryptedRecoveryKey === false) { return false; } $encryptedRecoveryKey = $this->crypt->encryptPrivateKey($decryptedRecoveryKey, $newPassword); @@ -180,7 +180,6 @@ class Recovery { * @return bool */ public function setRecoveryForUser($value) { - try { $this->config->setUserValue($this->user->getUID(), 'encryption', @@ -253,7 +252,7 @@ class Recovery { $encryptedKey = $this->keyManager->getSystemPrivateKey($this->keyManager->getRecoveryKeyId()); $privateKey = $this->crypt->decryptPrivateKey($encryptedKey, $recoveryPassword); - if($privateKey !== false) { + if ($privateKey !== false) { $this->recoverAllFiles('/' . $user . '/files/', $privateKey, $user); } } @@ -277,7 +276,6 @@ class Recovery { $this->recoverFile($filePath, $privateKey, $uid); } } - } /** @@ -309,8 +307,5 @@ class Recovery { $encryptedKeyfiles = $this->crypt->multiKeyEncrypt($fileKey, $publicKeys); $this->keyManager->setAllFileKeys($path, $encryptedKeyfiles); } - } - - } diff --git a/apps/encryption/lib/Session.php b/apps/encryption/lib/Session.php index 58357b2efe1..4398f9c4e0a 100644 --- a/apps/encryption/lib/Session.php +++ b/apps/encryption/lib/Session.php @@ -184,5 +184,4 @@ class Session { $this->session->remove('decryptAllKey'); $this->session->remove('decryptAllUid'); } - } diff --git a/apps/encryption/lib/Settings/Admin.php b/apps/encryption/lib/Settings/Admin.php index 91ce234ef58..d3b64bee4ee 100644 --- a/apps/encryption/lib/Settings/Admin.php +++ b/apps/encryption/lib/Settings/Admin.php @@ -125,5 +125,4 @@ class Admin implements ISettings { public function getPriority() { return 11; } - } diff --git a/apps/encryption/lib/Util.php b/apps/encryption/lib/Util.php index 681f025417b..2b11b8151c0 100644 --- a/apps/encryption/lib/Util.php +++ b/apps/encryption/lib/Util.php @@ -182,7 +182,6 @@ class Util { throw new \BadMethodCallException('Unknown user: ' . 'method expects path to a user folder relative to the data folder'); } - } return $owner; @@ -197,5 +196,4 @@ class Util { public function getStorage($path) { return $this->files->getMount($path)->getStorage(); } - } diff --git a/apps/encryption/templates/settings-admin.php b/apps/encryption/templates/settings-admin.php index 48cc4d40da8..1ae93dfb0e2 100644 --- a/apps/encryption/templates/settings-admin.php +++ b/apps/encryption/templates/settings-admin.php @@ -6,17 +6,19 @@ style('encryption', 'settings-admin'); ?> <form id="ocDefaultEncryptionModule" class="sub-section"> <h3><?php p($l->t("Default encryption module")); ?></h3> - <?php if(!$_["initStatus"] && $_['masterKeyEnabled'] === false): ?> + <?php if (!$_["initStatus"] && $_['masterKeyEnabled'] === false): ?> <?php p($l->t("Encryption app is enabled but your keys are not initialized, please log-out and log-in again")); ?> <?php else: ?> <p id="encryptHomeStorageSetting"> <input type="checkbox" class="checkbox" name="encrypt_home_storage" id="encryptHomeStorage" - value="1" <?php if ($_['encryptHomeStorage']) print_unescaped('checked="checked"'); ?> /> + value="1" <?php if ($_['encryptHomeStorage']) { + print_unescaped('checked="checked"'); +} ?> /> <label for="encryptHomeStorage"><?php p($l->t('Encrypt the home storage'));?></label></br> <em><?php p($l->t("Enabling this option encrypts all files stored on the main storage, otherwise only files on external storage will be encrypted")); ?></em> </p> <br /> - <?php if($_['masterKeyEnabled'] === false): ?> + <?php if ($_['masterKeyEnabled'] === false): ?> <p id="encryptionSetRecoveryKey"> <?php $_["recoveryEnabled"] === '0' ? p($l->t("Enable recovery key")) : p($l->t("Disable recovery key")); ?> <span class="msg"></span> @@ -41,7 +43,9 @@ style('encryption', 'settings-admin'); </p> <br/><br/> - <p name="changeRecoveryPasswordBlock" id="encryptionChangeRecoveryKey" <?php if($_['recoveryEnabled'] === '0') print_unescaped('class="hidden"');?>> + <p name="changeRecoveryPasswordBlock" id="encryptionChangeRecoveryKey" <?php if ($_['recoveryEnabled'] === '0') { + print_unescaped('class="hidden"'); +}?>> <?php p($l->t("Change recovery key password:")); ?> <span class="msg"></span> <br/> diff --git a/apps/encryption/tests/Command/TestEnableMasterKey.php b/apps/encryption/tests/Command/TestEnableMasterKey.php index f8cbd790adb..b8db72938a5 100644 --- a/apps/encryption/tests/Command/TestEnableMasterKey.php +++ b/apps/encryption/tests/Command/TestEnableMasterKey.php @@ -77,7 +77,6 @@ class TestEnableMasterKey extends TestCase { * @param string $answer */ public function testExecute($isAlreadyEnabled, $answer) { - $this->util->expects($this->once())->method('isMasterKeyEnabled') ->willReturn($isAlreadyEnabled); @@ -92,7 +91,6 @@ class TestEnableMasterKey extends TestCase { } else { $this->questionHelper->expects($this->once())->method('ask')->willReturn(false); $this->config->expects($this->never())->method('setAppValue'); - } } diff --git a/apps/encryption/tests/Controller/RecoveryControllerTest.php b/apps/encryption/tests/Controller/RecoveryControllerTest.php index 5f69f11d2f7..27d67a12dfa 100644 --- a/apps/encryption/tests/Controller/RecoveryControllerTest.php +++ b/apps/encryption/tests/Controller/RecoveryControllerTest.php @@ -65,8 +65,6 @@ class RecoveryControllerTest extends TestCase { * @param $expectedStatus */ public function testAdminRecovery($recoveryPassword, $passConfirm, $enableRecovery, $expectedMessage, $expectedStatus) { - - $this->recoveryMock->expects($this->any()) ->method('enableAdminRecovery') ->willReturn(true); @@ -82,8 +80,6 @@ class RecoveryControllerTest extends TestCase { $this->assertEquals($expectedMessage, $response->getData()['data']['message']); $this->assertEquals($expectedStatus, $response->getStatus()); - - } public function changeRecoveryPasswordProvider() { @@ -119,8 +115,6 @@ class RecoveryControllerTest extends TestCase { $this->assertEquals($expectedMessage, $response->getData()['data']['message']); $this->assertEquals($expectedStatus, $response->getStatus()); - - } public function userSetRecoveryProvider() { @@ -150,7 +144,6 @@ class RecoveryControllerTest extends TestCase { $this->assertEquals($expectedMessage, $response->getData()['data']['message']); $this->assertEquals($expectedStatus, $response->getStatus()); - } protected function setUp(): void { @@ -183,5 +176,4 @@ class RecoveryControllerTest extends TestCase { $this->l10nMock, $this->recoveryMock); } - } diff --git a/apps/encryption/tests/Controller/SettingsControllerTest.php b/apps/encryption/tests/Controller/SettingsControllerTest.php index 160c9794613..0cd69c8c1c4 100644 --- a/apps/encryption/tests/Controller/SettingsControllerTest.php +++ b/apps/encryption/tests/Controller/SettingsControllerTest.php @@ -76,7 +76,6 @@ class SettingsControllerTest extends TestCase { private $utilMock; protected function setUp(): void { - parent::setUp(); $this->requestMock = $this->createMock(IRequest::class); @@ -136,7 +135,6 @@ class SettingsControllerTest extends TestCase { * test updatePrivateKeyPassword() if wrong new password was entered */ public function testUpdatePrivateKeyPasswordWrongNewPassword() { - $oldPassword = 'old'; $newPassword = 'new'; @@ -162,7 +160,6 @@ class SettingsControllerTest extends TestCase { * test updatePrivateKeyPassword() if wrong old password was entered */ public function testUpdatePrivateKeyPasswordWrongOldPassword() { - $oldPassword = 'old'; $newPassword = 'new'; @@ -189,7 +186,6 @@ class SettingsControllerTest extends TestCase { * test updatePrivateKeyPassword() with the correct old and new password */ public function testUpdatePrivateKeyPassword() { - $oldPassword = 'old'; $newPassword = 'new'; @@ -254,5 +250,4 @@ class SettingsControllerTest extends TestCase { $this->utilMock->expects($this->once())->method('setEncryptHomeStorage')->with($value); $this->controller->setEncryptHomeStorage($value); } - } diff --git a/apps/encryption/tests/Controller/StatusControllerTest.php b/apps/encryption/tests/Controller/StatusControllerTest.php index fe2616f9c54..5028fefbbe0 100644 --- a/apps/encryption/tests/Controller/StatusControllerTest.php +++ b/apps/encryption/tests/Controller/StatusControllerTest.php @@ -52,7 +52,6 @@ class StatusControllerTest extends TestCase { protected $controller; protected function setUp(): void { - parent::setUp(); $this->sessionMock = $this->getMockBuilder(Session::class) @@ -73,7 +72,6 @@ class StatusControllerTest extends TestCase { $this->l10nMock, $this->sessionMock, $this->encryptionManagerMock); - } /** diff --git a/apps/encryption/tests/Crypto/CryptTest.php b/apps/encryption/tests/Crypto/CryptTest.php index dd892616d0f..6f7b0cc2765 100644 --- a/apps/encryption/tests/Crypto/CryptTest.php +++ b/apps/encryption/tests/Crypto/CryptTest.php @@ -76,7 +76,6 @@ class CryptTest extends TestCase { * test getOpenSSLConfig without any additional parameters */ public function testGetOpenSSLConfigBasic() { - $this->config->expects($this->once()) ->method('getSystemValue') ->with($this->equalTo('openssl'), $this->equalTo([])) @@ -92,7 +91,6 @@ class CryptTest extends TestCase { * test getOpenSSLConfig with additional parameters defined in config.php */ public function testGetOpenSSLConfig() { - $this->config->expects($this->once()) ->method('getSystemValue') ->with($this->equalTo('openssl'), $this->equalTo([])) @@ -113,7 +111,6 @@ class CryptTest extends TestCase { * @dataProvider dataTestGenerateHeader */ public function testGenerateHeader($keyFormat, $expected) { - $this->config->expects($this->once()) ->method('getSystemValue') ->with($this->equalTo('cipher'), $this->equalTo('AES-256-CTR')) @@ -176,7 +173,6 @@ class CryptTest extends TestCase { $this->assertSame($expected, $this->crypt->getCipher() ); - } /** @@ -199,7 +195,6 @@ class CryptTest extends TestCase { * test concatIV() */ public function testConcatIV() { - $result = self::invokePrivate( $this->crypt, 'concatIV', @@ -305,7 +300,6 @@ class CryptTest extends TestCase { * test parseHeader() */ public function testParseHeader() { - $header= 'HBEGIN:foo:bar:cipher:AES-256-CFB:HEND'; $result = self::invokePrivate($this->crypt, 'parseHeader', [$header]); @@ -323,7 +317,6 @@ class CryptTest extends TestCase { * @return string */ public function testEncrypt() { - $decrypted = 'content'; $password = 'password'; $iv = self::invokePrivate($this->crypt, 'generateIv'); @@ -340,7 +333,6 @@ class CryptTest extends TestCase { 'iv' => $iv, 'encrypted' => $result, 'decrypted' => $decrypted]; - } /** @@ -349,14 +341,12 @@ class CryptTest extends TestCase { * @depends testEncrypt */ public function testDecrypt($data) { - $result = self::invokePrivate( $this->crypt, 'decrypt', [$data['encrypted'], $data['iv'], $data['password']]); $this->assertSame($data['decrypted'], $result); - } /** @@ -461,5 +451,4 @@ class CryptTest extends TestCase { $this->invokePrivate($this->crypt, 'isValidPrivateKey', ['foo']) ); } - } diff --git a/apps/encryption/tests/Crypto/DecryptAllTest.php b/apps/encryption/tests/Crypto/DecryptAllTest.php index be980149145..b4d846bfd5a 100644 --- a/apps/encryption/tests/Crypto/DecryptAllTest.php +++ b/apps/encryption/tests/Crypto/DecryptAllTest.php @@ -110,7 +110,6 @@ class DecryptAllTest extends TestCase { $this->keyManager->expects($this->never())->method('getPrivateKey'); $this->crypt->expects($this->once())->method('decryptPrivateKey') ->with($masterKey, $password, $masterKeyId)->willReturn($unencryptedKey); - } else { $this->keyManager->expects($this->never())->method('getSystemPrivateKey'); $this->keyManager->expects($this->once())->method('getPrivateKey') @@ -131,5 +130,4 @@ class DecryptAllTest extends TestCase { ['masterKeyId', 'masterKeyId', 'masterKeyId'] ]; } - } diff --git a/apps/encryption/tests/Crypto/EncryptAllTest.php b/apps/encryption/tests/Crypto/EncryptAllTest.php index f5fd3d2287f..3041c27dee7 100644 --- a/apps/encryption/tests/Crypto/EncryptAllTest.php +++ b/apps/encryption/tests/Crypto/EncryptAllTest.php @@ -168,7 +168,6 @@ class EncryptAllTest extends TestCase { $encryptAll->expects($this->at(2))->method('encryptAllUsersFiles')->with(); $encryptAll->encryptAll($this->inputInterface, $this->outputInterface); - } public function testEncryptAllWithMasterKey() { @@ -198,7 +197,6 @@ class EncryptAllTest extends TestCase { $encryptAll->expects($this->never())->method('outputPasswords'); $encryptAll->encryptAll($this->inputInterface, $this->outputInterface); - } public function testCreateKeyPairs() { @@ -280,7 +278,6 @@ class EncryptAllTest extends TestCase { $encryptAll->expects($this->at(1))->method('encryptUsersFiles')->with('user2'); $this->invokePrivate($encryptAll, 'encryptAllUsersFiles'); - } public function testEncryptUsersFiles() { @@ -339,7 +336,6 @@ class EncryptAllTest extends TestCase { $progressBar = new ProgressBar($this->outputInterface); $this->invokePrivate($encryptAll, 'encryptUsersFiles', ['user1', $progressBar, '']); - } public function testGenerateOneTimePassword() { @@ -364,7 +360,7 @@ class EncryptAllTest extends TestCase { ->willReturn($fileInfo); - if($isEncrypted) { + if ($isEncrypted) { $this->view->expects($this->never())->method('copy'); $this->view->expects($this->never())->method('rename'); } else { @@ -383,5 +379,4 @@ class EncryptAllTest extends TestCase { [false], ]; } - } diff --git a/apps/encryption/tests/Crypto/EncryptionTest.php b/apps/encryption/tests/Crypto/EncryptionTest.php index 1e4cfad5e30..dee1118a992 100644 --- a/apps/encryption/tests/Crypto/EncryptionTest.php +++ b/apps/encryption/tests/Crypto/EncryptionTest.php @@ -118,7 +118,6 @@ class EncryptionTest extends TestCase { $this->loggerMock, $this->l10nMock ); - } /** @@ -200,7 +199,6 @@ class EncryptionTest extends TestCase { * @dataProvider dataTestBegin */ public function testBegin($mode, $header, $legacyCipher, $defaultCipher, $fileKey, $expected) { - $this->sessionMock->expects($this->once()) ->method('decryptAllModeActivated') ->willReturn(false); @@ -255,7 +253,6 @@ class EncryptionTest extends TestCase { * test begin() if decryptAll mode was activated */ public function testBeginDecryptAll() { - $path = '/user/files/foo.txt'; $recoveryKeyId = 'recoveryKeyId'; $recoveryShareKey = 'recoveryShareKey'; @@ -299,7 +296,6 @@ class EncryptionTest extends TestCase { * and continue */ public function testBeginInitMasterKey() { - $this->sessionMock->expects($this->once())->method('isReady')->willReturn(false); $this->utilMock->expects($this->once())->method('isMasterKeyEnabled') ->willReturn(true); @@ -343,7 +339,6 @@ class EncryptionTest extends TestCase { } public function testUpdateNoUsers() { - $this->invokePrivate($this->instance, 'rememberVersion', [['path' => 2]]); $this->keyManagerMock->expects($this->never())->method('getFileKey'); @@ -452,5 +447,4 @@ class EncryptionTest extends TestCase { $this->instance->prepareDecryptAll($input, $output, 'user'); } - } diff --git a/apps/encryption/tests/HookManagerTest.php b/apps/encryption/tests/HookManagerTest.php index c49938f4f3f..d1b6a4466af 100644 --- a/apps/encryption/tests/HookManagerTest.php +++ b/apps/encryption/tests/HookManagerTest.php @@ -56,7 +56,6 @@ class HookManagerTest extends TestCase { parent::setUpBeforeClass(); // have to make instance static to preserve data between tests self::$instance = new HookManager(); - } @@ -67,7 +66,5 @@ class HookManagerTest extends TestCase { $hookInstances = self::invokePrivate(self::$instance, 'hookInstances'); $this->assertCount(3, $hookInstances); - } - } diff --git a/apps/encryption/tests/Hooks/UserHooksTest.php b/apps/encryption/tests/Hooks/UserHooksTest.php index c676acb1e90..dcd82fe7e0f 100644 --- a/apps/encryption/tests/Hooks/UserHooksTest.php +++ b/apps/encryption/tests/Hooks/UserHooksTest.php @@ -155,7 +155,6 @@ class UserHooksTest extends TestCase { $this->instance->postPasswordReset($params); $passwordResetUsers = $this->invokePrivate($this->instance, 'passwordResetUsers'); $this->assertEmpty($passwordResetUsers); - } /** @@ -302,7 +301,6 @@ class UserHooksTest extends TestCase { } public function XtestSetPasswordNoUser() { - $userSessionMock = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->getMock(); @@ -390,7 +388,5 @@ class UserHooksTest extends TestCase { $this->recoveryMock ] )->setMethods(['setupFS'])->getMock(); - } - } diff --git a/apps/encryption/tests/KeyManagerTest.php b/apps/encryption/tests/KeyManagerTest.php index 02ab30f998c..da5777d75ab 100644 --- a/apps/encryption/tests/KeyManagerTest.php +++ b/apps/encryption/tests/KeyManagerTest.php @@ -250,7 +250,6 @@ class KeyManagerTest extends TestCase { }); $this->instance->userHasKeys($this->userId); - } /** @@ -286,7 +285,7 @@ class KeyManagerTest extends TestCase { $instance->expects($this->any())->method('getSystemPrivateKey')->with('masterKeyId')->willReturn('privateMasterKey'); $instance->expects($this->any())->method('getPrivateKey')->with($this->userId)->willReturn('privateUserKey'); - if($useMasterKey) { + if ($useMasterKey) { $this->cryptMock->expects($this->once())->method('decryptPrivateKey') ->with('privateMasterKey', 'masterKeyPassword', 'masterKeyId') ->willReturn('key'); @@ -381,7 +380,6 @@ class KeyManagerTest extends TestCase { * @param $expected */ public function testGetFileKey($uid, $isMasterKeyEnabled, $privateKey, $expected) { - $path = '/foo.txt'; if ($isMasterKeyEnabled) { @@ -422,7 +420,7 @@ class KeyManagerTest extends TestCase { $this->sessionMock->expects($this->once())->method('getPrivateKey')->willReturn($privateKey); } - if($privateKey) { + if ($privateKey) { $this->cryptMock->expects($this->once()) ->method('multiKeyDecrypt') ->willReturn(true); @@ -434,7 +432,6 @@ class KeyManagerTest extends TestCase { $this->assertSame($expected, $this->instance->getFileKey($path, $uid) ); - } public function testDeletePrivateKey() { @@ -467,7 +464,6 @@ class KeyManagerTest extends TestCase { * @param array $expectedKeys */ public function testAddSystemKeys($accessList, $publicKeys, $uid, $expectedKeys) { - $publicShareKeyId = 'publicShareKey'; $recoveryKeyId = 'recoveryKey'; @@ -574,7 +570,7 @@ class KeyManagerTest extends TestCase { $instance->expects($this->any())->method('getMasterKeyPassword')->willReturn('masterKeyPassword'); $this->cryptMock->expects($this->any())->method('generateHeader')->willReturn('header'); - if(empty($masterKey)) { + if (empty($masterKey)) { $this->cryptMock->expects($this->once())->method('createKeyPair') ->willReturn(['publicKey' => 'public', 'privateKey' => 'private']); $this->keyStorageMock->expects($this->once())->method('setSystemUserKey') @@ -677,5 +673,4 @@ class KeyManagerTest extends TestCase { ->with('OC_DEFAULT_MODULE', 'test', 'user1'); $this->instance->backupUserKeys('test', 'user1'); } - } diff --git a/apps/encryption/tests/RecoveryTest.php b/apps/encryption/tests/RecoveryTest.php index 5139e492f26..df5dc3241c0 100644 --- a/apps/encryption/tests/RecoveryTest.php +++ b/apps/encryption/tests/RecoveryTest.php @@ -172,7 +172,6 @@ class RecoveryTest extends TestCase { } public function testDisableAdminRecovery() { - $this->keyManagerMock->expects($this->exactly(2)) ->method('checkRecoveryPassword') ->willReturnOnConsecutiveCalls(true, false); @@ -185,7 +184,6 @@ class RecoveryTest extends TestCase { } public function testIsRecoveryEnabledForUser() { - $this->configMock->expects($this->exactly(2)) ->method('getUserValue') ->willReturnOnConsecutiveCalls('1', '0'); @@ -323,6 +321,4 @@ class RecoveryTest extends TestCase { } return null; } - - } diff --git a/apps/encryption/tests/SessionTest.php b/apps/encryption/tests/SessionTest.php index 279111e3c3b..19425cc8531 100644 --- a/apps/encryption/tests/SessionTest.php +++ b/apps/encryption/tests/SessionTest.php @@ -54,7 +54,6 @@ class SessionTest extends TestCase { public function testSetAndGetPrivateKey() { $this->instance->setPrivateKey('dummyPrivateKey'); $this->assertEquals('dummyPrivateKey', $this->instance->getPrivateKey()); - } /** diff --git a/apps/encryption/tests/Users/SetupTest.php b/apps/encryption/tests/Users/SetupTest.php index a580ca68e05..44bb2e55e86 100644 --- a/apps/encryption/tests/Users/SetupTest.php +++ b/apps/encryption/tests/Users/SetupTest.php @@ -84,7 +84,6 @@ class SetupTest extends TestCase { * @param bool $expected */ public function testSetupUser($hasKeys, $expected) { - $this->keyManagerMock->expects($this->once())->method('userHasKeys') ->with('uid')->willReturn($hasKeys); @@ -107,5 +106,4 @@ class SetupTest extends TestCase { [false, true] ]; } - } diff --git a/apps/encryption/tests/UtilTest.php b/apps/encryption/tests/UtilTest.php index d433826cb76..27c1469b031 100644 --- a/apps/encryption/tests/UtilTest.php +++ b/apps/encryption/tests/UtilTest.php @@ -216,5 +216,4 @@ class UtilTest extends TestCase { $this->assertEquals($return, $this->instance->getStorage($path)); } - } |