Review main Merged

90515[FEATURE] Introduce BeforePersistingReportEvent for CSP violations

Oliver Hader CR +2 V +2 Hard +430 −3 updated 02/19/26, 13:36

Commit message

When a CSP violation report needs to be persisted, the
Event `BeforePersistingReportEvent` can be used to provide an
alternative report or to prevent a particular report from
being persisted at all.

```
final class BeforePersistingReportEvent
{
    /**
     * The original report created by for the CSP violation
     */
    public readonly Report $originalReport;

    /**
     * The HTTP POST request submitting the CSP violation
     */
    public readonly ServerRequestInterface $request;

    /**
     * Alternative report, or `null` to skip persistence
     */
    public ?Report $report;
}
```

As a drive-by bugfix, possibly missing JSON array keys
'effective-directive' and 'blocked-uri' no longer throw
array index access PHP warnings when missing.

Also the AbstractContentSecurityPolicyReporter class is
now subject to functional tests by way of this event
test.

Review

  • Code review CR +2 Done
    • Oliver Hader +2
    • Garvin Hicking +1
    • Benni Mack +1
  • Verified V +2 Done
    • Oliver Hader +2
    • Garvin Hicking +1
    • Benni Mack +1
    • core-ci +1 CI

Issues 1

Files 5

Review log 2027

Show 2 earlier messages
  1. Oliver Hader uploaded patch set 1 08/29/25, 16:44

  2. Oliver Hader updated the commit message in patch set 2 08/29/25, 16:49

  1. core-ci voted on patch set 2 V +1 08/29/25, 17:02 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/84006

  2. Oliver Hader uploaded patch set 3 V +1 08/29/25, 17:29

  3. core-ci voted on patch set 3 V +1 08/29/25, 17:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/84009

  4. Simon Schaufelberger commented on patch set 3 08/29/25, 21:52

    BeforePersistingReportEvent.php:36

    the original request probably
  5. Oliver Hader uploaded patch set 4 V +1 08/30/25, 08:23

  6. Oliver Hader commented on patch set 4 08/30/25, 08:23

    BeforePersistingReportEvent.php:36 Reply

    Thanks. I've adjusted the comments.
  7. core-ci voted on patch set 4 V +1 08/30/25, 08:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/84043

  8. Simon Schaufelberger voted on patch set 4 CR +1 V +1 08/30/25, 10:39

  9. Georg Ringer voted on patch set 4 CR +1 V +1 08/30/25, 14:36

  10. Garvin Hicking commented on patch set 4 08/30/25, 15:37

    Maybe add an event test like for the other PSR-14 additions?
  11. Georg Ringer uploaded patch set 5 CR +1 V +1 02/07/26, 09:09

  12. core-ci voted on patch set 5 V +1 02/07/26, 09:19 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/95375

  13. Benni Mack uploaded patch set 6 V +1 02/18/26, 21:30

  14. Benni Mack commented on patch set 6 CR +1 V +1 02/18/26, 21:30

    Reply

    Done
  15. core-ci voted on patch set 6 V +1 02/18/26, 21:42 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/96194

  16. Garvin Hicking commented on patch set 6 CR -1 02/19/26, 06:14

    Reply

    Hang on, I meant a test that checks the event is actually dispatched and the "outer" workflow works, nit nust a getter/setter DTO test. I'll add one.
  17. Garvin Hicking uploaded patch set 7 CR +1 V +1 02/19/26, 09:40

  18. Garvin Hicking commented on patch set 7 CR +1 V +1 02/19/26, 09:44

    Reply

    I added a functional test for what I meant. That was more complex than anticipated because I have to jump through the middleware hoops and abstract class implementation. But I'd argue this is very helpful to now have the abstract class be subject to a proper test. Due to this I also found out that the wrong $report was actually persisted, which is now fixed :-D
  19. core-ci voted on patch set 7 V -1 02/19/26, 09:48 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/96223

  20. Garvin Hicking uploaded patch set 8 CR +1 V +1 02/19/26, 10:06

    fix namespace
  21. core-ci voted on patch set 8 V +1 02/19/26, 10:15 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/96225

  22. Benni Mack voted on patch set 8 CR +1 V +1 02/19/26, 10:19

  23. Garvin Hicking voted on patch set 8 CR +1 V +1 02/19/26, 10:26

  24. Oliver Hader commented on patch set 8 CR +2 V +2 02/19/26, 13:36

    Thx folks 😊
  25. Oliver Hader merged patch set 9 02/19/26, 13:36