()
| 1021 | * otherwise inject classifier allow/deny rules (RCE risk). |
| 1022 | */ |
| 1023 | export function getAutoModeConfig(): |
| 1024 | | { allow?: string[]; soft_deny?: string[]; environment?: string[] } |
| 1025 | | undefined { |
| 1026 | if (feature('TRANSCRIPT_CLASSIFIER')) { |
| 1027 | const schema = z.object({ |
| 1028 | allow: z.array(z.string()).optional(), |
| 1029 | soft_deny: z.array(z.string()).optional(), |
| 1030 | deny: z.array(z.string()).optional(), |
| 1031 | environment: z.array(z.string()).optional(), |
| 1032 | }) |
| 1033 | |
| 1034 | const allow: string[] = [] |
| 1035 | const soft_deny: string[] = [] |
| 1036 | const environment: string[] = [] |
| 1037 | |
| 1038 | for (const source of [ |
| 1039 | 'userSettings', |
| 1040 | 'localSettings', |
| 1041 | 'flagSettings', |
| 1042 | 'policySettings', |
| 1043 | ] as const) { |
| 1044 | const settings = getSettingsForSource(source) |
| 1045 | if (!settings) continue |
| 1046 | const result = schema.safeParse( |
| 1047 | (settings as Record<string, unknown>).autoMode, |
| 1048 | ) |
| 1049 | if (result.success) { |
| 1050 | if (result.data.allow) allow.push(...result.data.allow) |
| 1051 | if (result.data.soft_deny) soft_deny.push(...result.data.soft_deny) |
| 1052 | if (isInternalBuild()) { |
| 1053 | if (result.data.deny) soft_deny.push(...result.data.deny) |
| 1054 | } |
| 1055 | if (result.data.environment) |
| 1056 | environment.push(...result.data.environment) |
| 1057 | } |
| 1058 | } |
| 1059 | |
| 1060 | if (allow.length > 0 || soft_deny.length > 0 || environment.length > 0) { |
| 1061 | return { |
| 1062 | ...(allow.length > 0 && { allow }), |
| 1063 | ...(soft_deny.length > 0 && { soft_deny }), |
| 1064 | ...(environment.length > 0 && { environment }), |
| 1065 | } |
| 1066 | } |
| 1067 | } |
| 1068 | return undefined |
| 1069 | } |
| 1070 | |
| 1071 | export function rawSettingsContainsKey(key: string): boolean { |
| 1072 | for (const source of getEnabledSettingSources()) { |
no test coverage detected