Skip to content

Pin all Python dependencies - #289

Open
lelia wants to merge 2 commits into
mainfrom
lelia/ce-359-pin-all-dependencies-in-socket-python-cli
Open

Pin all Python dependencies#289
lelia wants to merge 2 commits into
mainfrom
lelia/ce-359-pin-all-dependencies-in-socket-python-cli

Conversation

@lelia

@lelia lelia commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Pins the Python dependency chain at all three points where versions could previously resolve loose (CE-359):

  • pyproject.toml: every runtime dependency is now pinned to an exact version. Several entries (requests, mdutils, prettytable, GitPython, packaging, python-dotenv) were previously unpinned; the rest were open ranges. Pins use the versions already resolved and tested in uv.lock.
  • bs4beautifulsoup4: the bs4 package is a shim that installs beautifulsoup4 unpinned underneath, so pinning the shim alone pins nothing. The dependency is now on beautifulsoup4 directly. (The bs4 import name is unaffected — it is provided by beautifulsoup4 itself.)
  • socketdev: pinned to 3.4.2 (previously >=3.3.0,<4.0.0).
  • Dockerfile: image builds previously ran pip install socketsecurity==$CLI_VERSION, resolving all transitive dependencies fresh from PyPI at build time. Builds now export the committed uv.lock to a hash-pinned requirements file (uv export) and install with pip install --require-hashes --no-deps; the CLI package itself installs with --no-deps, and pip check validates the final environment. The hatchling build backend and the uv binary copied into the image are pinned as well.

Dependabot (uv + docker ecosystems, 7-day cooldown) is already configured to keep the pins current.

Bumps version to 2.5.10 with a changelog entry.

Notes

  • Dockerfile.preview needs no changes: it resolves from the wheel's Requires-Dist metadata, which now carries the exact pins.
  • Rebuilding a pre-2.5.10 CLI_VERSION with this Dockerfile will fail at pip check (older metadata expects bs4, which the lock no longer provides). Image builds for a given version should use the Dockerfile from that version's tag, as the release workflows already do.
  • Possible follow-up: pin the python:3-alpine base image to a more specific tag or digest.

Testing

  • uv lock regenerated cleanly; only changes were bs4 removal and socketdev 3.3.0 → 3.4.2 (all other locked versions already matched the new pins).
  • Full test suite passes: 351 passed, 2 skipped (pre-existing).
  • Verified the exact uv export command from the Dockerfile produces a fully hashed 22-package requirements file, with environment markers intact and socketdev==3.4.2 resolvable from PyPI.
  • socketcli --version entrypoint works in the synced environment.

Refs CE-359.

🤖 Generated with Claude Code


Note

Medium Risk
Changes how dependencies are resolved in production Docker builds and bumps the socketdev SDK; misaligned lock/metadata could fail builds or pip check, but scan logic is untouched.

Overview
Release 2.5.10 locks down the Python supply chain: every runtime dependency in pyproject.toml is pinned to an exact version (including socketdev==3.4.2), bs4 is replaced by a direct beautifulsoup4 pin, and hatchling is pinned for builds.

Docker image builds no longer resolve transitive deps from PyPI at build time. They export the committed uv.lock to a hashed requirements file, install with pip install --require-hashes --no-deps, install socketsecurity with --no-deps, run pip check, and pin the copied uv image to 0.10.4.

uv.lock and changelog are updated accordingly; no application code behavior changes beyond the version string.

Reviewed by Cursor Bugbot for commit 51ca456. Configure here.

Pin every runtime dependency in pyproject.toml to an exact version,
replace the bs4 shim with a direct beautifulsoup4 dependency, pin the
socketdev SDK to 3.4.2, and install Docker image dependencies from the
committed uv.lock with pip hash verification so image builds no longer
resolve loose versions from PyPI at build time. Also pins the hatchling
build backend and the uv binary used in the Dockerfile.

Refs CE-359.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>
@lelia
lelia requested a review from a team as a code owner August 5, 2026 23:36
@socket-security

socket-security Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedpypi/​socketdev@​3.3.0 ⏵ 3.4.298 +1100100100100

View full report

@lelia
lelia temporarily deployed to socket-firewall August 5, 2026 23:36 — with GitHub Actions Inactive
@socket-security-staging

socket-security-staging Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedpypi/​socketdev@​3.3.0 ⏵ 3.4.298 +1100100100100

View full report

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix is ON. A cloud agent has been kicked off to fix the reported issues.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 51ca456. Configure here.

Comment thread Dockerfile Outdated
COPY pyproject.toml uv.lock /tmp/socket-cli-lock/
RUN uv export --directory /tmp/socket-cli-lock --frozen --no-dev --no-emit-project \
--format requirements-txt -o /tmp/socket-cli-lock/requirements.txt && \
pip install --require-hashes --no-deps -r /tmp/socket-cli-lock/requirements.txt

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pip index ARG leaks into lock install

Medium Severity

The new hash-pinned lockfile pip install has no --index-url, so it inherits PIP_INDEX_URL from the Docker ARG (BuildKit exposes ARGs as env vars). Test image builds set that ARG to TestPyPI (build_container.sh, deploy-test-docker.sh), so lockfile packages resolve against TestPyPI instead of production PyPI. This violates the Docker ARG / pip-recognized env var names rule; CLI/SDK installs already pass index flags explicitly.

Additional Locations (1)
Fix in Cursor Fix in Web

Triggered by learned rule: Docker ARG with pip-recognized env var names leaks into pip

Reviewed by Cursor Bugbot for commit 51ca456. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 33d6897 — the locked dependency install now passes explicit production PyPI index flags, so the TestPyPI ARGs no longer leak in via pip's env vars.

Comment thread Dockerfile Outdated
if [ ! -z "$SDK_VERSION" ]; then \
pip install --index-url ${PIP_INDEX_URL} --extra-index-url ${PIP_EXTRA_INDEX_URL} socketdev==${SDK_VERSION}; \
fi; \
pip check; \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SDK override fails pip check

Medium Severity

SDK_VERSION still overlays socketdev, but the new pip check runs afterward while socketsecurity now requires socketdev==3.4.2 exactly. Any override other than 3.4.2 makes pip check fail and aborts the image build. deploy-test-docker.sh always supplies a TestPyPI SDK version, so that path breaks.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 51ca456. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 33d6897pip check now runs before the SDK_VERSION override, so preview SDK builds that deviate from the exact pin still work.

Pass explicit production index flags on the hash-locked dependency
install so the PIP_INDEX_URL/PIP_EXTRA_INDEX_URL build args (pointed at
TestPyPI by the preview build scripts) don't leak in via pip's env
vars, and move pip check ahead of the SDK_VERSION override so a preview
SDK that deviates from the exact socketdev pin doesn't abort the build.

Addresses PR#289 review findings.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>
@lelia
lelia deployed to socket-firewall August 6, 2026 00:34 — with GitHub Actions Active
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.

1 participant