OpenSSF Scorecard - Security health metrics for Open Source
Go to file
laurentsimon d528b6e626
Cleanup code for github tokens #534 (#539)
* missed comments

* comments
2021-06-04 00:12:56 +00:00
.github 🌱 Bump goreleaser/goreleaser-action from 2.6.0 to 2.6.1 2021-05-31 09:14:30 -04:00
artwork adding logo (#44) 2020-11-06 11:36:23 -06:00
checker 🌱 Fix lint issues: Replace golint with revive (#493) 2021-05-24 11:34:33 -07:00
checks Cleanup code for github tokens #534 (#539) 2021-06-04 00:12:56 +00:00
cloudbuild Remove CloudBuild trigger for daily cron job (#535) 2021-06-02 19:02:13 -07:00
cmd Add new linter: errorlint 2021-05-30 13:12:42 -04:00
cron Poll Pubsub worker until message is received (#536) 2021-06-03 10:58:37 -07:00
e2e Remove daily cron job from codebase (#530) 2021-06-02 14:27:09 -07:00
gitcache Add new linter: gci (#498) 2021-05-23 20:51:52 -07:00
pkg Add new linter: gci (#498) 2021-05-23 20:51:52 -07:00
repos 🌱 Fix lint issues: Replace golint with revive (#493) 2021-05-24 11:34:33 -07:00
roundtripper 🌱 Fix lint issues: Replace golint with revive (#493) 2021-05-24 11:34:33 -07:00
scripts Cron job uses line-delimited JSON (#344) 2021-04-19 12:49:51 -07:00
stats 🌱 Fix lint issues: Replace golint with revive (#493) 2021-05-24 11:34:33 -07:00
.codecov.yml Feature - Report codecoverage to codecov.io 2021-01-26 17:49:11 -05:00
.gitignore Add worker to the PubSub framework. (#463) 2021-05-18 15:18:08 -07:00
.golangci.yml Add new linter: errorlint 2021-05-30 13:12:42 -04:00
.goreleaser.yml Feature - sign releases 2021-02-17 17:53:41 -05:00
CODE_OF_CONDUCT.md updating code of conduct to match ossfs (#42) 2020-11-05 14:13:16 -06:00
CONTRIBUTING.md 🌱Fix lint issues: gochecknoinits linter (#485) 2021-05-22 13:19:52 -04:00
Dockerfile 🌱 Bump golang from 6f0b0a3 to 8a106c4 (#519) 2021-05-28 12:11:23 -04:00
go.mod 🌱 Bump cloud.google.com/go/pubsub from 1.10.3 to 1.11.0 2021-06-03 12:07:47 -04:00
go.sum 🌱 Bump cloud.google.com/go/pubsub from 1.10.3 to 1.11.0 2021-06-03 12:07:47 -04:00
LICENSE Add license header and code of conduct files. (#34) 2020-10-26 15:22:13 -05:00
main.go Rename repo/modules. 2020-10-27 14:23:48 -05:00
Makefile Remove daily cron job from codebase (#530) 2021-06-02 14:27:09 -07:00
README.md 🌱 Move the docker containers to gcr.io (#419) 2021-05-11 14:11:06 +00:00
SECURITY.md Add SECURITY.md 2021-02-13 14:53:06 -05:00
tools.go 🌱 Move tool dependencies into go.mod (#460) 2021-05-17 15:20:28 -04:00

Security Scorecards

build CodeQL codecov

Motivation

A short motivational video clip to inspire us: https://youtu.be/rDMMYT3vkTk "You passed! All D's ... and an A!"

Goals

  1. Automate analysis and trust decisions on the security posture of open source projects.

  2. Use this data to proactively improve the security posture of the critical projects the world depends on.

Public Data

If you're only interested in seeing the results over time, we run this program nightly and publish the results in json format.

This data is available on Google Cloud Storage and can be downloaded via the gsutil command-line tool.

$ gsutil ls gs://ossf-scorecards/
gs://ossf-scorecards/11-11-2020.json
...

The latest results are also always available at https://storage.googleapis.com/ossf-scorecards/latest.json

The list of projects that are checked each night is available in the cron/projects.txt file in this repository. If you would like us to track more, please feel free to send a Pull Request with others.

Usage

The program only requires one argument to run, the name of the repo:

$ go build
$ ./scorecard --repo=github.com/kubernetes/kubernetes
Starting [Active]
Starting [Branch-Protection]
Starting [CI-Tests]
Starting [CII-Best-Practices]
Starting [Code-Review]
Starting [Contributors]
Starting [Frozen-Deps]
Starting [Fuzzing]
Starting [Packaging]
Starting [Pull-Requests]
Starting [SAST]
Starting [Security-Policy]
Starting [Signed-Releases]
Starting [Signed-Tags]
Finished [Fuzzing]
Finished [CII-Best-Practices]
Finished [Branch-Protection]
Finished [Packaging]
Finished [Security-Policy]
Finished [Frozen-Deps]
Finished [Signed-Tags]
Finished [Signed-Releases]
Finished [SAST]
Finished [CI-Tests]
Finished [Active]
Finished [Contributors]
Finished [Pull-Requests]
Finished [Code-Review]

RESULTS
-------
Active: Pass 10
Branch-Protection: Fail 10
CI-Tests: Pass 10
CII-Best-Practices: Pass 10
Code-Review: Pass 10
Contributors: Pass 10
Frozen-Deps: Pass 10
Fuzzing: Pass 10
Packaging: Fail 0
Pull-Requests: Pass 10
SAST: Fail 10
Security-Policy: Pass 10
Signed-Releases: Fail 10
Signed-Tags: Fail 10

Package manager support

scorecard has an option to provide either --npm / --pypi / --rubygems package name and it would run the checks on the corresponding GitHub source code.

For example:

./scorecard --npm=angular
Starting [Active]
Starting [Branch-Protection]
Starting [CI-Tests]
Starting [CII-Best-Practices]
Starting [Code-Review]
Starting [Contributors]
Starting [Frozen-Deps]
Starting [Fuzzing]
Starting [Packaging]
Starting [Pull-Requests]
Starting [SAST]
Starting [Security-Policy]
Starting [Signed-Releases]
Starting [Signed-Tags]
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]
Finished [Frozen-Deps]
Finished [Signed-Tags]
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
Frozen-Deps: Fail 0
Fuzzing: Fail 10
Packaging: Fail 0
Pull-Requests: Fail 9
SAST: Fail 10
Security-Policy: Pass 10
Signed-Releases: Fail 0
Signed-Tags: Fail 10

Docker

scorecard is available as a Docker container:

The GITHUB_AUTH_TOKEN has to be set to a valid token

docker run -e GITHUB_AUTH_TOKEN=token gcr.io/openssf/scorecard:latest --show-details --repo=https://github.com/ossf/scorecard

Caching

Scorecard uses httpcache with https://docs.github.com/en/rest/overview/resources-in-the-rest-api#conditional-requests for caching httpresponse. The default cache is in-memory.

Some details on caching https://github.com/ossf/scorecard/issues/80#issuecomment-782723182

Blob Cache

Scorecard results can be cached into a blob for increasing throughput for subsequent runs.

To use blob cache two env variables have to be set USE_BLOB_CACHE=true and BLOB_URL=gs://scorecards-cache/.

The code uses https://github.com/google/go-cloud for blob caching. It is compatible with GCS,S3 and Azure blob.

Disk Cache

Scorecard results can be cached into a disk for increasing throughput for subsequent runs.

To use disk cache two env variables have to be set USE_DISK_CACHE=true and DISK_CACHE_PATH=./cache.

There is no TTL on cache.

The default cache size is 10GB.

Gitcache

Gitcache reduces the GitHub API usage by cloning the Git repository without authentication and checking for updates.

In the initial run

  • Clone the repository anonymously (not using GitHub API token).
  • Tarball and compress it.
  • Store the compressed file into a blob store GCS.
  • Store the last commit date within the blob.
  • Also compress the folder without .git for the consumers.

On the subsequent runs

  • pull gzip from GCS
  • unzip git repo
  • git pull origin
  • update metadata (last sync, etc.)
  • gzip, reupload to GCS

gitcache documentation for more details.

Authentication

Before running Scorecard, you need to create a GitHub access token and set it in environment variable GITHUB_AUTH_TOKEN. This helps to avoid the GitHub's api rate limits with unauthenticated requests.

# For posix platforms, e.g. linux, mac:
export GITHUB_AUTH_TOKEN=<your access token>

# For windows:
set GITHUB_AUTH_TOKEN=<your access token>

GITHUB_AUTH_TOKEN

Multiple GITHUB_AUTH_TOKEN can be provided separated by comma to be utilized in a round robin fashion.

As an alternative to personal access tokens, we also support GitHub App Installations for higher rate-limit quotas. If you have an installed GitHub App and key file, you can use these three environment variables, following the commands shown above for your platform.

GITHUB_APP_KEY_PATH=<path to the key file on disk>
GITHUB_APP_INSTALLATION_ID=<installation id>
GITHUB_APP_ID=<app id>

These can be obtained from the GitHub developer settings page.

Checks

The following checks are all run against the target project:

Name Description
Security-Policy Does the project contain a security policy?
Contributors Does the project have contributors from at least two different organizations?
Frozen-Deps Does the project declare and freeze dependencies?
Signed-Releases Does the project cryptographically sign releases?
Signed-Tags Does the project cryptographically sign release tags?
CI-Tests Does the project run tests in CI, e.g. GitHub Actions, Prow?
Code-Review Does the project require code review before code is merged?
CII-Best-Practices Does the project have a CII Best Practices Badge?
Pull-Requests Does the project use Pull Requests for all code changes?
Fuzzing Does the project use fuzzing tools, e.g. OSS-Fuzz?
SAST Does the project use static code analysis tools, e.g. CodeQL, SonarCloud?
Active Did the project get any commits in the last 90 days?
Branch-Protection Does the project use Branch Protection ?
Packaging Does the project build and publish official packages from CI/CD, e.g. GitHub Publishing ?

To see detailed information about each check and remediation steps, check out the checks documentation page.

If you'd like to add a check, make sure it is something that meets the following criteria:

  • automate-able
  • objective
  • actionable

and then create a new GitHub Issue.

Results

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.

Many of the checks are based on heuristics, contributions are welcome to improve the detection!

Running specific checks

To use a particular check(s), add the --checks argument with a list of check names.

For example, --checks=CI-Tests,Code-Review.

Formatting Results

There are three formats currently: default, json, and csv. Others may be added in the future.

These may be specified with the --format flag.

Requirements

  • The scorecard must only be composed of automate-able, objective data. For example, a project having 10 contributors doesnt necessarily mean its more secure than a project with say 50 contributors. But, having two maintainers might be preferable to only having one - the larger bus factor and ability to provide code reviews is objectively better.
  • The scorecard criteria can be as specific as possible and not limited general recommendations. For example, for Go, we can recommend/require specific linters and analyzers to be run on the codebase.
  • The scorecard can be populated for any open source project without any work or interaction from maintainers.
  • Maintainers must be provided with a mechanism to correct any automated scorecard findings they feel were made in error, provide "hints" for anything we can't detect automatically, and even dispute the applicability of a given scorecard finding for that repository.
  • Any criteria in the scorecard must be actionable. It should be possible, with help, for any project to "check all the boxes".
  • Any solution to compile a scorecard should be usable by the greater open source community to monitor upstream security.

Contributing

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 meetings.

See the Community Calendar for the schedule and meeting invitations.

See the Contributing documentation for guidance on how to contribute.