mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 23:16:26 +00:00
36 lines
702 B
TypeScript
36 lines
702 B
TypeScript
const secrets = new Set<string>();
|
|
|
|
export const redactedFields = [
|
|
'authorization',
|
|
'token',
|
|
'githubAppKey',
|
|
'npmToken',
|
|
'npmrc',
|
|
'privateKey',
|
|
'privateKeyOld',
|
|
'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);
|
|
secrets.add(secret?.replace('x-access-token:', '')); // GitHub App tokens
|
|
}
|
|
|
|
export function clear(): void {
|
|
secrets.clear();
|
|
}
|