@@ -18,9 +18,17 @@ const createTool = async (req: Request, res: Response, next: NextFunction) => {
1818 throw new InternalFlowiseError ( StatusCodes . NOT_FOUND , `Error: toolsController.createTool - workspace ${ workspaceId } not found!` )
1919 }
2020 const body = req . body
21- body . workspaceId = workspaceId
21+ // Explicit allowlist — id/workspaceId/timestamps must not be overrideable by client
22+ const toolBody : Record < string , unknown > = { }
23+ if ( body . name !== undefined ) toolBody . name = body . name
24+ if ( body . description !== undefined ) toolBody . description = body . description
25+ if ( body . color !== undefined ) toolBody . color = body . color
26+ if ( body . iconSrc !== undefined ) toolBody . iconSrc = body . iconSrc
27+ if ( body . schema !== undefined ) toolBody . schema = body . schema
28+ if ( body . func !== undefined ) toolBody . func = body . func
29+ toolBody . workspaceId = workspaceId
2230
23- const apiResponse = await toolsService . createTool ( body , orgId )
31+ const apiResponse = await toolsService . createTool ( toolBody , orgId )
2432 return res . json ( apiResponse )
2533 } catch ( error ) {
2634 next ( error )
@@ -84,7 +92,16 @@ const updateTool = async (req: Request, res: Response, next: NextFunction) => {
8492 if ( ! workspaceId ) {
8593 throw new InternalFlowiseError ( StatusCodes . NOT_FOUND , `Error: toolsController.updateTool - workspace ${ workspaceId } not found!` )
8694 }
87- const apiResponse = await toolsService . updateTool ( req . params . id , req . body , workspaceId )
95+ const body = req . body
96+ // Explicit allowlist — id/workspaceId/timestamps must not be overrideable by client
97+ const toolBody : Record < string , unknown > = { }
98+ if ( body . name !== undefined ) toolBody . name = body . name
99+ if ( body . description !== undefined ) toolBody . description = body . description
100+ if ( body . color !== undefined ) toolBody . color = body . color
101+ if ( body . iconSrc !== undefined ) toolBody . iconSrc = body . iconSrc
102+ if ( body . schema !== undefined ) toolBody . schema = body . schema
103+ if ( body . func !== undefined ) toolBody . func = body . func
104+ const apiResponse = await toolsService . updateTool ( req . params . id , toolBody , workspaceId )
88105 return res . json ( apiResponse )
89106 } catch ( error ) {
90107 next ( error )
0 commit comments