renovate/lib/util/sanitize.ts
2020-05-16 12:35:41 +02:00

35 lines
619 B
TypeScript

const secrets = new Set<string>();
export const redactedFields = [
'authorization',
'token',
'githubAppKey',
'npmToken',
'npmrc',
'yarnrc',
'privateKey',
'gitPrivateKey',
'forkToken',
'password',
];
export function sanitize(input: string): string {
if (!input) {
return input;
}
let output: string = input;
secrets.forEach((secret) => {
while (output.includes(secret)) {
output = output.replace(secret, '**redacted**');
}
});
return output;
}
export function add(secret: string): void {
secrets.add(secret);
}
export function clear(): void {
secrets.clear();
}