1
1
mirror of https://github.com/n8n-io/n8n.git synced 2024-09-11 13:15:28 +03:00
n8n/patches/typedi@0.10.0.patch
कारतोफ्फेलस्क्रिप्ट™ d94c20ada5
fix(core): Prevent prototype pollution on injectable services (#6309)
This helps prevent classes from being tampered by external-hooks or community nodes
2023-05-26 18:03:06 +02:00

20 lines
1.4 KiB
Diff

diff --git a/cjs/container-instance.class.js b/cjs/container-instance.class.js
index e473b1e652aa0b6e7462f7ba93fcef2812483b20..1e406113d68c401ee170c997afb53e5f71edeee2 100644
--- a/cjs/container-instance.class.js
+++ b/cjs/container-instance.class.js
@@ -209,6 +209,7 @@ class ContainerInstance {
// this allows us to support javascript where we don't have decorators and emitted metadata about dependencies
// need to be injected, and user can use provided container to get instances he needs
params.push(this);
+ if (process.env.NODE_ENV === 'production') Object.freeze(constructableTargetType.prototype);
value = new constructableTargetType(...params);
// TODO: Calling this here, leads to infinite loop, because @Inject decorator registerds a handler
// TODO: which calls Container.get, which will check if the requested type has a value set and if not
@@ -234,6 +235,7 @@ class ContainerInstance {
*/
initializeParams(target, paramTypes) {
return paramTypes.map((paramType, index) => {
+ if (paramType === undefined) throw new ReferenceError('Cannot inject an `undefined` dependency. Possibly a circular dependency detected');
const paramHandler = container_class_1.Container.handlers.find(handler => {
/**
* @Inject()-ed values are stored as parameter handlers and they reference their target