From 10aa58e53b5bb7ef322d9f95c1a8b8850817cc35 Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 18 Sep 2025 11:38:19 +0100 Subject: [PATCH 1/5] disable available dependencies by default, only allow when ALLOW_BUILTIN_DEP is set to true --- CONTRIBUTING.md | 5 +++-- docker/.env.example | 1 + docker/docker-compose-queue-prebuilt.yml | 6 ++++-- docker/docker-compose.yml | 3 ++- docker/worker/.env.example | 1 + docker/worker/docker-compose.yml | 3 ++- packages/components/src/utils.ts | 2 +- packages/server/.env.example | 1 + packages/server/src/commands/base.ts | 4 +++- 9 files changed, 18 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bda3b5e119b..90a7acafb76 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -130,8 +130,9 @@ Flowise support different environment variables to configure your instance. You | LOG_PATH | Location where log files are stored | String | `your-path/Flowise/logs` | | LOG_LEVEL | Different levels of logs | Enum String: `error`, `info`, `verbose`, `debug` | `info` | | LOG_JSON_SPACES | Spaces to beautify JSON logs | | 2 | -| TOOL_FUNCTION_BUILTIN_DEP | NodeJS built-in modules to be used for Tool Function | String | | -| TOOL_FUNCTION_EXTERNAL_DEP | External modules to be used for Tool Function | String | | +| TOOL_FUNCTION_BUILTIN_DEP | NodeJS built-in modules to be used for Custom Tool or Function | String | | +| TOOL_FUNCTION_EXTERNAL_DEP | External modules to be used for Custom Tool or Function | String | | +| ALLOW_BUILTIN_DEP | Allow project dependencies to be used for Custom Tool or Function | Boolean | false | | DATABASE_TYPE | Type of database to store the flowise data | Enum String: `sqlite`, `mysql`, `postgres` | `sqlite` | | DATABASE_PATH | Location where database is saved (When DATABASE_TYPE is sqlite) | String | `your-home-dir/.flowise` | | DATABASE_HOST | Host URL or IP address (When DATABASE_TYPE is not sqlite) | String | | diff --git a/docker/.env.example b/docker/.env.example index 7e72923e926..07b65a45d95 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -39,6 +39,7 @@ LOG_PATH=/root/.flowise/logs # LOG_LEVEL=info #(error | warn | info | verbose | debug) # TOOL_FUNCTION_BUILTIN_DEP=crypto,fs # TOOL_FUNCTION_EXTERNAL_DEP=moment,lodash +# ALLOW_BUILTIN_DEP=false ############################################################################################################ diff --git a/docker/docker-compose-queue-prebuilt.yml b/docker/docker-compose-queue-prebuilt.yml index 3777cd9d180..0115af1b292 100644 --- a/docker/docker-compose-queue-prebuilt.yml +++ b/docker/docker-compose-queue-prebuilt.yml @@ -47,9 +47,10 @@ services: - LOG_PATH=${LOG_PATH} - LOG_LEVEL=${LOG_LEVEL} - # CUSTOM TOOL DEPENDENCIES + # CUSTOM TOOL/FUNCTION DEPENDENCIES - TOOL_FUNCTION_BUILTIN_DEP=${TOOL_FUNCTION_BUILTIN_DEP} - TOOL_FUNCTION_EXTERNAL_DEP=${TOOL_FUNCTION_EXTERNAL_DEP} + - ALLOW_BUILTIN_DEP=${ALLOW_BUILTIN_DEP} # STORAGE - STORAGE_TYPE=${STORAGE_TYPE} @@ -183,9 +184,10 @@ services: - LOG_PATH=${LOG_PATH} - LOG_LEVEL=${LOG_LEVEL} - # CUSTOM TOOL DEPENDENCIES + # CUSTOM TOOL/FUNCTION DEPENDENCIES - TOOL_FUNCTION_BUILTIN_DEP=${TOOL_FUNCTION_BUILTIN_DEP} - TOOL_FUNCTION_EXTERNAL_DEP=${TOOL_FUNCTION_EXTERNAL_DEP} + - ALLOW_BUILTIN_DEP=${ALLOW_BUILTIN_DEP} # STORAGE - STORAGE_TYPE=${STORAGE_TYPE} diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 3f7529983db..5b476977b03 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -32,9 +32,10 @@ services: - LOG_PATH=${LOG_PATH} - LOG_LEVEL=${LOG_LEVEL} - # CUSTOM TOOL DEPENDENCIES + # CUSTOM TOOL/FUNCTION DEPENDENCIES - TOOL_FUNCTION_BUILTIN_DEP=${TOOL_FUNCTION_BUILTIN_DEP} - TOOL_FUNCTION_EXTERNAL_DEP=${TOOL_FUNCTION_EXTERNAL_DEP} + - ALLOW_BUILTIN_DEP=${ALLOW_BUILTIN_DEP} # STORAGE - STORAGE_TYPE=${STORAGE_TYPE} diff --git a/docker/worker/.env.example b/docker/worker/.env.example index 0540cf76880..926224ed247 100644 --- a/docker/worker/.env.example +++ b/docker/worker/.env.example @@ -39,6 +39,7 @@ LOG_PATH=/root/.flowise/logs # LOG_LEVEL=info #(error | warn | info | verbose | debug) # TOOL_FUNCTION_BUILTIN_DEP=crypto,fs # TOOL_FUNCTION_EXTERNAL_DEP=moment,lodash +# ALLOW_BUILTIN_DEP=false ############################################################################################################ diff --git a/docker/worker/docker-compose.yml b/docker/worker/docker-compose.yml index 4a8924dd23d..703dfed7b48 100644 --- a/docker/worker/docker-compose.yml +++ b/docker/worker/docker-compose.yml @@ -32,9 +32,10 @@ services: - LOG_PATH=${LOG_PATH} - LOG_LEVEL=${LOG_LEVEL} - # CUSTOM TOOL DEPENDENCIES + # CUSTOM TOOL/FUNCTION DEPENDENCIES - TOOL_FUNCTION_BUILTIN_DEP=${TOOL_FUNCTION_BUILTIN_DEP} - TOOL_FUNCTION_EXTERNAL_DEP=${TOOL_FUNCTION_EXTERNAL_DEP} + - ALLOW_BUILTIN_DEP=${ALLOW_BUILTIN_DEP} # STORAGE - STORAGE_TYPE=${STORAGE_TYPE} diff --git a/packages/components/src/utils.ts b/packages/components/src/utils.ts index 7b0c4a25d5f..d07bbd06032 100644 --- a/packages/components/src/utils.ts +++ b/packages/components/src/utils.ts @@ -1543,7 +1543,7 @@ export const executeJavaScriptCode = async ( ? defaultAllowBuiltInDep.concat(process.env.TOOL_FUNCTION_BUILTIN_DEP.split(',')) : defaultAllowBuiltInDep const externalDeps = process.env.TOOL_FUNCTION_EXTERNAL_DEP ? process.env.TOOL_FUNCTION_EXTERNAL_DEP.split(',') : [] - const deps = availableDependencies.concat(externalDeps) + const deps = process.env.ALLOW_BUILTIN_DEP === 'true' ? availableDependencies.concat(externalDeps) : externalDeps const defaultNodeVMOptions: any = { console: 'inherit', diff --git a/packages/server/.env.example b/packages/server/.env.example index fe47880b00e..2c9fcce913f 100644 --- a/packages/server/.env.example +++ b/packages/server/.env.example @@ -39,6 +39,7 @@ PORT=3000 # LOG_LEVEL=info #(error | warn | info | verbose | debug) # TOOL_FUNCTION_BUILTIN_DEP=crypto,fs # TOOL_FUNCTION_EXTERNAL_DEP=moment,lodash +# ALLOW_BUILTIN_DEP=false ############################################################################################################ diff --git a/packages/server/src/commands/base.ts b/packages/server/src/commands/base.ts index bdffb8f620e..cc40e367f25 100644 --- a/packages/server/src/commands/base.ts +++ b/packages/server/src/commands/base.ts @@ -22,6 +22,7 @@ export abstract class BaseCommand extends Command { LOG_LEVEL: Flags.string(), TOOL_FUNCTION_BUILTIN_DEP: Flags.string(), TOOL_FUNCTION_EXTERNAL_DEP: Flags.string(), + ALLOW_BUILTIN_DEP: Flags.string(), NUMBER_OF_PROXIES: Flags.string(), DATABASE_TYPE: Flags.string(), DATABASE_PATH: Flags.string(), @@ -143,9 +144,10 @@ export abstract class BaseCommand extends Command { if (flags.LOG_PATH) process.env.LOG_PATH = flags.LOG_PATH if (flags.LOG_LEVEL) process.env.LOG_LEVEL = flags.LOG_LEVEL - // Tool functions + // Custom tool/function dependencies if (flags.TOOL_FUNCTION_BUILTIN_DEP) process.env.TOOL_FUNCTION_BUILTIN_DEP = flags.TOOL_FUNCTION_BUILTIN_DEP if (flags.TOOL_FUNCTION_EXTERNAL_DEP) process.env.TOOL_FUNCTION_EXTERNAL_DEP = flags.TOOL_FUNCTION_EXTERNAL_DEP + if (flags.ALLOW_BUILTIN_DEP) process.env.ALLOW_BUILTIN_DEP = flags.ALLOW_BUILTIN_DEP // Database config if (flags.DATABASE_TYPE) process.env.DATABASE_TYPE = flags.DATABASE_TYPE From 7f93ab9a911df7ba210c91dfc0ba3f8a74cad721 Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 28 Sep 2025 13:33:42 +0100 Subject: [PATCH 2/5] update contributing.md --- CONTRIBUTING.md | 79 +++++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 90a7acafb76..194bf66235d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -120,45 +120,46 @@ Flowise has 3 different modules in a single mono repository. Flowise support different environment variables to configure your instance. You can specify the following variables in the `.env` file inside `packages/server` folder. Read [more](https://docs.flowiseai.com/environment-variables) -| Variable | Description | Type | Default | -| ---------------------------------- | -------------------------------------------------------------------------------- | ------------------------------------------------ | ----------------------------------- | -| PORT | The HTTP port Flowise runs on | Number | 3000 | -| CORS_ORIGINS | The allowed origins for all cross-origin HTTP calls | String | | -| IFRAME_ORIGINS | The allowed origins for iframe src embedding | String | | -| FLOWISE_FILE_SIZE_LIMIT | Upload File Size Limit | String | 50mb | -| DEBUG | Print logs from components | Boolean | | -| LOG_PATH | Location where log files are stored | String | `your-path/Flowise/logs` | -| LOG_LEVEL | Different levels of logs | Enum String: `error`, `info`, `verbose`, `debug` | `info` | -| LOG_JSON_SPACES | Spaces to beautify JSON logs | | 2 | -| TOOL_FUNCTION_BUILTIN_DEP | NodeJS built-in modules to be used for Custom Tool or Function | String | | -| TOOL_FUNCTION_EXTERNAL_DEP | External modules to be used for Custom Tool or Function | String | | -| ALLOW_BUILTIN_DEP | Allow project dependencies to be used for Custom Tool or Function | Boolean | false | -| DATABASE_TYPE | Type of database to store the flowise data | Enum String: `sqlite`, `mysql`, `postgres` | `sqlite` | -| DATABASE_PATH | Location where database is saved (When DATABASE_TYPE is sqlite) | String | `your-home-dir/.flowise` | -| DATABASE_HOST | Host URL or IP address (When DATABASE_TYPE is not sqlite) | String | | -| DATABASE_PORT | Database port (When DATABASE_TYPE is not sqlite) | String | | -| DATABASE_USER | Database username (When DATABASE_TYPE is not sqlite) | String | | -| DATABASE_PASSWORD | Database password (When DATABASE_TYPE is not sqlite) | String | | -| DATABASE_NAME | Database name (When DATABASE_TYPE is not sqlite) | String | | -| DATABASE_SSL_KEY_BASE64 | Database SSL client cert in base64 (takes priority over DATABASE_SSL) | Boolean | false | -| DATABASE_SSL | Database connection overssl (When DATABASE_TYPE is postgre) | Boolean | false | -| SECRETKEY_PATH | Location where encryption key (used to encrypt/decrypt credentials) is saved | String | `your-path/Flowise/packages/server` | -| FLOWISE_SECRETKEY_OVERWRITE | Encryption key to be used instead of the key stored in SECRETKEY_PATH | String | | -| MODEL_LIST_CONFIG_JSON | File path to load list of models from your local config file | String | `/your_model_list_config_file_path` | -| STORAGE_TYPE | Type of storage for uploaded files. default is `local` | Enum String: `s3`, `local`, `gcs` | `local` | -| BLOB_STORAGE_PATH | Local folder path where uploaded files are stored when `STORAGE_TYPE` is `local` | String | `your-home-dir/.flowise/storage` | -| S3_STORAGE_BUCKET_NAME | Bucket name to hold the uploaded files when `STORAGE_TYPE` is `s3` | String | | -| S3_STORAGE_ACCESS_KEY_ID | AWS Access Key | String | | -| S3_STORAGE_SECRET_ACCESS_KEY | AWS Secret Key | String | | -| S3_STORAGE_REGION | Region for S3 bucket | String | | -| S3_ENDPOINT_URL | Custom Endpoint for S3 | String | | -| S3_FORCE_PATH_STYLE | Set this to true to force the request to use path-style addressing | Boolean | false | -| GOOGLE_CLOUD_STORAGE_PROJ_ID | The GCP project id for cloud storage & logging when `STORAGE_TYPE` is `gcs` | String | | -| GOOGLE_CLOUD_STORAGE_CREDENTIAL | The credential key file path when `STORAGE_TYPE` is `gcs` | String | | -| GOOGLE_CLOUD_STORAGE_BUCKET_NAME | Bucket name to hold the uploaded files when `STORAGE_TYPE` is `gcs` | String | | -| GOOGLE_CLOUD_UNIFORM_BUCKET_ACCESS | Enable uniform bucket level access when `STORAGE_TYPE` is `gcs` | Boolean | true | -| SHOW_COMMUNITY_NODES | Show nodes created by community | Boolean | | -| DISABLED_NODES | Hide nodes from UI (comma separated list of node names) | String | | +| Variable | Description | Type | Default | +| ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | ----------------------------------- | +| PORT | The HTTP port Flowise runs on | Number | 3000 | +| CORS_ORIGINS | The allowed origins for all cross-origin HTTP calls | String | | +| IFRAME_ORIGINS | The allowed origins for iframe src embedding | String | | +| FLOWISE_FILE_SIZE_LIMIT | Upload File Size Limit | String | 50mb | +| DEBUG | Print logs from components | Boolean | | +| LOG_PATH | Location where log files are stored | String | `your-path/Flowise/logs` | +| LOG_LEVEL | Different levels of logs | Enum String: `error`, `info`, `verbose`, `debug` | `info` | +| LOG_JSON_SPACES | Spaces to beautify JSON logs | | 2 | +| TOOL_FUNCTION_BUILTIN_DEP | NodeJS built-in modules to be used for Custom Tool or Function | String | | +| TOOL_FUNCTION_EXTERNAL_DEP | External modules to be used for Custom Tool or Function | String | | +| ALLOW_BUILTIN_DEP | Allow project dependencies to be used for Custom Tool or Function | Boolean | false | +| DATABASE_TYPE | Type of database to store the flowise data | Enum String: `sqlite`, `mysql`, `postgres` | `sqlite` | +| DATABASE_PATH | Location where database is saved (When DATABASE_TYPE is sqlite) | String | `your-home-dir/.flowise` | +| DATABASE_HOST | Host URL or IP address (When DATABASE_TYPE is not sqlite) | String | | +| DATABASE_PORT | Database port (When DATABASE_TYPE is not sqlite) | String | | +| DATABASE_USER | Database username (When DATABASE_TYPE is not sqlite) | String | | +| DATABASE_PASSWORD | Database password (When DATABASE_TYPE is not sqlite) | String | | +| DATABASE_NAME | Database name (When DATABASE_TYPE is not sqlite) | String | | +| DATABASE_SSL_KEY_BASE64 | Database SSL client cert in base64 (takes priority over DATABASE_SSL) | Boolean | false | +| DATABASE_SSL | Database connection overssl (When DATABASE_TYPE is postgre) | Boolean | false | +| SECRETKEY_PATH | Location where encryption key (used to encrypt/decrypt credentials) is saved | String | `your-path/Flowise/packages/server` | +| FLOWISE_SECRETKEY_OVERWRITE | Encryption key to be used instead of the key stored in SECRETKEY_PATH | String | | +| MODEL_LIST_CONFIG_JSON | File path to load list of models from your local config file | String | `/your_model_list_config_file_path` | +| STORAGE_TYPE | Type of storage for uploaded files. default is `local` | Enum String: `s3`, `local`, `gcs` | `local` | +| BLOB_STORAGE_PATH | Local folder path where uploaded files are stored when `STORAGE_TYPE` is `local` | String | `your-home-dir/.flowise/storage` | +| S3_STORAGE_BUCKET_NAME | Bucket name to hold the uploaded files when `STORAGE_TYPE` is `s3` | String | | +| S3_STORAGE_ACCESS_KEY_ID | AWS Access Key | String | | +| S3_STORAGE_SECRET_ACCESS_KEY | AWS Secret Key | String | | +| S3_STORAGE_REGION | Region for S3 bucket | String | | +| S3_ENDPOINT_URL | Custom Endpoint for S3 | String | | +| S3_FORCE_PATH_STYLE | Set this to true to force the request to use path-style addressing | Boolean | false | +| GOOGLE_CLOUD_STORAGE_PROJ_ID | The GCP project id for cloud storage & logging when `STORAGE_TYPE` is `gcs` | String | | +| GOOGLE_CLOUD_STORAGE_CREDENTIAL | The credential key file path when `STORAGE_TYPE` is `gcs` | String | | +| GOOGLE_CLOUD_STORAGE_BUCKET_NAME | Bucket name to hold the uploaded files when `STORAGE_TYPE` is `gcs` | String | | +| GOOGLE_CLOUD_UNIFORM_BUCKET_ACCESS | Enable uniform bucket level access when `STORAGE_TYPE` is `gcs` | Boolean | true | +| SHOW_COMMUNITY_NODES | Show nodes created by community | Boolean | | +| DISABLED_NODES | Hide nodes from UI (comma separated list of node names) | String | | +| TRUST_PROXY | Configure proxy trust settings for proper IP detection. Values: 'true' (trust all), 'false' (disable), number (hop count), or Express proxy values (e.g., 'loopback', 'linklocal', 'uniquelocal', IP addresses). [Learn More](https://expressjs.com/en/guide/behind-proxies.html) | Boolean/String/Number | true | You can also specify the env variables when using `npx`. For example: From 8972cf8c148832edc58a4e2db5bbb969fefda191 Mon Sep 17 00:00:00 2001 From: Henry Heng Date: Sun, 28 Sep 2025 13:34:29 +0100 Subject: [PATCH 3/5] update pnpm lock --- pnpm-lock.yaml | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 61da213b98a..d7cdd51e0bb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -977,6 +977,9 @@ importers: '@tabler/icons-react': specifier: ^3.30.0 version: 3.31.0(react@18.2.0) + '@tiptap/extension-code-block-lowlight': + specifier: ^3.4.3 + version: 3.4.3(@tiptap/core@2.12.0(@tiptap/pm@2.12.0))(@tiptap/extension-code-block@2.12.0(@tiptap/core@2.12.0(@tiptap/pm@2.12.0))(@tiptap/pm@2.12.0))(@tiptap/pm@2.12.0)(highlight.js@11.11.1)(lowlight@3.3.0) '@tiptap/extension-mention': specifier: ^2.11.5 version: 2.12.0(@tiptap/core@2.12.0(@tiptap/pm@2.12.0))(@tiptap/pm@2.12.0)(@tiptap/suggestion@2.12.0(@tiptap/core@2.12.0(@tiptap/pm@2.12.0))(@tiptap/pm@2.12.0)) @@ -1037,6 +1040,9 @@ importers: lodash: specifier: ^4.17.21 version: 4.17.21 + lowlight: + specifier: ^3.3.0 + version: 3.3.0 moment: specifier: ^2.29.3 version: 2.30.1 @@ -7135,6 +7141,15 @@ packages: peerDependencies: '@tiptap/core': ^2.7.0 + '@tiptap/extension-code-block-lowlight@3.4.3': + resolution: { integrity: sha512-d3vEhv2cLDdWL2unqRkF0LkGEDEm/pJCWZwSjqzYFe3vrTEsTExorpwZoVV8i9uX/DPG4AdM+mf3hLK9L5FZoA== } + peerDependencies: + '@tiptap/core': ^3.4.3 + '@tiptap/extension-code-block': ^3.4.3 + '@tiptap/pm': ^3.4.3 + highlight.js: ^11 + lowlight: ^2 || ^3 + '@tiptap/extension-code-block@2.12.0': resolution: { integrity: sha512-1D7cYAjgxEFHdfC/35Ooi4GqWKB5sszbW8iI7N16XILNln26xb0d5KflXqYrwr9CN/ZnZoCl2o6YsP7xEObcZA== } peerDependencies: @@ -11595,6 +11610,10 @@ packages: highlight.js@10.7.3: resolution: { integrity: sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A== } + highlight.js@11.11.1: + resolution: { integrity: sha512-Xwwo44whKBVCYoliBQwaPvtd/2tYFkRQtXDWj1nackaV2JPXx3L0+Jvd8/qCJ2p+ML0/XVkJ2q+Mr+UVdpJK5w== } + engines: { node: '>=12.0.0' } + history@5.3.0: resolution: { integrity: sha512-ZqaKwjjrAYUYfLG+htGaIIZ4nioX2L70ZUMIFysS3xvBsSG4x/n1V6TXV3N8ZYNuFGlDirFg32T7B6WOUPDYcQ== } @@ -13090,6 +13109,9 @@ packages: lowlight@1.20.0: resolution: { integrity: sha512-8Ktj+prEb1RoCPkEOrPMYUN/nCggB7qAWe3a7OpMjWQkh3l2RD5wKRQ+o8Q8YuI9RG/xs95waaI/E6ym/7NsTw== } + lowlight@3.3.0: + resolution: { integrity: sha512-0JNhgFoPvP6U6lE/UdVsSq99tn6DhjjpAj5MxG49ewd2mOBVtwWYIT8ClyABhq198aXXODMU6Ox8DrGy/CpTZQ== } + lru-cache@10.2.0: resolution: { integrity: sha512-2bIM8x+VAf6JT4bKAljS1qUWgMsqZRPGJS6FSahIMPVvctcNhyVp7AJu7quxOW9jwkryBReKZY5tY5JYv2n/7Q== } engines: { node: 14 || >=16.14 } @@ -27410,6 +27432,14 @@ snapshots: dependencies: '@tiptap/core': 2.12.0(@tiptap/pm@2.12.0) + '@tiptap/extension-code-block-lowlight@3.4.3(@tiptap/core@2.12.0(@tiptap/pm@2.12.0))(@tiptap/extension-code-block@2.12.0(@tiptap/core@2.12.0(@tiptap/pm@2.12.0))(@tiptap/pm@2.12.0))(@tiptap/pm@2.12.0)(highlight.js@11.11.1)(lowlight@3.3.0)': + dependencies: + '@tiptap/core': 2.12.0(@tiptap/pm@2.12.0) + '@tiptap/extension-code-block': 2.12.0(@tiptap/core@2.12.0(@tiptap/pm@2.12.0))(@tiptap/pm@2.12.0) + '@tiptap/pm': 2.12.0 + highlight.js: 11.11.1 + lowlight: 3.3.0 + '@tiptap/extension-code-block@2.12.0(@tiptap/core@2.12.0(@tiptap/pm@2.12.0))(@tiptap/pm@2.12.0)': dependencies: '@tiptap/core': 2.12.0(@tiptap/pm@2.12.0) @@ -33109,6 +33139,8 @@ snapshots: highlight.js@10.7.3: {} + highlight.js@11.11.1: {} + history@5.3.0: dependencies: '@babel/runtime': 7.24.0 @@ -35299,6 +35331,12 @@ snapshots: fault: 1.0.4 highlight.js: 10.7.3 + lowlight@3.3.0: + dependencies: + '@types/hast': 3.0.4 + devlop: 1.1.0 + highlight.js: 11.11.1 + lru-cache@10.2.0: {} lru-cache@4.1.5: @@ -41803,3 +41841,4 @@ snapshots: react: 18.2.0 zwitch@2.0.4: {} + From db4eb056e4265660b6f2242283428fd0eefaffb5 Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 28 Sep 2025 13:35:12 +0100 Subject: [PATCH 4/5] Enhance security by adding secure wrappers for Axios and Node Fetch in utils.ts, and update dependency handling to include default external dependencies. --- packages/components/src/utils.ts | 43 ++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/packages/components/src/utils.ts b/packages/components/src/utils.ts index 22b2b7caeff..6405480e808 100644 --- a/packages/components/src/utils.ts +++ b/packages/components/src/utils.ts @@ -18,7 +18,7 @@ import { TextSplitter } from 'langchain/text_splitter' import { DocumentLoader } from 'langchain/document_loaders/base' import { NodeVM } from '@flowiseai/nodevm' import { Sandbox } from '@e2b/code-interpreter' -import { secureFetch, checkDenyList } from './httpSecurity' +import { secureFetch, checkDenyList, secureAxiosRequest } from './httpSecurity' import JSON5 from 'json5' export const numberOrExpressionRegex = '^(\\d+\\.?\\d*|{{.*}})$' //return true if string consists only numbers OR expression {{}} @@ -85,7 +85,6 @@ export const availableDependencies = [ '@upstash/redis', '@zilliz/milvus2-sdk-node', 'apify-client', - 'axios', 'cheerio', 'chromadb', 'cohere-ai', @@ -103,10 +102,8 @@ export const availableDependencies = [ 'linkifyjs', 'lunary', 'mammoth', - 'moment', 'mongodb', 'mysql2', - 'node-fetch', 'node-html-markdown', 'notion-to-md', 'openai', @@ -122,6 +119,8 @@ export const availableDependencies = [ 'weaviate-ts-client' ] +const defaultAllowExternalDependencies = ['axios', 'moment', 'node-fetch'] + export const defaultAllowBuiltInDep = [ 'assert', 'buffer', @@ -1547,14 +1546,44 @@ export const executeJavaScriptCode = async ( ? defaultAllowBuiltInDep.concat(process.env.TOOL_FUNCTION_BUILTIN_DEP.split(',')) : defaultAllowBuiltInDep const externalDeps = process.env.TOOL_FUNCTION_EXTERNAL_DEP ? process.env.TOOL_FUNCTION_EXTERNAL_DEP.split(',') : [] - const deps = process.env.ALLOW_BUILTIN_DEP === 'true' ? availableDependencies.concat(externalDeps) : externalDeps + let deps = process.env.ALLOW_BUILTIN_DEP === 'true' ? availableDependencies.concat(externalDeps) : externalDeps + deps.push(...defaultAllowExternalDependencies) + deps = [...new Set(deps)] + + // Create secure wrappers for HTTP libraries + const secureWrappers: ICommonObject = {} + + // Axios + const secureAxiosWrapper = async (config: any) => { + return await secureAxiosRequest(config) + } + secureAxiosWrapper.get = async (url: string, config: any = {}) => secureAxiosWrapper({ ...config, method: 'GET', url }) + secureAxiosWrapper.post = async (url: string, data: any, config: any = {}) => + secureAxiosWrapper({ ...config, method: 'POST', url, data }) + secureAxiosWrapper.put = async (url: string, data: any, config: any = {}) => + secureAxiosWrapper({ ...config, method: 'PUT', url, data }) + secureAxiosWrapper.delete = async (url: string, config: any = {}) => secureAxiosWrapper({ ...config, method: 'DELETE', url }) + secureAxiosWrapper.patch = async (url: string, data: any, config: any = {}) => + secureAxiosWrapper({ ...config, method: 'PATCH', url, data }) + + secureWrappers['axios'] = secureAxiosWrapper + + // Node Fetch + const secureNodeFetch = async (url: string, options: any = {}) => { + return await secureFetch(url, options) + } + secureWrappers['node-fetch'] = secureNodeFetch const defaultNodeVMOptions: any = { console: 'inherit', sandbox, require: { - external: { modules: deps }, - builtin: builtinDeps + external: { + modules: deps, + transitive: false // Prevent transitive dependencies + }, + builtin: builtinDeps, + mock: secureWrappers // Replace HTTP libraries with secure wrappers }, eval: false, wasm: false, From 9402ed324d96977d115877f7ba71122c7a1ec524 Mon Sep 17 00:00:00 2001 From: Henry Heng Date: Sun, 28 Sep 2025 13:37:15 +0100 Subject: [PATCH 5/5] Fix formatting in pnpm-lock.yaml --- pnpm-lock.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d7cdd51e0bb..f843fb62716 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -41841,4 +41841,3 @@ snapshots: react: 18.2.0 zwitch@2.0.4: {} -