[Snyk] Security upgrade bcrypt from 1.0.0 to 5.0.1 - #296
Conversation
The following vulnerabilities are fixed with an upgrade: - https://snyk.io/vuln/SNYK-JS-TAR-15038581
Summary of ChangesHello @saurabharch, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request, automatically generated by Snyk, aims to enhance the security posture of the project by resolving a critical vulnerability. It achieves this by updating a key dependency to a more secure version, thereby mitigating potential risks associated with the identified weakness. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request upgrades bcrypt from version 1.0.0 to 5.0.1 to fix a security vulnerability. However, this upgrade introduces two critical breaking changes that will prevent the application from building and running correctly.
-
Node.js Version Incompatibility:
bcrypt@5.0.1requires Node.js version 10 or higher. This project is configured to use Node.js 6+ ("engines": { "node": ">= 6.0.0" }inpackage.json) and theDockerfileis based onnode:8-alpine. Thenpm installcommand will fail due to this version mismatch. -
API Breaking Changes:
bcryptversion 5.0.0 and later removed callback support for its asynchronous functions, which now exclusively return Promises. The codebase likely relies on the old callback-based API (or a promisification wrapper), which will cause runtime errors in features like user authentication.
To resolve this, you must:
- Update the Node.js version in your
Dockerfileand CI/CD environment to a compatible version (>=10). - Update the
enginesfield inpackage.json. - Refactor the code that uses
bcrypt(e.g., inlib/services/utils.js) to use the new Promise-based API.
Merging this PR as-is will break the build.
| }, | ||
| "dependencies": { | ||
| "bcrypt": "1.0.0", | ||
| "bcrypt": "5.0.1", |
There was a problem hiding this comment.
This upgrade to bcrypt@5.0.1 introduces two critical breaking changes:
-
Node.js Version Requirement:
bcrypt@5.0.1requires Node.js >= 10. YourDockerfileusesnode:8-alpine, and yourpackage.jsonspecifiesnode >= 6.0.0. This will causenpm installto fail. You need to upgrade your Node.js environment. -
API Changes: Asynchronous functions in
bcrypt(likecompareandhash) now only return Promises and no longer support callbacks. Any code using the old API will break. For example,utils.compareSaltAndHashed(used inlib/services/auth.js) will need to be updated to work with the new Promise-based API.
This PR cannot be merged without addressing these issues by updating the Node.js environment and refactoring the code that uses bcrypt.
Snyk has created this PR to fix 1 vulnerabilities in the npm dependencies of this project.
Snyk changed the following file(s):
final/gateway/package.jsonVulnerabilities that will be fixed with an upgrade:
SNYK-JS-TAR-15038581
Important
Note: You are seeing this because you or someone else with access to this repository has authorized Snyk to open fix PRs.
For more information:
🧐 View latest project report
📜 Customise PR templates
🛠 Adjust project settings
📚 Read about Snyk's upgrade logic
Learn how to fix vulnerabilities with free interactive lessons:
🦉 Learn about vulnerability in an interactive lesson of Snyk Learn.