85812[BUGFIX] Allow assigning empty sources to non-empty CSP directives
Commit message
Review
-
Code review CR +2 Done
- Oliver Hader +2
- Chris Müller +1
- Garvin Hicking +1
-
Verified V +2 Done
- Oliver Hader +2
- Chris Müller +1
- Garvin Hicking +1
- core-ci +1 CI
Issues 1
Files 2
Review log 910
-
Oliver Hader uploaded patch set 1 08/28/24, 12:37
-
Oliver Hader wrote 08/28/24, 12:38
Topic set to csp -
core-ci voted on patch set 1 V +1 08/28/24, 12:44 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/64418
-
Garvin Hicking commented on patch set 1 08/29/24, 08:03
I think there's still an issue. Using this csp.yaml: ``` inheritDefault: true mutations: - mode: reduce directive: 'style-src-attr' sources: - "'unsafe-inline'" - mode: reduce directive: 'style-src-attr' sources: - "'report-sample'" ``` I would expect that the whole "style-src-attr" directive goes away, but in reality I get the hadder with unsafe-inline and report-sample applied again. If I just use one "reduce" statement, the one source gets properly removed. Using: ``` mutations: - mode: reduce directive: 'style-src-attr' sources: - "'unsafe-inline'" - "'report-sample'" ``` also only the first source gets removed, not both? -
Oliver Hader commented on patch set 1 08/29/24, 12:42
Reply
That's a special case for `report-sample`: * `\TYPO3\CMS\Frontend\Middleware\ContentSecurityPolicyHeaders::process` resolves the reporting URI * `\TYPO3\CMS\Core\Security\ContentSecurityPolicy\Policy::report` automatically adds the `report-sample` to all applicable directives * see https://github.com/TYPO3/typo3/blob/main/typo3/sysext/core/Classes/Security/ContentSecurityPolicy/Policy.php#L176-L186 -
Oliver Hader commented on patch set 1 08/29/24, 12:44
Reply
Thus, the source item was removed, but automatically added for having a better experience with the potential reports. -
Garvin Hicking commented on patch set 1 CR +1 V +1 08/29/24, 13:49
Reply
Sorry, I think I misphrased/misused that, but your explaination was also helpful to understand I used a bad "sources" entry for this. I kind of expected that when using "reduce" to remove all existing sources of a directive, when none remains, it would remove the whole directive. But maybe that is outside of scope, because one should then instead use "mode: remove, directive: 'style-src-attr'". -
Chris Müller voted on patch set 1 CR +1 V +1 08/30/24, 18:43
-
Oliver Hader voted on patch set 1 CR +2 V +2 09/02/24, 10:26
-
Oliver Hader merged patch set 2 09/02/24, 10:27