YetiForceCompany/YetiForceCRM

View on GitHub
app/Encryption.php

Summary

Maintainability
A
25 mins
Test Coverage
C
75%

Function generatePassword has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function generatePassword($length = 10, $type = 'lbd')
    {
        $chars = [];
        if (false !== strpos($type, 'l')) {
            $chars[] = 'abcdefghjkmnpqrstuvwxyz';
Severity: Minor
Found in app/Encryption.php - About 25 mins to fix

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

The method decrypt has a boolean flag argument $testMode, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function decrypt($encrypted, bool $testMode = false)
Severity: Minor
Found in app/Encryption.php by phpmd

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

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)
Severity: Minor
Found in app/Encryption.php by phpmd

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

The method encrypt has a boolean flag argument $testMode, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function encrypt($decrypted, bool $testMode = false)
Severity: Minor
Found in app/Encryption.php by phpmd

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 '170', column '15').
Open

        return (new \App\Db\Query())->from('s_#__batchmethod')->where(['method' => static::class . '::recalculatePasswords', 'status' => \App\BatchMethod::STATUS_ENABLED])->exists();
Severity: Minor
Found in app/Encryption.php by phpmd

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 '191', column '8').
Open

        (new \App\BatchMethod(['method' => static::class . '::recalculatePasswords', 'params' => [$this->get('method'), $this->get('pass'), $this->get('vector'), $this->getTarget()]]))->save();
Severity: Minor
Found in app/Encryption.php by phpmd

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 '181', column '26').
Open

        return $result || (new \App\Db\Query())->from(self::TABLE_NAME)->where(['target' => $this->getTarget(), 'status' => self::STATUS_WORKING])->exists();
Severity: Minor
Found in app/Encryption.php by phpmd

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 '192', column '13').
Open

        if (!(new \App\Db\Query())->from(self::TABLE_NAME)->where(['target' => $this->getTarget()])->exists($db)) {
Severity: Minor
Found in app/Encryption.php by phpmd

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 '180', column '18').
Open

        $result = (new \App\Db\Query())->from('s_#__batchmethod')->where(['method' => static::class . '::recalculatePasswords', 'status' => [\App\BatchMethod::STATUS_ENABLED, \App\BatchMethod::STATUS_RUNNING, \App\BatchMethod::STATUS_HALTED, \App\BatchMethod::STATUS_COMPLETED]])->exists();
Severity: Minor
Found in app/Encryption.php by phpmd

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\Cache' in method 'getInstance'.
Open

        if (Cache::has('Encryption', $target)) {
Severity: Minor
Found in app/Encryption.php by phpmd

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\Encryptions\Module' in method 'getInstance'.
Open

            $instance = \App\Encryptions\Module::getInstance($target);
Severity: Minor
Found in app/Encryption.php by phpmd

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\BatchMethod' in method 'reload'.
Open

        \App\BatchMethod::deleteByMethod(static::class . '::recalculatePasswords');
Severity: Minor
Found in app/Encryption.php by phpmd

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

The method reload uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $db->createCommand()->update(self::TABLE_NAME, ['status' => self::STATUS_WORKING], ['target' => $this->getTarget()])->execute();
        }
Severity: Minor
Found in app/Encryption.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Avoid using static access to class '\App\Config' in method 'createPasswordHash'.
Open

        return password_hash(hash_hmac('sha256', $text, $pepper . \App\Config::main('application_unique_key')), \defined('PASSWORD_ARGON2ID') ? PASSWORD_ARGON2ID : PASSWORD_DEFAULT);
Severity: Minor
Found in app/Encryption.php by phpmd

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 'getInstance'.
Open

        Cache::save('Encryption', $target, $instance, Cache::LONG);
Severity: Minor
Found in app/Encryption.php by phpmd

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

The method getInstance uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $instance = \App\Encryptions\Module::getInstance($target);
        }
