mirror of
https://github.com/plankanban/planka.git
synced 2025-07-19 13:19:44 +02:00
fix: Fix path traversal vulnerability
This commit is contained in:
parent
a7a98e6870
commit
8f4a250705
2 changed files with 3 additions and 7 deletions
|
@ -14,10 +14,6 @@ module.exports = {
|
||||||
regex: /^[0-9]+$/,
|
regex: /^[0-9]+$/,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
filename: {
|
|
||||||
type: 'string',
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
exits: {
|
exits: {
|
||||||
|
@ -54,14 +50,14 @@ module.exports = {
|
||||||
sails.config.custom.attachmentsPath,
|
sails.config.custom.attachmentsPath,
|
||||||
attachment.dirname,
|
attachment.dirname,
|
||||||
'thumbnails',
|
'thumbnails',
|
||||||
inputs.filename,
|
'cover-256.jpg',
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!fs.existsSync(filePath)) {
|
if (!fs.existsSync(filePath)) {
|
||||||
throw Errors.ATTACHMENT_NOT_FOUND;
|
throw Errors.ATTACHMENT_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.res.type(attachment.filename);
|
this.res.type('image/jpeg');
|
||||||
this.res.set('Cache-Control', 'private, max-age=900'); // TODO: move to config
|
this.res.set('Cache-Control', 'private, max-age=900'); // TODO: move to config
|
||||||
|
|
||||||
return exits.success(fs.createReadStream(filePath));
|
return exits.success(fs.createReadStream(filePath));
|
||||||
|
|
|
@ -80,7 +80,7 @@ module.exports.routes = {
|
||||||
skipAssets: false,
|
skipAssets: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
'GET /attachments/:id/download/thumbnails/:filename': {
|
'GET /attachments/:id/download/thumbnails/cover-256.jpg': {
|
||||||
action: 'attachments/download-thumbnail',
|
action: 'attachments/download-thumbnail',
|
||||||
skipAssets: false,
|
skipAssets: false,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue