Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8.2: Added #[\SensitiveParameter] to all the codebase #4386

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,15 @@
DeadCode\ClassMethod\RemoveUselessParamTagRector::class,
DeadCode\ClassMethod\RemoveUselessReturnTagRector::class,
DeadCode\Property\RemoveUselessVarTagRector::class,
Rector\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector::class,
TypeDeclaration\ClassMethod\ReturnNeverTypeRector::class,
])
->withConfiguredRule(Rector\Php82\Rector\Param\AddSensitiveParameterAttributeRector::class, [
'sensitive_parameters' => [
'apiKey',
'email',
'useremail',
'username',
'password'
],
]);
2 changes: 1 addition & 1 deletion app/code/core/Mage/Admin/Model/Resource/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function recordLogin(Mage_Admin_Model_User $user)
* @param string $username
* @return false|array
*/
public function loadByUsername($username)
public function loadByUsername(#[\SensitiveParameter] $username)
{
$adapter = $this->_getReadAdapter();

Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Admin/Model/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ protected function logoutIndirect()
* @param Mage_Core_Controller_Request_Http $request
* @return Mage_Admin_Model_User|null
*/
public function login($username, $password, $request = null)
public function login(#[\SensitiveParameter] $username, #[\SensitiveParameter] $password, $request = null)
{
if (empty($username) || empty($password)) {
return null;
Expand Down Expand Up @@ -306,7 +306,7 @@ protected function _getRequestUri($request = null)
* @param string $message
* @param Mage_Core_Controller_Request_Http|null $request
*/
protected function _loginFailed($e, $request, $username, $message)
protected function _loginFailed($e, $request, #[\SensitiveParameter] $username, $message)
{
try {
Mage::dispatchEvent('admin_session_user_login_failed', [
Expand Down
10 changes: 5 additions & 5 deletions app/code/core/Mage/Admin/Model/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public function getAclRole()
* @return bool
* @throws Mage_Core_Exception
*/
public function authenticate($username, $password)
public function authenticate(#[\SensitiveParameter] $username, #[\SensitiveParameter] $password)
{
$config = Mage::getStoreConfigFlag('admin/security/use_case_sensitive_login');
$result = false;
Expand Down Expand Up @@ -425,7 +425,7 @@ public function validatePasswordHash(string $string1, string $string2): bool
* @return $this
* @throws Mage_Core_Exception
*/
public function login($username, $password)
public function login(#[\SensitiveParameter] $username, #[\SensitiveParameter] $password)
{
if ($this->authenticate($username, $password)) {
$this->getResource()->recordLogin($this);
Expand Down Expand Up @@ -460,7 +460,7 @@ public function reload()
* @param string $username
* @return $this
*/
public function loadByUsername($username)
public function loadByUsername(#[\SensitiveParameter] $username)
{
$this->setData($this->getResource()->loadByUsername($username));
return $this;
Expand All @@ -483,7 +483,7 @@ public function hasAssigned2Role($user)
* @param string $password
* @return string
*/
protected function _getEncodedPassword($password)
protected function _getEncodedPassword(#[\SensitiveParameter] $password)
{
return Mage::helper('core')->getHash($password, self::HASH_SALT_LENGTH);
}
Expand Down Expand Up @@ -641,7 +641,7 @@ public function validate()
* @return array|true
* @throws Zend_Validate_Exception
*/
public function validateCurrentPassword($password)
public function validateCurrentPassword(#[\SensitiveParameter] $password)
{
$result = [];

Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Adminhtml/Controller/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ protected function _validateSecretKey()
*
* @return mixed - returns true or array of errors
*/
protected function _validateCurrentPassword($password)
protected function _validateCurrentPassword(#[\SensitiveParameter] $password)
{
$user = Mage::getSingleton('admin/session')->getUser();
return $user->validateCurrentPassword($password);
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Api/Model/Resource/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@
* @param string $username
* @return array
*/
public function loadByUsername($username)
public function loadByUsername(#[\SensitiveParameter] $username)
{

Check failure on line 135 in app/code/core/Mage/Api/Model/Resource/User.php

View workflow job for this annotation

GitHub Actions / PHPStan / Analyze (ubuntu-latest, 7.4)

Syntax error, unexpected '{', expecting T_VARIABLE on line 135
$adapter = $this->_getReadAdapter();
$select = $adapter->select()->from($this->getTable('api/user'))
->where('username=:username');
Expand Down Expand Up @@ -169,7 +169,7 @@
* @param string $sessid
* @return $this
*/
public function clearBySessId($sessid)

Check failure on line 172 in app/code/core/Mage/Api/Model/Resource/User.php

View workflow job for this annotation

GitHub Actions / PHPStan / Analyze (ubuntu-latest, 7.4)

Syntax error, unexpected T_PUBLIC on line 172
{
$this->_getWriteAdapter()->delete(
$this->getTable('api/session'),
Expand All @@ -184,7 +184,7 @@
* @param int | Mage_Api_Model_User $user
* @return null | array
*/
public function hasAssigned2Role($user)

Check failure on line 187 in app/code/core/Mage/Api/Model/Resource/User.php

View workflow job for this annotation

GitHub Actions / PHPStan / Analyze (ubuntu-latest, 7.4)

Syntax error, unexpected T_PUBLIC on line 187
{
$userId = null;
$result = null;
Expand All @@ -209,7 +209,7 @@
*
* @return $this
*/
protected function _beforeSave(Mage_Core_Model_Abstract $user)

Check failure on line 212 in app/code/core/Mage/Api/Model/Resource/User.php

View workflow job for this annotation

GitHub Actions / PHPStan / Analyze (ubuntu-latest, 7.4)

Syntax error, unexpected T_PROTECTED on line 212
{
$now = Varien_Date::now();
if (!$user->getId()) {
Expand All @@ -225,7 +225,7 @@
* @return $this
* @throws Exception
*/
public function delete(Mage_Core_Model_Abstract $user)

Check failure on line 228 in app/code/core/Mage/Api/Model/Resource/User.php

View workflow job for this annotation

GitHub Actions / PHPStan / Analyze (ubuntu-latest, 7.4)

Syntax error, unexpected T_PUBLIC on line 228
{
$dbh = $this->_getWriteAdapter();
$uid = (int) $user->getId();
Expand All @@ -246,7 +246,7 @@
*
* @return $this|Mage_Core_Model_Abstract
*/
public function _saveRelations(Mage_Core_Model_Abstract $user)

Check failure on line 249 in app/code/core/Mage/Api/Model/Resource/User.php

View workflow job for this annotation

GitHub Actions / PHPStan / Analyze (ubuntu-latest, 7.4)

Syntax error, unexpected T_PUBLIC on line 249
{
$rolesIds = $user->getRoleIds();
if (!is_array($rolesIds) || count($rolesIds) == 0) {
Expand Down Expand Up @@ -296,7 +296,7 @@
*
* @return array
*/
public function _getRoles(Mage_Core_Model_Abstract $user)

Check failure on line 299 in app/code/core/Mage/Api/Model/Resource/User.php

View workflow job for this annotation

GitHub Actions / PHPStan / Analyze (ubuntu-latest, 7.4)

Syntax error, unexpected T_PUBLIC on line 299
{
if (!$user->getId()) {
return [];
Expand All @@ -323,7 +323,7 @@
*
* @return $this
*/
public function add(Mage_Core_Model_Abstract $user)

Check failure on line 326 in app/code/core/Mage/Api/Model/Resource/User.php

View workflow job for this annotation

GitHub Actions / PHPStan / Analyze (ubuntu-latest, 7.4)

Syntax error, unexpected T_PUBLIC on line 326
{
$adapter = $this->_getWriteAdapter();
$aRoles = $this->hasAssigned2Role($user);
Expand Down Expand Up @@ -358,7 +358,7 @@
*
* @return $this
*/
public function deleteFromRole(Mage_Core_Model_Abstract $user)

Check failure on line 361 in app/code/core/Mage/Api/Model/Resource/User.php

View workflow job for this annotation

GitHub Actions / PHPStan / Analyze (ubuntu-latest, 7.4)

Syntax error, unexpected T_PUBLIC on line 361
{
if ($user->getUserId() <= 0) {
return $this;
Expand All @@ -384,7 +384,7 @@
*
* @return array
*/
public function roleUserExists(Mage_Core_Model_Abstract $user)

Check failure on line 387 in app/code/core/Mage/Api/Model/Resource/User.php

View workflow job for this annotation

GitHub Actions / PHPStan / Analyze (ubuntu-latest, 7.4)

Syntax error, unexpected T_PUBLIC on line 387
{
$result = [];
if ($user->getUserId() > 0) {
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Api/Model/Server/Handler/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ protected function _prepareResourceModelName($resource)
* @param string $apiKey
* @return string
*/
public function login($username, $apiKey = null)
public function login(#[\SensitiveParameter] $username, #[\SensitiveParameter] $apiKey = null)
{
if (empty($username) || empty($apiKey)) {
return $this->_fault('invalid_request_param');
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Api/Model/Server/Wsi/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function __call($function, $args)
* @param string $apiKey
* @return stdClass
*/
public function login($username, $apiKey = null)
public function login(#[\SensitiveParameter] $username, #[\SensitiveParameter] $apiKey = null)
{
if (is_object($username)) {
$apiKey = $username->apiKey;
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Api/Model/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function getIsInstaLogin(): bool
* @return mixed
* @throws Mage_Core_Exception
*/
public function login($username, $apiKey)
public function login(#[\SensitiveParameter] $username, #[\SensitiveParameter] $apiKey)
{
$user = Mage::getModel('api/user')
->setSessid($this->getSessionId());
Expand Down
8 changes: 4 additions & 4 deletions app/code/core/Mage/Api/Model/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public function getAclRole()
* @return bool
* @throws Exception
*/
public function authenticate($username, $apiKey)
public function authenticate(#[\SensitiveParameter] $username, #[\SensitiveParameter] $apiKey)
{
$this->loadByUsername($username);
if (!$this->getId()) {
Expand All @@ -261,7 +261,7 @@ public function authenticate($username, $apiKey)
* @return Mage_Api_Model_User
* @throws Exception
*/
public function login($username, $apiKey)
public function login(#[\SensitiveParameter] $username, #[\SensitiveParameter] $apiKey)
{
$sessId = $this->getSessid();
if ($this->authenticate($username, $apiKey)) {
Expand Down Expand Up @@ -295,7 +295,7 @@ public function reload()
* @param string $username
* @return $this
*/
public function loadByUsername($username)
public function loadByUsername(#[\SensitiveParameter] $username)
{
$this->setData($this->getResource()->loadByUsername($username));
return $this;
Expand Down Expand Up @@ -342,7 +342,7 @@ public function hasAssigned2Role($user)
* @param string $apiKey
* @return string
*/
protected function _getEncodedApiKey($apiKey)
protected function _getEncodedApiKey(#[\SensitiveParameter] $apiKey)
{
return Mage::helper('core')->getHash($apiKey, Mage_Admin_Model_User::HASH_SALT_LENGTH);
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Checkout/Model/Type/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ protected function _createOrderFromAddress($address)
* @param Mage_Sales_Model_Order $order
* @deprecated after 1.4.0.0-rc1
*/
protected function _emailOrderConfirmation($email, $name, $order)
protected function _emailOrderConfirmation(#[\SensitiveParameter] $email, $name, $order)
{
$mailer = Mage::getModel('core/email')
->setTemplate('email/order.phtml')
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Checkout/Model/Type/Onepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ protected function validateOrder()
* @param int $websiteId
* @return false|Mage_Customer_Model_Customer
*/
protected function _customerEmailExists($email, $websiteId = null)
protected function _customerEmailExists(#[\SensitiveParameter] $email, $websiteId = null)
{
$customer = Mage::getModel('customer/customer');
if ($websiteId) {
Expand Down
6 changes: 3 additions & 3 deletions app/code/core/Mage/Core/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public function getRandomString($len, $chars = null)
* @param string|int|bool $salt
* @return string
*/
public function getHash($password, $salt = false)
public function getHash(#[\SensitiveParameter] $password, $salt = false)
{
return $this->getEncryptor()->getHash($password, $salt);
}
Expand All @@ -296,7 +296,7 @@ public function getHash($password, $salt = false)
* @param mixed $salt
* @return string
*/
public function getHashPassword($password, $salt = false)
public function getHashPassword(#[\SensitiveParameter] $password, $salt = false)
{
$encryptionModel = $this->getEncryptor();
$latestVersionHash = $this->getVersionHash($encryptionModel);
Expand All @@ -312,7 +312,7 @@ public function getHashPassword($password, $salt = false)
* @return bool
* @throws Exception
*/
public function validateHash($password, $hash)
public function validateHash(#[\SensitiveParameter] $password, $hash)
{
return $this->getEncryptor()->validateHash($password, $hash);
}
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Core/Model/Email/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Mage_Core_Model_Email_Info extends Varien_Object
* @param string|null $name
* @return $this
*/
public function addBcc($email, $name = null)
public function addBcc(#[\SensitiveParameter] $email, $name = null)
{
$this->_bccNames[] = $name;
$this->_bccEmails[] = $email;
Expand All @@ -76,7 +76,7 @@ public function addBcc($email, $name = null)
* @param array|string|null $name
* @return $this
*/
public function addTo($email, $name = null)
public function addTo(#[\SensitiveParameter] $email, $name = null)
{
$this->_toNames[] = $name;
$this->_toEmails[] = $email;
Expand Down
8 changes: 4 additions & 4 deletions app/code/core/Mage/Core/Model/Email/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ public function getInclude($template, array $variables)
* @param array $variables template variables
* @return bool
**/
public function send($email, $name = null, array $variables = [])
public function send(#[\SensitiveParameter] $email, $name = null, array $variables = [])
{
if (!$this->isValidForSend()) {
Mage::logException(new Exception('This letter cannot be sent.')); // translation is intentionally omitted
Expand Down Expand Up @@ -498,7 +498,7 @@ public function send($email, $name = null, array $variables = [])
*
* @return $this
*/
public function sendTransactional($templateId, $sender, $email, $name, $vars = [], $storeId = null)
public function sendTransactional($templateId, $sender, #[\SensitiveParameter] $email, $name, $vars = [], $storeId = null)
{
$this->setSentSuccess(false);
if (($storeId === null) && $this->getDesignConfig()->getStore()) {
Expand Down Expand Up @@ -583,7 +583,7 @@ public function addBcc($bcc)
* @param string $email
* @return $this
*/
public function setReturnPath($email)
public function setReturnPath(#[\SensitiveParameter] $email)
{
$this->getMail()->setReturnPath($email);
return $this;
Expand All @@ -595,7 +595,7 @@ public function setReturnPath($email)
* @param string $email
* @return $this
*/
public function setReplyTo($email)
public function setReplyTo(#[\SensitiveParameter] $email)
{
$this->getMail()->setReplyTo($email);
return $this;
Expand Down
8 changes: 4 additions & 4 deletions app/code/core/Mage/Core/Model/Encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function setHelper($helper)
* @param mixed $salt
* @return string
*/
public function getHash($password, $salt = false)
public function getHash(#[\SensitiveParameter] $password, $salt = false)
{
if (is_int($salt)) {
$salt = $this->_helper->getRandomString($salt);
Expand All @@ -87,7 +87,7 @@ public function getHash($password, $salt = false)
* @param mixed $salt
* @return string
*/
public function getHashPassword($password, $salt = null)
public function getHashPassword(#[\SensitiveParameter] $password, $salt = null)
{
if (is_int($salt)) {
$salt = $this->_helper->getRandomString($salt);
Expand Down Expand Up @@ -124,7 +124,7 @@ public function hash($data, $version = self::HASH_VERSION_MD5)
* @return bool
* @throws Exception
*/
public function validateHash($password, $hash)
public function validateHash(#[\SensitiveParameter] $password, $hash)
{
if (strlen($password) > self::MAXIMUM_PASSWORD_LENGTH) {
return false;
Expand All @@ -144,7 +144,7 @@ public function validateHash($password, $hash)
* @param int $version
* @return bool
*/
public function validateHashByVersion($password, $hash, $version = self::HASH_VERSION_MD5)
public function validateHashByVersion(#[\SensitiveParameter] $password, $hash, $version = self::HASH_VERSION_MD5)
{
if ($version == self::HASH_VERSION_LATEST && $version == $this->_helper->getVersionHash($this)) {
return password_verify($password, $hash);
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Customer/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ public function isConfirmationRequired()
* @param string $email
* @return string
*/
public function getEmailConfirmationUrl($email = null)
public function getEmailConfirmationUrl(#[\SensitiveParameter] $email = null)
{
return $this->_getUrl('customer/account/confirmation', ['email' => $email]);
}
Expand Down
14 changes: 7 additions & 7 deletions app/code/core/Mage/Customer/Model/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public function getSharingConfig()
* @throws Mage_Core_Exception
* @return true
*/
public function authenticate($login, $password)
public function authenticate($login, #[\SensitiveParameter] $password)
{
$this->loadByEmail($login);
if ($this->getConfirmation() && $this->isConfirmationRequired()) {
Expand Down Expand Up @@ -489,7 +489,7 @@ public function getPassword(): string
* @param string $password
* @return $this
*/
public function setPassword($password)
public function setPassword(#[\SensitiveParameter] $password)
{
$this->setData('password', $password);
$this->setPasswordHash($this->hashPassword($password));
Expand All @@ -504,7 +504,7 @@ public function setPassword($password)
* @param int $salt
* @return string
*/
public function hashPassword($password, $salt = null)
public function hashPassword(#[\SensitiveParameter] $password, $salt = null)
{
/** @var Mage_Core_Helper_Data $helper */
$helper = $this->_getHelper('core');
Expand Down Expand Up @@ -548,7 +548,7 @@ public function generatePassword($length = 8)
* @return bool
* @throws Exception
*/
public function validatePassword($password)
public function validatePassword(#[\SensitiveParameter] $password)
{
$hash = $this->getPasswordHash();
if (!$hash) {
Expand All @@ -563,7 +563,7 @@ public function validatePassword($password)
* @param string $password
* @return string
*/
public function encryptPassword($password)
public function encryptPassword(#[\SensitiveParameter] $password)
{
return Mage::helper('core')->encrypt($password);
}
Expand All @@ -574,7 +574,7 @@ public function encryptPassword($password)
* @param string $password
* @return string
*/
public function decryptPassword($password)
public function decryptPassword(#[\SensitiveParameter] $password)
{
return Mage::helper('core')->decrypt($password);
}
Expand Down Expand Up @@ -722,7 +722,7 @@ public function isAddressPrimary(Mage_Customer_Model_Address $address)
* @throws Mage_Core_Exception
* @return $this
*/
public function sendNewAccountEmail($type = 'registered', $backUrl = '', $storeId = '0', $password = null)
public function sendNewAccountEmail($type = 'registered', $backUrl = '', $storeId = '0', #[\SensitiveParameter] $password = null)
{
$types = [
'registered' => self::XML_PATH_REGISTER_EMAIL_TEMPLATE, // welcome email, when confirmation is disabled
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Customer/Model/Flowpassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected function _prepareData()
* @param string $email
* @return bool
*/
public function checkCustomerForgotPasswordFlowEmail($email)
public function checkCustomerForgotPasswordFlowEmail(#[\SensitiveParameter] $email)
{
$helper = Mage::helper('customer');
$checkForgotPasswordFlowTypes = [
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Customer/Model/Resource/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ protected function _getLoadRowSelect($object, $rowId)
* @param bool $testOnly
* @return $this
*/
public function loadByEmail(Mage_Customer_Model_Customer $customer, $email, $testOnly = false)
public function loadByEmail(Mage_Customer_Model_Customer $customer, #[\SensitiveParameter] $email, $testOnly = false)
{
$adapter = $this->_getReadAdapter();
$bind = ['customer_email' => $email];
Expand Down
Loading
Loading