-
Notifications
You must be signed in to change notification settings - Fork 0
[Snyk] Upgrade jimp from 0.16.1 to 0.22.12 #697
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
base: master
Are you sure you want to change the base?
Conversation
Snyk has created this PR to upgrade jimp from 0.16.1 to 0.22.12. See this package in npm: jimp See this project in Snyk: https://app.snyk.io/org/mohammadnewton/project/fee1832a-d2da-4b2f-b4c2-e49694f3c97e?utm_source=github&utm_medium=referral&page=upgrade-pr
Summary of ChangesHello @nejidevelops, 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, focuses on a critical update to the Highlights
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "express": "^4.17.1", | ||
| "jimp": "^0.16.1", | ||
| "jimp": "^0.22.12", | ||
| "rimraf": "^3.0.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upgrade jimp to ESM-only release breaks CommonJS import
The application imports jimp with import Jimp = require('jimp') and the TS compiler emits CommonJS modules. Version 0.22 of jimp is published as a pure ES module that cannot be loaded via require, and it also targets newer Node runtimes (>=16/18). After this bump, starting the server will throw ERR_REQUIRE_ESM when filterImageFromURL executes, so the image filter service no longer boots. Either keep a CJS-compatible jimp (≤0.21) or migrate the codebase and runtime to ESM before upgrading.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request upgrades jimp from 0.16.1 to 0.22.12, which is an important step to resolve multiple security vulnerabilities.
However, this large version jump introduces a critical breaking change in the jimp API that must be addressed before this PR can be merged. The current code that uses jimp will likely fail or exhibit race conditions with this new version.
Critical: Update jimp Usage
The jimp library made its write() method asynchronous from v0.18.0 onwards. The filterImageFromURL function in src/util/util.ts uses a new Promise constructor with a callback for write(), which is an anti-pattern and will not work correctly with the new version.
I strongly recommend refactoring filterImageFromURL to correctly use async/await and also to fix a pre-existing path-handling bug.
Suggested replacement for filterImageFromURL in src/util/util.ts:
import fs from "fs";
import Jimp = require("jimp");
import path from "path";
export async function filterImageFromURL(inputURL: string): Promise<string> {
const photo = await Jimp.read(inputURL);
const outpath = path.join(__dirname, "..", "tmp", `filtered.${Math.floor(Math.random() * 2000)}.jpg`);
await photo
.resize(256, 256)
.quality(60)
.greyscale()
.writeAsync(outpath);
return outpath;
}This change:
- Removes the
new Promiseanti-pattern. - Uses
writeAsync(), the correct promise-based API forjimp. - Fixes the file path to correctly use the
www/tmp/directory. You'll need to addimport path from "path";.
High: Other Outdated & Vulnerable Dependencies
While reviewing, I noticed other dependencies that should be updated to patch security vulnerabilities and stay current. Please consider creating separate PRs for these:
express: Upgrade from^4.17.1to^4.18.2to fix known high-severity vulnerabilities.lodash: Thepackage.jsonlists^4.17.15, which has known vulnerabilities. While the lockfile has correctly resolved this to4.17.21, it's best to updatepackage.jsonto^4.17.21to be explicit and prevent accidental downgrades.- Dev Dependencies:
typescript,@types/node, andts-node-devare very outdated. Also,tslintis deprecated and should be migrated toESLint.
Because of the critical breaking change, this PR is not safe to merge as is. The code using jimp must be updated.
Snyk has created this PR to upgrade jimp from 0.16.1 to 0.22.12.
ℹ️ Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project.
The recommended version is 111 versions ahead of your current version.
The recommended version was released 2 years ago.
Issues fixed by the recommended upgrade:
SNYK-JS-JPEGJS-2859218
SNYK-JS-BABELRUNTIME-10044504
SNYK-JS-MINDOCUMENT-13045385
SNYK-JS-PHIN-6598077
SNYK-JS-XML2JS-5414874
SNYK-JS-MINIMIST-2429795
Important
Note: You are seeing this because you or someone else with access to this repository has authorized Snyk to open upgrade PRs.
For more information: