From 02b34a4934d9e760fbc97e01d015fbc1933c6845 Mon Sep 17 00:00:00 2001 From: Josh GM Walker <56300765+Josh-Walker-GM@users.noreply.github.com> Date: Fri, 5 May 2023 22:12:32 +0100 Subject: [PATCH] minimal change to perform additional redactions (#8232) --- packages/telemetry/src/sendTelemetry.ts | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/packages/telemetry/src/sendTelemetry.ts b/packages/telemetry/src/sendTelemetry.ts index 97714f152cd6..fad08cca75a6 100644 --- a/packages/telemetry/src/sendTelemetry.ts +++ b/packages/telemetry/src/sendTelemetry.ts @@ -21,21 +21,31 @@ interface SensitiveArgPositions { positions: Array options?: never redactWith: Array + allowOnly: Array } g: { positions: Array options?: never redactWith: Array + allowOnly?: Array } generate: { positions: Array options?: never redactWith: Array + allowOnly?: Array } prisma: { positions?: never options: Array redactWith: Array + allowOnly?: Array + } + lint: { + positions?: Array + options?: never + redactWith: Array + allowOnly: Array } } @@ -45,6 +55,7 @@ const SENSITIVE_ARG_POSITIONS: SensitiveArgPositions = { exec: { positions: [1], redactWith: ['[script]'], + allowOnly: ['exec'], }, g: { positions: [2, 3], @@ -58,6 +69,10 @@ const SENSITIVE_ARG_POSITIONS: SensitiveArgPositions = { options: ['--name'], redactWith: ['[name]'], }, + lint: { + allowOnly: ['lint', '--fix'], + redactWith: ['[path]'], + }, } interface Args { @@ -149,6 +164,18 @@ export const sanitizeArgv = ( } }) } + + // allow only clause + if (sensitiveCommand.allowOnly) { + args.forEach((arg: string, index: number) => { + if ( + !sensitiveCommand.allowOnly?.includes(arg) && + !sensitiveCommand.redactWith.includes(arg) + ) { + args[index] = sensitiveCommand.redactWith[0] + } + }) + } } return args.join(' ')