Skip to content

Commit d467db5

Browse files
aksOpsclaude
andauthored
ci(scorecard): add OpenSSF Scorecard workflow + README badges (#16)
* ci(scorecard): add OpenSSF Scorecard workflow + README badges Adds .github/workflows/scorecard.yml — runs the OpenSSF Scorecard supply-chain check on push to main, weekly cron, and on branch_protection_rule changes. Results land in two places: - GitHub code-scanning (/security/code-scanning) via SARIF upload - Public Scorecard registry (api.scorecard.dev) via OIDC publish so the README badge resolves to a live score All third-party actions are pinned to commit SHAs: - actions/checkout@v4 - ossf/scorecard-action@v2.4.3 - actions/upload-artifact@v7.0.1 - github/codeql-action/upload-sarif@v4.35.2 README: add the Scorecard badge to the badge row, plus an HTML comment with the one-time steps to register the project at bestpractices.dev and append the Best Practices badge once a PROJECT_ID has been issued (the badge URL is invalid until the project is registered, so it's documented inline rather than shipped broken). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * ci(scorecard): scope permissions to contents:read at workflow level Sonar githubactions:S8234 flagged 'permissions: read-all' as a vulnerability. Job-level permissions already grant exactly what the scorecard analyzer needs (security-events: write for SARIF upload, id-token: write for OIDC publish, contents: read, actions: read); the top-level grant is only a fallback for any future steps without their own block, so contents:read is the right minimum. --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent fe891d6 commit d467db5

2 files changed

Lines changed: 97 additions & 0 deletions

File tree

.github/workflows/scorecard.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: OpenSSF Scorecard
2+
3+
# Runs the OpenSSF Scorecard supply-chain check on every push to main
4+
# and weekly. Results are uploaded to GitHub's code-scanning surface
5+
# (visible at /security/code-scanning) AND published to the public
6+
# Scorecard registry at api.scorecard.dev so the README badge shows
7+
# the live score.
8+
#
9+
# Required repo settings:
10+
# - Settings → Actions → General → Workflow permissions: at least
11+
# "Read repository contents and packages permissions" (default).
12+
# - Settings → Code security → Code scanning: enabled (so SARIF
13+
# uploads land somewhere).
14+
# - The workflow grants `id-token: write` so the action can mint an
15+
# OIDC token signed by GitHub and use it as proof-of-identity when
16+
# pushing results to the Scorecard API. No long-lived secret needed.
17+
18+
on:
19+
branch_protection_rule:
20+
push:
21+
branches: [main]
22+
schedule:
23+
# Weekly so the score reflects security-relevant changes (new
24+
# deps, new releases, branch-protection edits) even when there's
25+
# no push for a few days. Tuesdays 03:00 UTC keeps it off the
26+
# busy weekday-morning window.
27+
- cron: "0 3 * * 2"
28+
workflow_dispatch:
29+
30+
permissions:
31+
contents: read
32+
33+
jobs:
34+
analysis:
35+
name: Scorecard analysis
36+
runs-on: ubuntu-latest
37+
permissions:
38+
# Required for upload-sarif → /security/code-scanning.
39+
security-events: write
40+
# Required for OIDC publish_results=true → api.scorecard.dev.
41+
id-token: write
42+
contents: read
43+
actions: read
44+
steps:
45+
- name: Checkout
46+
# actions/checkout@v4 = b4ffde65f46336ab88eb53be808477a3936bae11
47+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
48+
with:
49+
persist-credentials: false
50+
51+
- name: Run analysis
52+
# ossf/scorecard-action@v2.4.3
53+
uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a
54+
with:
55+
results_file: results.sarif
56+
results_format: sarif
57+
# publish_results=true sends the score to the public registry
58+
# so the README badge resolves. It is also a public-good
59+
# contribution — anyone evaluating ctm's supply-chain posture
60+
# can read the breakdown without re-running the tool.
61+
publish_results: true
62+
63+
- name: Upload artifact
64+
# actions/upload-artifact@v7.0.1
65+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
66+
with:
67+
name: SARIF file
68+
path: results.sarif
69+
retention-days: 5
70+
71+
- name: Upload to code-scanning
72+
# github/codeql-action/upload-sarif@v4.35.2
73+
uses: github/codeql-action/upload-sarif@95e58e9a2cdfd71adc6e0353d5c52f41a045d225
74+
with:
75+
sarif_file: results.sarif

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,30 @@
77
<a href="https://goreportcard.com/report/github.com/RandomCodeSpace/ctm"><img src="https://goreportcard.com/badge/github.com/RandomCodeSpace/ctm" alt="Go Report Card"></a>
88
<img src="https://img.shields.io/github/go-mod/go-version/RandomCodeSpace/ctm?color=00ADD8&label=go" alt="Go version">
99
<a href="https://github.com/RandomCodeSpace/ctm/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green" alt="License MIT"></a>
10+
<a href="https://scorecard.dev/viewer/?uri=github.com/RandomCodeSpace/ctm"><img src="https://api.scorecard.dev/projects/github.com/RandomCodeSpace/ctm/badge" alt="OpenSSF Scorecard"></a>
1011
</p>
1112

13+
<!--
14+
OpenSSF Best Practices badge — one-time setup, then add the markup
15+
back into the badge row above:
16+
17+
1. Sign in with GitHub at https://www.bestpractices.dev/en/projects/new
18+
2. Submit the project; the form assigns a numeric PROJECT_ID and
19+
opens the criteria checklist (passing / silver / gold tiers).
20+
3. Add the following to the <p align="center"> block above (replace
21+
PROJECT_ID with the assigned number):
22+
23+
<a href="https://www.bestpractices.dev/projects/PROJECT_ID">
24+
<img src="https://www.bestpractices.dev/projects/PROJECT_ID/badge"
25+
alt="OpenSSF Best Practices">
26+
</a>
27+
28+
The badge auto-updates as criteria are checked off — no CI integration
29+
required (unlike the Scorecard badge, which is updated by the
30+
.github/workflows/scorecard.yml workflow on every push to main).
31+
-->
32+
33+
1234
<p align="center">
1335
<a href="#quickstart">Quickstart</a> ·
1436
<a href="#commands">Commands</a> ·

0 commit comments

Comments
 (0)