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

Commit

Permalink
Merge pull request #82 from paritytech/yj-remove-password-from-console
Browse files Browse the repository at this point in the history
Fix #77: don't show password in plaintext in console
  • Loading branch information
amaury1093 authored Jan 2, 2019
2 parents 89b5ed7 + 71fbf5a commit de07639
Showing 1 changed file with 11 additions and 1 deletion.
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] = '***';
}

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

0 comments on commit de07639

Please sign in to comment.