Skip to content
This repository was archived by the owner on Oct 9, 2023. It is now read-only.
This repository was archived by the owner on Oct 9, 2023. It is now read-only.

RC npm: lockfiles or no lockfiles #24

@laurentsimon

Description

@laurentsimon

(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:

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.

/cc @lirantal, @soldair

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions