Interview Prep/DevSecOps/Supply Chain Security

Why do you use `npm ci` and lockfiles in CI, and what does it protect against?

IntermediateScenarioSupply Chain Security
Answer

Situation read → npm install may update versions, so two builds of the same commit can differ.

What I'd do →

  1. Commit package-lock.json, poetry.lock, go.sum, Cargo.lock.
  2. In CI use npm ci (fails if the lockfile does not match package.json), pip install --require-hashes -r requirements.txt, go mod verify.
  3. Review lockfile diffs in PRs.
  4. Block registry-source changes in lockfile with a check.

Why → Reproducible installs mean a poisoned new release does not enter automatically.

Interview tip → Lockfile integrity hashes also detect tampered tarballs.

All DevSecOps questions Roadmap: Supply chain, secrets & identity

More on Supply Chain Security