mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-29 07:01:04 +03:00
Refractor/SecureZodSchemaParser (#4898)
* refactor: Implement SecureZodSchemaParser for safe Zod schema handling and add FilterParser for Supabase filters * Replaced direct Zod schema evaluation with SecureZodSchemaParser in StructuredOutputParserAdvanced and CustomTool. * Introduced FilterParser to safely handle Supabase filter strings, preventing arbitrary code execution. * Added new filterParser.ts file to encapsulate filter parsing logic. * Updated Supabase vector store to utilize the new FilterParser for RPC filters. * Created secureZodParser.ts for secure parsing of Zod schemas. * remove console log
This commit is contained in:
+2
-4
@@ -2,8 +2,8 @@ import { getBaseClasses, INode, INodeData, INodeParams } from '../../../src'
|
||||
import { BaseOutputParser } from '@langchain/core/output_parsers'
|
||||
import { StructuredOutputParser as LangchainStructuredOutputParser } from 'langchain/output_parsers'
|
||||
import { CATEGORY } from '../OutputParserHelpers'
|
||||
import { z } from 'zod'
|
||||
import { jsonrepair } from 'jsonrepair'
|
||||
import { SecureZodSchemaParser } from '../../../src/secureZodParser'
|
||||
|
||||
class AdvancedStructuredOutputParser implements INode {
|
||||
label: string
|
||||
@@ -57,10 +57,8 @@ class AdvancedStructuredOutputParser implements INode {
|
||||
const schemaString = nodeData.inputs?.exampleJson as string
|
||||
const autoFix = nodeData.inputs?.autofixParser as boolean
|
||||
|
||||
const zodSchemaFunction = new Function('z', `return ${schemaString}`)
|
||||
const zodSchema = zodSchemaFunction(z)
|
||||
|
||||
try {
|
||||
const zodSchema = SecureZodSchemaParser.parseZodSchema(schemaString)
|
||||
const structuredOutputParser = LangchainStructuredOutputParser.fromZodSchema(zodSchema)
|
||||
|
||||
const baseParse = structuredOutputParser.parse
|
||||
|
||||
Reference in New Issue
Block a user