-
Notifications
You must be signed in to change notification settings - Fork 318
Filter sensitive history items and avoid writing them to the history file #1058
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have PSReadLineOption to opt out
It would be generally useful for the This would require a signature change to |
With a default handler for |
Does save and restore not work? $handler = (Get-PSReadLineOption).AddToHistoryHandler
...
Set-PSReadLineOption -AddToHistoryHandler $handler |
Well, that DOES work 😄 |
Is it worth adding a |
Added a public static property |
@lzybkr Code has been updated, can you please take another look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be good to get some more feedback on this design, but I approve.
@SteveL-MSFT Can you please review again? Thanks! |
@SteveL-MSFT Would you like to take another look? |
Fix #934
Detect sensitive history items by using the regex
"password|asplaintext|token|key|secret"
suggested by Lee.For sensitive history items, we still keep them in the history queue, so they are still accessible within the same session.
However, we don't write them to the history file, so they will be gone when the session ends, just like the built-in powershell history.
This is done by adding a default handler to
AddToHistoryHandler
. Quoted from the updated doc for-AddToHistoryHandler
: