Better handling of the exceptions thrown by plugin's encrypt/decrypt

Created on 17 January 2023, over 2 years ago
Updated 18 January 2023, over 2 years ago

Problem/Motivation

The module requires plugins to either return encrypted or decrypted text as the return of a plugin's encrypt or decrypt methods. Since this code has been around before PHP8, the interface doesn't require any specific return type (which should be string), and many modules have been simply returning FALSE.

See encrypt_kms or the issue where real_aes 🐛 Decrypt and encrypt returns false Fixed stopped doing that, with multiple users now reporting problems with that.

Proposed resolution

In light of the fact that many modules have been getting away with simply returning FALSE, which in turn is returned by the encrypt module to the calller of the encrypt service, the encrypt module should add a try/catch around the calls to the decrypt/encrypt plugin methods, log the caught exception in the log and return FALSE to the caller.

One option might be to make this behaviour configurable: a strict version where, after logging the exception, the module simply re-throws it to be handled by the calling code; and a looser version where the code simply returns FALSE after the logging.

Remaining tasks

Implement, review and commit.

User interface changes

None

API changes

The return type of encrypt and decrypt would be changed to string | boolean.

Data model changes

None

Feature request
Status

Active

Version

3.0

Component

Code

Created by

🇵🇹Portugal jcnventura

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024