Repository navigation
Fix minor issues with command masking - #180
Merged
penguinolog merged 2 commits intoNov 10, 2026
Merged
penguinolog merged 2 commits into
penguinolog merged 2 commits into
Conversation
mask_command replaced every group of a match, including groups that did
not participate in it. Their span is (-1, -1), so a rule with
alternation or an optional group inserted a spurious mask before the
last character of the text:
mask_command("cmd --pass=abc --x", r"--pass=(abc)|--user=(\w+)")
# 'cmd --pass=<*masked*> --<*masked*>x'
- Groups that did not participate are skipped.
- Add tests for mask_command.
Two places reported the command without applying log_mask_re: - execute_together raised ParallelCallProcessError and ParallelCallExceptionsError with the raw command, which is also in their message. The rules of every remote and of the call now apply. - Subprocess logged the raw command when the FIFO buffers stayed open after the process exited. It now logs the masked command of the result.
penguinolog
approved these changes
Nov 10, 2026
Collaborator
Coverage Report for CI Build 42835859078Coverage increased (+0.02%) to 88.727%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
3 tasks done
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.
What do these changes do?
Two small fixes to
log_mask_re, which I bumped into while looking at masking a password argument.1. Groups that don't take part in a match garble the output.
_mask_commandreplaces every group of a match, including ones that didn't participate.For those,
re.Match.span()returns(-1, -1),1 so a rule with|or an optional group splices a spurious mask in before the last character:Non-participating groups are now just skipped.
2. Two places reported the command without applying
log_mask_reat all.SSHClient.execute_togetherraisedParallelCallProcessError/ParallelCallExceptionsErrorwith the raw command, which also ends up in the exception message.It now applies the per-call rule plus the rules of every remote.
The exception is shared by all the remotes, so masking with all of them felt safest.
Subprocesslogged the raw command at CRITICAL when the FIFO buffers were still open after the process exited.It now logs
result.cmd, which is already masked.Are there changes in behavior for the user?
Only in what gets logged / put in exceptions:
execute_togetherexceptions and the "FIFO buffers are still open" log line now show the masked command, like everything else already does.No API changes.
Related issue number
None that I could find (searched issues/PRs for "mask").
Checklist
test/test_mask_command.py(alternation, optional group, several rules)test_execute_together_failed_maskedintest/test_ssh_client_execute.py_mask_command; nothing user-facing needed updating)Footnotes
https://docs.python.org/3/library/re.html#re.Match.span ↩