-
Notifications
You must be signed in to change notification settings - Fork 15
RC npm: lockfiles or no lockfiles #24
Description
(Note: I will leave aside the npm-shrinkwrap.json since it's discussed separately in #10)
In this issue, I'd like to propose a change to the recommendation w.r.t lockfiles.
The OSSF (e.g., via the Scorecard's Pinned-Dependency checks) has been encouraging lockfiles, a.k.a. "hash dependency pinning".
The main advantages of lockfiles are the following:
- incidence response (Concerns about metrics from @ljharb scorecard#1826): engineers can quickly identify the list of hashes that made use of a malicious package
- avoids immediate (potentially malicious) package updates to prod
There has been feedback, e.g. by @ljharb in ossf/scorecard#1826 (comment) and #10 (comment) that lockfiles, in some scenarios, have disadvantages.
The main drawback highlighted by @ljharb is dev lock files. A dev lockfile is one that is used by the maintainer of a project, call it P. P relies on a set of dependencies: PPs. All tests may be passing for P, yet some bugs are reported by consumers because of a drift in PP versions.
As a results, consumers have a poorer experience, since they hit bugs (possibly in prod), need to file issues for P, etc. @ljharb describes it as it's [...] important to ensure that maintainers are notified as early as possible about issues in their dep graph..
Since the benefit of lockfiles is prod and their absence is motivated by catching bugs early, I'd like to suggest rephrasing the recommendation to (roughly):
We recommend using a lock file in privileged environments, such as:
- Production environments
- Other environments with access to sensitive data, such as secrets, PII, write/push permission to the repository, etc
The use of a lock file has the following benefits:
- In an incidence response, it helps identify vulnerable packages that have been used, using the sha512
- It reduces the chance of pulling in new-compromised packages directly into privileged environments.
- _others_from_current_draft_
In a non-privileged environment, developers need not use a lock file.
This is useful when developers want to exercise a wide range of dependency versions in their tests,
to anticipate breaking before consumers do. If you run CI via GitHub Actions, a non-privileged environment is one of the following:
- pull_request trigger
- Other triggers without secrets and permissions explicitly declared as read (the default permissions is write-all)
This is just a rough draft, but I'd like to hear your opinion whether it would address some of the concerns that were raised.