🔒 (logs) Remove some logs from API response to avoid sensit…
This commit is contained in:
@ -21,6 +21,9 @@ import prisma from '@typebot.io/lib/prisma'
|
||||
import { parseVariables } from '@typebot.io/variables/parseVariables'
|
||||
import { defaultSendEmailOptions } from '@typebot.io/schemas/features/blocks/integrations/sendEmail/constants'
|
||||
|
||||
export const sendEmailSuccessDescription = 'Email successfully sent'
|
||||
export const sendEmailErrorDescription = 'Email not sent'
|
||||
|
||||
export const executeSendEmailBlock = async (
|
||||
state: SessionState,
|
||||
block: SendEmailBlock
|
||||
@ -143,7 +146,7 @@ const sendEmail = async ({
|
||||
if (!emailBody) {
|
||||
logs.push({
|
||||
status: 'error',
|
||||
description: 'Email not sent',
|
||||
description: sendEmailErrorDescription,
|
||||
details: {
|
||||
error: 'No email body found',
|
||||
transportConfig,
|
||||
@ -177,7 +180,7 @@ const sendEmail = async ({
|
||||
await transporter.sendMail(email)
|
||||
logs.push({
|
||||
status: 'success',
|
||||
description: 'Email successfully sent',
|
||||
description: sendEmailSuccessDescription,
|
||||
details: {
|
||||
transportConfig: {
|
||||
...transportConfig,
|
||||
@ -189,7 +192,7 @@ const sendEmail = async ({
|
||||
} catch (err) {
|
||||
logs.push({
|
||||
status: 'error',
|
||||
description: 'Email not sent',
|
||||
description: sendEmailErrorDescription,
|
||||
details: {
|
||||
error: err instanceof Error ? err.toString() : err,
|
||||
transportConfig: {
|
||||
|
@ -41,6 +41,9 @@ export const longReqTimeoutWhitelist = [
|
||||
'https://api.anthropic.com',
|
||||
]
|
||||
|
||||
export const webhookSuccessDescription = `Webhook successfuly executed.`
|
||||
export const webhookErrorDescription = `Webhook returned an error.`
|
||||
|
||||
type Params = { disableRequestTimeout?: boolean }
|
||||
|
||||
export const executeWebhookBlock = async (
|
||||
@ -201,7 +204,7 @@ export const executeWebhook = async (
|
||||
const response = await got(request.url, omit(request, 'url'))
|
||||
logs.push({
|
||||
status: 'success',
|
||||
description: `Webhook successfuly executed.`,
|
||||
description: webhookSuccessDescription,
|
||||
details: {
|
||||
statusCode: response.statusCode,
|
||||
request,
|
||||
@ -224,7 +227,7 @@ export const executeWebhook = async (
|
||||
}
|
||||
logs.push({
|
||||
status: 'error',
|
||||
description: `Webhook returned an error.`,
|
||||
description: webhookErrorDescription,
|
||||
details: {
|
||||
statusCode: error.response.statusCode,
|
||||
request,
|
||||
|
20
packages/bot-engine/logs/filterPotentiallySensitiveLogs.ts
Normal file
20
packages/bot-engine/logs/filterPotentiallySensitiveLogs.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import {
|
||||
sendEmailErrorDescription,
|
||||
sendEmailSuccessDescription,
|
||||
} from '../blocks/integrations/sendEmail/executeSendEmailBlock'
|
||||
import {
|
||||
webhookErrorDescription,
|
||||
webhookSuccessDescription,
|
||||
} from '../blocks/integrations/webhook/executeWebhookBlock'
|
||||
|
||||
export const filterPotentiallySensitiveLogs = (log: {
|
||||
status: string
|
||||
description: string
|
||||
details?: unknown
|
||||
}) =>
|
||||
![
|
||||
webhookErrorDescription,
|
||||
webhookSuccessDescription,
|
||||
sendEmailErrorDescription,
|
||||
sendEmailSuccessDescription,
|
||||
].includes(log.description)
|
Reference in New Issue
Block a user