Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fastify-raw-body

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-raw-body - npm Package Compare versions

Comparing version 4.1.0 to 4.1.1

test/route-limit.test.js

4

package.json
{
"name": "fastify-raw-body",
"version": "4.1.0",
"version": "4.1.1",
"description": "Request raw body",

@@ -37,3 +37,3 @@ "main": "plugin.js",

"tap": "^16.2.0",
"tsd": "^0.23.0"
"tsd": "^0.24.1"
},

@@ -40,0 +40,0 @@ "dependencies": {

@@ -59,5 +59,7 @@ 'use strict'

function preparsingRawBody (request, reply, payload, done) {
const applyLimit = request.context._parserOptions.limit ?? fastify.initialConfig.bodyLimit
getRawBody(runFirst ? request.raw : payload, {
length: null, // avoid content lenght check: fastify will do it
limit: fastify.initialConfig.bodyLimit, // limit to avoid memory leak or DoS
limit: applyLimit, // limit to avoid memory leak or DoS
encoding

@@ -69,3 +71,7 @@ }, function (err, string) {

* so the request object will not have any
* `body` parsed
* `body` parsed.
*
* The preparsingRawBody decorates the request
* meanwhile the `payload` is processed by
* the fastify server.
*/

@@ -89,6 +95,7 @@ return

try {
var json = secureJson.parse(body.toString('utf8'), {
const json = secureJson.parse(body.toString('utf8'), {
protoAction: fastify.initialConfig.onProtoPoisoning,
constructorAction: fastify.initialConfig.onConstructorPoisoning
})
done(null, json)
} catch (err) {

@@ -98,3 +105,2 @@ err.statusCode = 400

}
done(null, json)
}

@@ -101,0 +107,0 @@ }

@@ -418,2 +418,8 @@ 'use strict'

t.equal(res.statusCode, 413)
t.same(res.json(), {
statusCode: 413,
code: 'FST_ERR_CTP_BODY_TOO_LARGE',
error: 'Payload Too Large',
message: 'Request body is too large'
})
})

@@ -420,0 +426,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc