2
0

(radar) Add radar cumulative keyword alternatives check

This commit is contained in:
Baptiste Arnaud
2024-01-15 10:13:55 +01:00
parent b412f0e4dc
commit 0b00fa7533
3 changed files with 15 additions and 3 deletions

4
packages/env/env.ts vendored
View File

@ -79,7 +79,9 @@ const baseEnv = {
RADAR_CUMULATIVE_KEYWORDS: z
.string()
.min(1)
.transform((val) => val.split('/').map((s) => s.split(',')))
.transform((val) =>
val.split('/').map((s) => s.split(',').map((s) => s.split('|')))
)
.optional(),
},
client: {

View File

@ -13,12 +13,14 @@ export const computeRiskLevel = (typebot: any) => {
if (
env.RADAR_CUMULATIVE_KEYWORDS?.some((set) =>
set.every((keyword) =>
new RegExp(`(?<!https?://[^\\s"]*)\\b${keyword}\\b`, 'gi').test(
keyword.some((k) =>
new RegExp(`(?<!https?://[^\\s"]*)\\b${k}\\b`, 'gi').test(
stringifiedTypebot
)
)
)
)
)
return 100
if (
env.RADAR_INTERMEDIATE_RISK_KEYWORDS?.some((keyword) =>

View File

@ -0,0 +1,8 @@
{
"extends": "@typebot.io/tsconfig/base.json",
"include": ["**/*.ts"],
"exclude": ["node_modules"],
"compilerOptions": {
"target": "ES2015"
}
}