Skip to content

Commit

Permalink
🛂 (radar) Match high risk keyword when not in urls
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Dec 20, 2023
1 parent 00f8bbc commit f2cccbd
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions packages/radar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@ import { env } from '@typebot.io/env'

export const computeRiskLevel = (typebot: any) => {
const stringifiedTypebot = JSON.stringify(typebot)
if (!env.RADAR_HIGH_RISK_KEYWORDS) return 0
if (
env.RADAR_HIGH_RISK_KEYWORDS.some((keyword) =>
stringifiedTypebot.toLowerCase().includes(keyword)
env.RADAR_HIGH_RISK_KEYWORDS?.some((keyword) =>
new RegExp(`(?<!https?://[^\\s"]*)\\b${keyword}\\b`, 'gi').test(
stringifiedTypebot
)
)
)
return 100
if (
env.RADAR_CUMULATIVE_KEYWORDS &&
env.RADAR_CUMULATIVE_KEYWORDS.every((keyword) =>
env.RADAR_CUMULATIVE_KEYWORDS?.every((keyword) =>
stringifiedTypebot.toLowerCase().includes(keyword)
)
)
return 100
if (
env.RADAR_INTERMEDIATE_RISK_KEYWORDS &&
env.RADAR_INTERMEDIATE_RISK_KEYWORDS.some((keyword) =>
env.RADAR_INTERMEDIATE_RISK_KEYWORDS?.some((keyword) =>
stringifiedTypebot.toLowerCase().includes(keyword)
)
)
Expand Down

1 comment on commit f2cccbd

@vercel
Copy link

@vercel vercel bot commented on f2cccbd Dec 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-git-main-typebot-io.vercel.app
app.typebot.io
builder-v2-typebot-io.vercel.app

Please sign in to comment.