Scrutinizer Auto-Fixes
This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
This commit is contained in:
parent
99c28a6ce6
commit
be4c3a8b56
|
@ -32,7 +32,7 @@ class Plugin extends ServerPlugin {
|
||||||
* This is for example 'versioning' and is added to the DAV: header
|
* This is for example 'versioning' and is added to the DAV: header
|
||||||
* in an OPTIONS response.
|
* in an OPTIONS response.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
function getFeatures() {
|
function getFeatures() {
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ class Plugin extends ServerPlugin {
|
||||||
*
|
*
|
||||||
* @param RequestInterface $request
|
* @param RequestInterface $request
|
||||||
* @param ResponseInterface $response
|
* @param ResponseInterface $response
|
||||||
* @return null|bool
|
* @return null|false
|
||||||
*/
|
*/
|
||||||
function httpPost(RequestInterface $request, ResponseInterface $response) {
|
function httpPost(RequestInterface $request, ResponseInterface $response) {
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,7 @@ class UserHooks implements IHook {
|
||||||
*
|
*
|
||||||
* @note This method should never be called for users using client side encryption
|
* @note This method should never be called for users using client side encryption
|
||||||
* @param array $params
|
* @param array $params
|
||||||
* @return bool
|
* @return boolean|null
|
||||||
*/
|
*/
|
||||||
public function login($params) {
|
public function login($params) {
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ class UserHooks implements IHook {
|
||||||
* If the password can't be changed within ownCloud, than update the key password in advance.
|
* If the password can't be changed within ownCloud, than update the key password in advance.
|
||||||
*
|
*
|
||||||
* @param array $params : uid, password
|
* @param array $params : uid, password
|
||||||
* @return bool
|
* @return boolean|null
|
||||||
*/
|
*/
|
||||||
public function preSetPassphrase($params) {
|
public function preSetPassphrase($params) {
|
||||||
if (App::isEnabled('encryption')) {
|
if (App::isEnabled('encryption')) {
|
||||||
|
@ -216,7 +216,7 @@ class UserHooks implements IHook {
|
||||||
* Change a user's encryption passphrase
|
* Change a user's encryption passphrase
|
||||||
*
|
*
|
||||||
* @param array $params keys: uid, password
|
* @param array $params keys: uid, password
|
||||||
* @return bool
|
* @return boolean|null
|
||||||
*/
|
*/
|
||||||
public function setPassphrase($params) {
|
public function setPassphrase($params) {
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,6 @@ use OCA\Encryption\Vendor\PBKDF2Fallback;
|
||||||
use OCP\Encryption\Exceptions\GenericEncryptionException;
|
use OCP\Encryption\Exceptions\GenericEncryptionException;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\ILogger;
|
use OCP\ILogger;
|
||||||
use OCP\IUser;
|
|
||||||
use OCP\IUserSession;
|
use OCP\IUserSession;
|
||||||
|
|
||||||
class Crypt {
|
class Crypt {
|
||||||
|
@ -146,7 +145,7 @@ class Crypt {
|
||||||
/**
|
/**
|
||||||
* @param string $plainContent
|
* @param string $plainContent
|
||||||
* @param string $passPhrase
|
* @param string $passPhrase
|
||||||
* @return bool|string
|
* @return false|string
|
||||||
* @throws GenericEncryptionException
|
* @throws GenericEncryptionException
|
||||||
*/
|
*/
|
||||||
public function symmetricEncryptFileContent($plainContent, $passPhrase) {
|
public function symmetricEncryptFileContent($plainContent, $passPhrase) {
|
||||||
|
@ -273,7 +272,7 @@ class Crypt {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $data
|
* @param string $data
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function addPadding($data) {
|
private function addPadding($data) {
|
||||||
|
@ -326,7 +325,7 @@ class Crypt {
|
||||||
* @param string $privateKey
|
* @param string $privateKey
|
||||||
* @param string $password
|
* @param string $password
|
||||||
* @param string $uid for regular users, empty for system keys
|
* @param string $uid for regular users, empty for system keys
|
||||||
* @return bool|string
|
* @return false|string
|
||||||
*/
|
*/
|
||||||
public function encryptPrivateKey($privateKey, $password, $uid = '') {
|
public function encryptPrivateKey($privateKey, $password, $uid = '') {
|
||||||
$cipher = $this->getCipher();
|
$cipher = $this->getCipher();
|
||||||
|
@ -343,7 +342,7 @@ class Crypt {
|
||||||
* @param string $privateKey
|
* @param string $privateKey
|
||||||
* @param string $password
|
* @param string $password
|
||||||
* @param string $uid for regular users, empty for system keys
|
* @param string $uid for regular users, empty for system keys
|
||||||
* @return bool|string
|
* @return false|string
|
||||||
*/
|
*/
|
||||||
public function decryptPrivateKey($privateKey, $password = '', $uid = '') {
|
public function decryptPrivateKey($privateKey, $password = '', $uid = '') {
|
||||||
|
|
||||||
|
@ -386,7 +385,7 @@ class Crypt {
|
||||||
/**
|
/**
|
||||||
* check if it is a valid private key
|
* check if it is a valid private key
|
||||||
*
|
*
|
||||||
* @param $plainKey
|
* @param string $plainKey
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function isValidPrivateKey($plainKey) {
|
protected function isValidPrivateKey($plainKey) {
|
||||||
|
@ -402,7 +401,7 @@ class Crypt {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $keyFileContents
|
* @param string $keyFileContents
|
||||||
* @param string $passPhrase
|
* @param string $passPhrase
|
||||||
* @param string $cipher
|
* @param string $cipher
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -424,7 +423,7 @@ class Crypt {
|
||||||
* remove padding
|
* remove padding
|
||||||
*
|
*
|
||||||
* @param $padded
|
* @param $padded
|
||||||
* @return bool|string
|
* @return string|false
|
||||||
*/
|
*/
|
||||||
private function removePadding($padded) {
|
private function removePadding($padded) {
|
||||||
if (substr($padded, -2) === 'xx') {
|
if (substr($padded, -2) === 'xx') {
|
||||||
|
@ -436,8 +435,8 @@ class Crypt {
|
||||||
/**
|
/**
|
||||||
* split iv from encrypted content
|
* split iv from encrypted content
|
||||||
*
|
*
|
||||||
* @param $catFile
|
* @param string|false $catFile
|
||||||
* @return array
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function splitIv($catFile) {
|
private function splitIv($catFile) {
|
||||||
// Fetch encryption metadata from end of file
|
// Fetch encryption metadata from end of file
|
||||||
|
@ -457,8 +456,8 @@ class Crypt {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $encryptedContent
|
* @param string $encryptedContent
|
||||||
* @param $iv
|
* @param string $iv
|
||||||
* @param string $passPhrase
|
* @param string $passPhrase
|
||||||
* @param string $cipher
|
* @param string $cipher
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -479,7 +478,7 @@ class Crypt {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $data
|
* @param string $data
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function parseHeader($data) {
|
protected function parseHeader($data) {
|
||||||
|
@ -551,7 +550,7 @@ class Crypt {
|
||||||
* @param $encKeyFile
|
* @param $encKeyFile
|
||||||
* @param $shareKey
|
* @param $shareKey
|
||||||
* @param $privateKey
|
* @param $privateKey
|
||||||
* @return mixed
|
* @return string
|
||||||
* @throws MultiKeyDecryptException
|
* @throws MultiKeyDecryptException
|
||||||
*/
|
*/
|
||||||
public function multiKeyDecrypt($encKeyFile, $shareKey, $privateKey) {
|
public function multiKeyDecrypt($encKeyFile, $shareKey, $privateKey) {
|
||||||
|
|
|
@ -247,7 +247,7 @@ class Encryption implements IEncryptionModule {
|
||||||
* encrypt data
|
* encrypt data
|
||||||
*
|
*
|
||||||
* @param string $data you want to encrypt
|
* @param string $data you want to encrypt
|
||||||
* @return mixed encrypted data
|
* @return string encrypted data
|
||||||
*/
|
*/
|
||||||
public function encrypt($data) {
|
public function encrypt($data) {
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ class Encryption implements IEncryptionModule {
|
||||||
* decrypt data
|
* decrypt data
|
||||||
*
|
*
|
||||||
* @param string $data you want to decrypt
|
* @param string $data you want to decrypt
|
||||||
* @return mixed decrypted data
|
* @return string decrypted data
|
||||||
* @throws DecryptionFailedException
|
* @throws DecryptionFailedException
|
||||||
*/
|
*/
|
||||||
public function decrypt($data) {
|
public function decrypt($data) {
|
||||||
|
|
|
@ -280,7 +280,7 @@ class KeyManager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $userId
|
* @param $userId
|
||||||
* @param $key
|
* @param string $key
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function setPrivateKey($userId, $key) {
|
public function setPrivateKey($userId, $key) {
|
||||||
|
@ -365,7 +365,7 @@ class KeyManager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $userId
|
* @param $userId
|
||||||
* @return mixed
|
* @return string
|
||||||
* @throws PrivateKeyMissingException
|
* @throws PrivateKeyMissingException
|
||||||
*/
|
*/
|
||||||
public function getPrivateKey($userId) {
|
public function getPrivateKey($userId) {
|
||||||
|
@ -379,7 +379,7 @@ class KeyManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $path
|
* @param string $path
|
||||||
* @param $uid
|
* @param $uid
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -412,7 +412,7 @@ class KeyManager {
|
||||||
/**
|
/**
|
||||||
* get the encrypted file key
|
* get the encrypted file key
|
||||||
*
|
*
|
||||||
* @param $path
|
* @param string $path
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getEncryptedFileKey($path) {
|
public function getEncryptedFileKey($path) {
|
||||||
|
@ -508,7 +508,7 @@ class KeyManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $purpose
|
* @param string $purpose
|
||||||
* @param bool $timestamp
|
* @param bool $timestamp
|
||||||
* @param bool $includeUserKeys
|
* @param bool $includeUserKeys
|
||||||
*/
|
*/
|
||||||
|
@ -534,13 +534,16 @@ class KeyManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $uid
|
* @param string $uid
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function deletePrivateKey($uid) {
|
private function deletePrivateKey($uid) {
|
||||||
return $this->keyStorage->deleteUserKey($uid, $this->privateKeyId, Encryption::ID);
|
return $this->keyStorage->deleteUserKey($uid, $this->privateKeyId, Encryption::ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $path
|
||||||
|
*/
|
||||||
public function deleteAllFileKeys($path) {
|
public function deleteAllFileKeys($path) {
|
||||||
return $this->keyStorage->deleteAllFileKeys($path);
|
return $this->keyStorage->deleteAllFileKeys($path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,7 +237,7 @@ class Migration {
|
||||||
/**
|
/**
|
||||||
* rename system wide public key
|
* rename system wide public key
|
||||||
*
|
*
|
||||||
* @param $privateKey private key for which we want to rename the corresponding public key
|
* @param string $privateKey private key for which we want to rename the corresponding public key
|
||||||
*/
|
*/
|
||||||
private function renameSystemPublicKey($privateKey) {
|
private function renameSystemPublicKey($privateKey) {
|
||||||
$publicKey = substr($privateKey,0 , strrpos($privateKey, '.privateKey')) . '.publicKey';
|
$publicKey = substr($privateKey,0 , strrpos($privateKey, '.privateKey')) . '.publicKey';
|
||||||
|
|
|
@ -103,7 +103,7 @@ class Recovery {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $recoveryKeyId
|
* @param $recoveryKeyId
|
||||||
* @param $password
|
* @param string $password
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function enableAdminRecovery($password) {
|
public function enableAdminRecovery($password) {
|
||||||
|
@ -144,7 +144,7 @@ class Recovery {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $recoveryPassword
|
* @param string $recoveryPassword
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function disableAdminRecovery($recoveryPassword) {
|
public function disableAdminRecovery($recoveryPassword) {
|
||||||
|
@ -212,6 +212,7 @@ class Recovery {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add recovery key to all encrypted files
|
* add recovery key to all encrypted files
|
||||||
|
* @param string $path
|
||||||
*/
|
*/
|
||||||
private function addRecoveryKeys($path) {
|
private function addRecoveryKeys($path) {
|
||||||
$dirContent = $this->view->getDirectoryContent($path);
|
$dirContent = $this->view->getDirectoryContent($path);
|
||||||
|
@ -239,6 +240,7 @@ class Recovery {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* remove recovery key to all encrypted files
|
* remove recovery key to all encrypted files
|
||||||
|
* @param string $path
|
||||||
*/
|
*/
|
||||||
private function removeRecoveryKeys($path) {
|
private function removeRecoveryKeys($path) {
|
||||||
$dirContent = $this->view->getDirectoryContent($path);
|
$dirContent = $this->view->getDirectoryContent($path);
|
||||||
|
|
|
@ -62,6 +62,9 @@ class MigrationTest extends \Test\TestCase {
|
||||||
$this->moduleId = \OCA\Encryption\Crypto\Encryption::ID;
|
$this->moduleId = \OCA\Encryption\Crypto\Encryption::ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $uid
|
||||||
|
*/
|
||||||
protected function createDummyShareKeys($uid) {
|
protected function createDummyShareKeys($uid) {
|
||||||
$this->loginAsUser($uid);
|
$this->loginAsUser($uid);
|
||||||
|
|
||||||
|
@ -89,6 +92,9 @@ class MigrationTest extends \Test\TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $uid
|
||||||
|
*/
|
||||||
protected function createDummyUserKeys($uid) {
|
protected function createDummyUserKeys($uid) {
|
||||||
$this->loginAsUser($uid);
|
$this->loginAsUser($uid);
|
||||||
|
|
||||||
|
@ -98,6 +104,9 @@ class MigrationTest extends \Test\TestCase {
|
||||||
$this->view->file_put_contents('/files_encryption/public_keys/' . $uid . '.publicKey', 'publicKey');
|
$this->view->file_put_contents('/files_encryption/public_keys/' . $uid . '.publicKey', 'publicKey');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $uid
|
||||||
|
*/
|
||||||
protected function createDummyFileKeys($uid) {
|
protected function createDummyFileKeys($uid) {
|
||||||
$this->loginAsUser($uid);
|
$this->loginAsUser($uid);
|
||||||
|
|
||||||
|
@ -111,6 +120,9 @@ class MigrationTest extends \Test\TestCase {
|
||||||
$this->view->file_put_contents($uid . '/files_encryption/keys/folder2/file.2.1/fileKey' , 'data');
|
$this->view->file_put_contents($uid . '/files_encryption/keys/folder2/file.2.1/fileKey' , 'data');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $uid
|
||||||
|
*/
|
||||||
protected function createDummyFiles($uid) {
|
protected function createDummyFiles($uid) {
|
||||||
$this->loginAsUser($uid);
|
$this->loginAsUser($uid);
|
||||||
|
|
||||||
|
@ -124,6 +136,9 @@ class MigrationTest extends \Test\TestCase {
|
||||||
$this->view->file_put_contents($uid . '/files/folder2/file.2.1/fileKey' , 'data');
|
$this->view->file_put_contents($uid . '/files/folder2/file.2.1/fileKey' , 'data');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $uid
|
||||||
|
*/
|
||||||
protected function createDummyFilesInTrash($uid) {
|
protected function createDummyFilesInTrash($uid) {
|
||||||
$this->loginAsUser($uid);
|
$this->loginAsUser($uid);
|
||||||
|
|
||||||
|
@ -239,6 +254,9 @@ class MigrationTest extends \Test\TestCase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $uid
|
||||||
|
*/
|
||||||
protected function verifyFilesInTrash($uid) {
|
protected function verifyFilesInTrash($uid) {
|
||||||
$this->loginAsUser($uid);
|
$this->loginAsUser($uid);
|
||||||
|
|
||||||
|
@ -266,6 +284,9 @@ class MigrationTest extends \Test\TestCase {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $uid
|
||||||
|
*/
|
||||||
protected function verifyNewKeyPath($uid) {
|
protected function verifyNewKeyPath($uid) {
|
||||||
// private key
|
// private key
|
||||||
if ($uid !== '') {
|
if ($uid !== '') {
|
||||||
|
@ -394,6 +415,11 @@ class MigrationTest extends \Test\TestCase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $table
|
||||||
|
* @param string $appid
|
||||||
|
* @param integer $expected
|
||||||
|
*/
|
||||||
public function verifyDB($table, $appid, $expected) {
|
public function verifyDB($table, $appid, $expected) {
|
||||||
/** @var \OCP\IDBConnection $connection */
|
/** @var \OCP\IDBConnection $connection */
|
||||||
$connection = \OC::$server->getDatabaseConnection();
|
$connection = \OC::$server->getDatabaseConnection();
|
||||||
|
|
Loading…
Reference in New Issue