File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -451,7 +451,7 @@ class MongoshNodeRepl implements EvaluationListener {
451
451
// repl.history is an array of previous commands. We need to hijack the
452
452
// value we just typed, and shift it off the history array if the info is
453
453
// sensitive.
454
- repl . on ( 'flushHistory ' , ( ) => {
454
+ repl . on ( 'line ' , ( ) => {
455
455
if ( this . redactHistory !== 'keep' ) {
456
456
const history : string [ ] = ( repl as any ) . history ;
457
457
changeHistory (
Original file line number Diff line number Diff line change @@ -1486,6 +1486,19 @@ describe('e2e', function () {
1486
1486
1487
1487
expect ( ( await fs . stat ( historyPath ) ) . mode & 0o077 ) . to . equal ( 0 ) ;
1488
1488
} ) ;
1489
+
1490
+ it ( 'redacts secrets' , async function ( ) {
1491
+ await shell . executeLine ( 'db.auth("myusername", "mypassword")' ) ;
1492
+ await shell . executeLine ( 'a = 42' ) ;
1493
+ await shell . executeLine ( 'foo = "bar"' ) ;
1494
+ shell . writeInput ( '.exit\n' ) ;
1495
+ await shell . waitForExit ( ) ;
1496
+
1497
+ const contents = await fs . readFile ( historyPath , 'utf8' ) ;
1498
+ expect ( contents ) . to . not . match ( / m y p a s s w o r d / ) ;
1499
+ expect ( contents ) . to . match ( / ^ a = 4 2 $ / m) ;
1500
+ expect ( contents ) . to . match ( / ^ f o o = " b a r " $ / m) ;
1501
+ } ) ;
1489
1502
} ) ;
1490
1503
1491
1504
describe ( 'mongoshrc' , function ( ) {
You can’t perform that action at this time.
0 commit comments