Lockfiles vs pinning vs hash checks: what actually protects you from a bad package update?
I'm trying to understand which habits really protect a project if a dependency publishes a malicious version.
My current understanding:
- A lockfile records exact versions, so a fresh install doesn't silently pick up something new
- Pinning in the manifest makes upgrades intentional, but doesn't cover dependencies of dependencies by itself
- Integrity hashes make sure the file you download is the same one you locked
None of that helps if you happily upgrade to the bad version yourself. Do you add a waiting period before adopting new releases, or review changes in critical packages?
Comments · 3
Your understanding is solid. Lockfiles with hashes help most, because they verify content as well as version. Also review dependency updates instead of auto-merging them.
Commit the lockfile, install from it in CI, and review upgrades. That's the core of it.
It's cheap risk reduction. A single compromised package can hurt a startup's reputation more than most bugs, so build update review into the routine.