Skip to content

Commit a36660d

Browse files
committed
ci: fix boj-build secrets-in-if + Scorecard enforcer
boj-build.yml: removed the job-level `if:` referencing secrets.BOJ_SERVER_URL. The `secrets` context is not available in `if:` — referencing it invalidates the whole workflow. The trigger step already shell-guards on an empty BOJ_URL and exits 0, so an unconfigured repo stays a fast no-op (honouring the documented secret-or-var configuration). scorecard-enforcer.yml: the scorecard job invoked ossf/scorecard-action with publish_results: true AND a run: step in the same job, which OSSF rejects with HTTP 400 ("scorecard job must only have steps with `uses`"), failing the run. Split into an uses-only publish job + an unprivileged JSON score-gate (reads top-level `.score`; the SARIF aggregate path is absent so the old gate always read 0 and failed < 5). Least-privilege contents:read, timeouts, SHA pins. https://claude.ai/code/session_01VwbFNQJw23tW8tqM7utWku
1 parent 4a848fd commit a36660d

2 files changed

Lines changed: 40 additions & 3 deletions

File tree

.github/workflows/boj-build.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ permissions:
1818
jobs:
1919
trigger-boj:
2020
runs-on: ubuntu-latest
21-
if: ${{ vars.BOJ_SERVER_URL != '' || secrets.BOJ_SERVER_URL != '' }}
21+
# No job-level enablement gate: the `secrets` context is not available in
22+
# `if:` (referencing it invalidates the whole workflow), and gating on
23+
# `vars` alone would silently drop a secret-only configuration. The
24+
# "Trigger BoJ Server" step shell-guards on an empty BOJ_URL and exits 0,
25+
# so an unconfigured repo is a fast no-op regardless of secret-or-var.
2226
steps:
2327
- name: Checkout
2428
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

.github/workflows/scorecard-enforcer.yml

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,15 @@ permissions:
2121
contents: read
2222

2323
jobs:
24+
# Publish job. The OSSF attestation flow requires that a job invoking
25+
# ossf/scorecard-action with publish_results: true contain ONLY `uses:`
26+
# steps (no `run:`). A `run:` step in this job makes the OSSF publish
27+
# endpoint reject the upload with HTTP 400 ("scorecard job must only have
28+
# steps with `uses`"), failing the whole workflow. Score enforcement is
29+
# therefore split into the separate unprivileged `score-gate` job below.
2430
scorecard:
2531
runs-on: ubuntu-latest
32+
timeout-minutes: 15
2633
permissions:
2734
security-events: write
2835
id-token: write # For OIDC
@@ -43,10 +50,35 @@ jobs:
4350
with:
4451
sarif_file: results.sarif
4552

53+
# Unprivileged enforcement gate. Re-derives the score read-only (no
54+
# publish, no id-token), so it may legally contain a `run:` step.
55+
# NOTE: uses JSON output deliberately. The SARIF format does NOT carry the
56+
# aggregate score at .runs[0].tool.driver.properties.score (it is absent
57+
# there, so a SARIF-based gate reads the `// 0` fallback and ALWAYS fails
58+
# the < MIN_SCORE check); the JSON format exposes the aggregate at the
59+
# top-level `.score`. publish_results is false here and does not affect the
60+
# computed score, so enforcement behaviour is unchanged.
61+
score-gate:
62+
runs-on: ubuntu-latest
63+
timeout-minutes: 15
64+
permissions:
65+
contents: read
66+
steps:
67+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
68+
with:
69+
persist-credentials: false
70+
71+
- name: Run Scorecard (analysis only)
72+
uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3
73+
with:
74+
results_file: results.json
75+
results_format: json
76+
publish_results: false
77+
4678
- name: Check minimum score
4779
run: |
48-
# Parse score from results
49-
SCORE=$(jq -r '.runs[0].tool.driver.properties.score // 0' results.sarif 2>/dev/null || echo "0")
80+
# JSON output carries the aggregate score at the top-level `.score`.
81+
SCORE=$(jq -r '.score // 0' results.json 2>/dev/null || echo "0")
5082
5183
echo "OpenSSF Scorecard Score: $SCORE"
5284
@@ -61,6 +93,7 @@ jobs:
6193
# Check specific high-priority items
6294
check-critical:
6395
runs-on: ubuntu-latest
96+
timeout-minutes: 15
6497
steps:
6598
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
6699

0 commit comments

Comments
 (0)