2020-10-26 23:22:13 +03:00
# Security Scorecards
2021-01-11 21:14:06 +03:00
2021-01-07 22:40:55 +03:00
![build ](https://github.com/ossf/scorecard/workflows/build/badge.svg?branch=main )
![CodeQL ](https://github.com/ossf/scorecard/workflows/CodeQL/badge.svg?branch=main )
2020-10-09 17:47:59 +03:00
2020-11-06 20:36:23 +03:00
< img align = "right" src = "artwork/openssf_security.png" width = "200" height = "400" >
2021-02-23 18:27:36 +03:00
<!-- vim - markdown - toc GFM -->
2021-07-29 23:58:36 +03:00
* [Motivation ](#motivation )
* [Goals ](#goals )
* [Scorecard Checks ](#scorecard-checks )
* [Usage ](#usage )
2021-08-24 03:12:03 +03:00
* [Authentication ](#authentication )
2021-07-29 23:58:36 +03:00
* [Docker ](#docker )
* [Using repository URL ](#using-repository-url )
* [Using a Package manager ](#using-a-package-manager )
* [Running specific checks ](#running-specific-checks )
* [Understanding Scorecard results ](#understanding-scorecard-results )
* [Formatting Results ](#formatting-results )
* [Public Data ](#public-data )
* [Adding a Scorecard Check ](#adding-a-scorecard-check )
* [Troubleshooting ](#troubleshooting )
* [Supportability ](#supportability )
* [Contributing ](#contributing )
2021-02-23 18:27:36 +03:00
<!-- vim - markdown - toc -->
2021-06-17 07:05:46 +03:00
2020-10-16 18:08:43 +03:00
## Motivation
2020-10-09 21:28:31 +03:00
2021-08-26 23:53:40 +03:00
We created Scorecards to give consumers of open-source projects an easy way to judge whether their dependencies are safe.
Scorecards is an automated tool that assesses a number of important heuristics [("checks") ](#scorecard-checks ) associated with software security and assigns each check a score of 0-10. You can use these scores to understand specific areas to improve in order to strengthen the security posture of your project. You can also assess the risks that dependencies introduce, and make informed decisions about accepting these risks, evaluating alternative solutions, or working with the maintainers to make improvements.
The inspiration for Scorecards’ logo: ["You passed! All D's ... and an A!" ](https://youtu.be/rDMMYT3vkTk )
2020-10-09 20:39:00 +03:00
2020-10-16 18:08:43 +03:00
## Goals
2021-01-05 03:47:02 +03:00
2021-06-17 07:05:46 +03:00
1. Automate analysis and trust decisions on the security posture of open source
projects.
2020-10-09 20:39:00 +03:00
2021-06-17 07:05:46 +03:00
1. Use this data to proactively improve the security posture of the critical
projects the world depends on.
2020-11-12 21:26:38 +03:00
2021-06-17 07:05:46 +03:00
## Scorecard Checks
2020-11-12 21:26:38 +03:00
2021-06-17 07:05:46 +03:00
The following checks are all run against the target project by default:
2020-11-12 21:26:38 +03:00
2021-07-29 23:58:36 +03:00
Name | Description
--------------------------- | -----------
2021-09-13 21:38:16 +03:00
[Binary-Artifacts ](docs/checks.md#binary-artifacts ) | Is the project free of checked-in binaries?
[Branch-Protection ](docs/checks.md#branch-protection ) | Does the project use [Branch Protection ](https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/about-protected-branches ) ?
[CI-Tests ](docs/checks.md#ci-tests ) | Does the project run tests in CI, e.g. [GitHub Actions ](https://docs.github.com/en/free-pro-team@latest/actions ), [Prow ](https://github.com/kubernetes/test-infra/tree/master/prow )?
[CII-Best-Practices ](docs/checks.md#cii-best-practices ) | Does the project have a [CII Best Practices Badge ](https://bestpractices.coreinfrastructure.org/en )?
[Code-Review ](docs/checks.md#code-review ) | Does the project require code review before code is merged?
[Contributors ](docs/checks.md#contributors ) | Does the project have contributors from at least two different organizations?
[Dependency-Update-Tool ](docs/checks.md#dependency-update-tool ) | Does the project use tools to help update its dependencies?
[Fuzzing ](docs/checks.md#fuzzing ) | Does the project use fuzzing tools, e.g. [OSS-Fuzz ](https://github.com/google/oss-fuzz )?
[Maintained ](docs/checks.md#Maintained ) | Is the project maintained?
[Pinned-Dependencies ](docs/checks.md#pinned-dependencies ) | Does the project declare and pin [dependencies ](https://docs.github.com/en/free-pro-team@latest/github/visualizing-repository-data-with-graphs/about-the-dependency-graph#supported-package-ecosystems )?
[Packaging ](docs/checks.md#packaging ) | Does the project build and publish official packages from CI/CD, e.g. [GitHub Publishing ](https://docs.github.com/en/free-pro-team@latest/actions/guides/about-packaging-with-github-actions#workflows-for-publishing-packages ) ?
[SAST ](docs/checks.md#sast ) | Does the project use static code analysis tools, e.g. [CodeQL ](https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/enabling-code-scanning-for-a-repository#enabling-code-scanning-using-actions ), [SonarCloud ](https://sonarcloud.io )?
[Security-Policy ](docs/checks.md#security-policy ) | Does the project contain a [security policy ](https://docs.github.com/en/free-pro-team@latest/github/managing-security-vulnerabilities/adding-a-security-policy-to-your-repository )?
[Signed-Releases ](docs/checks.md#signed-releases ) | Does the project cryptographically [sign releases ](https://wiki.debian.org/Creating%20signed%20GitHub%20releases )?
[Token-Permissions ](docs/checks.md#token-permissions ) | Does the project declare GitHub workflow tokens as [read only ](https://docs.github.com/en/actions/reference/authentication-in-a-workflow )?
[Vulnerabilities ](docs/checks.md#vulnerabilities ) | Does the project have unfixed vulnerabilities? Uses the [OSV service ](https://osv.dev ).
2021-06-29 22:02:12 +03:00
2021-06-17 07:05:46 +03:00
To see detailed information about each check and remediation steps, check out
2021-08-03 00:33:17 +03:00
the [checks documentation page ](docs/checks.md ).
2020-11-12 21:26:38 +03:00
2020-10-09 17:47:59 +03:00
## Usage
2021-08-24 03:12:03 +03:00
### Authentication
2021-09-08 18:22:25 +03:00
Before running Scorecard, you need to either:
2021-08-24 03:12:03 +03:00
- [create a GitHub access token ](https://docs.github.com/en/free-pro-team@latest/developers/apps/about-apps#personal-access-tokens )
and set it in an environment variable called `GITHUB_AUTH_TOKEN` ,
`GITHUB_TOKEN` , `GH_AUTH_TOKEN` or `GH_TOKEN` . This helps to avoid the
GitHub's [api rate limits ](https://developer.github.com/v3/#rate-limiting )
with unauthenticated requests.
```shell
# For posix platforms, e.g. linux, mac:
export GITHUB_AUTH_TOKEN=< your access token >
# Multiple tokens can be provided separated by comma to be utilized
# in a round robin fashion.
export GITHUB_AUTH_TOKEN=< your access token1 > ,< your access token2 >
# For windows:
set GITHUB_AUTH_TOKEN=< your access token >
set GITHUB_AUTH_TOKEN=< your access token1 > ,< your access token2 >
```
- create a GitHub App Installations for higher rate-limit quotas. If you have
2021-09-08 18:22:25 +03:00
an installed GitHub App and key file, you can use the three environment
variables below, following the commands shown above for your platform.
2021-08-24 03:12:03 +03:00
```
GITHUB_APP_KEY_PATH=< path to the key file on disk >
GITHUB_APP_INSTALLATION_ID=< installation id >
GITHUB_APP_ID=< app id >
```
2021-09-08 18:22:25 +03:00
These variables can be obtained from the GitHub
2021-08-24 03:12:03 +03:00
[developer settings ](https://github.com/settings/apps ) page.
2021-07-16 20:18:42 +03:00
### Docker
`scorecard` is available as a Docker container:
The `GITHUB_AUTH_TOKEN` has to be set to a valid [token ](#Authentication )
2021-07-29 23:58:36 +03:00
```shell
2021-08-18 18:41:20 +03:00
docker run -e GITHUB_AUTH_TOKEN=token gcr.io/openssf/scorecard:stable --show-details --repo=https://github.com/ossf/scorecard
2021-07-16 20:18:42 +03:00
```
2021-09-08 18:22:25 +03:00
### Running Scorecards Using a URL
2021-06-17 07:05:46 +03:00
2021-09-08 18:22:25 +03:00
Scorecards can run using just one argument, the URL of the target repo:
2020-10-09 17:47:59 +03:00
```shell
2021-09-03 18:09:32 +03:00
$ go install github.com/ossf/scorecard/v2@latest
2021-08-26 00:02:23 +03:00
$ scorecard --repo=github.com/ossf-tests/scorecard-check-branch-protection-e2e
Starting [CII-Best-Practices]
2020-10-16 17:54:29 +03:00
Starting [Fuzzing]
2021-08-26 00:02:23 +03:00
Starting [Pinned-Dependencies]
Starting [CI-Tests]
Starting [Maintained]
2021-06-29 22:02:12 +03:00
Starting [Packaging]
2021-08-26 00:02:23 +03:00
Starting [SAST]
Starting [Dependency-Update-Tool]
2021-06-29 22:02:12 +03:00
Starting [Token-Permissions]
Starting [Security-Policy]
2021-08-26 00:02:23 +03:00
Starting [Signed-Releases]
2021-06-29 22:02:12 +03:00
Starting [Binary-Artifacts]
2021-08-26 00:02:23 +03:00
Starting [Branch-Protection]
Starting [Code-Review]
Starting [Contributors]
Starting [Vulnerabilities]
2021-06-29 22:02:12 +03:00
Finished [CI-Tests]
2021-08-26 00:02:23 +03:00
Finished [Maintained]
2021-01-15 19:29:07 +03:00
Finished [Packaging]
2021-08-26 00:02:23 +03:00
Finished [SAST]
Finished [Signed-Releases]
Finished [Binary-Artifacts]
Finished [Branch-Protection]
Finished [Code-Review]
Finished [Contributors]
Finished [Dependency-Update-Tool]
2021-06-29 22:02:12 +03:00
Finished [Token-Permissions]
2021-01-15 19:29:07 +03:00
Finished [Security-Policy]
2021-08-26 00:02:23 +03:00
Finished [Vulnerabilities]
Finished [CII-Best-Practices]
2021-06-29 22:02:12 +03:00
Finished [Fuzzing]
2021-08-26 00:02:23 +03:00
Finished [Pinned-Dependencies]
2020-10-09 18:26:43 +03:00
RESULTS
-------
2021-08-26 00:02:23 +03:00
|---------|------------------------|--------------------------------|---------------------------------------------------------------------------|
| SCORE | NAME | REASON | DOCUMENTATION/REMEDIATION |
|---------|------------------------|--------------------------------|---------------------------------------------------------------------------|
| 10 / 10 | Binary-Artifacts | no binaries found in the repo | github.com/ossf/scorecard/blob/main/docs/checks.md#binary-artifacts |
|---------|------------------------|--------------------------------|---------------------------------------------------------------------------|
| 9 / 10 | Branch-Protection | branch protection is not | github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection |
| | | maximal on development and all | |
| | | release branches | |
|---------|------------------------|--------------------------------|---------------------------------------------------------------------------|
| ? | CI-Tests | no pull request found | github.com/ossf/scorecard/blob/main/docs/checks.md#ci-tests |
|---------|------------------------|--------------------------------|---------------------------------------------------------------------------|
| 0 / 10 | CII-Best-Practices | no badge found | github.com/ossf/scorecard/blob/main/docs/checks.md#cii-best-practices |
|---------|------------------------|--------------------------------|---------------------------------------------------------------------------|
| 10 / 10 | Code-Review | branch protection for default | github.com/ossf/scorecard/blob/main/docs/checks.md#code-review |
| | | branch is enabled | |
|---------|------------------------|--------------------------------|---------------------------------------------------------------------------|
| 0 / 10 | Contributors | 0 different companies found -- | github.com/ossf/scorecard/blob/main/docs/checks.md#contributors |
| | | score normalized to 0 | |
|---------|------------------------|--------------------------------|---------------------------------------------------------------------------|
| 0 / 10 | Dependency-Update-Tool | no update tool detected | github.com/ossf/scorecard/blob/main/docs/checks.md#dependency-update-tool |
|---------|------------------------|--------------------------------|---------------------------------------------------------------------------|
| 0 / 10 | Fuzzing | project is not fuzzed in | github.com/ossf/scorecard/blob/main/docs/checks.md#fuzzing |
| | | OSS-Fuzz | |
|---------|------------------------|--------------------------------|---------------------------------------------------------------------------|
| 1 / 10 | Maintained | 2 commit(s) found in the last | github.com/ossf/scorecard/blob/main/docs/checks.md#maintained |
| | | 90 days -- score normalized to | |
| | | 1 | |
|---------|------------------------|--------------------------------|---------------------------------------------------------------------------|
| ? | Packaging | no published package detected | github.com/ossf/scorecard/blob/main/docs/checks.md#packaging |
|---------|------------------------|--------------------------------|---------------------------------------------------------------------------|
| 8 / 10 | Pinned-Dependencies | unpinned dependencies detected | github.com/ossf/scorecard/blob/main/docs/checks.md#pinned-dependencies |
| | | -- score normalized to 8 | |
|---------|------------------------|--------------------------------|---------------------------------------------------------------------------|
| 0 / 10 | SAST | no SAST tool detected | github.com/ossf/scorecard/blob/main/docs/checks.md#sast |
|---------|------------------------|--------------------------------|---------------------------------------------------------------------------|
| 0 / 10 | Security-Policy | security policy file not | github.com/ossf/scorecard/blob/main/docs/checks.md#security-policy |
| | | detected | |
|---------|------------------------|--------------------------------|---------------------------------------------------------------------------|
| ? | Signed-Releases | no releases found | github.com/ossf/scorecard/blob/main/docs/checks.md#signed-releases |
|---------|------------------------|--------------------------------|---------------------------------------------------------------------------|
| 10 / 10 | Token-Permissions | tokens are read-only in GitHub | github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions |
| | | workflows | |
|---------|------------------------|--------------------------------|---------------------------------------------------------------------------|
| 10 / 10 | Vulnerabilities | no vulnerabilities detected | github.com/ossf/scorecard/blob/main/docs/checks.md#vulnerabilities |
|---------|------------------------|--------------------------------|---------------------------------------------------------------------------|
2021-06-29 22:02:12 +03:00
```
2021-09-08 18:22:25 +03:00
### Showing Detailed Results
2021-06-29 22:02:12 +03:00
For more details why a check fails, use the `--show-details` option:
2021-07-29 23:58:36 +03:00
2021-06-29 22:02:12 +03:00
```
2021-08-26 00:02:23 +03:00
./scorecard --repo=github.com/ossf-tests/scorecard-check-branch-protection-e2e --checks Branch-Protection --show-details
Starting [Pinned-Dependencies]
Finished [Pinned-Dependencies]
RESULTS
-------
|---------|------------------------|--------------------------------|--------------------------------|---------------------------------------------------------------------------|
| SCORE | NAME | REASON | DETAILS | DOCUMENTATION/REMEDIATION |
|---------|------------------------|--------------------------------|--------------------------------|---------------------------------------------------------------------------|
| 9 / 10 | Branch-Protection | branch protection is not | Info: 'force pushes' disabled | github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection |
| | | maximal on development and all | on branch 'main' Info: 'allow | |
| | | release branches | deletion' disabled on branch | |
| | | | 'main' Info: linear history | |
| | | | enabled on branch 'main' Info: | |
| | | | strict status check enabled | |
| | | | on branch 'main' Warn: status | |
| | | | checks for merging have no | |
| | | | specific status to check on | |
| | | | branch 'main' Info: number | |
| | | | of required reviewers is 2 | |
| | | | on branch 'main' Info: Stale | |
| | | | review dismissal enabled on | |
| | | | branch 'main' Info: Owner | |
| | | | review required on branch | |
| | | | 'main' Info: 'admininistrator' | |
| | | | PRs need reviews before being | |
| | | | merged on branch 'main' | |
|---------|------------------------|--------------------------------|--------------------------------|---------------------------------------------------------------------------|
2020-10-09 17:47:59 +03:00
```
2021-09-08 18:22:25 +03:00
### Running Scorecards Using a Package Manager
2021-02-02 19:29:31 +03:00
2021-09-08 18:22:25 +03:00
For projects in the `--npm` , `--pypi` , or `--rubygems` ecosystems, you have the option to run Scorecards using a package manager. Provide the package name to run the checks on the corresponding GitHub source code.
2021-03-01 19:21:20 +03:00
For example:
2021-02-02 19:29:31 +03:00
2021-06-17 07:05:46 +03:00
```shell
2021-02-02 19:29:31 +03:00
./scorecard --npm=angular
Starting [Active]
Starting [Branch-Protection]
Starting [CI-Tests]
Starting [CII-Best-Practices]
Starting [Code-Review]
Starting [Contributors]
2021-08-26 00:02:23 +03:00
Starting [Pinned-Dependencies]
2021-02-02 19:29:31 +03:00
Starting [Fuzzing]
Starting [Packaging]
Starting [Pull-Requests]
Starting [SAST]
Starting [Security-Policy]
Starting [Signed-Releases]
Finished [Signed-Releases]
Finished [Fuzzing]
Finished [CII-Best-Practices]
Finished [Security-Policy]
Finished [CI-Tests]
Finished [Packaging]
Finished [SAST]
Finished [Code-Review]
Finished [Branch-Protection]
2021-08-26 00:02:23 +03:00
Finished [Pinned-Dependencies]
2021-02-02 19:29:31 +03:00
Finished [Active]
Finished [Pull-Requests]
Finished [Contributors]
RESULTS
-------
Active: Fail 10
Branch-Protection: Fail 0
CI-Tests: Pass 10
CII-Best-Practices: Fail 10
Code-Review: Pass 10
Contributors: Pass 10
2021-08-26 00:02:23 +03:00
Pinned-Dependencies: Fail 0
2021-02-02 19:29:31 +03:00
Fuzzing: Fail 10
Packaging: Fail 0
Pull-Requests: Fail 9
SAST: Fail 10
Security-Policy: Pass 10
Signed-Releases: Fail 0
```
2021-09-08 18:22:25 +03:00
### Running Specific Checks
2021-03-13 01:57:44 +03:00
2021-09-08 18:22:25 +03:00
To run only specific check(s), add the `--checks` argument with a list of check
2021-06-17 07:05:46 +03:00
names.
2021-03-13 01:57:44 +03:00
2021-06-17 07:05:46 +03:00
For example, `--checks=CI-Tests,Code-Review` .
2021-02-22 20:18:28 +03:00
2021-09-08 18:22:25 +03:00
### Understanding Scorecard Results
2020-10-09 17:47:59 +03:00
2021-06-17 07:05:46 +03:00
Each check returns a **Pass / Fail** decision, as well as a confidence score
between **0 and 10** . A confidence of 0 should indicate the check was unable to
achieve any real signal, and the result should be ignored. A confidence of 10
indicates the check is completely sure of the result.
2020-10-22 17:38:33 +03:00
2021-06-17 07:05:46 +03:00
### Formatting Results
2020-10-14 22:42:05 +03:00
2021-06-17 07:05:46 +03:00
There are three formats currently: `default` , `json` , and `csv` . Others may be
added in the future.
2020-10-09 17:47:59 +03:00
2021-06-17 07:05:46 +03:00
These may be specified with the `--format` flag.
2020-10-09 17:47:59 +03:00
2021-06-17 07:05:46 +03:00
## Public Data
2020-10-09 17:47:59 +03:00
2021-09-08 18:22:25 +03:00
We publish a list of projects checked by Scorecards and their results in the
[BigQuery public dataset ](https://cloud.google.com/bigquery/public-data )
2021-06-17 07:05:46 +03:00
`openssf:scorecardcron.scorecard` . The latest results are available in the
BigQuery view `openssf:scorecardcron.scorecard_latest` .
2020-11-10 05:29:37 +03:00
2021-06-17 07:05:46 +03:00
You can extract the latest results to Google Cloud storage in JSON format using
the [`bq` ](https://cloud.google.com/bigquery/docs/bq-command-line-tool ) tool:
2020-11-10 05:29:37 +03:00
2021-06-17 07:05:46 +03:00
```
# Get the latest PARTITION_ID
bq query --nouse_legacy_sql 'SELECT partition_id FROM
2021-08-11 03:56:39 +03:00
openssf.scorecardcron.INFORMATION_SCHEMA.PARTITIONS WHERE table_name="scorecard"
ORDER BY partition_id DESC
2021-06-17 07:05:46 +03:00
LIMIT 1'
2020-11-10 05:29:37 +03:00
2021-06-17 07:05:46 +03:00
# Extract to GCS
bq extract --destination_format=NEWLINE_DELIMITED_JSON
'openssf:scorecardcron.scorecard$< partition_id > ' gs://bucket-name/filename.json
2020-11-10 05:29:37 +03:00
2021-06-17 07:05:46 +03:00
```
2020-11-10 05:29:37 +03:00
2021-06-17 07:05:46 +03:00
The list of projects that are checked is available in the
[`cron/data/projects.csv` ](https://github.com/ossf/scorecard/blob/main/cron/data/projects.csv )
file in this repository. If you would like us to track more, please feel free to
send a Pull Request with others.
2021-01-05 03:47:02 +03:00
2021-06-17 07:05:46 +03:00
**NOTE**: Currently, these lists are derived from **projects hosted on GitHub
ONLY**. We do plan to expand them in near future to account for projects hosted
on other source control systems.
## Adding a Scorecard Check
2021-09-08 18:22:25 +03:00
If you'd like to add a check, please see guidance [here ](checks/write.md ).
2020-11-05 23:27:10 +03:00
2021-06-05 00:47:45 +03:00
## Troubleshooting
2021-01-05 20:32:06 +03:00
2021-06-17 07:05:46 +03:00
- ### Bugs and Feature Requests:
If you have what looks like a bug, or you would like to make a feature
request, please use the
[Github issue tracking system. ](https://github.com/ossf/scorecard/issues )
Before you file an issue, please search existing issues to see if your issue
is already covered.
2021-06-05 00:47:45 +03:00
2021-06-17 07:05:46 +03:00
- ### Slack
2021-06-05 00:47:45 +03:00
2021-06-17 07:05:46 +03:00
For realtime discussion, you can join the
[#security_scorecards ](https://slack.openssf.org/#security_scorecards ) slack
2021-09-08 18:22:25 +03:00
channel. The Slack platform requires registration, but the openssf team channel is open
to anyone. Feel free to come and ask any
2021-06-17 07:05:46 +03:00
questions.
2021-06-05 00:47:45 +03:00
## Supportability
2021-09-08 18:22:25 +03:00
Currently, scorecard officially supports OSX and Linux platforms. If you are
2021-06-17 07:05:46 +03:00
using a Windows OS you may find issues. Contributions towards supporting Windows
are welcome.
2021-01-05 16:45:15 +03:00
2020-11-05 23:27:10 +03:00
## Contributing
2021-06-17 07:05:46 +03:00
If you want to get involved or have ideas you'd like to chat about, we discuss
this project in the
[OSSF Best Practices Working Group ](https://github.com/ossf/wg-best-practices-os-developers )
meetings.
2021-06-05 00:47:45 +03:00
2021-06-17 07:05:46 +03:00
See the
[Community Calendar ](https://calendar.google.com/calendar?cid=czYzdm9lZmhwNWk5cGZsdGI1cTY3bmdwZXNAZ3JvdXAuY2FsZW5kYXIuZ29vZ2xlLmNvbQ )
for the schedule and meeting invitations. The meetings happen biweekly
https://calendar.google.com/calendar/embed?src=s63voefhp5i9pfltb5q67ngpes%40group.calendar.google.com& ctz=America%2FLos_Angeles
2021-06-05 00:47:45 +03:00
2021-06-17 07:05:46 +03:00
See the [Contributing ](CONTRIBUTING.md ) documentation for guidance on how to
contribute.