Completed
Pull Request — master (#225)
by Sander
07:55 queued 01:15
created
lib/Service/EncryptService.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -272,7 +272,9 @@
 block discarded – undo
272 272
 	protected function unpad($data) {
273 273
 		$length = $this->getKeySize();
274 274
 		$last = ord($data[strlen($data) - 1]);
275
-		if ($last > $length) return false;
275
+		if ($last > $length) {
276
+			return false;
277
+		}
276 278
 		if (substr($data, -1 * $last) !== str_repeat(chr($last), $last)) {
277 279
 			return false;
278 280
 		}
Please login to merge, or discard this patch.
Doc Comments   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -205,6 +205,10 @@  discard block
 block discarded – undo
205 205
 		return array($cipherKey, $macKey, $iv);
206 206
 	}
207 207
 
208
+	/**
209
+	 * @param string $a
210
+	 * @param string $b
211
+	 */
208 212
 	protected function hash_equals($a, $b) {
209 213
 		if (function_exists('random_bytes')) {
210 214
 			$key = random_bytes(128);
@@ -246,7 +250,7 @@  discard block
 block discarded – undo
246 250
 	/**
247 251
 	 * Pad the data with a random char chosen by the pad amount.
248 252
 	 *
249
-	 * @param $data
253
+	 * @param string $data
250 254
 	 * @return string
251 255
 	 */
252 256
 	protected function pad($data) {
@@ -262,8 +266,8 @@  discard block
 block discarded – undo
262 266
 	/**
263 267
 	 * Unpad the the data
264 268
 	 *
265
-	 * @param $data
266
-	 * @return bool|string
269
+	 * @param string $data
270
+	 * @return false|string
267 271
 	 */
268 272
 	protected function unpad($data) {
269 273
 		$length = $this->getKeySize();
@@ -280,7 +284,7 @@  discard block
 block discarded – undo
280 284
 	 * Encrypt a credential
281 285
 	 *
282 286
 	 * @param Credential|array $credential the credential to decrypt
283
-	 * @return Credential|array
287
+	 * @return string
284 288
 	 */
285 289
 	public function decryptCredential($credential) {
286 290
 		return $this->handleCredential($credential, EncryptService::OP_DECRYPT);
@@ -353,7 +357,7 @@  discard block
 block discarded – undo
353 357
 	/**
354 358
 	 * Decrypt a file
355 359
 	 *
356
-	 * @param  File|array $file
360
+	 * @param  File $file
357 361
 	 * @return File|array
358 362
 	 */
359 363
 
Please login to merge, or discard this patch.
migration/serversideencryption.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@
 block discarded – undo
83 83
 		}
84 84
 	}
85 85
 
86
-	private function fetchAll($sql){
86
+	private function fetchAll($sql) {
87 87
 		return $this->db->executeQuery($sql)->fetchAll();
88 88
 	}
89 89
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@
 block discarded – undo
83 83
 		}
84 84
 	}
85 85
 
86
-	private function fetchAll($sql){
86
+	private function fetchAll($sql) {
87 87
 		return $this->db->executeQuery($sql)->fetchAll();
88 88
 	}
89 89
 
Please login to merge, or discard this patch.
middleware/sharemiddleware.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
 			$setting = (in_array($methodName, $publicMethods)) ? 'link_sharing_enabled' : 'user_sharing_enabled';
27 27
 			$sharing_enabled = ($this->settings->isEnabled($setting));
28 28
 
29
-			if(in_array($methodName, $user_pub_methods)){
29
+			if (in_array($methodName, $user_pub_methods)) {
30 30
 				$sharing_enabled = ($this->settings->isEnabled('link_sharing_enabled') || $this->settings->isEnabled('user_sharing_enabled'));
31 31
 			}
32 32
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
 			$setting = (in_array($methodName, $publicMethods)) ? 'link_sharing_enabled' : 'user_sharing_enabled';
27 27
 			$sharing_enabled = ($this->settings->isEnabled($setting));
28 28
 
29
-			if(in_array($methodName, $user_pub_methods)){
29
+			if(in_array($methodName, $user_pub_methods)) {
30 30
 				$sharing_enabled = ($this->settings->isEnabled('link_sharing_enabled') || $this->settings->isEnabled('user_sharing_enabled'));
31 31
 			}
32 32
 
Please login to merge, or discard this patch.
lib/Db/SharingACLMapper.php 3 patches
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -30,66 +30,66 @@
 block discarded – undo
30 30
 use OCA\Passman\Utility\Utils;
31 31
 
32 32
 class SharingACLMapper extends Mapper {
33
-    const TABLE_NAME = '*PREFIX*passman_sharing_acl';
33
+	const TABLE_NAME = '*PREFIX*passman_sharing_acl';
34 34
 
35
-    public function __construct(IDBConnection $db) {
36
-        parent::__construct($db, 'passman_sharing_acl');
37
-    }
35
+	public function __construct(IDBConnection $db) {
36
+		parent::__construct($db, 'passman_sharing_acl');
37
+	}
38 38
 
39
-    public function createACLEntry(SharingACL $acl){
40
-        return $this->insert($acl);
41
-    }
39
+	public function createACLEntry(SharingACL $acl){
40
+		return $this->insert($acl);
41
+	}
42 42
 
43
-    /**
44
-     * Gets the currently accepted share requests from the given user for the given vault guid
45
-     * @param $user_id
46
-     * @param $vault_guid
47
-     * @return SharingACL[]
48
-     */
49
-    public function getVaultEntries($user_id, $vault_guid) {
50
-        $q = "SELECT * FROM ". self::TABLE_NAME ." WHERE user_id = ? AND vault_guid = ?";
51
-        return $this->findEntities($q, [$user_id, $vault_guid]);
52
-    }
43
+	/**
44
+	 * Gets the currently accepted share requests from the given user for the given vault guid
45
+	 * @param $user_id
46
+	 * @param $vault_guid
47
+	 * @return SharingACL[]
48
+	 */
49
+	public function getVaultEntries($user_id, $vault_guid) {
50
+		$q = "SELECT * FROM ". self::TABLE_NAME ." WHERE user_id = ? AND vault_guid = ?";
51
+		return $this->findEntities($q, [$user_id, $vault_guid]);
52
+	}
53 53
 
54
-    /**
55
-     * Gets the acl for a given item guid
56
-     * @param $user_id
57
-     * @param $item_guid
58
-     * @return SharingACL
59
-     */
60
-    public function getItemACL($user_id, $item_guid) {
61
-        $q = "SELECT * FROM " . self::TABLE_NAME . " WHERE item_guid = ? AND ";
62
-        $filter = [$item_guid];
63
-        $q .= ($user_id === null) ? 'user_id is null' : 'user_id = ? ';
64
-        if ($user_id !== null){
54
+	/**
55
+	 * Gets the acl for a given item guid
56
+	 * @param $user_id
57
+	 * @param $item_guid
58
+	 * @return SharingACL
59
+	 */
60
+	public function getItemACL($user_id, $item_guid) {
61
+		$q = "SELECT * FROM " . self::TABLE_NAME . " WHERE item_guid = ? AND ";
62
+		$filter = [$item_guid];
63
+		$q .= ($user_id === null) ? 'user_id is null' : 'user_id = ? ';
64
+		if ($user_id !== null){
65 65
 			$filter[] = $user_id;
66
-        }
66
+		}
67 67
 
68
-        return $this->findEntity($q, $filter);
69
-    }
68
+		return $this->findEntity($q, $filter);
69
+	}
70 70
 
71
-    /**
72
-     * Update the acl for a given item guid
73
-     * @param $user_id
74
-     * @param $item_guid
75
-     * @return SharingACL
76
-     */
77
-    public function updateCredentialACL(SharingACL $sharingACL) {
78
-        return $this->update($sharingACL);
79
-    }
71
+	/**
72
+	 * Update the acl for a given item guid
73
+	 * @param $user_id
74
+	 * @param $item_guid
75
+	 * @return SharingACL
76
+	 */
77
+	public function updateCredentialACL(SharingACL $sharingACL) {
78
+		return $this->update($sharingACL);
79
+	}
80 80
 
81
-    /**
82
-     * Gets the currently accepted share requests from the given user for the given vault guid
83
-     * @param $user_id
84
-     * @param $vault_id
85
-     * @return SharingACL[]
86
-     */
87
-    public function getCredentialAclList($item_guid) {
88
-        $q = "SELECT * FROM ". self::TABLE_NAME ." WHERE item_guid = ?";
89
-        return $this->findEntities($q, [$item_guid]);
90
-    }
81
+	/**
82
+	 * Gets the currently accepted share requests from the given user for the given vault guid
83
+	 * @param $user_id
84
+	 * @param $vault_id
85
+	 * @return SharingACL[]
86
+	 */
87
+	public function getCredentialAclList($item_guid) {
88
+		$q = "SELECT * FROM ". self::TABLE_NAME ." WHERE item_guid = ?";
89
+		return $this->findEntities($q, [$item_guid]);
90
+	}
91 91
 
92
-    public function deleteShareACL(SharingACL $ACL){
93
-    	return $this->delete($ACL);
92
+	public function deleteShareACL(SharingACL $ACL){
93
+		return $this->delete($ACL);
94 94
 	}
95 95
 }
96 96
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
         parent::__construct($db, 'passman_sharing_acl');
37 37
     }
38 38
 
39
-    public function createACLEntry(SharingACL $acl){
39
+    public function createACLEntry(SharingACL $acl) {
40 40
         return $this->insert($acl);
41 41
     }
42 42
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      * @return SharingACL[]
48 48
      */
49 49
     public function getVaultEntries($user_id, $vault_guid) {
50
-        $q = "SELECT * FROM ". self::TABLE_NAME ." WHERE user_id = ? AND vault_guid = ?";
50
+        $q = "SELECT * FROM " . self::TABLE_NAME . " WHERE user_id = ? AND vault_guid = ?";
51 51
         return $this->findEntities($q, [$user_id, $vault_guid]);
52 52
     }
53 53
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
         $q = "SELECT * FROM " . self::TABLE_NAME . " WHERE item_guid = ? AND ";
62 62
         $filter = [$item_guid];
63 63
         $q .= ($user_id === null) ? 'user_id is null' : 'user_id = ? ';
64
-        if ($user_id !== null){
64
+        if ($user_id !== null) {
65 65
 			$filter[] = $user_id;
66 66
         }
67 67
 
@@ -85,11 +85,11 @@  discard block
 block discarded – undo
85 85
      * @return SharingACL[]
86 86
      */
87 87
     public function getCredentialAclList($item_guid) {
88
-        $q = "SELECT * FROM ". self::TABLE_NAME ." WHERE item_guid = ?";
88
+        $q = "SELECT * FROM " . self::TABLE_NAME . " WHERE item_guid = ?";
89 89
         return $this->findEntities($q, [$item_guid]);
90 90
     }
91 91
 
92
-    public function deleteShareACL(SharingACL $ACL){
92
+    public function deleteShareACL(SharingACL $ACL) {
93 93
     	return $this->delete($ACL);
94 94
 	}
95 95
 }
96 96
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
         parent::__construct($db, 'passman_sharing_acl');
37 37
     }
38 38
 
39
-    public function createACLEntry(SharingACL $acl){
39
+    public function createACLEntry(SharingACL $acl) {
40 40
         return $this->insert($acl);
41 41
     }
42 42
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
         $q = "SELECT * FROM " . self::TABLE_NAME . " WHERE item_guid = ? AND ";
62 62
         $filter = [$item_guid];
63 63
         $q .= ($user_id === null) ? 'user_id is null' : 'user_id = ? ';
64
-        if ($user_id !== null){
64
+        if ($user_id !== null) {
65 65
 			$filter[] = $user_id;
66 66
         }
67 67
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
         return $this->findEntities($q, [$item_guid]);
90 90
     }
91 91
 
92
-    public function deleteShareACL(SharingACL $ACL){
92
+    public function deleteShareACL(SharingACL $ACL) {
93 93
     	return $this->delete($ACL);
94 94
 	}
95 95
 }
96 96
\ No newline at end of file
Please login to merge, or discard this patch.
controller/internalcontroller.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	public function remind($credential_id) {
42 42
 		$credential = $this->credentialService->getCredentialById($credential_id, $this->userId);
43
-		if($credential) {
43
+		if ($credential) {
44 44
 			$credential->setExpireTime(time() + (24 * 60 * 60));
45 45
 			$this->credentialService->upd($credential);
46 46
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	public function read($credential_id) {
60 60
 
61 61
 		$credential = $this->credentialService->getCredentialById($credential_id, $this->userId);
62
-		if($credential) {
62
+		if ($credential) {
63 63
 			$credential->setExpireTime(0);
64 64
 			$this->credentialService->upd($credential);
65 65
 
Please login to merge, or discard this patch.
lib/Service/SettingsService.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -110,7 +110,7 @@
 block discarded – undo
110 110
 	/**
111 111
 	 * Check if an setting is enabled (value of 1)
112 112
 	 *
113
-	 * @param $setting
113
+	 * @param string $setting
114 114
 	 * @return bool
115 115
 	 */
116 116
 	public function isEnabled($setting) {
Please login to merge, or discard this patch.
controller/vaultcontroller.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@
 block discarded – undo
59 59
 			foreach ($vaults as $vault) {
60 60
 				$credential = $this->credentialService->getRandomCredentialByVaultId($vault->getId(), $this->userId);
61 61
 				$secret_field = $protected_credential_fields[array_rand($protected_credential_fields)];
62
-				if(isset($credential)) {
62
+				if (isset($credential)) {
63 63
 					array_push($result, array(
64 64
 						'vault_id' => $vault->getId(),
65 65
 						'guid' => $vault->getGuid(),
Please login to merge, or discard this patch.
lib/Db/VaultMapper.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
63 63
 	 * @return Vault[]
64 64
 	 */
65
-	public function findVaultsFromUser($userId){
65
+	public function findVaultsFromUser($userId) {
66 66
 		$sql = 'SELECT * FROM `*PREFIX*passman_vaults` ' .
67 67
 			'WHERE `user_id` = ? ';
68 68
 		$params = [$userId];
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 * @param $userId
76 76
 	 * @return Vault
77 77
 	 */
78
-	public function create($vault_name, $userId){
78
+	public function create($vault_name, $userId) {
79 79
 		$vault = new Vault();
80 80
 		$vault->setName($vault_name);
81 81
 		$vault->setUserId($userId);
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 * @param $vault_id
91 91
 	 * @param $user_id
92 92
 	 */
93
-	public function setLastAccess($vault_id, $user_id){
93
+	public function setLastAccess($vault_id, $user_id) {
94 94
 		$vault = new Vault();
95 95
 		$vault->setId($vault_id);
96 96
 		$vault->setUserId($user_id);
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 * Update vault
103 103
 	 * @param Vault $vault
104 104
 	 */
105
-	public function updateVault(Vault $vault){
105
+	public function updateVault(Vault $vault) {
106 106
 		$this->update($vault);
107 107
 	}
108 108
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	 * @param $privateKey
113 113
 	 * @param $publicKey
114 114
 	 */
115
-	public function updateSharingKeys($vault_id, $privateKey, $publicKey){
115
+	public function updateSharingKeys($vault_id, $privateKey, $publicKey) {
116 116
 		$vault = new Vault();
117 117
 		$vault->setId($vault_id);
118 118
 		$vault->setPrivateSharingKey($privateKey);
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	 * Delete a vault
126 126
 	 * @param Vault $vault
127 127
 	 */
128
-	public function deleteVault(Vault $vault){
128
+	public function deleteVault(Vault $vault) {
129 129
 		$this->delete($vault);
130 130
 	}
131 131
 }
132 132
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
63 63
 	 * @return Vault[]
64 64
 	 */
65
-	public function findVaultsFromUser($userId){
65
+	public function findVaultsFromUser($userId) {
66 66
 		$sql = 'SELECT * FROM `*PREFIX*passman_vaults` ' .
67 67
 			'WHERE `user_id` = ? ';
68 68
 		$params = [$userId];
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 * @param $userId
76 76
 	 * @return Vault
77 77
 	 */
78
-	public function create($vault_name, $userId){
78
+	public function create($vault_name, $userId) {
79 79
 		$vault = new Vault();
80 80
 		$vault->setName($vault_name);
81 81
 		$vault->setUserId($userId);
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 * @param $vault_id
91 91
 	 * @param $user_id
92 92
 	 */
93
-	public function setLastAccess($vault_id, $user_id){
93
+	public function setLastAccess($vault_id, $user_id) {
94 94
 		$vault = new Vault();
95 95
 		$vault->setId($vault_id);
96 96
 		$vault->setUserId($user_id);
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 * Update vault
103 103
 	 * @param Vault $vault
104 104
 	 */
105
-	public function updateVault(Vault $vault){
105
+	public function updateVault(Vault $vault) {
106 106
 		$this->update($vault);
107 107
 	}
108 108
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	 * @param $privateKey
113 113
 	 * @param $publicKey
114 114
 	 */
115
-	public function updateSharingKeys($vault_id, $privateKey, $publicKey){
115
+	public function updateSharingKeys($vault_id, $privateKey, $publicKey) {
116 116
 		$vault = new Vault();
117 117
 		$vault->setId($vault_id);
118 118
 		$vault->setPrivateSharingKey($privateKey);
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	 * Delete a vault
126 126
 	 * @param Vault $vault
127 127
 	 */
128
-	public function deleteVault(Vault $vault){
128
+	public function deleteVault(Vault $vault) {
129 129
 		$this->delete($vault);
130 130
 	}
131 131
 }
132 132
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Service/VaultService.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	 * @param $vault_id
93 93
 	 * @param $user_id
94 94
 	 */
95
-	public function setLastAccess($vault_id, $user_id){
95
+	public function setLastAccess($vault_id, $user_id) {
96 96
 		return $this->vaultMapper->setLastAccess($vault_id, $user_id);
97 97
 	}
98 98
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 * @param $privateKey
103 103
 	 * @param $publicKey
104 104
 	 */
105
-	public function updateSharingKeys($vault_id, $privateKey, $publicKey){
105
+	public function updateSharingKeys($vault_id, $privateKey, $publicKey) {
106 106
 		return $this->vaultMapper->updateSharingKeys($vault_id, $privateKey, $publicKey);
107 107
 	}
108 108
 
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
 	 * @param string $vault_guid
112 112
 	 * @param string $user_id
113 113
 	 */
114
-	public function deleteVault($vault_guid, $user_id){
114
+	public function deleteVault($vault_guid, $user_id) {
115 115
 		$vault = $this->getByGuid($vault_guid, $user_id);
116
-		if($vault instanceof Vault) {
116
+		if ($vault instanceof Vault) {
117 117
 			$this->vaultMapper->deleteVault($vault);
118 118
 		}
119 119
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	 * @param $vault_id
93 93
 	 * @param $user_id
94 94
 	 */
95
-	public function setLastAccess($vault_id, $user_id){
95
+	public function setLastAccess($vault_id, $user_id) {
96 96
 		return $this->vaultMapper->setLastAccess($vault_id, $user_id);
97 97
 	}
98 98
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 * @param $privateKey
103 103
 	 * @param $publicKey
104 104
 	 */
105
-	public function updateSharingKeys($vault_id, $privateKey, $publicKey){
105
+	public function updateSharingKeys($vault_id, $privateKey, $publicKey) {
106 106
 		return $this->vaultMapper->updateSharingKeys($vault_id, $privateKey, $publicKey);
107 107
 	}
108 108
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 * @param string $vault_guid
112 112
 	 * @param string $user_id
113 113
 	 */
114
-	public function deleteVault($vault_guid, $user_id){
114
+	public function deleteVault($vault_guid, $user_id) {
115 115
 		$vault = $this->getByGuid($vault_guid, $user_id);
116 116
 		if($vault instanceof Vault) {
117 117
 			$this->vaultMapper->deleteVault($vault);
Please login to merge, or discard this patch.