-
Notifications
You must be signed in to change notification settings - Fork 85
fix(logging): handle credential redaction in some cases with special characters MONGOSH-2991 #2581
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
Changes from all commits
900b354
6e38fe8
a202007
3cf5d52
34e7852
64132af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,4 @@ | ||||||||||||||||||||
| import redactSensitiveData from 'mongodb-redact'; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| export const HIDDEN_COMMANDS = String.raw`\b(createUser|auth|updateUser|changeUserPassword|connect|Mongo)\b`; | ||||||||||||||||||||
| import { shouldRedactCommand, redact } from 'mongodb-redact'; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| /** | ||||||||||||||||||||
| * Modifies the most recent command in history based on sensitive information. | ||||||||||||||||||||
|
|
@@ -11,16 +9,13 @@ export const HIDDEN_COMMANDS = String.raw`\b(createUser|auth|updateUser|changeUs | |||||||||||||||||||
| */ | ||||||||||||||||||||
| export function changeHistory( | ||||||||||||||||||||
| history: string[], | ||||||||||||||||||||
| redact: 'redact-sensitive-data' | 'keep-sensitive-data' | ||||||||||||||||||||
| redactMode: 'redact-sensitive-data' | 'keep-sensitive-data' | ||||||||||||||||||||
| ): void { | ||||||||||||||||||||
| if (history.length === 0) return; | ||||||||||||||||||||
| const hiddenCommands = new RegExp(HIDDEN_COMMANDS, 'g'); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if (hiddenCommands.test(history[0])) { | ||||||||||||||||||||
| if (shouldRedactCommand(history[0])) { | ||||||||||||||||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just so I understand right, we always redact data from history if it's a redactable command,
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mongosh/packages/cli-repl/src/mongosh-repl.ts Lines 565 to 573 in f3ff98c
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah cool, it'd be nice to move the whole logic into the function and make that enum include "keep" |
||||||||||||||||||||
| history.shift(); | ||||||||||||||||||||
| } else if (redact === 'redact-sensitive-data') { | ||||||||||||||||||||
| history[0] = redactSensitiveData(history[0]); | ||||||||||||||||||||
| } else if (redactMode === 'redact-sensitive-data') { | ||||||||||||||||||||
| history[0] = redact(history[0]); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| export { redactSensitiveData }; | ||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1 @@ | ||
| export { changeHistory, redactSensitiveData, HIDDEN_COMMANDS } from './history'; | ||
| export { redactConnectionString as redactURICredentials } from 'mongodb-connection-string-url'; | ||
| export { changeHistory } from './history'; |
Uh oh!
There was an error while loading. Please reload this page.