Repository navigation
π fix(config): mask secrets in parser errors - #4507
Merged
Merged
Conversation
argparse quotes the rejected argument as given in its errors, so an invalid --force-dep requirement, --colored choice or -x override printed URL credentials that tox masks in command displays and TOX_ warnings. Every argparse error now goes through the masking used for command displays. The unrecognized arguments error still masks each argument on its own, since masking the joined message would hide the hint after a secret inline flag.
argparse quotes a rejected value with repr, which turns a line break or tab into a backslash escape. The inline flag rule needed real whitespace before the dash, so --colored 'a<newline>--token=x' still printed the token. The rule now also accepts the repr escape of each whitespace character before the dash. Masking the message after argparse builds it keeps the fix out of argparse internals, at the cost of masking a literal backslash-n before a secret-looking flag in command displays.
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.
When tox rejected a command line argument, the error quoted that argument as typed, including the password in a URL such as
https://user:password@host. A CI job that builds a--force-deprequirement from a credentialed URL plus a free-text value someone else controls, such as a release label containing a space, printed its credential to the job log, while the same URL in command displays has been masked since #4334. π Once this merges, rejected arguments get the same masking in errors. This addresses draft advisory GHSA-25fg-rr6h-j853.Output before (
-) and after (+) this change:tox's command line parser, which every subcommand inherits, now masks the message of each argparse error before printing it, using the rules tox already applies to command displays: URL user and password, and the value of a secret-looking
--name=valueflag. argparse quotes the rejected value withrepr, so a line break or tab before such a flag reaches the message as\nor\t; the flag rule treats those escapes as whitespace too. The error for unrecognized arguments keeps masking each argument on its own, so a masked flag value does not swallow the hint printed after it.Invalid requirements, invalid choices such as
--colored, ambiguous option prefixes and-xoverrides without=now show*in place of credentials; the exit code and the rest of each message stay the same. The space-separated--name valueform stays outside the flag rule, as the logging docs describe.Reported by oss-scanner: ANT-2026-CJO3IQIA.