Skip to content

fix(ci): install setuptools into Python 3.12 toolcache for semgrep#44

Merged
lhanjian merged 4 commits intokong-devfrom
fix/sast-setuptools-python-3.12-kong-dev
Apr 20, 2026
Merged

fix(ci): install setuptools into Python 3.12 toolcache for semgrep#44
lhanjian merged 4 commits intokong-devfrom
fix/sast-setuptools-python-3.12-kong-dev

Conversation

@lhanjian
Copy link
Copy Markdown

The Kong semgrep action spins up a fresh Python 3.12 via setup-python, so the previous pip install setuptools ran on an unrelated Python and the action still failed with ModuleNotFoundError: pkg_resources.

Call setup-python with the same pinned version first so setuptools lands in the toolcache the action reuses.

The Kong semgrep action spins up a fresh Python 3.12 via setup-python,
so the previous `pip install setuptools` ran on an unrelated Python
and the action still failed with ModuleNotFoundError: pkg_resources.

Call setup-python with the same pinned version first so setuptools
lands in the toolcache the action reuses.
The Kong public-shared-actions/semgrep action calls setup-python@v6
with python-version 3.12 and then pip installs semgrep. semgrep pulls
in opentelemetry-instrumentation 0.46b0, which imports pkg_resources
at load time - but Python 3.12 no longer ships setuptools by default,
so semgrep ci crashes with ModuleNotFoundError.

Replace the shared action with the same composite steps so we can pip
install setuptools alongside semgrep. The artifact upload and SARIF
upload steps are preserved with the same pinned SHAs as before.
setuptools 81 removed the pkg_resources module, but
opentelemetry-instrumentation (a semgrep transitive dep) still imports
it at load time. The previous attempt installed setuptools-82.0.1,
which has no pkg_resources, so semgrep ci still crashed with
ModuleNotFoundError. Pin to the pre-removal series.
Revert the inline rewrite and keep using the Kong shared semgrep
action. The real fix is the setuptools version: 3.12 no longer bundles
pkg_resources, and setuptools >=81 dropped the module entirely, so we
must seed the toolcache with setuptools<81 before the action reuses
Python 3.12.
@lhanjian lhanjian merged commit fbe94c4 into kong-dev Apr 20, 2026
31 checks passed
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.

3 participants