Skip to content

ci(security): run the weekly Dependabot fix routine in GitHub Actions - #1790

Open
PMerlet wants to merge 6 commits into
mainfrom
ci/security-fixes-workflow
Open

ci(security): run the weekly Dependabot fix routine in GitHub Actions#1790
PMerlet wants to merge 6 commits into
mainfrom
ci/security-fixes-workflow

Conversation

@PMerlet

@PMerlet PMerlet commented Jul 30, 2026

Copy link
Copy Markdown
Member

Why

The weekly "Fix vulnerabilities" claude.ai cloud routines have been failing with 403 on the Dependabot alerts API. Root cause (established 2026-07-23): the Claude cloud environments' GitHub proxy replaces the Authorization header of every request to api.github.com with its own GitHub App user-to-server token — regardless of any PAT configured in the environment — and that token cannot read Dependabot alerts, Actions runs, or commit statuses. This is by design ("keeps your real GitHub credentials outside the sandbox"), so the routine can never work there.

This PR moves the same routine into GitHub Actions, where secrets reach the job untouched.

What

  • .github/workflows/security-fixes.yml — scheduled job (Thursdays 11:00 UTC, same slot as before), runs the agent via anthropics/claude-code-action@v1, 120 min timeout, manual trigger available (workflow_dispatch).
  • .github/security-fixes-prompt.md — the agent instructions (same battle-tested prompt as the cloud routine: preflight probe, strict triage with explicit ignore reasons, 7-day age gate, narrowest-bump-first strategy, pin/resolution hygiene audit, PR with the :lock: security label pinging @first_level_support, CI monitoring with a 3-retry cap).

Before merging — org secrets required

The workflow needs two organization-level secrets (shared by the 5 repos getting this workflow: forestadmin-server, forestadmin, toolbelt, agent-nodejs, agent-ruby):

Secret Value
SECURITY_GH_PAT The "Claude routines" fine-grained PAT (Dependabot alerts RO, Contents RW, Pull requests RW, Issues RW, Actions RW, Commit statuses RO on the 5 repos)
ANTHROPIC_API_KEY A Claude API key

Without them, the run stops at preflight with an explicit error message.

Notes

  • The claude.ai cloud routines are disabled (kept for reference, not deleted).
  • First run: next Thursday 13:00 Paris — or trigger it manually from the Actions tab to validate earlier.

🤖 Generated with Claude Code

Note

Add weekly GitHub Actions workflow to automate Dependabot vulnerability fixes via Claude

  • Adds security-fixes.yml, a scheduled workflow (Thursdays 11:00 UTC) that runs the anthropics/claude-code-action to triage and fix Dependabot alerts, then open labeled PRs.
  • Adds security-fixes-prompt.md as the instruction set for the agent, covering alert triage rules (FIX/IGNORE/DEFER), a 7-day age gate, dependency bump strategy, PR formatting, and CI monitoring via the Actions and Commit Status APIs.
  • The workflow uses a fine-grained PAT (SECURITY_GH_PAT) for checkout and push operations, with a 240-minute timeout and concurrency guard (cancel-in-progress: false).
  • Risk: the agent runs with up to 250 turns and broad tool access; a misconfigured PAT or prompt regression could push unintended changes to the repository.

Macroscope summarized 3162e24.

The claude.ai cloud routines cannot call the Dependabot alerts API (the
cloud GitHub proxy substitutes its own app token on api.github.com by
design). Same schedule (Thursdays 11:00 UTC), same agent instructions,
now running where the SECURITY_GH_PAT secret reaches the job untouched.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Comment thread .github/workflows/security-fixes.yml Outdated
Comment thread .github/security-fixes-prompt.md
Comment thread .github/security-fixes-prompt.md Outdated
@qltysh

qltysh Bot commented Jul 30, 2026

Copy link
Copy Markdown

Qlty


Coverage Impact

This PR will not change total coverage.

🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

…kflow

- raise the job timeout to 240 min to cover the full CI-polling retry budget
- resume the existing security/<date> branch and PR on same-day reruns
- refresh the head SHA after each corrective push during CI monitoring
- treat an empty combined-status (total_count: 0) as no status gate
- provide GH_PAT at job level instead of step level

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Comment thread .github/security-fixes-prompt.md Outdated
- override the action's default guardrails (--append-system-prompt) so the
  unattended agent actually pushes the security branch and opens the PR
- same-day rerun now supersedes the dated branch with --force-with-lease
  (recomputed from scratch), instead of fragile stash/resume logic that
  could carry stale history from closed PRs
- phase 8: startup guard against vacuous green (zero workflow runs),
  all-green now also requires combined status success when contexts exist,
  failing status contexts are reported explicitly
- agent-ruby: Gemfile.lock is gitignored (library repo) — preflight and
  fix strategy reworked around gemspec/Gemfile constraints, local-only lock

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Comment thread .github/security-fixes-prompt.md Outdated
PMerlet and others added 2 commits July 30, 2026 10:46
- pin anthropics/claude-code-action to an immutable commit SHA (supply
  chain: the job holds ANTHROPIC_API_KEY and a repo-write PAT)
- fetch the remote security branch before --force-with-lease so the lease
  has an expected value (fresh checkouts only fetch the default branch)
- set SHA via git rev-parse HEAD on every path, including PR reuse
- agent-ruby: treat all packages/*/*.gemspec as direct-dependency owners
  (monorepo of published gems); Gemfile pins flagged as CI-only fixes;
  generate the local Gemfile.lock in the workflow before the agent runs

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- treat skipped/neutral workflow conclusions as non-failures; only
  failure/timed_out/cancelled/action_required trigger remediation
- the 'unreachable code path' IGNORE reason now requires call-chain or
  configuration evidence — a negative repo grep alone is insufficient

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Comment thread .github/security-fixes-prompt.md Outdated
Comment thread .github/security-fixes-prompt.md Outdated
- the _example/ ignore rule now requires a workspace-aware resolved-tree
  check (npm ls --all / yarn why); manifest grep is not sufficient
- direct bumps and resolutions/overrides pins now target the smallest
  patched version within the parent-compatible major instead of an
  unbounded >= range that could resolve to a breaking major

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant