Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix code scanning alert no. 1: Clear-text logging of sensitive information #1

Closed
wants to merge 4 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/utils/ssh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,24 @@
*/
function logDebug(message: string, debug?: boolean) {
if (debug) {
console.log(`[DEBUG] ${message}`);
// Sanitize the message to remove sensitive information
const sanitizedMessage = sanitizeSensitiveData(message);
console.log(`[DEBUG] ${sanitizedMessage}`);
}
}

/**
* Sanitizes a message to remove sensitive information such as passwords, usernames, and other credentials.
* @param {string} message - The message to sanitize.
* @returns {string} The sanitized message.
*/
function sanitizeSensitiveData(message: string): string {
return message
.replace(/--password=\S+/g, '--password=****')
.replace(/--username=\S+/g, '--username=****')
.replace(/--apn=\S+/g, '--apn=****');
}

/**
* Creates an SSH connection using the provided options.
* @param {SSHOptions} options - The SSH connection options.
Expand Down