Skip to content
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

Idea: Test for bad version parsing tuple(map(int, __version__))) #12961

Closed
randolf-scholz opened this issue Aug 18, 2024 · 2 comments · Fixed by #14373
Closed

Idea: Test for bad version parsing tuple(map(int, __version__))) #12961

randolf-scholz opened this issue Aug 18, 2024 · 2 comments · Fixed by #14373
Labels
accepted Ready for implementation rule Implementing or modifying a lint rule

Comments

@randolf-scholz
Copy link
Contributor

Inspired by a recent bug in pycharm, caused by bad version parsing that went undetected until matplotlib, for the first time in 20 years, published a non-pre-release version with a postfix (3.9.1.post1 on Aug 7th).

What it does

Checks for the presence of tuple(map(int, obj.__version__.split("."))) and equivalent variants thereof.

Why this is bad

This breaks if the package uses a postfix that is not convertible to integer, such as matplotlib==3.9.1.post1.

Use instead

Version string should be parsed using the PEP440 specification.

@randolf-scholz
Copy link
Contributor Author

A quick GitHub search shows that this vulnerability is present in many packages.

@charliermarsh charliermarsh added the rule Implementing or modifying a lint rule label Aug 18, 2024
@charliermarsh
Copy link
Member

I'm in favor of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Ready for implementation rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants