From 11beb721832853fb03fb18053b17e3f64f02a231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Lochm=C3=BCller?= Date: Sat, 2 Nov 2024 14:06:15 +0100 Subject: [PATCH] Prepare CSP infos --- Classes/Cache/Listener/NoIntScriptsListener.php | 7 +++++++ Classes/Cache/Listener/StaticCacheableListener.php | 2 ++ 2 files changed, 9 insertions(+) diff --git a/Classes/Cache/Listener/NoIntScriptsListener.php b/Classes/Cache/Listener/NoIntScriptsListener.php index 148e69e3c18..ce64ad44651 100644 --- a/Classes/Cache/Listener/NoIntScriptsListener.php +++ b/Classes/Cache/Listener/NoIntScriptsListener.php @@ -5,6 +5,7 @@ namespace SFC\Staticfilecache\Cache\Listener; use SFC\Staticfilecache\Event\CacheRuleEvent; +use TYPO3\CMS\Frontend\Cache\NonceValueSubstitution; use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; class NoIntScriptsListener @@ -14,6 +15,12 @@ public function __invoke(CacheRuleEvent $event): void $tsfe = $GLOBALS['TSFE'] ?? null; if ($tsfe instanceof TypoScriptFrontendController && $tsfe->isINTincScript()) { foreach ((array) $tsfe->config['INTincScript'] as $key => $configuration) { + + // Check CSP Handling + // if (isset($configuration['target']) && $configuration['target'] === NonceValueSubstitution::class . '->substituteNonce') { + // continue; + // } + $event->addExplanation(__CLASS__ . ':' . $key, 'The page has a INTincScript: ' . implode(', ', $this->getInformation($configuration))); } } diff --git a/Classes/Cache/Listener/StaticCacheableListener.php b/Classes/Cache/Listener/StaticCacheableListener.php index 68b320af98b..1a019894d07 100644 --- a/Classes/Cache/Listener/StaticCacheableListener.php +++ b/Classes/Cache/Listener/StaticCacheableListener.php @@ -23,6 +23,8 @@ public function __construct(private readonly Typo3Version $typo3Version) {} */ public function __invoke(CacheRuleEvent $event): void { + // @todo migrate this event to check + // $request->getAttribute('frontend.cache.instruction')->isCachingAllowed() if (($GLOBALS['TSFE'] ?? null) instanceof TypoScriptFrontendController) { if ($this->typo3Version->getMajorVersion() >= 13) { /* @phpstan-ignore-next-line */