Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Fix #77: don't show password in plaintext in console #82

Merged
merged 6 commits into from
Jan 2, 2019
Merged
Changes from all 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
12 changes: 11 additions & 1 deletion packages/api/src/transport/ws/ws.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,17 @@ class Ws extends JsonRpcBase {

// Don't print error if request rejected or not is not yet up...
if (!/(rejected|not yet up)/.test(result.error.message)) {
console.error(`${method}(${JSON.stringify(params)}): ${result.error.code}: ${result.error.message}`);
// fether Issue #317
// js-libs Issue #77 Masks the password param when logging error to console on methods that contain it as a param.
// e.g. ["0x2",{},"myincorrectpassword"] -> ["0x2",{},"***"]
const dangerous_methods = ['signer_confirmRequest', 'signer_confirmRequestWithToken'];
let safe_params;
if (dangerous_methods.includes(method)) {
safe_params = params.slice();
safe_params[params.length - 1] = '***';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a comment somewhere here, to tell future devs what we're doing here, it might not be obvious at 1st sight.

}

console.error(`${method}(${JSON.stringify(safe_params || params)}): ${result.error.code}: ${result.error.message}`);
}

const error = new TransportError(method, result.error.code, result.error.message);
Expand Down