fix(python/setup): match package names containing '-', '.', '_'#2162
Open
theinfosecguy wants to merge 1 commit into
Open
fix(python/setup): match package names containing '-', '.', '_'#2162theinfosecguy wants to merge 1 commit into
theinfosecguy wants to merge 1 commit into
Conversation
The packageVersionRe regex used \w+ for the name capture group, which matches only [A-Za-z0-9_]. PEP 508 distribution names containing '-' or '.' (e.g. Flask-Security-Too, python-dateutil, zope.interface) were silently skipped by the setup.py extractor. Relax the name capture group to allow the characters permitted by PEP 508 (letters, digits, '.', '-', '_'), while requiring the first and last characters to be alphanumeric. Tighten whitespace handling (\W? -> \s*) and require at least one version character. Fixes google#2113
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.
Fix #2113
Problem
The
python/setupextractor'spackageVersionReused\w+for the package name, which matches only[A-Za-z0-9_]. As a result, valid PEP 508 distribution names containing-or.were silently dropped:Flask-Security-Too==3.4.3python-dateutil>=2.8.0zope.interface==5.4.0Changes
[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?, matching PEP 508 (letters, digits,.,-,_; first and last characters must be alphanumeric).\W?to\s*.[\w.]*→[\w.]+).Flask-Security-Too,python-dateutil,zope.interfacecases totestdata/valid.testdata/invalid_namesnegative fixture covering 6 PEP 508 boundary violations (leading / trailing-,.,_).