Skip to content

bugfix: utils: catch configparser.Error #1240

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

Merged
merged 2 commits into from
Apr 11, 2025
Merged

bugfix: utils: catch configparser.Error #1240

merged 2 commits into from
Apr 11, 2025

Conversation

woodruffw
Copy link
Member

This catches any configparser exceptions when parsing the user's pypirc file. Without this the user would see an uncontrolled exception trace, which in turn could sometimes leak sensitive configuration fields.

The "fix" here is to mask the configparser exception entirely with twine's own InvalidConfiguration exception. This avoids the leakage risk, but it also means that the errors we return to users are slightly less specific in terms of where their invalid syntax is. We offset that by including a link to the pypirc docs.

Fixes #1233.

This catches any configparser exceptions when parsing the user's
pypirc file. Without this the user would see an uncontrolled
exception trace, which in turn could sometimes leak sensitive
configuration fields.

The "fix" here is to mask the configparser exception entirely
with twine's own `InvalidConfiguration` exception. This avoids
the leakage risk, but it also means that the errors we return to
users are slightly less specific in terms of where their invalid
syntax is. We offset that by including a link to the pypirc docs.

Fixes #1233.

Signed-off-by: William Woodruff <william@yossarian.net>
@woodruffw woodruffw self-assigned this Apr 11, 2025
Signed-off-by: William Woodruff <william@yossarian.net>
@woodruffw woodruffw marked this pull request as ready for review April 11, 2025 20:52
@WhyNotHugo
Copy link

LGTM, thanks!

@woodruffw woodruffw merged commit ae1d03b into main Apr 11, 2025
24 checks passed
@woodruffw woodruffw deleted the ww/pypirc-redact branch April 11, 2025 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

If pypirc has an invalid format, twine leaks its contents to stdout
3 participants