mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 19:32:15 +00:00
fix(core): Don't use unbound context methods in code sandboxes (#11914)
This commit is contained in:
committed by
GitHub
parent
2c252b0b2d
commit
f6c0d045e9
@@ -121,7 +121,7 @@ export class AiTransform implements INodeType {
|
||||
sandbox.on(
|
||||
'output',
|
||||
workflowMode === 'manual'
|
||||
? this.sendMessageToUI
|
||||
? this.sendMessageToUI.bind(this)
|
||||
: CODE_ENABLE_STDOUT === 'true'
|
||||
? (...args) =>
|
||||
console.log(`[Workflow "${this.getWorkflow().id}"][Node "${node.name}"]`, ...args)
|
||||
|
||||
@@ -133,7 +133,7 @@ export class Code implements INodeType {
|
||||
sandbox.on(
|
||||
'output',
|
||||
workflowMode === 'manual'
|
||||
? this.sendMessageToUI
|
||||
? this.sendMessageToUI.bind(this)
|
||||
: CODE_ENABLE_STDOUT === 'true'
|
||||
? (...args) =>
|
||||
console.log(`[Workflow "${this.getWorkflow().id}"][Node "${node.name}"]`, ...args)
|
||||
|
||||
@@ -35,8 +35,8 @@ export function getSandboxContext(
|
||||
};
|
||||
return {
|
||||
// from NodeExecuteFunctions
|
||||
$getNodeParameter: this.getNodeParameter,
|
||||
$getWorkflowStaticData: this.getWorkflowStaticData,
|
||||
$getNodeParameter: this.getNodeParameter.bind(this),
|
||||
$getWorkflowStaticData: this.getWorkflowStaticData.bind(this),
|
||||
helpers,
|
||||
|
||||
// to bring in all $-prefixed vars and methods from WorkflowDataProxy
|
||||
|
||||
@@ -92,8 +92,8 @@ return items;`,
|
||||
|
||||
// Define the global objects for the custom function
|
||||
const sandbox = {
|
||||
getNodeParameter: this.getNodeParameter,
|
||||
getWorkflowStaticData: this.getWorkflowStaticData,
|
||||
getNodeParameter: this.getNodeParameter.bind(this),
|
||||
getWorkflowStaticData: this.getWorkflowStaticData.bind(this),
|
||||
helpers: this.helpers,
|
||||
items,
|
||||
// To be able to access data of other items
|
||||
@@ -157,7 +157,7 @@ return items;`,
|
||||
const vm = new NodeVM(options);
|
||||
|
||||
if (mode === 'manual') {
|
||||
vm.on('console.log', this.sendMessageToUI);
|
||||
vm.on('console.log', this.sendMessageToUI.bind(this));
|
||||
}
|
||||
|
||||
// Get the code to execute
|
||||
|
||||
@@ -113,8 +113,8 @@ return item;`,
|
||||
}
|
||||
item.binary = data;
|
||||
},
|
||||
getNodeParameter: this.getNodeParameter,
|
||||
getWorkflowStaticData: this.getWorkflowStaticData,
|
||||
getNodeParameter: this.getNodeParameter.bind(this),
|
||||
getWorkflowStaticData: this.getWorkflowStaticData.bind(this),
|
||||
helpers: this.helpers,
|
||||
item: item.json,
|
||||
getBinaryDataAsync: async (): Promise<IBinaryKeyData | undefined> => {
|
||||
@@ -165,7 +165,7 @@ return item;`,
|
||||
const vm = new NodeVM(options as unknown as NodeVMOptions);
|
||||
|
||||
if (mode === 'manual') {
|
||||
vm.on('console.log', this.sendMessageToUI);
|
||||
vm.on('console.log', this.sendMessageToUI.bind(this));
|
||||
}
|
||||
|
||||
// Get the code to execute
|
||||
|
||||
Reference in New Issue
Block a user