Skip to content

Commit 661fcc8

Browse files
authored
fix(shell-api): use redactPassword in rs/sh print methods (#584)
Do the same thing we do for printing `Mongo` and `ClientEncryption` classes.
1 parent fb80fde commit 661fcc8

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/shell-api/src/replica-set.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { asPrintable } from './enums';
1212
import { assertArgsDefined, assertArgsType } from './helpers';
1313
import { CommonErrors, MongoshDeprecatedError, MongoshInvalidInputError, MongoshRuntimeError } from '@mongosh/errors';
1414
import { CommandResult } from './result';
15-
15+
import { redactPassword } from '@mongosh/history';
1616

1717
@shellApiClassDefault
1818
@hasAsyncChild
@@ -252,7 +252,7 @@ export default class ReplicaSet extends ShellApiClass {
252252
* Internal method to determine what is printed for this class.
253253
*/
254254
[asPrintable](): string {
255-
return `ReplicaSet class connected to ${this._database._mongo._uri} via db ${this._database._name}`;
255+
return `ReplicaSet class connected to ${redactPassword(this._database._mongo._uri)} via db ${this._database._name}`;
256256
}
257257

258258
/**

packages/shell-api/src/shard.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type { Document } from '@mongosh/service-provider-core';
99
import { assertArgsDefined, assertArgsType, getConfigDB, getPrintableShardStatus } from './helpers';
1010
import { ServerVersions, asPrintable } from './enums';
1111
import { CommandResult, UpdateResult } from './result';
12+
import { redactPassword } from '@mongosh/history';
1213

1314
@shellApiClassDefault
1415
@hasAsyncChild
@@ -24,7 +25,7 @@ export default class Shard extends ShellApiClass {
2425
* Internal method to determine what is printed for this class.
2526
*/
2627
[asPrintable](): string {
27-
return `Shard class connected to ${this._database._mongo._uri} via db ${this._database._name}`;
28+
return `Shard class connected to ${redactPassword(this._database._mongo._uri)} via db ${this._database._name}`;
2829
}
2930

3031
/**

0 commit comments

Comments
 (0)