Skip to content

fix: include transitive dependencies to harden against supply chain attacks#435

Merged
zkoppert merged 1 commit intomainfrom
fix-pip-hash-check
Feb 28, 2026
Merged

fix: include transitive dependencies to harden against supply chain attacks#435
zkoppert merged 1 commit intomainfrom
fix-pip-hash-check

Conversation

@zkoppert
Copy link
Collaborator

@zkoppert zkoppert commented Feb 27, 2026

Resolves https://github.com/github-community-projects/stale-repos/security/code-scanning/133

Changes

  • Expanded requirements.txt to include all transitive dependencies (generated via pip-compile) so every installed package is explicitly pinned
  • Added --no-deps to the pip install command in the Dockerfile to prevent pip from resolving transitive dependencies at build time

Why

Without --no-deps, pip resolves and fetches transitive dependencies dynamically during the Docker build, which opens the door to supply chain attacks if a dependency is compromised between builds. With all deps pinned in requirements.txt and --no-deps enforced, only explicitly listed packages are installed.

Dependabot compatibility

Since all dependencies (including transitive) are listed directly in requirements.txt, dependabot can still detect and update each pin individually — no separate hashed file to maintain.

Testing

  1. Test suite — Ran make test locally. All 45 repo tests pass with 95% code coverage (above the 80% threshold).
  2. Clean venv --no-deps install — Created a fresh Python virtual environment, ran pip install --no-deps -r requirements.txt, and confirmed all 14 packages installed successfully with no missing dependency errors.
  3. Import verification — After the --no-deps install, verified that every module the application uses (github3, dateutil, dotenv, requests, certifi, urllib3, six, uritemplate, idna, charset_normalizer, cffi, cryptography, jwt, pycparser) imports successfully — confirming no transitive dependencies are missing from requirements.txt.
  4. CI checks — All CI checks pass, including the Docker image build which validates the Dockerfile change end-to-end.

@github-actions github-actions bot added the fix label Feb 27, 2026
@zkoppert zkoppert changed the title fix: enforce pip hash verification in Dockerfile thinking out loud/WIP: ignore me Feb 28, 2026
@zkoppert zkoppert changed the title thinking out loud/WIP: ignore me ci: thinking out loud/WIP: ignore me Feb 28, 2026
Expand requirements.txt to include all transitive dependencies
(via pip-compile) and use --no-deps in the Dockerfile to prevent
pip from fetching any packages not explicitly listed.

This resolves code scanning alert #133 by ensuring only
explicitly pinned packages are installed, mitigating supply
chain risks from unexpected transitive dependency resolution.

The fully-resolved requirements.txt remains dependabot-friendly
since each pin can be updated independently.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions bot added the automation automation label Feb 28, 2026
@zkoppert zkoppert self-assigned this Feb 28, 2026
@zkoppert zkoppert changed the title ci: thinking out loud/WIP: ignore me fix: include transitive dependencies to harden against supply chain attacks Feb 28, 2026
@zkoppert zkoppert marked this pull request as ready for review February 28, 2026 00:31
Copilot AI review requested due to automatic review settings February 28, 2026 00:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Pins all Python dependencies (including transitive ones) in requirements.txt and updates the container build to install only those pinned packages, reducing exposure to dependency-resolution changes during builds.

Changes:

  • Expanded requirements.txt to include explicitly pinned transitive dependencies (pip-compile style output).
  • Updated Docker build to install Python packages with pip --no-deps to prevent dynamic dependency resolution.

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.

File Description
requirements.txt Replaces a short dependency list with a fully pinned set of direct + transitive dependencies.
Dockerfile Enforces pip install --no-deps so only explicitly pinned packages are installed during image build.

COPY requirements.txt *.py /action/workspace/

RUN python3 -m pip install --no-cache-dir -r requirements.txt \
RUN python3 -m pip install --no-cache-dir --no-deps -r requirements.txt \
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

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

Because --no-deps is now enforced, the Docker build will no longer resolve any missing/conditional transitive dependencies. To keep builds reliable, ensure requirements.txt is generated for the same interpreter/platform as this image (Python 3.14 slim) so any version-marker differences are captured in the lock file.

Suggested change
RUN python3 -m pip install --no-cache-dir --no-deps -r requirements.txt \
RUN python3 -m pip install --no-cache-dir -r requirements.txt \

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we're good. @zkoppert your change here is the whole point of the change. You're handling it with the requirements.txt changes.

@zkoppert zkoppert merged commit 4e4111c into main Feb 28, 2026
44 checks passed
@zkoppert zkoppert deleted the fix-pip-hash-check branch February 28, 2026 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants