snyk / snyk/snyk-python-plugin

Possible to register & be aware of pip-compile lock files?

Open
#248 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
23
Forks
30
Avg merge
2d 6h
Merged PRs (30d)
3

Description

Sorry, perhaps this is not the correct place to report this.

TL;DR - is there a way to configure snyk so it understands we have both direct-dependencies and transitive-dependencies manifests inside our repository?

Detail

We manage a python service. It has a folder structure like:

/components
  /requirements.txt
  /requirements.linux.lock
  /requirements.macos.lock
/tools
  /requirements.txt
  /requirements.linux.lock
  /requirements.macos.lock

We manage our dependencies with uv, because it's (dramatically) faster than pip. It is drop-in-compatible however (same file formats etc); one can think of it as faster pip for our purposes here.

The requirements.txt files are manifests of our direct dependencies. We exclusively use == to pin; we like build hermeticity.

We use uv pip compile ... to create the requirements.*.lock files; we support development on linux & macos; deployment on linux. We generate these lock files because we want to be aware of, and pin, our transitive dependencies to be aware of our total attack surface and increase our build hermeticity across the team and CI.

We have a CI job to make certain that when we change a requirements.txt file we regenerate the lock files so they are not stale.

We have snyk wired up against our git-based source control; it automatically scans the repository. It picks up the requirements.txt files but not the lock files.

We see false-positive reports from components/requirements.txt - for example, requests@2.31.0 is vulnerable via SNYK-PYTHON-REQUESTS-6928867. However, we can see via our lock file that we depend on requests@2.33.3.

Is there a way to get snyk to understand our lock-files?

Perhaps it could scan our requirements.txt files as now but then use our lock files to filter those reports with the additional knowledge of what versions are actually in use.

Constraints in play

dependabot is in play within the repository. It understands requirements.in and requirements.txt files. It is directory-configured.

We don't want dependabot to aim at our transitive-dependencies lock files because it would open PRs against them that are not actionable by us until each of our direct-dependencies' upstream upgrades - at which point we'd have a new dependabot PR against that, making the others against the transitive-dependencies just be noise.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing how repository scanning handles components/requirements.txt and tools/requirements.txt, then investigate support for the corresponding requirements.linux.lock and requirements.macos.lock files generated by uv pip compile. Done should mean Snyk can account for the pinned transitive versions in these lock files and avoid reports based on outdated direct-dependency versions.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools, security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.