MCPcopy
hub / github.com/prisma/prisma / redactCommandArray

Function redactCommandArray

packages/cli/src/utils/checkpoint.ts:192–218  ·  view source on GitHub ↗
(commandArray: string[])

Source from the content-addressed store, hash-verified

190 * removes potentially sensitive information from the command array (argv strings)
191 */
192export const redactCommandArray = (commandArray: string[]): string[] => {
193 const REDACTED_TAG = '[redacted]'
194
195 for (let i = 0; i < commandArray.length; i++) {
196 const arg = commandArray[i]
197 // redact --option arguments
198 SENSITIVE_CLI_OPTIONS.forEach((option: string) => {
199 // --url file:./dev.db
200 // arg is `--url` and a complete match
201 const argIndexCompleteMatch = arg === option
202 // --url=file:./dev.db
203 // arg value is `--url=file:./dev.db` and a partial match
204 const argIndexPartialMatch = arg.indexOf(option)
205
206 // First check for complete match and redact the value
207 if (argIndexCompleteMatch) {
208 commandArray[i + 1] = REDACTED_TAG
209 }
210 // else check for partial match and redact the value
211 else if (argIndexPartialMatch !== -1) {
212 commandArray[i] = `${option}=${REDACTED_TAG}`
213 }
214 })
215 }
216
217 return commandArray
218}

Callers 3

mainFunction · 0.90
checkpoint.test.tsFile · 0.90
runCheckpointClientCheckFunction · 0.85

Calls 1

indexOfMethod · 0.80

Tested by

no test coverage detected