Skip to content

Commit

Permalink
minimal change to perform additional redactions (#8232)
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Walker-GM authored May 5, 2023
1 parent 28bf392 commit 02b34a4
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions packages/telemetry/src/sendTelemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,31 @@ interface SensitiveArgPositions {
positions: Array<number>
options?: never
redactWith: Array<string>
allowOnly: Array<string>
}
g: {
positions: Array<number>
options?: never
redactWith: Array<string>
allowOnly?: Array<string>
}
generate: {
positions: Array<number>
options?: never
redactWith: Array<string>
allowOnly?: Array<string>
}
prisma: {
positions?: never
options: Array<string>
redactWith: Array<string>
allowOnly?: Array<string>
}
lint: {
positions?: Array<number>
options?: never
redactWith: Array<string>
allowOnly: Array<string>
}
}

Expand All @@ -45,6 +55,7 @@ const SENSITIVE_ARG_POSITIONS: SensitiveArgPositions = {
exec: {
positions: [1],
redactWith: ['[script]'],
allowOnly: ['exec'],
},
g: {
positions: [2, 3],
Expand All @@ -58,6 +69,10 @@ const SENSITIVE_ARG_POSITIONS: SensitiveArgPositions = {
options: ['--name'],
redactWith: ['[name]'],
},
lint: {
allowOnly: ['lint', '--fix'],
redactWith: ['[path]'],
},
}

interface Args {
Expand Down Expand Up @@ -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(' ')
Expand Down

0 comments on commit 02b34a4

Please # to comment.