Skip to content

Commit f031f80

Browse files
authored
Merge pull request #47 from Quantco/scorecard
Add OpenSSF scorecard to repo and template
2 parents 0bf02b8 + 21c3715 commit f031f80

File tree

2 files changed

+163
-0
lines changed

2 files changed

+163
-0
lines changed

.github/workflows/scorecard.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# This workflow uses actions that are not certified by GitHub. They are provided
2+
# by a third-party and are governed by separate terms of service, privacy
3+
# policy, and support documentation.
4+
5+
name: Scorecard supply-chain security
6+
on:
7+
# For Branch-Protection check. Only the default branch is supported. See
8+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
9+
branch_protection_rule:
10+
# To guarantee Maintained check is occasionally updated. See
11+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
12+
schedule:
13+
- cron: "34 5 * * 0"
14+
workflow_dispatch:
15+
push:
16+
branches: ["main"]
17+
18+
# Declare default permissions as read only.
19+
permissions: read-all
20+
21+
jobs:
22+
analysis:
23+
name: Scorecard analysis
24+
runs-on: ubuntu-latest
25+
# `publish_results: true` only works when run from the default branch. conditional can be removed if disabled.
26+
if: github.event.repository.default_branch == github.ref_name || github.event_name == 'pull_request'
27+
permissions:
28+
# Needed to upload the results to code-scanning dashboard.
29+
security-events: write
30+
# Needed to publish results and get a badge (see publish_results below).
31+
id-token: write
32+
# Uncomment the permissions below if installing in a private repository.
33+
# contents: read
34+
# actions: read
35+
36+
steps:
37+
- name: "Checkout code"
38+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
39+
with:
40+
persist-credentials: false
41+
42+
- name: "Run analysis"
43+
uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1
44+
with:
45+
results_file: results.sarif
46+
results_format: sarif
47+
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
48+
# - you want to enable the Branch-Protection check on a *public* repository, or
49+
# - you are installing Scorecard on a *private* repository
50+
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action?tab=readme-ov-file#authentication-with-fine-grained-pat-optional.
51+
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
52+
53+
# Public repositories:
54+
# - Publish results to OpenSSF REST API for easy access by consumers
55+
# - Allows the repository to include the Scorecard badge.
56+
# - See https://github.com/ossf/scorecard-action#publishing-results.
57+
# For private repositories:
58+
# - `publish_results` will always be set to `false`, regardless
59+
# of the value entered here.
60+
publish_results: true
61+
62+
# (Optional) Uncomment file_mode if you have a .gitattributes with files marked export-ignore
63+
# file_mode: git
64+
65+
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
66+
# format to the repository Actions tab.
67+
- name: "Upload artifact"
68+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
69+
with:
70+
name: SARIF file
71+
path: results.sarif
72+
retention-days: 5
73+
74+
# Upload the results to GitHub's code scanning dashboard (optional).
75+
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
76+
- name: "Upload to code-scanning"
77+
uses: github/codeql-action/upload-sarif@97a2bfd2a3d26d458da69e548f7f859d6fca634d # v3.28.15
78+
with:
79+
sarif_file: results.sarif
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{%- raw -%}
2+
# This workflow uses actions that are not certified by GitHub. They are provided
3+
# by a third-party and are governed by separate terms of service, privacy
4+
# policy, and support documentation.
5+
6+
name: Scorecard supply-chain security
7+
on:
8+
# For Branch-Protection check. Only the default branch is supported. See
9+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
10+
branch_protection_rule:
11+
# To guarantee Maintained check is occasionally updated. See
12+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
13+
schedule:
14+
- cron: "34 5 * * 0"
15+
workflow_dispatch:
16+
push:
17+
branches: ["main"]
18+
19+
# Declare default permissions as read only.
20+
permissions: read-all
21+
22+
jobs:
23+
analysis:
24+
name: Scorecard analysis
25+
runs-on: ubuntu-latest
26+
# `publish_results: true` only works when run from the default branch. conditional can be removed if disabled.
27+
{%- endraw -%}
28+
{%- set github_repo_url = github_url.split("/")[-2:] -%}
29+
if: (github.event.repository.default_branch == github.ref_name || github.event_name == 'pull_request') && github.repository == '{{ github_repo_url|join("/") }}'
30+
{%- raw %}
31+
permissions:
32+
# Needed to upload the results to code-scanning dashboard.
33+
security-events: write
34+
# Needed to publish results and get a badge (see publish_results below).
35+
id-token: write
36+
# Uncomment the permissions below if installing in a private repository.
37+
# contents: read
38+
# actions: read
39+
40+
steps:
41+
- name: "Checkout code"
42+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
43+
with:
44+
persist-credentials: false
45+
46+
- name: "Run analysis"
47+
uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1
48+
with:
49+
results_file: results.sarif
50+
results_format: sarif
51+
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
52+
# - you want to enable the Branch-Protection check on a *public* repository, or
53+
# - you are installing Scorecard on a *private* repository
54+
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action?tab=readme-ov-file#authentication-with-fine-grained-pat-optional.
55+
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
56+
57+
# Public repositories:
58+
# - Publish results to OpenSSF REST API for easy access by consumers
59+
# - Allows the repository to include the Scorecard badge.
60+
# - See https://github.com/ossf/scorecard-action#publishing-results.
61+
# For private repositories:
62+
# - `publish_results` will always be set to `false`, regardless
63+
# of the value entered here.
64+
publish_results: true
65+
66+
# (Optional) Uncomment file_mode if you have a .gitattributes with files marked export-ignore
67+
# file_mode: git
68+
69+
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
70+
# format to the repository Actions tab.
71+
- name: "Upload artifact"
72+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
73+
with:
74+
name: SARIF file
75+
path: results.sarif
76+
retention-days: 5
77+
78+
# Upload the results to GitHub's code scanning dashboard (optional).
79+
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
80+
- name: "Upload to code-scanning"
81+
uses: github/codeql-action/upload-sarif@97a2bfd2a3d26d458da69e548f7f859d6fca634d # v3.28.15
82+
with:
83+
sarif_file: results.sarif
84+
{%- endraw %}

0 commit comments

Comments
 (0)