Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

fix(crawl): validate includes.excludes regexes

Gergő Móricz1f580deefc07
diff --git a/apps/api/src/controllers/crawl.ts b/apps/api/src/controllers/crawl.ts
index 2e31c2576..4335334ac 100644
--- a/apps/api/src/controllers/crawl.ts
+++ b/apps/api/src/controllers/crawl.ts
@@ -57,6 +57,26 @@ export async function crawlController(req: Request, res: Response) {
};
const pageOptions = { ...defaultCrawlPageOptions, ...req.body.pageOptions };
+ if (Array.isArray(crawlerOptions.includes)) {
+ for (const x of crawlerOptions.includes) {
+ try {
+ new RegExp(x);
+ } catch (e) {
+ return res.status(400).json({ error: e.message });
+ }
+ }
+ }
+
+ if (Array.isArray(crawlerOptions.excludes)) {
+ for (const x of crawlerOptions.excludes) {
+ try {
+ new RegExp(x);
+ } catch (e) {
+ return res.status(400).json({ error: e.message });
+ }
+ }
+ }
+
const limitCheck = req.body?.crawlerOptions?.limit ?? 1;
const { success: creditsCheckSuccess, message: creditsCheckMessage, remainingCredits } =
await checkTeamCredits(team_id, limitCheck);