mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
✨ Allow to use built-in modules in Function-Nodes if configured
This commit is contained in:
@@ -100,6 +100,24 @@ export N8N_CUSTOM_EXTENSIONS="/home/jim/n8n/custom-nodes;/data/n8n/nodes"
|
||||
```
|
||||
|
||||
|
||||
## Use built-in modules in Function-Nodes
|
||||
|
||||
By default is it for security reasons not allowed to import modules in Function-Nodes.
|
||||
It is, however, possible to lift that restriction for built-in modules by setting the
|
||||
environment variable `NODE_FUNCTION_ALLOW_BUILTIN`.
|
||||
|
||||
```bash
|
||||
# Allows usage of all builtin modules
|
||||
export NODE_FUNCTION_ALLOW_BUILTIN=*
|
||||
|
||||
# Allows usage of only crypto
|
||||
export NODE_FUNCTION_ALLOW_BUILTIN=crypto
|
||||
|
||||
# Allows usage of only crypto and fs
|
||||
export NODE_FUNCTION_ALLOW_BUILTIN=crypto,fs
|
||||
```
|
||||
|
||||
|
||||
## Timezone
|
||||
|
||||
The timezone is set by default to "America/New_York". It gets for example used by the
|
||||
|
||||
@@ -59,14 +59,21 @@ export class Function implements INodeType {
|
||||
// By default use data from first item
|
||||
Object.assign(sandbox, sandbox.$item(0));
|
||||
|
||||
const vm = new NodeVM({
|
||||
const options = {
|
||||
console: 'inherit',
|
||||
sandbox,
|
||||
require: {
|
||||
external: false,
|
||||
builtin: [] as string[],
|
||||
root: './',
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (process.env.NODE_FUNCTION_ALLOW_BUILTIN) {
|
||||
options.require.builtin = process.env.NODE_FUNCTION_ALLOW_BUILTIN.split(',');
|
||||
}
|
||||
|
||||
const vm = new NodeVM(options);
|
||||
|
||||
// Get the code to execute
|
||||
const functionCode = this.getNodeParameter('functionCode', 0) as string;
|
||||
|
||||
@@ -64,14 +64,21 @@ export class FunctionItem implements INodeType {
|
||||
const dataProxy = this.getWorkflowDataProxy();
|
||||
Object.assign(sandbox, dataProxy);
|
||||
|
||||
const vm = new NodeVM({
|
||||
const options = {
|
||||
console: 'inherit',
|
||||
sandbox,
|
||||
require: {
|
||||
external: false,
|
||||
builtin: [] as string[],
|
||||
root: './',
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (process.env.NODE_FUNCTION_ALLOW_BUILTIN) {
|
||||
options.require.builtin = process.env.NODE_FUNCTION_ALLOW_BUILTIN.split(',');
|
||||
}
|
||||
|
||||
const vm = new NodeVM(options);
|
||||
|
||||
// Get the code to execute
|
||||
const functionCode = this.getNodeParameter('functionCode') as string;
|
||||
|
||||
Reference in New Issue
Block a user