OpenSSF Scorecard - Security health metrics for Open Source
Go to file
Appu Goundan 7fd331adf2 Update local install instructions to use v2
Signed-off-by: Appu Goundan <appu@google.com>
2021-07-27 10:14:34 -04:00
.github 🌱 Bump actions/stale from 3.0.19 to 4 (#695) 2021-07-16 17:30:01 +00:00
artwork adding logo (#44) 2020-11-06 11:36:23 -06:00
checker rename var (#756) 2021-07-26 17:24:34 -07:00
checks rename var (#756) 2021-07-26 17:24:34 -07:00
clients 🌱 Fix the go.mod with v2 upgrade (#716) 2021-07-26 13:01:25 -05:00
cloudbuild Remove CloudBuild trigger for daily cron job (#535) 2021-06-02 19:02:13 -07:00
cmd 🌱 Fix the go.mod with v2 upgrade (#716) 2021-07-26 13:01:25 -05:00
cron 🌱 Fix the go.mod with v2 upgrade (#716) 2021-07-26 13:01:25 -05:00
e2e cleanup Frozen-Deps MakeResultAnd (#742) 2021-07-26 22:02:46 +00:00
errors cleanup Frozen-Deps MakeResultAnd (#742) 2021-07-26 22:02:46 +00:00
pkg 🌱 Fix the go.mod with v2 upgrade (#716) 2021-07-26 13:01:25 -05:00
repos Move repos.RepoResult -> pkg.ScorecardResult (#620) 2021-06-28 16:14:34 +10:00
roundtripper 🌱 Fix the go.mod with v2 upgrade (#716) 2021-07-26 13:01:25 -05:00
scripts Add all Google-owned repositories to cron job (#555) 2021-06-08 16:55:43 -07:00
stats Add monitoring for Scorecard errors (#597) 2021-06-21 15:38:50 -07:00
utests cleanup Frozen-Deps MakeResultAnd (#742) 2021-07-26 22:02:46 +00:00
.codecov.yml Feature - Report codecoverage to codecov.io 2021-01-26 17:49:11 -05:00
.gitignore Binary Artifact check (#563) 2021-06-21 15:49:31 +00: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 [migration to score] 1: create errors and new functions (#712) 2021-07-20 11:36:35 -07:00
Dockerfile 🌱 Bump distroless/base from 38778ff to ccbc79c (#722) 2021-07-26 12:00:10 -05:00
go.mod 🌱 Fix the go.mod with v2 upgrade (#716) 2021-07-26 13:01:25 -05:00
go.sum 🌱 Fix the go.mod with v2 upgrade (#716) 2021-07-26 13:01:25 -05:00
LICENSE Add license header and code of conduct files. (#34) 2020-10-26 15:22:13 -05:00
main.go 🌱 Fix the go.mod with v2 upgrade (#716) 2021-07-26 13:01:25 -05:00
Makefile PubSub integration test framework (#706) 2021-07-18 17:33:45 -07:00
README.md Update local install instructions to use v2 2021-07-27 10:14:34 -04:00
SECURITY.md Add SECURITY.md 2021-02-13 14:53:06 -05:00
tools.go 🌱 Fix broken e2e tests 2021-06-28 15:28:10 -05:00

Security Scorecards

build CodeQL

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.

Scorecard Checks

The following checks are all run against the target project by default:

Name Description
Active Did the project get any commits in the last 90 days?
Automatic-Dependency-Update Does the project use tools to automatically update its dependencies?
Binary-Artifacts Is the project free of checked-in binaries?
Branch-Protection Does the project use Branch Protection ?
CI-Tests Does the project run tests in CI, e.g. GitHub Actions, Prow?
CII-Best-Practices Does the project have a CII Best Practices Badge?
Code-Review Does the project require code review before code is merged?
Contributors Does the project have contributors from at least two different organizations?
Fuzzing Does the project use fuzzing tools, e.g. OSS-Fuzz?
Frozen-Deps Does the project declare and freeze dependencies?
Packaging Does the project build and publish official packages from CI/CD, e.g. GitHub Publishing ?
Pull-Requests Does the project use Pull Requests for all code changes?
SAST Does the project use static code analysis tools, e.g. CodeQL, SonarCloud?
Security-Policy Does the project contain a security policy?
Signed-Releases Does the project cryptographically sign releases?
Signed-Tags Does the project cryptographically sign release tags?
Token-Permissions Does the project declare GitHub workflow tokens as read only?
Vulnerabilities Does the project have unfixed vulnerabilities? Uses the OSV service.

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

Usage

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

Using repository URL

The program can run using just one argument, the URL of the repo:

$ go get github.com/ossf/scorecard/v2
$ scorecard --repo=github.com/kubernetes/kubernetes
Starting [Signed-Tags]
Starting [Automatic-Dependency-Update]
Starting [Frozen-Deps]
Starting [Fuzzing]
Starting [Pull-Requests]
Starting [Branch-Protection]
Starting [Code-Review]
Starting [SAST]
Starting [Contributors]
Starting [Signed-Releases]
Starting [Packaging]
Starting [Token-Permissions]
Starting [Security-Policy]
Starting [Active]
Starting [Binary-Artifacts]
Starting [CI-Tests]
Starting [CII-Best-Practices]

Finished [Contributors]
Finished [Signed-Releases]
Finished [Active]
Finished [Binary-Artifacts]
Finished [CI-Tests]
Finished [CII-Best-Practices]
Finished [Packaging]
Finished [Token-Permissions]
Finished [Security-Policy]
Finished [Automatic-Dependency-Update]
Finished [Frozen-Deps]
Finished [Fuzzing]
Finished [Pull-Requests]
Finished [Signed-Tags]
Finished [Branch-Protection]
Finished [Code-Review]
Finished [SAST]

RESULTS
-------
Repo: github.com/kubernetes/kubernetes
Active: Pass 10
Automatic-Dependency-Update: Fail 3
Binary-Artifacts: Pass 10
Branch-Protection: Fail 0
CI-Tests: Pass 10
CII-Best-Practices: Pass 10
Code-Review: Pass 10
Contributors: Pass 10
Frozen-Deps: Fail 10
Fuzzing: Pass 10
Packaging: Fail 0
Pull-Requests: Pass 10
SAST: Fail 10
Security-Policy: Fail 5
Signed-Releases: Fail 10
Signed-Tags: Fail 10
Token-Permissions: Pass 10

For more details why a check fails, use the --show-details option:

./scorecard --repo=github.com/kubernetes/kubernetes --checks Frozen-Deps --show-details
Starting [Frozen-Deps]
Finished [Frozen-Deps]

RESULTS
-------
Repo: github.com/kubernetes/kubernetes
Frozen-Deps: Fail 10
...
!! frozen-deps/docker - cluster/addons/fluentd-elasticsearch/es-image/Dockerfile has non-pinned dependency 'golang:1.16.5'
...
!! frozen-deps/fetch-execute - cluster/gce/util.sh is fetching and executing non-pinned program 'curl https://sdk.cloud.google.com | bash'
...
!! frozen-deps/fetch-execute - hack/jenkins/benchmark-dockerized.sh is fetching an non-pinned dependency 'GO111MODULE=on go install github.com/cespare/prettybench'
...

Using a Package manager

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

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.

Authentication

Before running Scorecard, you need to, either:

  • create a GitHub access token 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 with unauthenticated requests.
# 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 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.

Understanding Scorecard 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.

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.

Public Data

If you're only interested in seeing a list of projects with their Scorecard check results, we publish these results in a BigQuery public dataset.

This data is available in the public BigQuery dataset openssf:scorecardcron.scorecard. The latest results are available in the BigQuery view openssf:scorecardcron.scorecard_latest.

You can extract the latest results to Google Cloud storage in JSON format using the bq tool:

# Get the latest PARTITION_ID
bq query --nouse_legacy_sql 'SELECT partition_id FROM
openssf.scorecardcron.INFORMATION_SCHEMA.PARTITIONS ORDER BY partition_id DESC
LIMIT 1'

# Extract to GCS
bq extract --destination_format=NEWLINE_DELIMITED_JSON
'openssf:scorecardcron.scorecard$<partition_id>' gs://bucket-name/filename.json

The list of projects that are checked is available in the 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.

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

If you'd like to add a check, make sure it is something that meets the following criteria and then create a new GitHub Issue:

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

Troubleshooting

  • 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. Before you file an issue, please search existing issues to see if your issue is already covered.

  • Slack

    For realtime discussion, you can join the #security_scorecards slack channel. Slack requires registration, but the openssf team is open invitation to anyone to register here. Feel free to come and ask any questions.

Supportability

Currently, scorecard officially supports OSX and Linux platforms. So, if you are using a Windows OS you may find issues. Contributions towards supporting Windows are welcome.

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. The meetings happen biweekly https://calendar.google.com/calendar/embed?src=s63voefhp5i9pfltb5q67ngpes%40group.calendar.google.com&ctz=America%2FLos_Angeles

See the Contributing documentation for guidance on how to contribute.