Skip to content

Commit 053722d

Browse files
author
Oleksandr Gorkun
committed
MC-19927: Implement hash-whitelisting, dynamic CSP
1 parent 67488fe commit 053722d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

app/code/Magento/Csp/Helper/InlineUtil.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,11 @@ private function extractRemoteFonts(string $styleContent): array
109109
* Extract remote hosts utilized.
110110
*
111111
* @param string $tag
112+
* @param string[] $attributes
112113
* @param string|null $content
113114
* @return string[]
114115
*/
115-
private function extractRemoteHosts(string $tag, ?string $content): array
116+
private function extractRemoteHosts(string $tag, array $attributes, ?string $content): array
116117
{
117118
/** @var string[] $remotes */
118119
$remotes = [];
@@ -163,7 +164,7 @@ public function renderTag(string $tagName, array $attributes, ?string $content =
163164
}
164165
/** @var string $policyId */
165166
$policyId = self::$tagMeta[$tagName]['id'];
166-
$remotes = $this->extractRemoteHosts($tagName, $content);
167+
$remotes = $this->extractRemoteHosts($tagName, $attributes, $content);
167168
if (empty($remotes) && !$content) {
168169
throw new \InvalidArgumentException('Either remote URL or hashable content is required to whitelist');
169170
}
@@ -180,7 +181,6 @@ public function renderTag(string $tagName, array $attributes, ?string $content =
180181
);
181182
}
182183

183-
184184
return $this->render($tagName, $attributes, $content);
185185
}
186186

app/code/Magento/Csp/Plugin/CspAwareControllerPlugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct(ControllerCollector $collector)
3838
* @return ActionInterface|null
3939
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
4040
*/
41-
public function afterMatch(RouterInterface $router, ?ActionInterface $matched): ?ActionInterface
41+
public function afterMatch(RouterInterface $router, $matched)
4242
{
4343
if ($matched && $matched instanceof CspAwareActionInterface) {
4444
$this->collector->setCurrentActionInstance($matched);

0 commit comments

Comments
 (0)