Menu Knowledge-base updates

Project

Knowledge-base updates

The scheduled workflows that keep the vulnerability knowledge bases current.

A scheduled GitHub Action (.github/workflows/update-knowledge-base.yml) keeps the sh-kb-* knowledge bases fresh. Every alternate day (and on manual workflow_dispatch), it runs an agent to distill new, reputable public security research - OWASP, PortSwigger Research, CWE/CAPEC, NIST, MDN, curated GitHub repos, and public HackerOne disclosures - into small, well-sourced improvements. A second, adversarial reviewer agent then scans the resulting diff for malicious/injected content, and the PR is auto-merged only if that reviewer approves.

Two workflows, three jobs

PR creation is deliberately separated from review and merge, so the thing that writes the diff is never the thing that decides to ship it.

Stage 1 - update-knowledge-base.yml (scheduled or manual). One job, create-pr:

  1. Generate - the agent edits the KB from allowlisted sources. No commit, no push.
  2. Open PR - a deterministic step opens (or updates) a PR on the automated/kb-update branch, labeled awaiting-review.
  3. Hand off - on a successful PR creation it dispatches stage 2 with the PR number.

Stage 2 - kb-review-and-merge.yml (dispatched by stage 1, or run by hand against any automated PR). Two jobs:

Why a dispatch rather than a pull_request trigger: a PR opened by GITHUB_TOKEN does not trigger pull_request workflows. workflow_dispatch is one of the two events exempt from that recursion guard, so stage 1 can hand off reliably.

Auto-merge means an approving agent lands code in main. The controls on that:

Requires the repo setting "Allow GitHub Actions to create and approve pull requests" (Settings → Actions → General → Workflow permissions) so the workflow can open the PR. If you want a human in the loop despite auto-merge, protect main with a branch-protection rule requiring a pull request and at least one approving review - the auto-merge path honours it.

Pluggable agents

Both stages run through .github/actions/ai-agent, a composite action that dispatches to whichever agent you configure. Claude Code, OpenAI Codex, Gemini CLI, and an escape hatch for anything else:

agentRunsCredential
claude (default)anthropics/claude-code-action@v1CLAUDE_CODE_OAUTH_TOKEN or ANTHROPIC_API_KEY
codexcodex exec --full-autoOPENAI_API_KEY
geminigemini --yolo --promptGEMINI_API_KEY
customyour KB_AGENT_INSTALL / KB_AGENT_COMMANDwhatever it needs

Pick per run from the workflow_dispatch inputs, or set repo variables to change the default: KB_AGENT and KB_MODEL for the generator, KB_REVIEW_AGENT and KB_REVIEW_MODEL for the reviewer. Running the generator and the reviewer on different agents is a meaningful hardening step: an injection tuned for one model is less likely to land on a second, independent one.

For agent: custom, set KB_AGENT_COMMAND to a shell command. The prompt is written to the file named by $AGENT_PROMPT_FILE, and $AGENT_MODEL carries the model input.

Prompt-injection defenses, since the generator reads the open web:

Setup:

Each run records what it did in .github/kb-update/last-run-summary.md.