Skip to content

Conversation

@deer-wmde
Copy link
Contributor

  • Using just random_bytes does not guarantee a valid Bcrypt password value
  • Using the sha1 hashsum of that value should be sufficient

From time to time you would see this bug with the command failing in the unit test:

1) Tests\Commands\DisableTest::testSuccess
ValueError: Bcrypt password must not contain null character

/var/www/html/vendor/laravel/framework/src/Illuminate/Hashing/BcryptHasher.php:47
/var/www/html/vendor/laravel/framework/src/Illuminate/Hashing/HashManager.php:63
/var/www/html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:355
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php:1325
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php:998
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:2238
/var/www/html/app/Console/Commands/User/Disable.php:55
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/Util.php:41
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:35
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php:662
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php:211
/var/www/html/vendor/symfony/console/Command/Command.php:326
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php:180
/var/www/html/vendor/symfony/console/Application.php:1078
/var/www/html/vendor/symfony/console/Application.php:324
/var/www/html/vendor/symfony/console/Application.php:175
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php:162
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:400
/var/www/html/vendor/laravel/framework/src/Illuminate/Testing/PendingCommand.php:297
/var/www/html/vendor/laravel/framework/src/Illuminate/Testing/PendingCommand.php:484
/var/www/html/tests/Commands/User/DisableTest.php:31
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:61

Copy link
Contributor

@tarrow tarrow left a comment

Choose a reason for hiding this comment

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

coolio!

@deer-wmde deer-wmde merged commit 2156e09 into main Nov 25, 2025
6 checks passed
@deer-wmde deer-wmde deleted the de/flakybcrypt branch November 25, 2025 09:30
deer-wmde added a commit that referenced this pull request Dec 15, 2025
- Using just `random_bytes` does not guarantee a valid Bcrypt password
value
- Using the sha1 hashsum of that value should be sufficient

From time to time you would see this bug with the command failing in the
unit test:

```
1) Tests\Commands\DisableTest::testSuccess
ValueError: Bcrypt password must not contain null character

/var/www/html/vendor/laravel/framework/src/Illuminate/Hashing/BcryptHasher.php:47
/var/www/html/vendor/laravel/framework/src/Illuminate/Hashing/HashManager.php:63
/var/www/html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:355
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php:1325
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php:998
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:2238
/var/www/html/app/Console/Commands/User/Disable.php:55
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/Util.php:41
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:35
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php:662
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php:211
/var/www/html/vendor/symfony/console/Command/Command.php:326
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php:180
/var/www/html/vendor/symfony/console/Application.php:1078
/var/www/html/vendor/symfony/console/Application.php:324
/var/www/html/vendor/symfony/console/Application.php:175
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php:162
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:400
/var/www/html/vendor/laravel/framework/src/Illuminate/Testing/PendingCommand.php:297
/var/www/html/vendor/laravel/framework/src/Illuminate/Testing/PendingCommand.php:484
/var/www/html/tests/Commands/User/DisableTest.php:31
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:61
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants