Function recalculatePasswords
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
public static function recalculatePasswords(string $method, string $password, string $vector)
{
$dbAdmin = \App\Db::getInstance('admin');
$decryptInstance = static::getInstance();
if ($decryptInstance->get('method') === $method && $decryptInstance->get('vector') === $vector && $decryptInstance->get('pass') === $password) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method recalculatePasswords
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function recalculatePasswords(string $method, string $password, string $vector)
{
$dbAdmin = \App\Db::getInstance('admin');
$decryptInstance = static::getInstance();
if ($decryptInstance->get('method') === $method && $decryptInstance->get('vector') === $vector && $decryptInstance->get('pass') === $password) {
The method recalculatePasswords() has an NPath complexity of 316. The configured NPath complexity threshold is 200. Open
public static function recalculatePasswords(string $method, string $password, string $vector)
{
$dbAdmin = \App\Db::getInstance('admin');
$decryptInstance = static::getInstance();
if ($decryptInstance->get('method') === $method && $decryptInstance->get('vector') === $vector && $decryptInstance->get('pass') === $password) {
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method recalculatePasswords() has a Cyclomatic Complexity of 17. The configured cyclomatic complexity threshold is 10. Open
public static function recalculatePasswords(string $method, string $password, string $vector)
{
$dbAdmin = \App\Db::getInstance('admin');
$decryptInstance = static::getInstance();
if ($decryptInstance->get('method') === $method && $decryptInstance->get('vector') === $vector && $decryptInstance->get('pass') === $password) {
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
Refactor this function to reduce its Cognitive Complexity from 41 to the 15 allowed. Open
public static function recalculatePasswords(string $method, string $password, string $vector)
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Missing class import via use statement (line '93', column '22'). Open
$configFile = new \App\ConfigFile('securityKeys');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method isActive has a boolean flag argument $testMode, which is a certain sign of a Single Responsibility Principle violation. Open
public function isActive(bool $testMode = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Missing class import via use statement (line '108', column '19'). Open
throw new \App\Exceptions\AppException('ERR_IMPOSSIBLE_ENCRYPT');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '83', column '20'). Open
throw new \App\Exceptions\AppException('ERR_IMPOSSIBLE_DECRYPT');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '36', column '14'). Open
throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE||target', 406);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '38', column '15'). Open
$row = (new \App\Db\Query())->from(static::TABLE_NAME)->where(['target' => $target])->one(\App\Db::getInstance('admin'));
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '70', column '20'). Open
$values = (new \App\Db\Query())->select(array_merge([$info['index']], $info['columnName']))
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '122', column '22'). Open
$configFile = new \App\ConfigFile('securityKeys');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Avoid using static access to class '\App\Config' in method 'recalculatePasswords'. Open
\App\Config::set('securityKeys', 'encryptionMethod', $method);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Db' in method 'recalculatePasswords'. Open
$dbAdmin = \App\Db::getInstance('admin');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Db' in method 'recalculatePasswords'. Open
->createCommand(\App\Db::getInstance($info['db']))
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Config' in method 'isActive'. Open
$method = \App\Config::securityKeys('encryptionMethod');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Db' in method 'getInstance'. Open
$row = (new \App\Db\Query())->from(static::TABLE_NAME)->where(['target' => $target])->one(\App\Db::getInstance('admin'));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Config' in method 'recalculatePasswords'. Open
\App\Config::set('securityKeys', 'encryptionPass', $password);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Config' in method 'getInstance'. Open
$instance->set('pass', \App\Config::securityKeys('encryptionPass'));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Cache' in method 'recalculatePasswords'. Open
\App\Cache::clear();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Define a constant instead of duplicating this literal "index" 11 times. Open
'roundcube_users' => ['columnName' => ['password'], 'index' => 'user_id', 'db' => 'base'],
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "method" 8 times. Open
$instance->set('method', $row['method']);
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "target" 6 times. Open
$row = (new \App\Db\Query())->from(static::TABLE_NAME)->where(['target' => $target])->one(\App\Db::getInstance('admin'));
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "admin" 6 times. Open
's_#__mail_smtp' => ['columnName' => ['password', 'smtp_password'], 'index' => 'id', 'db' => 'admin'],
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "columnName" 10 times. Open
'roundcube_users' => ['columnName' => ['password'], 'index' => 'user_id', 'db' => 'base'],
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "password" 3 times. Open
'roundcube_users' => ['columnName' => ['password'], 'index' => 'user_id', 'db' => 'base'],
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "webservice" 3 times. Open
'w_#__api_user' => ['columnName' => ['auth'], 'index' => 'id', 'db' => 'webservice'],
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "encryptionMethod" 4 times. Open
$configFile->set('encryptionMethod', $method);
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "securityKeys" 4 times. Open
$configFile = new \App\ConfigFile('securityKeys');
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "encryptionPass" 3 times. Open
$instance->set('pass', \App\Config::securityKeys('encryptionPass'));
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Call to undeclared method \App\Encryptions\Settings::set
Open
$instance->set('vector', $row['pass']);
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$row = (new \App\Db\Query())->from(static::TABLE_NAME)->where(['target' => $target])->one(\App\Db::getInstance('admin'));
- Exclude checks
Reference to undeclared constant \App\Encryptions\Settings::STATUS_ACTIVE
Open
$dbAdmin->createCommand()->update(self::TABLE_NAME, ['status' => self::STATUS_ACTIVE], ['target' => self::TARGET_SETTINGS])->execute();
- Exclude checks
Call to undeclared method \App\Encryptions\Settings::get
Open
|| !\in_array($this->get('method'), static::getMethods())
- Exclude checks
Class extends undeclared class \App\Encryption
(Did you mean class \Tests\App\Encryption) Open
class Settings extends \App\Encryption
- Exclude checks
Reference to undeclared constant \App\Encryptions\Settings::TABLE_NAME
Open
$dbAdmin->createCommand()->update(self::TABLE_NAME, ['status' => self::STATUS_ACTIVE], ['target' => $decryptInstance->getTarget()])->execute();
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$values = (new \App\Db\Query())->select(array_merge([$info['index']], $info['columnName']))
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$dbAdmin->createCommand()->update(self::TABLE_NAME, ['method' => $method, 'pass' => $vector], ['target' => self::TARGET_SETTINGS])->execute();
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$dbAdmin->createCommand()->update(self::TABLE_NAME, ['status' => self::STATUS_ACTIVE], ['target' => self::TARGET_SETTINGS])->execute();
- Exclude checks
Call to undeclared method \App\Encryptions\Settings::set
Open
$instance->set('target', (int) $row['target']);
- Exclude checks
Call to undeclared method \App\Encryptions\Settings::isEmpty
Open
|| $this->isEmpty('method')
- Exclude checks
Reference to undeclared constant \App\Encryptions\Settings::TARGET_SETTINGS
Open
$dbAdmin->createCommand()->update(self::TABLE_NAME, ['method' => $method, 'pass' => $vector], ['target' => self::TARGET_SETTINGS])->execute();
- Exclude checks
Call to undeclared method \App\Encryptions\Settings::set
Open
$instance->set('method', $row['method']);
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$dbCommand = \App\Db::getInstance(self::$mapPasswords[$tableName]['db'])->createCommand();
- Exclude checks
Call to undeclared method \App\Encryptions\Settings::encrypt
Open
$value = $encryptInstance->encrypt($value);
- Exclude checks
Reference to undeclared constant \App\Encryptions\Settings::TARGET_SETTINGS
Open
$dbAdmin->createCommand()->update(self::TABLE_NAME, ['status' => self::STATUS_ACTIVE], ['target' => self::TARGET_SETTINGS])->execute();
- Exclude checks
Call to undeclared method \App\Encryptions\Settings::get
Open
|| ($this->get('method') !== $method && !$testMode)
- Exclude checks
Call to undeclared method \App\Encryptions\Settings::get
Open
$oldMethod = $decryptInstance->get('method');
- Exclude checks
Reference to undeclared constant \App\Encryptions\Settings::TABLE_NAME
Open
$row = (new \App\Db\Query())->from(static::TABLE_NAME)->where(['target' => $target])->one(\App\Db::getInstance('admin'));
- Exclude checks
Call to undeclared method \App\Encryptions\Settings::get
Open
if ($decryptInstance->get('method') === $method && $decryptInstance->get('vector') === $vector && $decryptInstance->get('pass') === $password) {
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$dbAdmin->createCommand()->update(self::TABLE_NAME, ['status' => self::STATUS_ACTIVE], ['target' => $decryptInstance->getTarget()])->execute();
- Exclude checks
Reference to undeclared constant \App\Encryptions\Settings::TABLE_NAME
Open
$dbAdmin->createCommand()->update(self::TABLE_NAME, ['status' => self::STATUS_ACTIVE], ['target' => self::TARGET_SETTINGS])->execute();
- Exclude checks
Reference to undeclared constant \App\Encryptions\Settings::TARGET_SETTINGS
Open
if ($target !== static::TARGET_SETTINGS) {
- Exclude checks
Call to undeclared method \App\Encryptions\Settings::getTarget
Open
$dbAdmin->createCommand()->update(self::TABLE_NAME, ['status' => self::STATUS_ACTIVE], ['target' => $decryptInstance->getTarget()])->execute();
- Exclude checks
Call to undeclared method \App\Db::beginTransaction
Open
$transactionBase = \App\Db::getInstance()->beginTransaction();
- Exclude checks
Call to undeclared method \App\Encryptions\Settings::decrypt
Open
$value = $decryptInstance->decrypt($value);
- Exclude checks
Static call to undeclared method \App\Encryptions\Settings::getMethods
Open
|| !\in_array($this->get('method'), static::getMethods())
- Exclude checks
Reference to undeclared constant \App\Encryptions\Settings::STATUS_ACTIVE
Open
$dbAdmin->createCommand()->update(self::TABLE_NAME, ['status' => self::STATUS_ACTIVE], ['target' => $decryptInstance->getTarget()])->execute();
- Exclude checks
Call to undeclared method \App\Db::beginTransaction
Open
$transactionAdmin = $dbAdmin->beginTransaction();
- Exclude checks
Reference to undeclared constant \App\Encryptions\Settings::TABLE_NAME
Open
$dbAdmin->createCommand()->update(self::TABLE_NAME, ['method' => $method, 'pass' => $vector], ['target' => self::TARGET_SETTINGS])->execute();
- Exclude checks
Reference to undeclared constant \App\Encryptions\Settings::TARGET_SETTINGS
Open
public static function getInstance(int $target = self::TARGET_SETTINGS)
- Exclude checks
Call to undeclared method \App\Encryptions\Settings::set
Open
$instance->set('pass', \App\Config::securityKeys('encryptionPass'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getInstance(int $target = self::TARGET_SETTINGS)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance->set('vector', $row['pass']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
's_#__mail_smtp' => ['columnName' => ['password', 'smtp_password'], 'index' => 'id', 'db' => 'admin'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'roundcube_users' => ['columnName' => ['password'], 'index' => 'user_id', 'db' => 'base'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $instance;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\MeetingService::TABLE_NAME => ['columnName' => ['secret'], 'index' => 'id', 'db' => 'admin'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $method
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($target !== static::TARGET_SETTINGS) {
- Exclude checks
Line exceeds 120 characters; contains 129 characters Open
$row = (new \App\Db\Query())->from(static::TABLE_NAME)->where(['target' => $target])->one(\App\Db::getInstance('admin'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($row) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance->set('pass', \App\Config::securityKeys('encryptionPass'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'a_#__smsnotifier_servers' => ['columnName' => ['api_key'], 'index' => 'id', 'db' => 'admin'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'i_#__magento_servers' => ['columnName' => ['password'], 'index' => 'id', 'db' => 'admin'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance->set('method', $row['method']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to change password for encryption.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance->set('target', (int) $row['target']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'dav_users' => ['columnName' => ['key'], 'index' => 'id', 'db' => 'base'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE||target', 406);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row = (new \App\Db\Query())->from(static::TABLE_NAME)->where(['target' => $target])->one(\App\Db::getInstance('admin'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'w_#__portal_user' => ['columnName' => ['auth'], 'index' => 'id', 'db' => 'webservice'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var array Passwords to encrypt */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'w_#__api_user' => ['columnName' => ['auth'], 'index' => 'id', 'db' => 'webservice'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'w_#__servers' => ['columnName' => ['pass', 'api_key'], 'index' => 'id', 'db' => 'webservice'],
- Exclude checks
Line exceeds 120 characters; contains 155 characters Open
$dbAdmin->createCommand()->update(self::TABLE_NAME, ['status' => self::STATUS_ACTIVE], ['target' => $decryptInstance->getTarget()])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($columns as &$value) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::clear();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbAdmin = \App\Db::getInstance('admin');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$decryptInstance = static::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$values = (new \App\Db\Query())->select(array_merge([$info['index']], $info['columnName']))
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
!\function_exists('openssl_encrypt')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->create();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$encryptInstance = static::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->create();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Line exceeds 120 characters; contains 152 characters Open
if ($decryptInstance->get('method') === $method && $decryptInstance->get('vector') === $vector && $decryptInstance->get('pass') === $password) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$oldMethod = $decryptInstance->get('method');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('encryptionPass', $password);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
try {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($values as &$value) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$values) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = $decryptInstance->decrypt($value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($value)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$passwords[$tableName] = $values;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$transactionAdmin->rollBack();
- Exclude checks
Line exceeds 120 characters; contains 154 characters Open
$dbAdmin->createCommand()->update(self::TABLE_NAME, ['method' => $method, 'pass' => $vector], ['target' => self::TARGET_SETTINGS])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Config::set('securityKeys', 'encryptionPass', $password);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $testMode
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
|| $this->isEmpty('method')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
|| !\in_array($this->get('method'), static::getMethods())
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $password
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
continue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($value)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw $e;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Checks if encrypt or decrypt is possible.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbAdmin->createCommand()->update(self::TABLE_NAME, ['status' => self::STATUS_ACTIVE], ['target' => $decryptInstance->getTarget()])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$passwords = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($value)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance = new static();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile = new \App\ConfigFile('securityKeys');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from($tableName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$transactionBase = \App\Db::getInstance()->beginTransaction();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (self::$mapPasswords as $tableName => $info) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbAdmin->createCommand()->update(self::TABLE_NAME, ['status' => self::STATUS_ACTIVE], ['target' => self::TARGET_SETTINGS])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\AppException('ERR_IMPOSSIBLE_DECRYPT');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($pass as $index => $values) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->createCommand(\App\Db::getInstance($info['db']))
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$transactionBase->rollBack();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($values as &$columns) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
|| ($this->get('method') !== $method && !$testMode)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbAdmin->createCommand()->update(self::TABLE_NAME, ['method' => $method, 'pass' => $vector], ['target' => self::TARGET_SETTINGS])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = $encryptInstance->encrypt($value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$transactionBase->commit();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} catch (\Throwable $e) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $vector
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$transactionAdmin = $dbAdmin->beginTransaction();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($decryptInstance->isActive()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('encryptionMethod', $method);
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
$dbCommand->update($tableName, $values, [self::$mapPasswords[$tableName]['index'] => $index])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$transactionAdmin->commit();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function isActive(bool $testMode = false)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function recalculatePasswords(string $method, string $password, string $vector)
- Exclude checks
Line exceeds 120 characters; contains 147 characters Open
$dbAdmin->createCommand()->update(self::TABLE_NAME, ['status' => self::STATUS_ACTIVE], ['target' => self::TARGET_SETTINGS])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('encryptionMethod', $oldMethod);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Config::set('securityKeys', 'encryptionMethod', $method);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($passwords as $tableName => $pass) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($value)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\AppException('ERR_IMPOSSIBLE_ENCRYPT');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand->update($tableName, $values, [self::$mapPasswords[$tableName]['index'] => $index])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private static $mapPasswords = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand = \App\Db::getInstance(self::$mapPasswords[$tableName]['db'])->createCommand();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($decryptInstance->get('method') === $method && $decryptInstance->get('vector') === $vector && $decryptInstance->get('pass') === $password) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->queryAllByGroup(1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile = new \App\ConfigFile('securityKeys');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$method = \App\Config::securityKeys('encryptionMethod');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return !(
- Exclude checks