feat: allow redaction of secrets in commands, rather than filtering them#2933
Open
keithamus wants to merge 3 commits intoatuinsh:mainfrom
Open
Conversation
This attempts to resolve atuinsh#2769 by adding a new `secrets_redact` option. When enabled this option will change how `secrets_filter` works: - If `secrets_filter = false` then no change is made, secrets will appear in the users' history, regardless of `secrets_redact`. - If `secrets_filter = true` and `secrets_redact` is `false`, then the "old" behaviour will occur: any detected secret will exclude that whole command from the users' history. - If `secrets_filter = true` and `secrets_redact = true` then this _new_ mode will engage: commands with secrets will be edited before they're saved into history and the secret _content_ will be replaced with the string `"[REDACTED]"`.
keithamus
commented
Oct 1, 2025
Comment on lines
+388
to
+394
| debug_assert!( | ||
| !settings.secrets_filter || settings.secrets_redact, | ||
| "Only return true if secrets_filter is off or redactions are enabled!" | ||
| ); | ||
| // secrets_redact is enabled, so `redact_if_needed` will remove the secret from the | ||
| // command, therefore it is save to save. | ||
| true |
Contributor
Author
There was a problem hiding this comment.
This true looks scary so I added a debug_assert! to make sure we're really sure we can safely pass true 😅
Contributor
Author
keithamus
commented
Oct 1, 2025
…rather-than-filtering-them
…rather-than-filtering-them
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This attempts to resolve #2769 by adding a new
secrets_redactoption. When enabled this option will change howsecrets_filterworks:secrets_filter = falsethen no change is made, secrets will appear in the users' history, regardless ofsecrets_redact.secrets_filter = trueandsecrets_redactisfalse, then the "old" behaviour will occur: any detected secret will exclude that whole command from the users' history.secrets_filter = trueandsecrets_redact = truethen this new mode will engage: commands with secrets will be edited before they're saved into history and the secret content will be replaced with the string"[REDACTED]".This could probably do with more testing. I think I've got it largely correct but given how sensitive the topic is I'd prefer some extra scrutiny on this one.
Checks