Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.1] Catch block for generic TUF exceptions #43477

Merged
merged 8 commits into from
May 20, 2024

Conversation

SniperSister
Copy link
Contributor

@SniperSister SniperSister commented May 15, 2024

Pull Request for Issue #43328

Summary of Changes

This PR adds a generic catch block that catches exceptions thrown in the TUF library. So far, we only caught attack-specific exceptions, internal errors, or errors related to metadata syntax error remained uncaught, making the site unusable.

Furthermore, it catches non-tuf exceptions from the HTTP library in our transport and converts them into TUF exceptions to also get them caught in the fetcher library.

Testing Instructions

We have to simulate an exception in the library in order to verify that the patch works. To do so, find the following code block in libraries/src/TUF/TufFetcher.php:

try {
                // Refresh the data if needed, it will be written inside the DB, then we fetch it afterwards and return it to
                // the caller
                $updater->refresh();

                // Persist the data as it was correctly fetched and verified
                $storage->persist();

                return $storage->read('targets');
            } catch (\Exception $e) {

and replace it with

try {
               throw new Tuf\Exception\TufException("Test TUF exception");

                // Refresh the data if needed, it will be written inside the DB, then we fetch it afterwards and return it to
                // the caller
                $updater->refresh();

                // Persist the data as it was correctly fetched and verified
                $storage->persist();

                return $storage->read('targets');
            } catch (\Exception $e) {

Actual result BEFORE applying this Pull Request

Unhandled exception.

Expected result AFTER applying this Pull Request

Proper system message shown, system remains usable.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • [x ] No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • [x ] No documentation changes for manual.joomla.org needed

…er/joomla-cms into 5.1-tuf-generic-catch

# Conflicts:
#	administrator/language/en-GB/lib_joomla.ini
@LadySolveig LadySolveig added this to the Joomla! 5.1.1 milestone May 15, 2024
@SniperSister
Copy link
Contributor Author

For the record: a user from the german forum has tested the patch and it solved a http-transport related issue, see: https://forum.joomla.de/thread/20986-failed-to-connect-to-update-joomla-org-port-443/?postID=154136#post154136

@dautrich
Copy link

I have tested this item ✅ successfully on fa179de


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/43477.

@LadySolveig LadySolveig merged commit e46f075 into joomla:5.1-dev May 20, 2024
1 of 3 checks passed
@LadySolveig
Copy link
Contributor

Thank you @SniperSister and also for testing and review @dautrich @brianteeman @Fedik

Kostelano added a commit to JPathRu/localisation that referenced this pull request May 25, 2024
joomla/joomla-cms#43249 - (только для en-GB)
joomla/joomla-cms#43454 +
joomla/joomla-cms#43414 - (только для en-GB)
joomla/joomla-cms#43401 - (только для др. пакетов)
joomla/joomla-cms#43251 +
joomla/joomla-cms#43481 +
joomla/joomla-cms#43483 - (только для др. пакетов)
joomla/joomla-cms#43477 +
joomla/joomla-cms#43435 +
Kostelano added a commit to Joomla-Ukraine/uk-UA that referenced this pull request Jun 3, 2024
joomla/joomla-cms#43249 - (тільки для en-GB)
joomla/joomla-cms#43454 +
joomla/joomla-cms#43414 - (тільки для en-GB)
joomla/joomla-cms#43401 - (тільки для ін. пакетів)
joomla/joomla-cms#43251 +
joomla/joomla-cms#43481 +
joomla/joomla-cms#43483 - (тільки для ін. пакетів)
joomla/joomla-cms#43477 +
joomla/joomla-cms#43435 +
та інші виправлення
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Language Change This is for Translators
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants