Skip to content

Fix: Harden Scorecard against agent startup races - #204

Merged
ModeSevenIndustrialSolutions merged 2 commits into
lfreleng-actions:mainfrom
lfreleng-bot-forks:code-monkey/issue-201
Nov 12, 2026
Merged

ModeSevenIndustrialSolutions merged 2 commits into
lfreleng-actions:mainfrom
lfreleng-bot-forks:code-monkey/issue-201

Conversation

@lf-releng-code-monkey-bot

Copy link
Copy Markdown
Contributor

Closes #201

Authored by an AI agent; human review required
Command Exit
bash tests/scorecard-retry-steps.sh 0
bash tests/workflow-steps.sh 0
bash tests/python-warning-steps.sh 0
bash tests/tox-python-steps.sh 0
bash tests/uv-interpreter-steps.sh 0
prek run --files <changed files> 0
uvx [email protected] --persona auditor --offline --no-progress <changed workflows> 0
aislop scan --changes --base df36b8d --json . 0
git log --raw --format=%h df36b8d85d1b8bb7c9ebafb0b1c11381ac315615..HEAD 0

The github-code-monkey-bot workflow opened this pull request.
Nobody has merged it; a maintainer must review it first.
Review findings on this pull request are answered by a later revision round of this workflow, up to ten rounds per antagonistic review round; after that a maintainer, or the next antagonistic review, takes on any finding that remains, and a maintainer reviews every round before merge.


