-
Notifications
You must be signed in to change notification settings - Fork 5
56 lines (51 loc) · 2.4 KB
/
Copy pathossf.yml
File metadata and controls
56 lines (51 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# OSSF Scorecard — PUBLIC repositories only.
# Runs the PUBLIC ossf/scorecard-action on GitHub-hosted runners (free for public).
# Results are NOT published (publish_results: false -> no OpenSSF API, no badge).
# The job gates the PR on the aggregate score. Ramp with THRESHOLD + MODE before
# flipping MODE=enforce org-wide (today 0/52 public repos are >= 8).
name: OSSF Scorecard
on:
pull_request:
branches: ['main', 'master', 'dev', 'develop', 'stage']
schedule:
- cron: '0 6 * * 1' # weekly measurement on the default branch
workflow_dispatch:
permissions: {}
jobs:
scorecard:
name: OSSF Scorecard # <- this string is the required_status_checks context
runs-on: ubuntu-latest # GitHub-hosted, free for public — never azion-runners
permissions:
contents: read
env:
THRESHOLD: '8' # target aggregate; start lower during the ramp
MODE: 'warn' # warn = never blocks; enforce = fail PR below THRESHOLD
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Run Scorecard (results not published)
uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3
with:
results_file: results.json
results_format: json
publish_results: false # NOT published: no OpenSSF API, no badge
- name: Gate on aggregate score
run: |
SCORE=$(jq -r '.score' results.json)
echo "OSSF aggregate = ${SCORE} (threshold ${THRESHOLD}, mode ${MODE})"
# -1 == inconclusive: don't block on it
if [ "$SCORE" = "-1" ] || [ "$SCORE" = "null" ]; then
echo "::warning::Scorecard returned inconclusive score — not gating"; exit 0
fi
below=$(awk -v s="$SCORE" -v t="$THRESHOLD" 'BEGIN{print (s<t)?1:0}')
if [ "$below" = "1" ]; then
if [ "$MODE" = "enforce" ]; then
echo "::error::OSSF ${SCORE} < ${THRESHOLD} — blocking merge"; exit 1
else
echo "::warning::OSSF ${SCORE} < ${THRESHOLD} — warn mode, not blocking"
fi
fi
# NOTE: results.json (full findings) is never printed — only the aggregate.
# To also keep findings in the private Security tab, run a second step with
# results_format: sarif + github/codeql-action/upload-sarif (needs security-events: write).