返回 last30days-skill
scorecard.yml
根目录 / .github / workflows / scorecard.yml
1 name: Scorecard
2
3 # OpenSSF Scorecard tracks broader repo security-health drift (branch
4 # protection, token permissions, pinned actions, dangerous workflows, CI
5 # tests, maintenance signals) on a schedule, complementing the per-diff
6 # dependency-audit and secret-scan jobs in security.yml.
7 #
8 # Advisory-first: this workflow only measures and publishes a score, and it
9 # never blocks merges. It runs on the default branch (Scorecard needs repo-level
10 # data and a token, so it is not meaningful on PR forks) plus a weekly schedule
11 # so regressions in security health surface even when no code changes.
12
13 on:
14 branch_protection_rule:
15 schedule:
16 # Weekly, Mondays at 07:00 UTC.
17 - cron: '0 7 * * 1'
18 push:
19 branches:
20 - main
21 workflow_dispatch:
22
23 # Top-level token is read-only; the analysis job widens only what it needs.
24 permissions: read-all
25
26 jobs:
27 analysis:
28 name: Scorecard analysis
29 runs-on: ubuntu-latest
30 # Job-level permissions fully replace the top-level block (unlisted scopes
31 # default to none), so the reads checkout and Scorecard need are explicit.
32 permissions:
33 # Needed by actions/checkout to clone the repo, and by Scorecard to read
34 # workflow files for its Dangerous-Workflow / Token-Permissions checks.
35 contents: read
36 actions: read
37 # Needed to upload the SARIF results to the code-scanning dashboard.
38 security-events: write
39 # Needed to publish results and obtain a badge (uses OIDC, no secrets).
40 id-token: write
41
42 steps:
43 - name: Checkout
44 uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
45 with:
46 persist-credentials: false
47
48 - name: Run OpenSSF Scorecard
49 uses: ossf/scorecard-action@23f22cd43608bae7a1f1fa2603d7314dee9538a5 # v2.6.0
50 with:
51 results_file: scorecard.sarif
52 results_format: sarif
53 # Archives omit .github/ via export-ignore, hiding workflows from checks.
54 file_mode: git
55 # Publishes results to the OpenSSF REST API for the public badge and
56 # trend tracking. Set to false if maintainers prefer to keep the
57 # score private (the SARIF upload below still works either way).
58 publish_results: true
59
60 # Retain the raw SARIF as a build artifact for offline inspection.
61 - name: Upload artifact
62 uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
63 with:
64 name: scorecard-sarif
65 path: scorecard.sarif
66 retention-days: 5
67
68 - name: Upload SARIF to code-scanning
69 uses: github/codeql-action/upload-sarif@1bd86f2fdb4b86187fa4059f16f31a3202acc9ea # v4.39.4
70 with:
71 sarif_file: scorecard.sarif
72
72 lines YAML