INFO
The issue asks for the retry shape checks to go into tests/workflow-steps.sh. That file is executable, and this workflow cannot edit an executable file, so the checks live in a new tests/scorecard-retry-steps.sh, run with bash from workflow-tests.yaml like the other tests/*-steps.sh files. A human can fold them into tests/workflow-steps.sh later. It is a mechanical move.

This follows the revised request in the issue comment, which replaces requested changes 1 and 2.

What changed

1. Chore: Bump harden-runner-block-action to v0.16.4 (Link job)

All ten lfreleng-actions/harden-runner-block-action pins, across nine workflow files, move from v0.16.3 (f5a4756…) to v0.16.4 (65ff87957e1cac2de3203a85dbb07c31810321cb). After a transient resolver failure, v0.16.4 restarts the agent (agent_restart_attempts, default 2). Before, a single SERVFAIL from dns.google killed the Scorecard Link job. The Link job keeps using the shared loader, with no curated list and no new inputs, and the harden_runner_* inputs work as before. docs/BRIEF.md D15 records why the summary job stays on the loader.

2. Fix: Retry the Scorecard analysis once (Scan job)

  • Run analysis now has id: analysis and continue-on-error: true.
  • Directly after it, Run analysis (retry) runs the same ossf/scorecard-action commit with the same with: inputs, guarded by if: steps.analysis.outcome == 'failure'.
  • The two upload steps are unchanged. How the expressions behave:
    • First attempt succeeds: the retry is skipped. A skipped step does not fail the job, so the uploads' implicit success() is true.
    • First attempt fails: with continue-on-error, its outcome is failure but its conclusion is success. The job stays successful, so the retry runs, and the uploads run if the retry succeeds.
    • Both fail: the retry has no continue-on-error, so the job fails and the uploads are skipped.
  • Comments in the workflow (in the header and above the step) say what the retry works around and why the job cannot wait for the agent. A run: step is rejected, harden-runner-block-action is not on the permitted list, and a second harden-runner step skips its wait.
  • README.md (Egress allow-list section) and docs/BRIEF.md D15 describe the retry and its limits.
  • The new tests/scorecard-retry-steps.sh checks that:
    • exactly two steps use ossf/scorecard-action, next to each other;
    • both use the same ref and the same with:;
    • the first has an id, continue-on-error: true and no if:;
    • the second has if: steps.<id>.outcome == 'failure' and no continue-on-error.

What this does not do

  • The race cannot be forced in CI. The retry path is reasoned from the failed and near-miss runs cited in the issue, and no test run exercises it. The new test checks only the workflow's shape.
  • The retry fires on any failure of the first attempt, so a genuine failure runs the analysis twice.
  • It does not close the window in which the job's first steps run before egress filtering is in place. Only a change in step-security/harden-runner can close that.

What I ran

  • bash tests/scorecard-retry-steps.sh: 10/10 pass. I also ran it against mutated copies of the workflow: different inputs on the retry, a different if:, and the original single-step file. Each mutation failed the expected cases.
  • bash tests/workflow-steps.sh: 119/119 pass. This includes "scan is the one job running ossf/scorecard-action" and "scan job uses only permitted actions".
  • bash tests/python-warning-steps.sh, tox-python-steps.sh, uv-interpreter-steps.sh: all pass.
  • prek run --files <changed files> (yamllint, actionlint, zizmor, reuse, codespell, workflow validators, gitlint on commit): pass.
  • zizmor --persona auditor --offline on every changed workflow: no findings.
  • aislop scan --changes --base df36b8d: empty diagnostics.

For reviewers

  • Scorecard verifier: the issue says it inspects only each step's uses, so two ossf/scorecard-action steps in one job, with id, if and continue-on-error, are accepted. I could not check this against ossf/scorecard-infra from this session. The first real publish confirms it: a rejection shows up as a warning in the analysis step.
  • Double publish: if the first attempt publishes and then fails, the retry publishes again. In the observed race the container is killed before the analysis completes, so this should be rare.
  • v0.16.4 SHA: taken from the issue. I did not resolve it against the upstream repository, because this session cannot fetch from it.
  • Separate test file: the new checks are not in tests/workflow-steps.sh, for the reason in the banner above.

lf-releng-code-monkey-bot Bot and others added 2 commits November 12, 2026 13:12
v0.16.4 restarts the harden-runner agent after a transient resolver
failure (agent_restart_attempts, default 2). Under v0.16.3 a single
SERVFAIL from dns.google while the agent resolved the organisation
allow-list made the agent exit, and the action then failed the job
closed. That is how the OpenSSF Scorecard 'Link' job has been failing
intermittently, on a different unrelated host each time.

The fix lands in the loader, so every lane that pins it benefits with
no new inputs to wire, and the existing harden_runner_* inputs keep
their behaviour. This updates all ten pins across nine workflows.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>
harden-runner's pre hook waits about 9 s for its agent, then lets the
job continue. When DNS is slow the agent finishes setting up only after
ossf/scorecard-action has started, and its 'systemctl restart docker'
kills the analysis container ('unexpected EOF', 'context canceled').

The Scorecard API leaves no way to make the scan job wait: run: steps
and harden-runner-block-action are off its permitted list, and a
second harden-runner step returns at once because the agent is already
installed. It checks only each step's 'uses', so the 'Run analysis'
step now carries an id and continue-on-error, and an identical step
straight after it runs only when that outcome is 'failure'. A failed
first attempt leaves the job successful, so the retry and the uploads
pass their implicit success() check; a failed retry fails the job.

The race cannot be forced in CI, so the retry path is reasoned from
logs, not exercised. A genuine failure now runs the analysis twice, and
the window before egress filtering starts remains open.

tests/scorecard-retry-steps.sh holds the shape: same ref and inputs,
adjacent steps, the outcome condition. It is a new file because
tests/workflow-steps.sh is executable and this change could not edit
it. The workflow comments, README and design brief describe the retry
and its limits.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

YAML-shape tests cannot exercise the Docker startup race, so a maintainer must validate a real publishing Scan and Link run, including uploads and startup recovery logs.

No open issues 🎉

What changed in this PR

This PR mitigates intermittent OpenSSF Scorecard failures during harden-runner startup. It updates the shared hardening loader and adds one conditional analysis retry without changing caller inputs.

Changes:

  • Updates all ten harden-runner-block-action pins to v0.16.4 for agent restart support.
  • Retries failed Scorecard analysis once, keeping the scan job failed if both attempts fail.
  • Adds workflow-shape tests and documents the mitigation’s limits, including the remaining startup window without egress filtering.
File Description
tests/​scorecard-retry-steps.sh Adds checks for matching, adjacent analysis attempts and retry conditions.
README.md Explains the retry and links to its design rationale.
docs/​BRIEF.md Documents startup failures, retry limits, and continued shared-loader use.
.github/​workflows/​zizmor.yaml Updates both hardening-loader pins to v0.16.4.
.github/​workflows/​workflow-tests.yaml Runs the new retry checks and updates the hardening loader.
.github/​workflows/​sonatype-lifecycle.yaml Updates the hardening loader to v0.16.4.
.github/​workflows/​sonarqube-cloud.yaml Updates the hardening loader to v0.16.4.
.github/​workflows/​release-drafter.yaml Updates the hardening loader to v0.16.4.
.github/​workflows/​package-hardening-audit.yaml Updates the hardening loader to v0.16.4.
.github/​workflows/​openssf-scorecard.yaml Adds conditional analysis retry, explains restrictions, and updates the Link job’s loader.
.github/​workflows/​codeql.yaml Updates the hardening loader to v0.16.4.
.github/​workflows/​action-pin-audit.yaml Updates the hardening loader to v0.16.4.

Review effort: Balanced

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Antagonistic review by agent: no line-level findings; the summary below is the verdict.

No actionable defects found in the diff: the bounded retry preserves failure reporting, upload gating, and existing permissions. The offline review cannot establish recovery from the live startup race or independently verify the upstream loader revision and publish verifier compatibility.

Antagonistic round 1 of 3.


Automated antagonistic review by lf-releng-antagonistic-review-bot[bot] using model gpt-6-astra; see the run. This is not a human review and never an approval: a maintainer must still review and approve this pull request.

@ModeSevenIndustrialSolutions
ModeSevenIndustrialSolutions merged commit 6edd901 into lfreleng-actions:main Nov 12, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix: Scorecard jobs fail on slow harden-runner startup

2 participants