Severity: Minor
Found in app/Encryption.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Avoid using static access to class 'App\Cache' in method 'getInstance'.
Open

            return Cache::get('Encryption', $target);
Severity: Minor
Found in app/Encryption.php by phpmd

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 'createHash'.
Open

        return crypt($text, '$1$' . \App\Config::main('application_unique_key'));
Severity: Minor
Found in app/Encryption.php by phpmd

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 '\Settings_Password_Record_Model' in method 'generateUserPassword'.
Open

        $passDetail = \Settings_Password_Record_Model::getUserPassConfig();
Severity: Minor
Found in app/Encryption.php by phpmd

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\Encryptions\Settings' in method 'getInstance'.
Open

            $instance = \App\Encryptions\Settings::getInstance($target);
Severity: Minor
Found in app/Encryption.php by phpmd

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 'reload'.
Open

        \App\Cache::delete('Encryption', $this->getTarget());
Severity: Minor
Found in app/Encryption.php by phpmd

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 'verifyPasswordHash'.
Open

        return password_verify(hash_hmac('sha256', $password, $pepper . \App\Config::main('application_unique_key')), $hash);
Severity: Minor
Found in app/Encryption.php by phpmd

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 'reload'.
Open

        $db = \App\Db::getInstance('admin');
Severity: Minor
Found in app/Encryption.php by phpmd

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

syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ',' or ')'
Open

        return array_filter(openssl_get_cipher_methods(), fn ($methodName) => false === stripos($methodName, 'gcm') && false === stripos($methodName, 'ccm'));
Severity: Critical
Found in app/Encryption.php by phan

Avoid variables with short names like $db. Configured minimum length is 3.
Open

        $db = \App\Db::getInstance('admin');
Severity: Minor
Found in app/Encryption.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

