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

Bump jimp from 0.22.12 to 1.6.0 #5537

Merged
merged 3 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Dependencies:
- Bump countly-sdk-web from 24.4.1 to 24.11.0
- Bump tslib from 2.7.0 to 2.8.1
- Bump form-data from 4.0.0 to 4.0.1
- Bump jimp from 0.22.12 to 1.6.0

## Version 24.05.19
Fixes:
Expand Down
23 changes: 8 additions & 15 deletions api/parts/mgmt/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ appsApi.getAppsDetails = function(params) {
* @param {params} params - params object with args to create app
* @return {object} return promise object;
**/
const iconUpload = function(params) {
const iconUpload = async function(params) {
const appId = params.app_id || common.sanitizeFilename(params.qstring.args.app_id);
if (params.files && params.files.app_image) {
const tmp_path = params.files.app_image.path,
Expand All @@ -183,25 +183,18 @@ const iconUpload = function(params) {
return Promise.reject();
}
try {
return jimp.read(tmp_path, function(err, icon) {
if (err) {
log.e(err, err.stack);
fs.unlink(tmp_path, function() {});
return true;
const icon = await jimp.Jimp.read(tmp_path);
const buffer = await icon.cover({h: 72, w: 72}).getBuffer(jimp.JimpMime.png);
countlyFs.saveData("appimages", target_path, buffer, {id: appId + ".png", writeMode: "overwrite"}, function(err3) {
if (err3) {
log.e(err3, err3.stack);
}
icon.cover(72, 72).getBuffer(jimp.MIME_PNG, function(err2, buffer) {
countlyFs.saveData("appimages", target_path, buffer, {id: appId + ".png", writeMode: "overwrite"}, function(err3) {
if (err3) {
log.e(err3, err3.stack);
}
fs.unlink(tmp_path, function() {});
});
});
});
}
catch (e) {
log.e(e.stack);
console.log("Problem uploading app icon", e);
}
fs.unlink(tmp_path, function() {});
}
};

Expand Down
47 changes: 18 additions & 29 deletions frontend/express/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,7 @@
req.body.app_id = req.body.app_image_id;
}
var params = paramsGenerator({req, res});
validateCreate(params, 'global_upload', function() {
validateCreate(params, 'global_upload', async function() {
if (!req.session.uid && !req.body.app_image_id) {
res.end();
return false;
Expand All @@ -1634,25 +1634,18 @@
}
plugins.callMethod("iconUpload", {req: req, res: res, next: next, data: req.body});
try {
jimp.read(tmp_path, function(err, icon) {
if (err) {
console.log(err, err.stack);
fs.unlink(tmp_path, function() {});
res.status(400).send(false);
return true;
}
icon.cover(72, 72).getBuffer(jimp.MIME_PNG, function(err2, buffer) {
countlyFs.saveData("appimages", target_path, buffer, {id: req.body.app_image_id + ".png", writeMode: "overwrite"}, function() {
fs.unlink(tmp_path, function() {});
res.send("appimages/" + req.body.app_image_id + ".png");
countlyDb.collection('apps').updateOne({_id: countlyDb.ObjectID(req.body.app_image_id)}, {'$set': {'has_image': true}}, function() {});
});
}); // save
const icon = await jimp.Jimp.read(tmp_path);
const buffer = await icon.cover({h: 72, w: 72}).getBuffer(jimp.JimpMime.png);
countlyFs.saveData("appimages", target_path, buffer, {id: req.body.app_image_id + ".png", writeMode: "overwrite"}, function() {
res.send("appimages/" + req.body.app_image_id + ".png");
countlyDb.collection('apps').updateOne({_id: countlyDb.ObjectID(req.body.app_image_id)}, {'$set': {'has_image': true}}, function() {});
});
}
catch (e) {
console.log(e.stack);
console.log("Problem uploading app icon", e);
res.status(400).send(false);
}
fs.unlink(tmp_path, function() {});

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.
});
});

Expand Down Expand Up @@ -1694,23 +1687,19 @@
}
plugins.callMethod("iconUpload", {req: req, res: res, next: next, data: req.body});
try {
jimp.read(tmp_path, function(err, icon) {
if (err) {
console.log(err, err.stack);
}
icon.cover(72, 72).getBuffer(jimp.MIME_PNG, function(err2, buffer) {
countlyFs.saveData("memberimages", target_path, buffer, {id: req.body.member_image_id + ".png", writeMode: "overwrite"}, function() {
fs.unlink(tmp_path, function() {});
countlyDb.collection('members').updateOne({_id: countlyDb.ObjectID(req.body.member_image_id + "")}, {'$set': {'member_image': "memberimages/" + req.body.member_image_id + ".png"}}, function() {
res.send("memberimages/" + req.body.member_image_id + ".png");
});
});
}); // save
const icon = await jimp.Jimp.read(tmp_path);
const buffer = await icon.cover({h: 72, w: 72}).getBuffer(jimp.JimpMime.png);
countlyFs.saveData("memberimages", target_path, buffer, {id: req.body.member_image_id + ".png", writeMode: "overwrite"}, function() {
countlyDb.collection('members').updateOne({_id: countlyDb.ObjectID(req.body.member_image_id + "")}, {'$set': {'member_image': "memberimages/" + req.body.member_image_id + ".png"}}, function() {
res.send("memberimages/" + req.body.member_image_id + ".png");
});
});
}
catch (e) {
console.log(e.stack);
console.log("Problem uploading member icon", e);
res.status(400).send(false);
}
fs.unlink(tmp_path, function() {});

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.
});
});

Expand Down
Loading
Loading