Skip to content

Commit cdd4d4b

Browse files
authored
Merge pull request #6772 from magento-tsg/MC-41213
[Arrows] MC-41213: Update existing Magento 2.4 code to pass Insecure Function phpcs checks
2 parents 7aed4cd + e36cb3c commit cdd4d4b

File tree

59 files changed

+142
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+142
-6
lines changed

app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ protected function _getConfigUrl()
101101
*/
102102
public function getIdentity()
103103
{
104+
// md5() here is not for cryptographic use.
105+
// phpcs:ignore Magento2.Security.InsecureFunction
104106
return md5('BASE_URL' . $this->_getConfigUrl());
105107
}
106108

app/code/Magento/AdminNotification/Model/System/Message/CacheOutdated.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ protected function _getCacheTypesForRefresh()
6262
*/
6363
public function getIdentity()
6464
{
65+
// md5() here is not for cryptographic use.
66+
// phpcs:ignore Magento2.Security.InsecureFunction
6567
return md5('cache' . implode(':', $this->_getCacheTypesForRefresh()));
6668
}
6769

app/code/Magento/AsynchronousOperations/Model/ResourceModel/System/Message/Collection/Synchronized/Plugin.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ public function afterToArray(
108108
'data' => [
109109
'text' => __('Task "%1": ', $bulk->getDescription()) . $text,
110110
'severity' => \Magento\Framework\Notification\MessageInterface::SEVERITY_MAJOR,
111+
// md5() here is not for cryptographic use.
112+
// phpcs:ignore Magento2.Security.InsecureFunction
111113
'identity' => md5('bulk' . $bulkUuid),
112114
'uuid' => $bulkUuid,
113115
'status' => $bulkStatus,

app/code/Magento/Backend/Test/Mftf/Helper/CurlHelpers.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ public function assertImageContentIsEqual($url, $expectedString, $postBody = nul
4949
$imageContent = $this->getCurlResponse($url, $cookie, $postBody);
5050
// Must make request twice until bug is resolved: B2B-1789
5151
$imageContent = $this->getCurlResponse($url, $cookie, $postBody);
52+
// md5() here is not for cryptographic use.
53+
// phpcs:ignore Magento2.Security.InsecureFunction
5254
$imageContentMD5 = md5($imageContent);
5355
$this->assertStringContainsString($expectedString, $imageContentMD5, $message);
5456
}

app/code/Magento/Catalog/Block/Navigation.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ public function getCacheKeyInfo()
152152

153153
$shortCacheId = array_values($shortCacheId);
154154
$shortCacheId = implode('|', $shortCacheId);
155+
// md5() here is not for cryptographic use.
156+
// phpcs:ignore Magento2.Security.InsecureFunction
155157
$shortCacheId = md5($shortCacheId);
156158

157159
$cacheId['category_path'] = $this->getCurrentCategoryKey();

app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ protected function generateCode($label)
126126
);
127127
$validatorAttrCode = new \Zend_Validate_Regex(['pattern' => '/^[a-z][a-z_0-9]{0,29}[a-z0-9]$/']);
128128
if (!$validatorAttrCode->isValid($code)) {
129+
// md5() here is not for cryptographic use.
130+
// phpcs:ignore Magento2.Security.InsecureFunction
129131
$code = 'attr_' . ($code ?: substr(md5(time()), 0, 8));
130132
}
131133
return $code;

app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public function validate($processingParams, $option)
213213
}
214214
}
215215

216-
$fileHash = md5($tmpDirectory->readFile($tmpDirectory->getRelativePath($fileInfo['tmp_name'])));
216+
$fileHash = hash('sha256', $tmpDirectory->readFile($tmpDirectory->getRelativePath($fileInfo['tmp_name'])));
217217

218218
$userValue = [
219219
'type' => $fileInfo['type'],

app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorInfo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function validate($optionValue, $option)
125125
*/
126126
protected function buildSecretKey($fileRelativePath)
127127
{
128-
return substr(md5($this->rootDirectory->readFile($fileRelativePath)), 0, 20);
128+
return substr(hash('sha256', $this->rootDirectory->readFile($fileRelativePath)), 0, 20);
129129
}
130130

131131
/**

app/code/Magento/Catalog/Model/Webapi/Product/Option/Type/File/Processor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function processFileContent(ImageContentInterface $imageContent)
5959
$filePath = $this->saveFile($imageContent);
6060

6161
$fileAbsolutePath = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA)->getAbsolutePath($filePath);
62-
$fileHash = md5($this->filesystem->getDirectoryRead(DirectoryList::MEDIA)->readFile($filePath));
62+
$fileHash = hash('sha256', $this->filesystem->getDirectoryRead(DirectoryList::MEDIA)->readFile($filePath));
6363
$imageSize = getimagesize($fileAbsolutePath);
6464
$result = [
6565
'type' => $imageContent->getType(),

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/serializer.phtml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
?>
99

1010
// phpcs:disable Magento2.Security.InsecureFunction.DiscouragedWithAlternative
11-
<?php $_id = 'id_' . md5(microtime()) ?>
11+
<?php
12+
// md5() here is not for cryptographic use.
13+
// phpcs:ignore Magento2.Security.InsecureFunction
14+
$_id = 'id_' . md5(microtime())
15+
?>
1216
<input type="hidden"
1317
name="<?= $block->escapeHtmlAttr($block->getInputElementName()) ?>"
1418
value=""

0 commit comments

Comments
 (0)