Skip to content

fix(python/setup): match package names containing '-', '.', '_'#2162

Open
theinfosecguy wants to merge 1 commit into
google:mainfrom
theinfosecguy:fix/python-setup-dash-names
Open

fix(python/setup): match package names containing '-', '.', '_'#2162
theinfosecguy wants to merge 1 commit into
google:mainfrom
theinfosecguy:fix/python-setup-dash-names

Conversation

@theinfosecguy

Copy link
Copy Markdown

Fix #2113

Problem

The python/setup extractor's packageVersionRe used \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.3
  • python-dateutil>=2.8.0
  • zope.interface==5.4.0

Changes

  • Relax the name capture group to [A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?, matching PEP 508 (letters, digits, ., -, _; first and last characters must be alphanumeric).
  • Tighten surrounding whitespace handling from \W? to \s*.
  • Require at least one version character ([\w.]*[\w.]+).
  • Add Flask-Security-Too, python-dateutil, zope.interface cases to testdata/valid.
  • Add testdata/invalid_names negative fixture covering 6 PEP 508 boundary violations (leading / trailing -, ., _).

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
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.

python/setup extractor doesn't extract dependencies that have a dash in the name

1 participant