Spaces must be used to indent lines; tabs are not allowed
Open

        if (self::TARGET_SETTINGS === $target) {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return $instance;
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            return $decrypted;
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function getMethods()
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public const STATUS_ACTIVE = 1;
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        } else {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public const TARGET_SETTINGS = 0;
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return self
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return string
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return string
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return openssl_decrypt(base64_decode($encrypted), $this->getMethod(), $this->get('pass'), $this->getOptions(), $this->get('vector'));
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Line exceeds 120 characters; contains 141 characters
Open

        return openssl_decrypt(base64_decode($encrypted), $this->getMethod(), $this->get('pass'), $this->getOptions(), $this->get('vector'));
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return string[]
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return array_filter(openssl_get_cipher_methods(), fn ($methodName) => false === stripos($methodName, 'gcm') && false === stripos($methodName, 'ccm'));
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return $this->get('vector') ?? '';
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /** @var string Table name */
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return int
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if (Cache::has('Encryption', $target)) {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return int
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            return $encrypted;
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param bool $testMode
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return bool
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function getTarget()
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Get options or options default value(0).
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public const TABLE_NAME = 'a_#__encryption';
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to get instance.
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function getInstance(int $target = self::TARGET_SETTINGS)
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to decrypt data.
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Returns list method of encryption.
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Line exceeds 120 characters; contains 158 characters
Open

        return array_filter(openssl_get_cipher_methods(), fn ($methodName) => false === stripos($methodName, 'gcm') && false === stripos($methodName, 'ccm'));
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /** @var array Recommended encryption methods */
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        'aes-256-cbc', 'aes-256-ctr', 'aes-192-cbc', 'aes-192-ctr',
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return $this->get('options') ?? 0;
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function encrypt($decrypted, bool $testMode = false)
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $encrypted
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param bool   $testMode
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return (new \App\Db\Query())->from('s_#__batchmethod')->where(['method' => static::class . '::recalculatePasswords', 'status' => \App\BatchMethod::STATUS_ENABLED])->exists();
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /** @var int Encryption status */
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $instance = \App\Encryptions\Settings::getInstance($target);
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        Cache::save('Encryption', $target, $instance, Cache::LONG);
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return base64_encode($encrypted);
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if (!$this->isActive($testMode)) {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Checks if encrypt or decrypt is possible.
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    ];
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to encrypt data.
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $encrypted = openssl_encrypt($decrypted, $this->getMethod(), $this->get('pass'), $this->getOptions(), $this->get('vector'));
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Line exceeds 120 characters; contains 132 characters
Open

        $encrypted = openssl_encrypt($decrypted, $this->getMethod(), $this->get('pass'), $this->getOptions(), $this->get('vector'));
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $instance = \App\Encryptions\Module::getInstance($target);
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function getLengthVector($method)
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return openssl_cipher_iv_length($method);
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return string
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return $this->get('target');
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return int
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return bool
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Line exceeds 120 characters; contains 182 characters
Open

        return (new \App\Db\Query())->from('s_#__batchmethod')->where(['method' => static::class . '::recalculatePasswords', 'status' => \App\BatchMethod::STATUS_ENABLED])->exists();
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /** @var int The encryption ID for the configuration */
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Specifies the length of the vector.
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Get vector.
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Get method.
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function getOptions(): int
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param bool   $testMode
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function isReady(): bool
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Check if the encryption change has started.
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public const STATUS_WORKING = 2;
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static $recommendedMethods = [
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param int $target self::TARGET_SETTINGS or module ID
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            return Cache::get('Encryption', $target);
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Get target ID.
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return $this->get('method');
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Check if the encryption change has been set.
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $decrypted
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if (!$this->isActive($testMode)) {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function isActive(bool $testMode = false)
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /** @var int Encryption status */
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $method
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return $result || (new \App\Db\Query())->from(self::TABLE_NAME)->where(['target' => $this->getTarget(), 'status' => self::STATUS_WORKING])->exists();
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return string
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $password = $allChars = '';
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if ($length > $passDetail['max_length']) {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $type .= 'b';
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return static::generatePassword($length, $type);
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return string
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function createPasswordHash(string $text, string $pepper): string
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Line exceeds 120 characters; contains 182 characters
Open

        return password_hash(hash_hmac('sha256', $text, $pepper . \App\Config::main('application_unique_key')), \defined('PASSWORD_ARGON2ID') ? PASSWORD_ARGON2ID : PASSWORD_DEFAULT);
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function getVector(): string
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return string
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function getMethod()
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function decrypt($encrypted, bool $testMode = false)
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return $testMode;
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $result = (new \App\Db\Query())->from('s_#__batchmethod')->where(['method' => static::class . '::recalculatePasswords', 'status' => [\App\BatchMethod::STATUS_ENABLED, \App\BatchMethod::STATUS_RUNNING, \App\BatchMethod::STATUS_HALTED, \App\BatchMethod::STATUS_COMPLETED]])->exists();
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        \App\BatchMethod::deleteByMethod(static::class . '::recalculatePasswords');
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        (new \App\BatchMethod(['method' => static::class . '::recalculatePasswords', 'params' => [$this->get('method'), $this->get('pass'), $this->get('vector'), $this->getTarget()]]))->save();
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        for ($i = 0; $i < $missing; ++$i) {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $password .= $allChars[array_rand($allChars)];
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return string
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if ('true' === $passDetail['numbers']) {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return string
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $hash
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return bool
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function isRunning(): bool
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function reload()
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if (false !== strpos($type, 'l')) {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $chars[] = 'abcdefghjkmnpqrstuvwxyz';
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if (false !== strpos($type, 's')) {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Generate user password.
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $length = $passDetail['min_length'];
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $allChars = str_split($allChars);
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $missing = $length - \count($chars);
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if ('true' === $passDetail['special']) {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function createHash($text)
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Line exceeds 120 characters; contains 193 characters
Open

        (new \App\BatchMethod(['method' => static::class . '::recalculatePasswords', 'params' => [$this->get('method'), $this->get('pass'), $this->get('vector'), $this->getTarget()]]))->save();
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $chars = [];
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if (!(new \App\Db\Query())->from(self::TABLE_NAME)->where(['target' => $this->getTarget()])->exists($db)) {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Line exceeds 120 characters; contains 140 characters
Open

            $db->createCommand()->update(self::TABLE_NAME, ['status' => self::STATUS_WORKING], ['target' => $this->getTarget()])->execute();
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param mixed $type
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return password_hash(hash_hmac('sha256', $text, $pepper . \App\Config::main('application_unique_key')), \defined('PASSWORD_ARGON2ID') ? PASSWORD_ARGON2ID : PASSWORD_DEFAULT);
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $db->createCommand()->update(self::TABLE_NAME, ['status' => self::STATUS_WORKING], ['target' => $this->getTarget()])->execute();
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Generate random password.
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to create a password hash.
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Check password hash.
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return password_verify(hash_hmac('sha256', $password, $pepper . \App\Config::main('application_unique_key')), $hash);
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Line exceeds 120 characters; contains 290 characters
Open

        $result = (new \App\Db\Query())->from('s_#__batchmethod')->where(['method' => static::class . '::recalculatePasswords', 'status' => [\App\BatchMethod::STATUS_ENABLED, \App\BatchMethod::STATUS_RUNNING, \App\BatchMethod::STATUS_HALTED, \App\BatchMethod::STATUS_COMPLETED]])->exists();
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param int   $length
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $chars[] = '!"#$%&\'()*+,-./:;<=>?@[\]^_{|}';
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $type = 'l';
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $type .= 's';
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $text
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function generateUserPassword($length = 10)
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to create a hash.
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $pepper
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        \App\Cache::delete('Encryption', $this->getTarget());
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function generatePassword($length = 10, $type = 'lbd')
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param int $length
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $length = $passDetail['max_length'];
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $text
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function verifyPasswordHash(string $password, string $hash, string $pepper): bool
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return bool
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if ('true' === $passDetail['big_letters']) {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $db->createCommand()->insert(self::TABLE_NAME, ['method' => '', 'pass' => '', 'target' => $this->getTarget(), 'status' => self::STATUS_WORKING])->execute();
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $chars[] = 'ABCDEFGHJKMNPQRSTUVWXYZ';
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $passDetail = \Settings_Password_Record_Model::getUserPassConfig();
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return crypt($text, '$1$' . \App\Config::main('application_unique_key'));
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if (false !== strpos($type, 'b')) {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        foreach ($chars as $char) {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if ($length < $passDetail['min_length']) {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $db = \App\Db::getInstance('admin');
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        } else {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $password .= $char[array_rand(str_split($char))];
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $type .= 'd';
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if (false !== strpos($type, 'd')) {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $pepper
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Line exceeds 120 characters; contains 157 characters
Open

        return $result || (new \App\Db\Query())->from(self::TABLE_NAME)->where(['target' => $this->getTarget(), 'status' => self::STATUS_WORKING])->exists();
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Encryption change.
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Line exceeds 120 characters; contains 168 characters
Open

            $db->createCommand()->insert(self::TABLE_NAME, ['method' => '', 'pass' => '', 'target' => $this->getTarget(), 'status' => self::STATUS_WORKING])->execute();
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $chars[] = '0123456789';
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $allChars .= $char;
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return str_shuffle($password);
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $password
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Line exceeds 120 characters; contains 125 characters
Open

        return password_verify(hash_hmac('sha256', $password, $pepper . \App\Config::main('application_unique_key')), $hash);
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

Space before opening parenthesis of function call prohibited
Open

        return array_filter(openssl_get_cipher_methods(), fn ($methodName) => false === stripos($methodName, 'gcm') && false === stripos($methodName, 'ccm'));
Severity: Minor
Found in app/Encryption.php by phpcodesniffer

There are no issues that match your filters.

Category
Status