Fix #110 rn 0.75 buffer issue with android, added new core tests#111
Merged
Fix #110 rn 0.75 buffer issue with android, added new core tests#111
Conversation
…ore-tests' into fix-rn-buffer-and-core-tests
|
|
||
| it(`should${ok ? '' : "n't"} auth with hash`, done => { | ||
| const chinook = getConnection() | ||
| chinook.sendCommands(`AUTH USER ${username} HASH ${createHash('sha256').update(password).digest('base64')}`, test(done, chinook, ok)) |
Check failure
Code scanning / CodeQL
Use of password hash with insufficient computational effort
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI over 1 year ago
To fix the problem, we need to replace the use of sha256 with a more secure password hashing algorithm like bcrypt. This change will ensure that the password hashing is computationally intensive and secure against brute-force attacks.
- Replace the
createHash('sha256')method withbcrypt.hashSync. - Import the
bcryptlibrary at the beginning of the file. - Update the hashing logic to use
bcryptwith a salt.
Suggested changeset
2
test/core/built-in-commands.test.ts
| @@ -4,3 +4,3 @@ | ||
|
|
||
| import { createHash } from 'crypto' | ||
| import bcrypt from 'bcrypt' | ||
| import { | ||
| @@ -396,3 +396,5 @@ | ||
| const chinook = getConnection() | ||
| chinook.sendCommands(`AUTH USER ${username} HASH ${createHash('sha256').update(password).digest('base64')}`, test(done, chinook, ok)) | ||
| const saltRounds = 10; | ||
| const hashedPassword = bcrypt.hashSync(password, saltRounds); | ||
| chinook.sendCommands(`AUTH USER ${username} HASH ${hashedPassword}`, test(done, chinook, ok)) | ||
| }) |
package.json
Outside changed files
| @@ -53,3 +53,4 @@ | ||
| "socket.io-client": "^4.7.5", | ||
| "whatwg-url": "^14.0.0" | ||
| "whatwg-url": "^14.0.0", | ||
| "bcrypt": "^5.1.1" | ||
| }, |
This fix introduces these dependencies
| Package | Version | Security advisories |
| bcrypt (npm) | 5.1.1 | None |
Copilot is powered by AI and may make mistakes. Always verify output.
TizianoT
approved these changes
Oct 3, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of change
fix #110 and added new core tests
Pull-Request Checklist
mainbranchnpm run lintpasses with this changenpm run testpasses with this changeFixes #0000