Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
multer-autoreap
Advanced tools
Connect middleware providing auto gc of tmp uploaded files by multer or any multipart middleware.
Express middleware for reaping uploaded files saved to disk by multer or any multipart middleware propagating the req.files object. The middleware will automatically remove any uploaded files left in their temporary location upon response end or close.
$ npm install multer-autoreap
as app middleware
const express = require('express');
const multer = require('multer');
const autoReap = require('multer-autoreap');
let app = express();
app.use(multer({ dest: '/tmp/' }));
app.use(autoReap);
...
or attaching to a route / router.
const express = require('express');
const router = express.Router();
const multer = require('multer');
const autoReap = require('multer-autoreap');
let app = express();
app.use(multer({ dest: '/tmp/' }));
app.route('/upload-a').post(autoReap, function(req, res, next) {
res.on('autoreap', function(file) {
console.log('auto-reaped: ', file);
});
res.send('ok');
});
router.use('/upload-b', autoReap, function(req, res, next) {
res.on('autoreap', function(file) {
console.log('auto-reaped: ', file);
});
res.send('ok');
});
...
Multer is an efficient multipart/form-data
handling middleware that uses busboy. Files encoded in a miltipart request body are piped to a temporary upload location (def: multer options dest ). This can have the effect of leaving open an attack vector where disk space can be consumed by these temporary files. Its prudent and generally good form to clean them up. While reap cleans based on age, multer-autoreap cleans them up as soon as the request is done.
autoReap.options = {
reapOnError: true
};
var autoReap = require('multer-autoreap');
autoReap.options.reapOnError = false;
The middleware will emit an 'autoreap' event on the Response object when removing files. The event will include the original file object from req.files[].
res.on('autoreap', function(reapedFile) {
console.log(reapedFile);
});
Please report any issues...
FAQs
Connect middleware providing auto gc of tmp uploaded files by multer or any multipart middleware.
We found that multer-autoreap demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.