Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@coolgk/formdata
Advanced tools
A http request form data parser (large file friendly) for 'application/json', 'application/x-www-form-urlencoded' and 'multipart/form-data'. It only parses form data when you ask for it.
a javascript / typescript module
npm install @coolgk/formdata
A http request form data parser (large file friendly) for 'application/json', 'application/x-www-form-urlencoded' and 'multipart/form-data'. It only parses form data when you ask for it.
Report bugs here: https://github.com/coolgk/node-utils/issues
<form method="POST" enctype="multipart/form-data">
<input type="text" name="name">
<input type="text" name="age">
<input type="file" name="photo">
<input type="file" name="photo">
<input type="file" name="id">
</form>
// express middleware
const app = require('express')();
const formdata = require('@coolgk/formdata');
app.use(formdata.express());
app.post('/id-only', async (request, response, next) => {
const post = await request.formdata.getData('id'); // upload 3 files but only parse 1, ignore others
console.log(post);
response.json(post);
// output
// {
// "name": "Tim",
// "age": "33",
// "id": {
// "error": null,
// "fieldname": "id",
// "filename": "test.txt",
// "encoding": "7bit",
// "mimetype": "text/plain",
// "size": 13,
// "path": "/tmp/151605931497716067xZGgxPUdNvoj"
// }
// }
});
app.post('/all-files', async (request, response, next) => {
const post = await request.formdata.getData(['id', 'photo']); // parse all files
console.log(post);
response.json(post);
// output
// {
// "name": "Tim",
// "age": "33",
// "photo": [
// {
// "error": null,
// "fieldname": "photo",
// "filename": "test.png",
// "encoding": "7bit",
// "mimetype": "image/png",
// "size": 604,
// "path": "/tmp/151605931497716067xZGgxPUdNvoj"
// },
// {
// "error": null,
// "fieldname": "photo",
// "filename": "test.svg",
// "encoding": "7bit",
// "mimetype": "image/svg+xml",
// "size": 2484,
// "path": "/tmp/151605931497916067EAUAa3yB4q42"
// }
// ],
// "id": {
// "error": null,
// "fieldname": "id",
// "filename": "test.txt",
// "encoding": "7bit",
// "mimetype": "text/plain",
// "size": 13,
// "path": "/tmp/151605931498016067zqZe6dlhidQ5"
// }
// }
});
app.listen(8888);
const { formData, express, getFormData, FormDataError } = require('@coolgk/formdata');
const http = require('http');
http.createServer(async (request, response) => {
const data = await getFormData(request, { fileFieldNames: ['id', 'photo'] });
// OR
// const formdata = formData(request);
// ... some middelware
// ... in some routes
// const data = formdata.getData(['id', 'photo']);
console.log(data);
response.end(JSON.stringify(data));
// {
// "name": "Tim",
// "age": "33",
// "photo": [
// {
// "error": null,
// "fieldname": "photo",
// "filename": "test.png",
// "encoding": "7bit",
// "mimetype": "image/png",
// "size": 604,
// "path": "/tmp/151605931497716067xZGgxPUdNvoj"
// },
// {
// "error": null,
// "fieldname": "photo",
// "filename": "test.svg",
// "encoding": "7bit",
// "mimetype": "image/svg+xml",
// "size": 2484,
// "path": "/tmp/151605931497916067EAUAa3yB4q42"
// }
// ],
// "id": {
// "error": null,
// "fieldname": "id",
// "filename": "test.txt",
// "encoding": "7bit",
// "mimetype": "text/plain",
// "size": 13,
// "path": "/tmp/151605931498016067zqZe6dlhidQ5"
// }
// }
}).listen(8888);
FAQs
A http request form data parser (large file friendly) for 'application/json', 'application/x-www-form-urlencoded' and 'multipart/form-data'. It only parses form data when you ask for it.
The npm package @coolgk/formdata receives a total of 1 weekly downloads. As such, @coolgk/formdata popularity was classified as not popular.
We found that @coolgk/formdata 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.