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

refactor: starter key handling in SodiumHandler #9207

Merged
merged 1 commit into from
Oct 3, 2024

Conversation

datamweb
Copy link
Contributor

@datamweb datamweb commented Oct 1, 2024

Description
While I recognize that this change might be seen as a BC, it appears that it will not significantly impact many users. The improved validation of the starter key in the SodiumHandler class primarily focuses on enhancing error handling and preventing potential issues related to an empty key, which should lead to a more robust encryption process.

See : https://github.com/codeigniter4/CodeIgniter4/actions/runs/11033764630/job/30645688529?pr=9202

 ------ ----------------------------------------------------------------------- 
  Line   system/Encryption/Handlers/SodiumHandler.php                           
 ------ ----------------------------------------------------------------------- 
  66     Property CodeIgniter\Encryption\Handlers\SodiumHandler::$key (string)  
         does not accept null.                                                  
         🪪  assign.propertyType                                                
  108    Property CodeIgniter\Encryption\Handlers\SodiumHandler::$key (string)  
         does not accept null.                                                  
         🪪  assign.propertyType                                                
 ------ ----------------------------------------------------------------------- 

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

Copy link
Member

@michalsn michalsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, such changes should go to branch 4.6, and here we should fix it by typing the variable, but... these changes are unlikely to affect anyone, so we might as well do it in develop.

We will also need a changelog entry.

system/Encryption/Handlers/SodiumHandler.php Outdated Show resolved Hide resolved
@kenjis kenjis added the refactor Pull requests that refactor code label Oct 3, 2024
@kenjis
Copy link
Member

kenjis commented Oct 3, 2024

How about this?

--- a/system/Encryption/Handlers/SodiumHandler.php
+++ b/system/Encryption/Handlers/SodiumHandler.php
@@ -26,7 +26,7 @@ class SodiumHandler extends BaseHandler
     /**
      * Starter key
      *
-     * @var string
+     * @var string|null Null is used for buffer cleanup.
      */
     protected $key = '';
 

@datamweb
Copy link
Contributor Author

datamweb commented Oct 3, 2024

Thank you all for your help, I truly appreciate it. I didn’t mean to pull all of you into this, but your support means a lot!

@kenjis kenjis merged commit 118c2c4 into codeigniter4:develop Oct 3, 2024
41 checks passed
@datamweb datamweb deleted the refctor-SodiumHandler branch October 3, 2024 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Pull requests that refactor code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants