fix: redact SFTP key passphrases

This commit is contained in:
Furox 2026-09-05 01:12:01 +03:00 committed by Furox88
parent 28cc54a6f2
commit 66c1ceb7ce

View File

@ -1,12 +1,11 @@
/**
* Redacts credentials from rclone command strings before they reach logs or
* user-facing error output. Handles both the existing S3 flags and the
* provider-specific FTP/SFTP password flags generated by the destination
* builder.
* provider-specific FTP/SFTP credential flags used by backup destinations.
*/
export const redactRcloneCredentials = (command: string): string => {
return command.replace(
/(--(?:s3-access-key-id|s3-secret-access-key|ftp-pass|sftp-pass)=)(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|[^\s]+)/g,
/(--(?:s3-access-key-id|s3-secret-access-key|ftp-pass|sftp-pass|sftp-key-file-pass)=)(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|[^\s]+)/g,
'$1"[REDACTED]"',
);
};
};