Skip to content

CVE fix, use importlib.metadata instead of pkg_resources - #187

Open
Greglobrien wants to merge 2 commits into
CyberSource:masterfrom
Greglobrien:replace-pkg-resources
Open

CVE fix, use importlib.metadata instead of pkg_resources#187
Greglobrien wants to merge 2 commits into
CyberSource:masterfrom
Greglobrien:replace-pkg-resources

Conversation

@Greglobrien

Copy link
Copy Markdown

The Problem

The pinned setuptools version carries a known vulnerability (CVE-2026-59890, fixed in setuptools 83.0.0). On review, setuptools isn't actually needed at runtime — its only runtime consumer was pkg_resources in CyberSource/api_client.py -> get_client_id() but not beyond that.

The Fix

Swap that lookup to the stdlib importlib.metadata and drop setuptools from install_requires, requirements.txt, and template. On Python 3.8 and below the import falls back to the importlib_metadata backport.

Applied to both the generated CyberSource/api_client.py and its generator template (.../api_client.mustache) so it survives updates.

Verification

Test suite passed, no additional tests added.

Greg O'Brien and others added 2 commits July 31, 2026 12:06
…e dep

pkg_resources was removed in setuptools 82, which broke importing
CyberSource.api_client (unguarded top-level import) and the runtime
version lookup in get_client_id(). Switch to the stdlib
importlib.metadata API (Python 3.8+), with a PackageNotFoundError
guard that is more robust than the previous unguarded require() call.

The change is applied to both the generated CyberSource/api_client.py
and its source-of-truth generator template
(generator/cybersource-python-template/api_client.mustache) so it
survives SDK regeneration.

pkg_resources was the only runtime consumer of setuptools, so setuptools
is removed from install_requires (setup.py), requirements.txt, and
requirements.mustache rather than merely unpinning it.

Verified under setuptools 82.0.1: import succeeds, get_client_id()
returns "cybs-rest-sdk-python-<version>", and the test suite is
unchanged from the pre-existing baseline.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant