← Requirements Pin Check

How to pin and hash Python dependencies

A requirements.txt that says flask>=2.0 is a promise to install whatever is newest on the day someone runs pip install. That is fine for a notebook and a risk for anything you deploy. Three changes make an install repeatable and much harder to tamper with.

The categories this tool uses

Checklist

  1. Keep loose intent in requirements.in (flask>=2.0) and generate the locked file: pip-compile --generate-hashes requirements.in or uv pip compile --generate-hashes requirements.in -o requirements.txt.
  2. Install with pip install --require-hashes -r requirements.txt so any file that does not match its hash fails the build.
  3. Use one index. If you need a private index, put it behind a proxy that serves both, rather than adding --extra-index-url.
  4. Pin git dependencies to a full 40-character commit, not a branch or tag.
  5. Add node requirements-check.mjs --fail-on medium to CI so a loose line cannot be committed silently.

What this does not tell you

It scans the text of the file. It does not run pip's resolver, read transitive dependencies, or check pinned versions against a vulnerability database, so a fully pinned file can still contain a vulnerable release. It is a heuristic and is not security advice.