@@ -18,6 +18,7 @@ import { TextSplitter } from 'langchain/text_splitter'
1818import { DocumentLoader } from 'langchain/document_loaders/base'
1919import { NodeVM } from '@flowiseai/nodevm'
2020import { Sandbox } from '@e2b/code-interpreter'
21+ import { secureFetch , checkDenyList } from './httpSecurity'
2122import JSON5 from 'json5'
2223
2324export const numberOrExpressionRegex = '^(\\d+\\.?\\d*|{{.*}})$' //return true if string consists only numbers OR expression {{}}
@@ -422,7 +423,7 @@ async function crawl(baseURL: string, currentURL: string, pages: string[], limit
422423
423424 if ( process . env . DEBUG === 'true' ) console . info ( `actively crawling ${ currentURL } ` )
424425 try {
425- const resp = await fetch ( currentURL )
426+ const resp = await secureFetch ( currentURL )
426427
427428 if ( resp . status > 399 ) {
428429 if ( process . env . DEBUG === 'true' ) console . error ( `error in fetch with status code: ${ resp . status } , on page: ${ currentURL } ` )
@@ -453,6 +454,8 @@ async function crawl(baseURL: string, currentURL: string, pages: string[], limit
453454 * @returns {Promise<string[]> }
454455 */
455456export async function webCrawl ( stringURL : string , limit : number ) : Promise < string [ ] > {
457+ await checkDenyList ( stringURL )
458+
456459 const URLObj = new URL ( stringURL )
457460 const modifyURL = stringURL . slice ( - 1 ) === '/' ? stringURL . slice ( 0 , - 1 ) : stringURL
458461 return await crawl ( URLObj . protocol + '//' + URLObj . hostname , modifyURL , [ ] , limit )
@@ -476,7 +479,7 @@ export async function xmlScrape(currentURL: string, limit: number): Promise<stri
476479 let urls : string [ ] = [ ]
477480 if ( process . env . DEBUG === 'true' ) console . info ( `actively scarping ${ currentURL } ` )
478481 try {
479- const resp = await fetch ( currentURL )
482+ const resp = await secureFetch ( currentURL )
480483
481484 if ( resp . status > 399 ) {
482485 if ( process . env . DEBUG === 'true' ) console . error ( `error in fetch with status code: ${ resp . status } , on page: ${ currentURL } ` )
0 commit comments