Skip to content

Commit ae52d11

Browse files
authored
Added scorecard security check
1 parent 78dca72 commit ae52d11

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-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+
name: Scorecard security
2+
on:
3+
# For Branch-Protection check. Only the default branch is supported. See
4+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
5+
branch_protection_rule:
6+
# To guarantee Maintained check is occasionally updated. See
7+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
8+
schedule:
9+
- cron: '0 0 * * *'
10+
push:
11+
branches: [ "main" ]
12+
13+
# Declare default permissions as read-only.
14+
permissions: read-all
15+
16+
jobs:
17+
analysis:
18+
name: Scorecard analysis
19+
runs-on: ubuntu-latest
20+
# `publish_results: true` only works when run from the default branch. The condition can be removed if disabled.
21+
if: github.event.repository.default_branch == github.ref_name || github.event_name == 'pull_request'
22+
permissions:
23+
# Needed to upload the results to the code-scanning dashboard.
24+
security-events: write
25+
# Needed to publish results and get a badge (see publish_results below).
26+
id-token: write
27+
# Uncomment the permissions below if installing in a private repository.
28+
# contents: read
29+
# actions: read
30+
31+
steps:
32+
- name: Harden Runner
33+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
34+
with:
35+
egress-policy: audit
36+
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@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
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 the upload of results to your repo's Code Scanning dashboard
76+
- name: "Upload to code-scanning"
77+
uses: github/codeql-action/upload-sarif@v3
78+
with:
79+
sarif_file: results.sarif

0 commit comments

Comments
 (0)