genediazjr / disinfect Goto Github PK
View Code? Open in Web Editor NEWRequest query, payload, and params sanitization for Hapi
License: MIT License
Request query, payload, and params sanitization for Hapi
License: MIT License
The following deprecations are present:
warning disinfect > [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning disinfect > [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning disinfect > joi > [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning disinfect > joi > [email protected]: This module has moved and is now available at @hapi/topo. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
warning disinfect > joi > topo > [email protected]: This module has moved and is now available at @hapi/hoek. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.```
Referring to hapijs/hapi#771
The returned result is malformed somewhere when setting output to stream
and parse to true
Hi,
I was testing this plugin to sanitize my payload. However is seems like any array contained in my payload is cast into a string.
Example payload :
{ "text1": "test a", "text2": "test b", "array": [ { "text3": "test c", "text4": "test d" }, { "text3": "test e", "text4": "test f" } ] }
Result :
{"text1":"test a","text2":"test b","array":"[object Object],[object Object]"}
Hi, I have an outstanding pull request that upgrades this to HAPI-17
I am using hapi server and I want to use joi header validation( for content-type: 'application/json') in my PUT method.
The problem comes when the user sends a valid json in payload and sends 'content-type' header with value 'text/css' or 'text/javascript'. On postAuth this payload as a stringified string goes to disinfect and it is throwing error.
TypeError: Cannot assign to read only property '0' of string
Because of this the request in not reaching to the joi validation, which is present at the route level.
It can be one of the edge cases. Ideally the purpose of disinfect is the sanitation of the request data and should not throw error.
I am also attaching the request curl
curl --location --request PUT 'http://localhost:3000/blogs/b1' \ --header 'Content-Type: text/css' \ --data-raw '{ "text1": "test a", "text2": "test b" }'
"error": { "code": "Internal Server Error", "message": "An internal server error occurred", "statusCode": 500, "trace": "TypeError: Cannot assign to read only property '0' of string '{ \"text1\": \"test a\", \"text2\": \"test b\" }'\n at Object.internals.sanitize (/Users/infinity/Desktop/myAppService/node_modules/disinfect/lib/index.js:37:26)\n at Object.internals.disinfect (/Users/infinity/Desktop/myAppService/node_modules/disinfect/lib/index.js:75:34)\n at /Users/infinity/Desktop/myAppService/node_modules/disinfect/lib/index.js:137:45\n at exports.Manager.execute (/Users/infinity/Desktop/myAppService/node_modules/@hapi/hapi/lib/toolkit.js:57:29)\n at Request._invoke (/Users/infinity/Desktop/myAppService/node_modules/@hapi/hapi/lib/request.js:391:55)\n at Request._lifecycle (/Users/infinity/Desktop/myAppService/node_modules/@hapi/hapi/lib/request.js:364:86)\n at processTicksAndRejections (internal/process/task_queues.js:97:5)\n at async Request._execute (/Users/infinity/Desktop/myAppService/node_modules/@hapi/hapi/lib/request.js:273:9)" }
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.