Review main Merged

83044[TASK] Allow transport_spool_filepath outside project root

Elias Häußler CR +2 V +2 Normal +67 −5 updated 02/21/25, 22:53

Commit message

The `transport_spool_filepath` setting used for the mailer's
file spool now accepts paths outside the project root.
Those paths must be configured as absolute paths and added in
`$GLOBALS['TYPO3_CONF_VARS']['BE']['lockRootPath']`.

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
    • Stephan Großberndt +1
    • Garvin Hicking +1
  • Verified V +2 Done
    • Stefan Bürk +2
    • Stephan Großberndt +1
    • Garvin Hicking +1
    • core-ci +1 CI

Issues 1

Files 2

Review log 3447

Show 1522 earlier messages
  1. Elias Häußler uploaded patch set 1 02/20/24, 12:53

  2. core-ci voted on patch set 1 V +1 02/20/24, 12:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53372

  3. Elias Häußler uploaded patch set 2 V +1 02/20/24, 13:03

  4. Mathias Brodala commented on patch set 2 02/20/24, 13:10

    TransportFactory.php:212

    These two conditions should be combined instead.
  5. core-ci voted on patch set 2 V +1 02/20/24, 13:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53374

  6. Elias Häußler commented on patch set 2 02/20/24, 13:20

    TransportFactory.php:212 Reply

    Like this? ```php if (!PathUtility::isAbsolutePath($path) || !GeneralUtility::validPathStr($path)) { $path = GeneralUtility::getFileAbsFileName($path); } ```
  7. Mathias Brodala commented on patch set 2 02/20/24, 13:24

    TransportFactory.php:212 Reply

    That would be different. Combining 1:1 would be: if (PathUtility::isAbsolutePath($path) && !GeneralUtility::validPathStr($path))
  8. Elias Häußler commented on patch set 2 02/20/24, 13:27

    TransportFactory.php:212 Reply

    But this would again call `GU::getFileAbsFileName()` for *valid* absolute paths in `else`, which is what this patch tries to avoid.
  9. Mathias Brodala commented on patch set 2 02/20/24, 13:32

    TransportFactory.php:212 Reply

    Indeed, then the whole block could be simplified: if (!PathUtility::isAbsolutePath($path)) { $path = GeneralUtility::getFileAbsFileName($path); } Thus keep absolute paths as is, in all other cases normalize the path just like before. The extra "validPathStr" call is not necessary since that happens within "getFileAbsFileName" already.
  10. Elias Häußler commented on patch set 2 02/20/24, 13:37

    TransportFactory.php:212 Reply

    Yes, this would indeed be the most elegant solution. I had this in the first place, but wasn't sure if it causes problems if the additional `validPathStr()` is not called for absolute paths. If you think it can be safely removed, I'll be happy to simplify the condition.
  11. Stefan Bürk commented on patch set 2 02/20/24, 13:58

    TransportFactoryTest.php:404

    Plese keeo tge dataProvider next to the test methods (before the test method using it).
  12. Elias Häußler uploaded patch set 3 V +1 02/20/24, 15:15

  13. Elias Häußler commented on patch set 2 02/20/24, 15:15

    TransportFactoryTest.php:404 Reply

    Done
  14. core-ci voted on patch set 3 V +1 02/20/24, 15:20 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53383

  15. Elias Häußler uploaded patch set 4 V +1 02/23/24, 13:56

  16. Elias Häußler uploaded patch set 5 02/23/24, 13:56

  17. core-ci voted on patch set 4 V -1 02/23/24, 14:02 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53500

  18. core-ci voted on patch set 5 V +1 02/23/24, 14:02 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53501

  19. Benni Mack updated the commit message in patch set 6 V +1 10/18/24, 13:22

  20. core-ci voted on patch set 6 V -1 10/18/24, 17:51 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67958

  21. Benni Mack rebased onto patch set 7 V -1 10/21/24, 05:44

  22. core-ci voted on patch set 7 V +1 10/21/24, 05:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/68279

  1. Stephan Großberndt commented on patch set 7 11/11/24, 18:08

    TransportFactory.php:212 Reply

    Just stumbled across the same problem. I think `GU::isAllowedAbsPath()` was created for this purpose and should be used here.
  2. Stephan Großberndt commented on patch set 8 V +1 11/11/24, 19:03

    Published edit on patch set 7.
  3. Stephan Großberndt updated the commit message in patch set 9 11/11/24, 19:06

  4. Stephan Großberndt commented on patch set 9 CR +1 V +1 11/11/24, 19:06

    TransportFactory.php:212 Reply

    This is broken since TYPO3 v12, when `GeneralUtility::getFileAbsFileName` was refactored in https://review.typo3.org/c/Packages/TYPO3.CMS/+/78034
  5. core-ci voted on patch set 8 V -1 11/11/24, 19:10 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/69315

  6. core-ci voted on patch set 9 V -1 11/11/24, 19:11 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/69316

  7. Stephan Großberndt commented on patch set 10 CR +1 V +1 11/11/24, 19:20

    Published edit on patch set 9.
  8. Stephan Großberndt commented on patch set 10 11/11/24, 19:21

    The tests now fail because the path /var/mailqueue is not in lockRootPath. Should it be added in the test?
  9. core-ci voted on patch set 10 V -1 11/11/24, 19:25 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/69317

  10. Stephan Großberndt commented on patch set 11 V -1 11/11/24, 19:32

    Published edit on patch set 10.
  11. core-ci voted on patch set 11 V -1 11/11/24, 19:38 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/69319

  12. Elias Häußler uploaded patch set 12 V -1 11/12/24, 06:29

  13. Elias Häußler commented on patch set 12 11/12/24, 06:30

    TransportFactory.php:212 Reply

    Done
  14. Elias Häußler commented on patch set 12 11/12/24, 06:34

    Thank you @stephan.grossberndt@typo3.org for the valuable addition! I added lockRootPath to the test case. Please review & vote again 😊
  15. core-ci voted on patch set 12 V +1 11/12/24, 06:42 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/69342

  16. Stephan Großberndt voted on patch set 12 CR +1 V +1 11/12/24, 13:27

  17. Elias Häußler uploaded patch set 13 CR +1 V +1 01/23/25, 09:49

  18. core-ci voted on patch set 13 V +1 01/23/25, 09:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/72913

  19. Stephan Großberndt voted on patch set 13 CR +1 V +1 01/23/25, 11:01

  20. Garvin Hicking commented on patch set 13 01/23/25, 22:57

    If you define the valid spool path in "lockRootPath" that would make your spool directory accessible in FAL mounts and other data retrieval, possibly leaking spool dara then? I would guess the spool directory should be write&read only for the spool context and these directories should not be made accessible anywhere else? (Maybe I am misunderstanding the intent, so please see this as an honest late night question 😅)
  21. Stefan Bürk commented on patch set 13 01/24/25, 09:52

    Reply

    I think this change is fine. `GeneralUtility::getFileAbsFileName()` makes a configured path absolute, prefixing it with the public folder path when not absolute. If it is already absolute, it checks that it is within the project or public path and return otherwise an empty string. That is the reason, why it is not possible to configure a spool path outside the project folder. Spool transport folder should be considered kind of TYPO3 API, and TYPO3 works on guard paths outside the project to be configured `easily` , which should also be done here while allowing absolute paths outside the project. To allow that, the known mechanic should be used, which is `$GLOBALS['TYPO3_CONF_VARS']['BE']['lockRootPath']` and respected with the used method `GeneralUtility::isAllowedAbsPath($path)` in advanced. That mechanic is not used soley for FAL, but for other things to. For example for lock file paths using the SimpleLockStrategy and a couple of others, making the use here valid in my eyes. What do you think, @gh@faktor-e.de ?
  22. Garvin Hicking commented on patch set 13 01/24/25, 11:18

    Reply

    My point here is that by adding the spoolpath to 'lockRootPath' it makes this directory accessible to more places than just the spooler. And spooling will contain mail contents that may have DSGVO/GDPR relevance, and thus should NOT be accessible by FAL and other methods. So I would argue that we should NOT add a spool path outside the TYPO3 storage to be a 'lockRootPath' but it should stand on its own; the spooler should be allowed to "fire and forget" its storage files to any place it can write to and read from? This might probably need a setting like 'internalRootPath' needed, in case it should still be configured which external directories are allowed. Maybe things apart from the spooler could need that too? On the other hand this raises the complexity a lot. I just wanted to bring this up, if everyone else thinks 'this is fine' I'm good. :-)
  23. Garvin Hicking commented on patch set 13 CR +1 V +1 02/21/25, 07:32

    Reply

    I'm really sorry it took that long for me and Stefan to get to talk over it properly. I see the original intent now much better. This patch makes the setup and situation much clearer. If any "additional" path setup like "internalLockPath" is needed at some point, it would be part of a follow-up. This patch improves the current situation, and that's the goalpost right now.
  24. Stefan Bürk voted on patch set 13 CR +2 V +2 02/21/25, 22:38

  25. Stefan Bürk merged patch set 14 02/21/25, 22:53