Third-party libraries save time, but they also add supply chain risk. For teams with lots of Python services, what controls are useful without making every dependency update a headache?
How do you handle Python dependency security without slowing everything down?
Answers
Pin dependencies in a lockfile, scan for known vulnerabilities, and put a short delay on routine updates so brand-new releases don't go straight into production. For example, uv has an exclude-newer setting, and automated update tools can use a cooldown.
A week is one possible starting point, not a guarantee that a package is safe. You still need a way to move faster when there's an urgent fix.
Reply to this answer
A private repository can give you a review point without asking every developer to vet every download. One setup is to scan packages as they come in, then promote approved versions to a separate repository that services install from.
That adds maintenance and can slow updates, so it makes more sense if you have enough services to share the process. A managed mirror is another option, but a simple two-stage setup doesn't necessarily need a commercial tool.
Reply to this answer
Don't treat every scanner alert as an automatic major-version upgrade. Check whether the affected code is actually reachable in your application, whether a fix was backported, and whether a transitive dependency can be pinned or overridden safely.
Reachability can help prioritize findings, but an unreachable result isn't proof that a dependency is safe. Keep the finding visible and reassess if how you use the package changes.
Reply to this answer
For a more conservative setup, start with the standard library and add external packages when they solve a problem that's worth the dependency. Favor well-maintained, widely used projects, and consider packages supplied by a major Linux distribution if that fits your deployment model.
That won't suit every service. Avoiding public package repositories entirely can reduce exposure to that particular source, but it also narrows your choices.
Reply to this answer
Another small design choice is to make a dependency optional when the feature allows it. If a noncritical package is unavailable or fails a security check, you might disable that feature or use a simpler fallback instead of blocking the whole service.
That's resilience, not a substitute for scanning or reviewing dependencies.
Reply to this answer
Add your answer
Answers are reviewed before publication.
2r+mapspindle_438:
It also helps to have a clear request process for packages that aren't in the approved repository yet. Otherwise the mirror can become a bottleneck.