Issues (15)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

Plugin/Model/AccountManagement.php (4 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * File: AccountManagement.php
7
 *
8
 * @author Bartosz Kubicki [email protected]>
9
 * @copyright Copyright (C) 2018 Lizard Media (http://lizardmedia.pl)
10
 */
11
12
namespace LizardMedia\PasswordMigrator\Plugin\Model;
13
14
use LizardMedia\PasswordMigrator\Api\Data\PasswordRepositoryInterface;
15
use Magento\Customer\Model\AccountManagement as MagentoAccountManagement;
16
use Magento\Customer\Model\Customer;
17
use Magento\Customer\Model\CustomerRegistry;
18
use Magento\Framework\Exception\NoSuchEntityException;
19
use Psr\Log\LoggerInterface;
20
21
/**
22
 * Class AccountManagement
23
 * @package LizardMedia\PasswordMigrator\Plugin\Model
24
 */
25
class AccountManagement
26
{
27
    /**
28
     * @var PasswordRepositoryInterface
29
     */
30
    private $passwordRepository;
31
32
    /**
33
     * @var CustomerRegistry
34
     */
35
    private $customerRegistry;
36
37
    /**
38
     * @var LoggerInterface
39
     */
40
    private $logger;
41
42
    /**
43
     * PasswordManagement constructor.
44
     * @param PasswordRepositoryInterface $passwordRepository
45
     * @param CustomerRegistry $customerRegistry
46
     * @param LoggerInterface $logger
47
     */
48
    public function __construct(
49
        PasswordRepositoryInterface $passwordRepository,
50
        CustomerRegistry $customerRegistry,
51
        LoggerInterface $logger
52
    ) {
53
        $this->passwordRepository = $passwordRepository;
54
        $this->customerRegistry = $customerRegistry;
55
        $this->logger = $logger;
56
    }
57
58
59
    /**
60
     * @param MagentoAccountManagement $subject
61
     * @param callable $proceed
62
     * @param $email
63
     * @param $resetToken
64
     * @param $newPassword
65
     * @return bool
66
     */
67
    public function aroundResetPassword(
68
        MagentoAccountManagement $subject,
0 ignored issues
show
The parameter $subject is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
69
        callable $proceed,
70
        $email,
71
        $resetToken,
72
        $newPassword
73
    ) {
74
        $result = $proceed($email, $resetToken, $newPassword);
75
76
        if ($result === true) {
77
            $this->processRemovingLegacyPassword($email);
78
        }
79
80
        return $result;
81
    }
82
83
84
    /**
85
     * @param string $email
86
     * @return void
87
     */
88
    private function processRemovingLegacyPassword(string $email) : void
89
    {
90
        try {
91
            $customer = $this->getCustomer($email);
92
            $this->removeLegacyPasswordIfExists((int) $customer->getId());
93
        } catch (NoSuchEntityException $exception) {
0 ignored issues
show
Coding Style Comprehensibility introduced by Bartosz Kubicki
Consider adding a comment why this CATCH block is empty.
Loading history...
The class Magento\Framework\Exception\NoSuchEntityException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
94
        } catch (\Exception $exception) {
95
            $this->logger->error($exception->getMessage());
96
        }
97
    }
98
99
    /**
100
     * @param string $email
101
     * @return Customer
102
     * @throws NoSuchEntityException
103
     */
104
    private function getCustomer(string $email) : Customer
105
    {
106
        return $customer = $this->customerRegistry->retrieveByEmail($email);
0 ignored issues
show
$customer is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
107
    }
108
109
110
    /**
111
     * @param int $customerId
112
     * @return void
113
     */
114
    private function removeLegacyPasswordIfExists(int $customerId): void
115
    {
116
        $password = $this->passwordRepository->getByCustomerId($customerId);
117
        $this->passwordRepository->delete($password);
118
    }
119
}