Skip to content

Commit 3eab4dd

Browse files
authored
📖 Clarifications about the pinned dependencies check (#2319)
* Clarifications about the pinned dependencies check The pinned dependencies check is confusing to authors of libraries, who shouldn't be pinning the dependencies of the library. But it is still valuable for flagging things which are used as part of the build and release process for a library. Signed-off-by: Jeremy Katz <jeremy@tidelift.com> * Regenerate docs/checks.md Signed-off-by: Jeremy Katz <jeremy@tidelift.com> Signed-off-by: Jeremy Katz <jeremy@tidelift.com>
1 parent 9b9006e commit 3eab4dd

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

docs/checks.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -438,13 +438,14 @@ issue](https://github.com/ossf/scorecard/issues/new/choose).
438438

439439
Risk: `Medium` (possible compromised dependencies)
440440

441-
This check tries to determine if the project pins its dependencies.
441+
This check tries to determine if the project pins dependencies used during its build and release process.
442442
A "pinned dependency" is a dependency that is explicitly set to a specific hash instead of
443443
allowing a mutable version or range of versions. It
444444
is currently limited to repositories hosted on GitHub, and does not support
445445
other source hosting repositories (i.e., Forges).
446446

447-
The check works by looking for unpinned dependencies in Dockerfiles, shell scripts and GitHub workflows.
447+
The check works by looking for unpinned dependencies in Dockerfiles, shell scripts, and GitHub workflows
448+
which are used during the build and release process of a project.
448449

449450
Pinned dependencies reduce several security risks:
450451

@@ -464,7 +465,6 @@ However, pinning dependencies can inhibit software updates, either because of a
464465
security vulnerability or because the pinned version is compromised. Mitigate
465466
this risk by:
466467

467-
- [having applications and _not_ libraries pin to specific hashes](https://jbeckwith.com/2019/12/18/package-lock/);
468468
- using automated tools to notify applications when their dependencies are
469469
outdated;
470470
- quickly updating applications that do pin dependencies.
@@ -474,11 +474,10 @@ dependencies using the [GitHub dependency graph](https://docs.github.com/en/code
474474

475475

476476
**Remediation steps**
477-
- First determine if your project is producing a library or application. If it is a library, you generally don't want to pin dependencies of library users, and should not follow any remediation steps.
478477
- If your project is producing an application, declare all your dependencies with specific versions in your package format file (e.g. `package.json` for npm, `requirements.txt` for python). For C/C++, check in the code from a trusted source and add a `README` on the specific version used (and the archive SHA hashes).
479-
- If the package manager supports lock files (e.g. `package-lock.json` for npm), make sure to check these in the source code as well. These files maintain signatures for the entire dependency tree and saves from future exploitation in case the package is compromised.
480-
- For Dockerfiles, pin dependencies by hash. See [Dockerfile](https://github.com/ossf/scorecard/blob/main/cron/internal/worker/Dockerfile) for example. If you are using a manifest list to support builds across multiple architectures, you can pin to the manifest list hash instead of a single image hash. You can use a tool like [crane](https://github.com/google/go-containerregistry/blob/main/cmd/crane/README.md) to obtain the hash of the manifest list like in this [example](https://github.com/ossf/scorecard/issues/1773#issuecomment-1076699039).
481-
- For GitHub workflows, pin dependencies by hash. See [main.yaml](https://github.com/ossf/scorecard/blob/f55b86d6627cc3717e3a0395e03305e81b9a09be/.github/workflows/main.yml#L27) for example. To determine the permissions needed for your workflows, you may use [StepSecurity's online tool](https://app.stepsecurity.io/) by ticking the "Pin actions to a full length commit SHA". You may also tick the "Restrict permissions for GITHUB_TOKEN" to fix issues found by the Token-Permissions check.
478+
- If your project is producing an application and the package manager supports lock files (e.g. `package-lock.json` for npm), make sure to check these in the source code as well. These files maintain signatures for the entire dependency tree and saves from future exploitation in case the package is compromised.
479+
- For Dockerfiles used in building and releasing your project, pin dependencies by hash. See [Dockerfile](https://github.com/ossf/scorecard/blob/main/cron/internal/worker/Dockerfile) for example. If you are using a manifest list to support builds across multiple architectures, you can pin to the manifest list hash instead of a single image hash. You can use a tool like [crane](https://github.com/google/go-containerregistry/blob/main/cmd/crane/README.md) to obtain the hash of the manifest list like in this [example](https://github.com/ossf/scorecard/issues/1773#issuecomment-1076699039).
480+
- For GitHub workflows used in building and releasing your project, pin dependencies by hash. See [main.yaml](https://github.com/ossf/scorecard/blob/f55b86d6627cc3717e3a0395e03305e81b9a09be/.github/workflows/main.yml#L27) for example. To determine the permissions needed for your workflows, you may use [StepSecurity's online tool](https://app.stepsecurity.io/) by ticking the "Pin actions to a full length commit SHA". You may also tick the "Restrict permissions for GITHUB_TOKEN" to fix issues found by the Token-Permissions check.
482481
- To help update your dependencies after pinning them, use tools such as
483482
Github's [dependabot](https://github.blog/2020-06-01-keep-all-your-packages-up-to-date-with-dependabot/)
484483
or [renovate bot](https://github.com/renovatebot/renovate).

docs/checks/internal/checks.yaml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -447,17 +447,18 @@ checks:
447447
risk: Medium
448448
tags: supply-chain, security, dependencies
449449
repos: GitHub, local
450-
short: Determines if the project has declared and pinned its dependencies.
450+
short: Determines if the project has declared and pinned the dependencies of its build process.
451451
description: |
452452
Risk: `Medium` (possible compromised dependencies)
453453
454-
This check tries to determine if the project pins its dependencies.
454+
This check tries to determine if the project pins dependencies used during its build and release process.
455455
A "pinned dependency" is a dependency that is explicitly set to a specific hash instead of
456456
allowing a mutable version or range of versions. It
457457
is currently limited to repositories hosted on GitHub, and does not support
458458
other source hosting repositories (i.e., Forges).
459459
460-
The check works by looking for unpinned dependencies in Dockerfiles, shell scripts and GitHub workflows.
460+
The check works by looking for unpinned dependencies in Dockerfiles, shell scripts, and GitHub workflows
461+
which are used during the build and release process of a project.
461462
462463
Pinned dependencies reduce several security risks:
463464
@@ -477,35 +478,30 @@ checks:
477478
security vulnerability or because the pinned version is compromised. Mitigate
478479
this risk by:
479480
480-
- [having applications and _not_ libraries pin to specific hashes](https://jbeckwith.com/2019/12/18/package-lock/);
481481
- using automated tools to notify applications when their dependencies are
482482
outdated;
483483
- quickly updating applications that do pin dependencies.
484484
485485
For projects hosted on GitHub, you can learn more about
486486
dependencies using the [GitHub dependency graph](https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-the-dependency-graph).
487487
remediation:
488-
- >-
489-
First determine if your project is producing a library or
490-
application. If it is a library, you generally don't want to pin dependencies of
491-
library users, and should not follow any remediation steps.
492488
- >-
493489
If your project is producing an application, declare all your dependencies with specific versions in your package
494490
format file (e.g. `package.json` for npm, `requirements.txt` for python).
495491
For C/C++, check in the code from a trusted source and add a `README` on the
496492
specific version used (and the archive SHA hashes).
497493
- >-
498-
If the package manager supports lock files (e.g. `package-lock.json` for
494+
If your project is producing an application and the package manager supports lock files (e.g. `package-lock.json` for
499495
npm), make sure to check these in the source code as well. These files
500496
maintain signatures for the entire dependency tree and saves from future
501497
exploitation in case the package is compromised.
502498
- >-
503-
For Dockerfiles, pin dependencies by hash. See [Dockerfile](https://github.com/ossf/scorecard/blob/main/cron/internal/worker/Dockerfile) for example. If you are using a manifest list to support builds
499+
For Dockerfiles used in building and releasing your project, pin dependencies by hash. See [Dockerfile](https://github.com/ossf/scorecard/blob/main/cron/internal/worker/Dockerfile) for example. If you are using a manifest list to support builds
504500
across multiple architectures, you can pin to the manifest list hash instead
505501
of a single image hash. You can use a tool like [crane](https://github.com/google/go-containerregistry/blob/main/cmd/crane/README.md)
506502
to obtain the hash of the manifest list like in this [example](https://github.com/ossf/scorecard/issues/1773#issuecomment-1076699039).
507503
- >-
508-
For GitHub workflows, pin dependencies by hash. See [main.yaml](https://github.com/ossf/scorecard/blob/f55b86d6627cc3717e3a0395e03305e81b9a09be/.github/workflows/main.yml#L27) for example.
504+
For GitHub workflows used in building and releasing your project, pin dependencies by hash. See [main.yaml](https://github.com/ossf/scorecard/blob/f55b86d6627cc3717e3a0395e03305e81b9a09be/.github/workflows/main.yml#L27) for example.
509505
To determine the permissions needed for your workflows, you may use [StepSecurity's online tool](https://app.stepsecurity.io/) by ticking
510506
the "Pin actions to a full length commit SHA". You may also tick the "Restrict permissions for GITHUB_TOKEN" to fix issues found
511507
by the Token-Permissions check.

0 commit comments

Comments
 (0)