Skip to content
Back to skills

Cve Remediation Factory

BSecurity

Set up a private CVE remediation factory on GitHub: build an inventory of what you ship (container images and source repositories), seed a findings repository that scans it daily with Trivy and Grype, and create a remediation automation that opens small upgrade pull requests for fixable CRITICAL and HIGH findings. Also maintains an existing factory: run it again and name the findings repository to troubleshoot, improve it, or add deployment artifacts (`/cve-remediation-factory inventory`).

  • 191 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added November 17, 2026
toolspythonrustgobashdebugginggitapi

Works with

  • terminal
  • cli
  • api

Security analysis

B75/100
  • criticalSends environment variables or credentials to an external URL

Pro scans all 16 files and shows the line behind each finding

Scanned November 17, 2026

npx -y skills add OpenHands/extensions --skill cve-remediation-factory --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Cve Remediation Factory?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Cve Remediation Factory
[![Security: B — Skills Directory](https://www.skillsdirectory.com/api/skills/openhands-cve-remediation-factory/badge)](https://www.skillsdirectory.com/skills/openhands-cve-remediation-factory)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: cve-remediation-factory
description: >
  Set up a private CVE remediation factory on GitHub: build an inventory of what you ship (container
  images and source repositories), seed a findings repository that scans it daily with Trivy and Grype,
  and create a remediation automation that opens small upgrade pull requests
  for fixable CRITICAL and HIGH findings. Also maintains an existing factory:
  run it again and name the findings repository to troubleshoot, improve it, or
  add deployment artifacts (`/cve-remediation-factory inventory`).
triggers:
  - /cve-remediation-factory
  - cve remediation factory
---

# GitHub CVE Remediation Factory

Sets up two cooperating parts in one conversation, then hands over:

| Part | Runs as | Does |
|---|---|---|
| Scanner | CI in the findings repository (`scripts/run_scan.sh`), daily, no LLM | Trivy + Grype on every image and repository in `.cve-factory/factory.yaml`; results, trend chart and inventory on the `scan-results` branch |
| Remediator | OpenHands automation, weekdays, preset prompt | Follows `.cve-factory/remediator.md`: opens upgrade PRs, keeps a work log and status report on the `automation-worklog` branch |

GitHub only. Progress beats perfection: a working repository, scanner and remediator with a
partial inventory is the goal, because the user improves it later by editing `factory.yaml`.

## Conversation contract

The user hears from you exactly twice, in these words:

1. **Findings** (end of Phase 1): the "Findings" template, then end the turn.
2. **Done** (end of Phase 2): the "Done" template, then end the turn.

The only other message is **Blocked**, when a step fails and only the user can fix it:
`**Blocked:** <what failed, one sentence>. <the one thing to do, with its link>.` Then end the turn.

Fill each template's placeholders and send it word for word (with a count of 1, use the singular: "1 image", "1 repository"). Add no other text: no tables, no
explanations of how you found things, no caveats, no restating the form. Details belong in
`factory.yaml`, which the scan publishes as the "What's scanned" section of the results README.

The form's answers in the first message are decisions: never restate, confirm or ask about them.
A blank answer means "use the default". A reply to Findings that changes something is a go-ahead
with that change, unless it asks a question.

## Progress lines

Don't use the task list. Instead, when you start each step below, put exactly this line, filled in,
as the text of the same response as that step's first command; it shows in the chat right away.
Send the line alone, with nothing before or after it. Write no other text between commands, and keep
your thinking between commands short.

| Step | Line |
|---|---|
| Check GitHub access | `Checking your GitHub access.` |
| Find what you ship | `Looking through your repositories for what you ship.` |
| Check image access | `Checking which images and repositories I can reach.` |
| Prepare your plan | `Putting your plan together.` |
| Create the findings repository | `Creating {owner}/{findings repo}.` |
| Push the scanner | `Pushing the scanner; the first scan starts with it.` |
| Set up the remediator | `Setting up the remediator in the form on the right.` |

## Identity

The factory acts through one token, which the helper script picks:

- `CVE_FACTORY_GIT_TOKEN` when the user saved one: a bot account.
- Otherwise the user's own GitHub connection (`GITHUB_TOKEN`, `GITHUB_PERSONAL_ACCESS_TOKEN` or
  `GH_TOKEN`, whichever is set). Commits and pull requests show as theirs.

Never ask for a token. If the user asks for a bot account, see "Using a bot account".

## Helper script

`scripts/seed.py` in this skill's directory. Run it as:

```bash
CVE_FACTORY_GIT_TOKEN="$CVE_FACTORY_GIT_TOKEN" GITHUB_TOKEN="$GITHUB_TOKEN" GITHUB_PERSONAL_ACCESS_TOKEN="$GITHUB_PERSONAL_ACCESS_TOKEN" GH_TOKEN="$GH_TOKEN" python3 <this skill's directory>/scripts/seed.py <command> ...
```

Keep every secret name in the command: the agent server passes a saved secret into a command only
when the command names it. The script never prints a token. It prints JSON on stdout and `✓`
progress lines on stderr.

| Command | Does |
|---|---|
| `whoami [--repo ORG/NAME ...]` | `token_env` (the token in use), `login`, `can_create_repos` (`false` for a GitHub App token, which cannot create repositories), and per repository `read`/`write`, or a prefilled `create_url` plus `app_installation` when it cannot be read. |
| `repos [--owner ORG] [--days 90]` | Active repositories the token can read: not archived, pushed in the last 90 days, newest first. |
| `fetch --repo ORG/NAME ... [--dir DIR]` | Shallow-clones the repositories in parallel, each at its latest release when it has one, else its default branch. |
| `find-images [--dir DIR]` | Every line in the fetched repositories that names (`image`, `image_block` with its `repository`/`tag` lines, `kustomize`), builds (`from`, `compose_build`) or publishes (`publish`) an image, as `file:line` hits, plus each repository's `lockfiles`. Test and example directories are skipped. |
| `registry-check --factory FILE` | For each image under `targets.images` in that `factory.yaml`: `public`, `private` or `missing` to an anonymous client, its `source` label (the repository that builds it, when the image declares one), and for a private ghcr.io package the `fix_url` of its settings page. |
| `find-access --registry FILE [--dir DIR] [--org ORG ...]` | Only when `registry-check` (its output is `FILE`) found private images. Searches the fetched repositories' workflows, and a code search of each `--org`'s workflows, for logins to those registries only. Returns `groups`: the private images per registry (`label`, `count`, `kind`, `docs_anchor`), each with a `state`: `grant` (GitHub Packages), `reuse` (with the pull-only `login` to copy: `repo`, `method` `oidc` or `secret`, `role`, secret names, never values) or `no_path` (`reason` `none_found` or `publish_or_deploy`). |
| `seed --repo ORG/NAME --name NAME [--factory FILE] [--access FILE]` | Creates the private findings repository if missing and pushes the template. With `--factory`, installs that `factory.yaml`. With `--access` (`find-access`'s output), copies each `reuse` login into the scan workflow and returns `access`: per reused login, the secrets or variables the new repository is `missing`. Refuses to write into an existing repository that is not a factory repository. The push starts the first scan. |
| `scan-status --repo ORG/NAME [--wait MIN]` | The latest scan run and, once results exist, the totals and any images that failed. For follow-up debugging only, never during setup. |
| `find-factories --owner ORG [--near ORG/NAME]` | The owner's existing factory repositories (they have `.cve-factory/factory.yaml`), closest to `--near` first. |
| `remediator-check --repo ORG/NAME` | Whether a remediator for that findings repository already exists: `automations` from the automation API (`[]` when there is none, `null` when the API can't be reached) and `last_run` from its work log. Also name `OPENHANDS_API_KEY`, `OPENHANDS_HOST` and `OH_WEBHOOKS_0_BASE_URL` in this command. |
| `token-url --owner ORG [--read-only]` | A prefilled GitHub token page for a bot account; with `--read-only`, a token that only reads repositories, for the scanner's `CVE_FACTORY_READ_TOKEN`. |

## Rules

- **Token**: never ask for its value in chat, echo it, or put it in a file or tool argument.
- **Cloning**: use `fetch`. If you must clone by hand, never put the token in a URL; use exactly
  this, `<TOKEN>` being `whoami`'s `token_env`:
  `GIT_TERMINAL_PROMPT=0 git -c credential.helper= -c http.extraHeader="Authorization: Basic $(printf 'x-access-token:%s' "$<TOKEN>" | base64 | tr -d '\n')" clone -q --depth 1 https://github.com/<owner>/<repo>.git <dir>`
- **Writes**: create only the findings repository and the one automation, and nothing before the
  go-ahead. Never push to, open PRs in, or change settings of the user's other repositories.
- **Registry access**: reuse logins only through `seed --access`, which copies only pull-only ones.
  Never copy a login from a job that publishes or deploys, and never ask for or handle a secret's value.
- Default `policy.autonomy` is `propose`: the remediator opens PRs and never merges.

## Phase 1 - Find and propose (no questions)

1. **Form first.** When the `automation_form_update` tool is available, the automation setup form is
   open beside this conversation. Your very first action is one call that fills it: `kind`
   `"prompt"`, `name` `"CVE remediator"`, `prompt` `"Filled in once the agent
   completes the initial investigation."`, `triggerKind` `"cron"`, `frequency` `"weekdays"`, `time` `"09:00"`,
   `timezone` `"UTC"`, `showTimeout` `true`, `timeoutSeconds` `"1800"`.
2. **Check GitHub access.** `whoami`. If it fails: Blocked, "Reconnect GitHub in OpenHands".
3. **Find what you ship.** Follow [references/inventory.md](references/inventory.md): `fetch` the
   starting repositories, `find-images`, then write a local `factory.yaml` from
   `template/.cve-factory/factory.yaml` with `identity.token_secret` set to `whoami`'s `token_env`.
   When you will update an existing factory repository, start from its current `factory.yaml` instead
   and add to it: keep every existing target.
   Spend at most about 10 commands here after `find-images`. Then write `factory.yaml` with what you
   have, and put anything unclear in `suggested`.
4. **Check image access.**
   - `registry-check --factory <your factory.yaml> > /tmp/cve-factory-registry.json`.
   - Move each `missing` image to `suggested` with the note `"tag not found in the registry"`.
   - Only when it reports `private` images: find how the user's CI already reaches those registries.
     `find-access --registry /tmp/cve-factory-registry.json --dir <fetch dir> --org <owner> > /tmp/cve-factory-access.json`,
     one `--org` per owner of the starting repositories, then read its `groups`.
     - Move the images of each `no_path` group to `suggested` with the note
       `"private registry: no pull access found"` (`none_found`) or
       `"private registry: only publish or deploy logins found"` (`publish_or_deploy`).
     - `grant` and `reuse` images stay in `images`: they scan as soon as access is in place.
   - Where an image has a `source` on github.com, set its `source_repo` to that `owner/name` (and its
     `group` to the image name).
   - Repository targets: `whoami --repo` each one. Public ones scan as is. Private ones stay in
     `targets.repos` and need the scanner's read token, `CVE_FACTORY_READ_TOKEN`, in the findings
     repository: they count toward the ACCESS LINE.
5. **Prepare your plan.**
   - Slack: a blank "Slack channel" means no Slack. Leave `report.slack_channel` empty and never ask
     about Slack. Otherwise set `report.slack_channel` to the channel as given. Slack is connected when
     this conversation has Slack tools, or when
     `SLACK_BOT_TOKEN="$SLACK_BOT_TOKEN" sh -c '[ -n "$SLACK_BOT_TOKEN" ] && echo set'` prints `set`.
   - Findings repository: `<owner>/cve-remediation-factory`, the owner being the one most of the
     repositories belong to, unless the form's notes name another. When the notes name a findings
     repository that doesn't exist, check for a near miss before creating it:
     `find-factories --owner <owner> --near <the name>`. If it lists a factory with a similar name, send
     only `I couldn't find **<the name>**. Did you mean **<closest factory>**? Reply **yes** to add to it,
     or **go ahead** to create <the name>.` and end the turn. `whoami --repo <it>`. If it
     already exists, someone else may own it: use `<owner>/cve-remediation-factory-<login>` instead
     (`<login>` from `whoami`). If that one exists and is a factory repository (it has
     `.cve-factory/factory.yaml`), it is this user's own and you update it; if it exists and is not,
     use `<owner>/cve-remediation-factory-<login>-2`.
   - When the findings repository you will use already exists, check for an existing remediator, so
     the user doesn't create a duplicate: `OPENHANDS_API_KEY="$OPENHANDS_API_KEY" OPENHANDS_HOST="$OPENHANDS_HOST" OH_WEBHOOKS_0_BASE_URL="$OH_WEBHOOKS_0_BASE_URL" <the usual prefix> remediator-check --repo <it>`.
     Keep the result for Done's first line.
   - With the form, update `name` to `"CVE remediator · <name>"` (the findings repository's short name) and
     `prompt` to the `prompt` value in Phase 2, step 3.
   - Send Findings and end the turn.

### Findings

```
**Alright, I am now ready to set up your CVE Remediation Factory**

- I will be acting as **@<login>**: commits and pull requests show as yours.
- I will create 1 new private repository, called **<owner>/<name>**, with workflows that scan for vulnerabilities daily at 06:00 UTC.
- I'll scan <WHAT> from <up to 3 repository names, then "and K more">. <When there are any: "<M> more are saved for later.">
- <ACCESS LINE: only when there are private images>
<REPO LINE: only when the user has to create the repository>
- The automation form is on the right: when we are done, I will ask you to create this automation. It will interpret the scan results every weekday, then open pull requests addressing CVEs for you to review, at most 3 open at a time.
- <SLACK LINE>

Green light? Reply **go ahead**, or tell me what to change.
```

`<WHAT>` is `**<N> images**`, `**<R> repositories**`, or `**<N> images** and **<R> repositories**`:
`<N>` counts the public images in `images`, `<R>` the public repositories in `repos`. `<M>` counts `suggested` entries other than the ones moved
there for registry access, which the ACCESS LINE already counts.

`<ACCESS LINE>`, one line for everything private: every `find-access` group, plus private repository
targets labelled `GitHub repositories`:
`**<PRIVATE>** in <up to 3 group labels, then "and J more"> need an access change before I can scan them; I'll give you the exact steps when I'm done.`
`<PRIVATE>` is `<K> private images`, `<R> private repositories`, or both joined by "and".

`<REPO LINE>` appears only when `can_create_repos` is `false`: `- Create **<owner>/<name>** with [this prefilled link](<create_url>), then reply **go ahead**.` When `app_installation.repository_selection` is `selected`, append ` Also add it to the [OpenHands app](<app_installation.settings_url>).` Otherwise leave it out: the second bullet already names the repository.

`<SLACK LINE>` is one of:
- no channel: `The daily status goes to the findings repository's work-log branch. Add a Slack channel in factory.yaml any time to get it in Slack.`
- a channel, Slack connected: `Posts a daily status to **<channel>**.`
- a channel, Slack not connected: `To post the daily status to **<channel>**, connect Slack under **Integrations** in OpenHands before you press **Run now**.`

Other variants:
- With `CVE_FACTORY_GIT_TOKEN`, the first line is `- I will be acting as **@<login>** (bot account).`
- For an existing factory repository, the second line is `- My actions will update your existing findings repository and its vulnerability scanning workflows.`
- Without the form, the remediator line is `- I'll create the remediator: weekdays at 09:00 UTC, at most 3 open pull requests, never merges.`

## Phase 2 - Build (after the go-ahead, no check-ins)

Do not wait for or check the first scan: the push starts it, and the user tests it afterwards.

1. **Create the findings repository.** If the user had to create it, `whoami --repo` first; if it
   still cannot be read: Blocked, naming which of the two links they still need to follow.
2. **Push the scanner.** `seed --repo <owner>/<name> --name <short name> --factory <your factory.yaml>`, plus
   `--access /tmp/cve-factory-access.json` when you ran `find-access`. Keep its `access` result for Done.
   It also creates the `automation-worklog` branch with a placeholder `README.md`.
3. **Set up the remediator.** The automation runs this prompt, `<TOKEN>` being `whoami`'s `token_env`:

   `Clone <owner>/<name> into ./findings with the token in $<TOKEN>, never putting the token in a URL: GIT_TERMINAL_PROMPT=0 git -c credential.helper= -c http.extraHeader="Authorization: Basic $(printf 'x-access-token:%s' "$<TOKEN>" | base64 | tr -d '\n')" clone -q --depth 1 https://github.com/<owner>/<name>.git findings. Then read findings/.cve-factory/remediator.md and findings/.cve-factory/factory.yaml and follow remediator.md exactly. This run's time limit is 30 minutes.`

   **With the form**: check it still holds the values from Phase 1 and fix any that drifted. Do not
   use the automation API at all; the user creates it with **Create Automation**.

   **Without the form**, create it through the automation API. Use the first base that answers
   `GET <base>/api/automation/v1?limit=1` with 200: `$OPENHANDS_HOST` when set; on a self-hosted
   (Enterprise) sandbox the origin of `$OH_WEBHOOKS_0_BASE_URL` with
   `Authorization: Bearer $OPENHANDS_API_KEY`; otherwise what the `openhands-automation` skill says.
   Never fall back to app.all-hands.dev from a self-hosted sandbox: send Blocked instead.
   `POST <automation API>/preset/prompt` with `{"name": "CVE remediator · <name>",
   "description": "Opens upgrade pull requests for fixable CRITICAL and HIGH findings. Policy: .cve-factory/factory.yaml in <owner>/<name>.",
   "prompt": <the prompt above>, "trigger": {"type": "cron", "schedule": "0 9 * * 1-5", "timezone": "UTC"}, "timeout": 1800}`,
   without `repos`. Then `PATCH <automation API>/<id>` with `{"tags": ["cve-factory"]}`, skipping it if
   rejected. If the deployment requires an agent profile, use the active one. Do not run it.
4. Send Done and end the turn.

### Done

```
<LAST STEP>

**Overview and links to review in order**
- [<owner>/<name>](<repository URL>) is now where your scanning workflows run.
- Daily vulnerability scans run as GitHub workflow actions; [the first one is running now](<repository URL>/actions/workflows/cve-scan.yml) and can take a while.
- Scan results are mostly read by the agent, but [a human-readable view lands on this branch called scan-results](<repository URL>/tree/scan-results) when the scan finishes.
- The agent tracks its work on [its own branch called automation-worklog](<repository URL>/tree/automation-worklog): the daily status message and the CVEs it's working on. It fills in after the remediator's first run.

<ACCESS BLOCK: only when something needs access>

**Later:** come back to this conversation or run `/cve-remediation-factory` again and point me at <owner>/<name> to troubleshoot issues (agents can make mistakes), change what's scanned, or adjust the remediator's prompt.
```

Keep the blank lines exactly as shown.

`<LAST STEP>` is one of:
- New findings repository, or the automation API answered and `automations` is `[]` (it is the authority, even when the work log shows an older run): `**Last step: press Create Automation on the right.** Once the first scan finishes, press **Run now** on it to see it open pull requests.`
- `remediator-check` found one in `automations`: `**No new automation needed:** your remediator **<its name>** already uses <owner>/<name> and picks up these changes on its next run, so don't press Create Automation.`
- The automation API couldn't be reached (`automations` is `null`) and `last_run` is set: `**You probably already have a remediator:** it last ran <last_run as a date> and picks up these changes on its next run. Only press Create Automation if you don't have one for <owner>/<name>.`
- The automation API couldn't be reached and there is no `last_run`, for an existing repository: `**Last step: press Create Automation on the right, unless you already created one for <owner>/<name>.** Once the first scan finishes, press **Run now** on it to see it open pull requests.`

`<ACCESS BLOCK>` is the line `**To scan private images and repositories**` followed by one `<ACCESS STEP>` bullet per
group that needs one, in the Findings order.

`<ACCESS STEP>`, `<docs>` being `<repository URL>/blob/main/docs/registries.md`:
- `grant`: ``To scan <K> GitHub Packages images, give `<name>` **Read** under **Manage Actions access** on each: [<package>](<url>), [<package>](<url>).`` (from the group's `fix_urls`)
- `reuse`, `oidc`, Amazon ECR: ``To scan <K> Amazon ECR images, add `repo:<owner>/<name>:*` to the trust policy of `<login.role>` ([how](<docs>#amazon-ecr)).``
- `reuse`, `oidc`, Google Artifact Registry: ``To scan <K> Google Artifact Registry images, let `<owner>/<name>` use `<login.role>` through your workload identity pool ([how](<docs>#google-artifact-registry)).``
- `reuse`, `oidc`, any other registry: ``To scan <K> <label> images, let `<owner>/<name>` use the login copied from <login.repo> ([how](<docs>#<docs_anchor>)).``
- `reuse` whose `seed` `access` entry lists `missing` or `unknown` names: ``To scan <K> <label> images, make `<NAME>`, `<NAME>` available to `<name>` ([how](<docs>#a-reused-secret-is-missing)).`` No line when both lists are empty.
- `no_path`: ``To add <K> <label> images later, follow [these steps](<docs>#<docs_anchor>).``
- Private repository targets: ``To scan <R> private repositories, save a token that can read them as the Actions secret `CVE_FACTORY_READ_TOKEN` in `<name>` ([create one](<token-url --owner <owner> --read-only>), [how](<docs>#source-repositories)).``

Without the form, the first line is `**Last step: once the first scan finishes, press Run now on [the remediator](<origin>/automations/<id>).**`

## Coming back to a factory

When the user returns to this conversation after Done, or runs `/cve-remediation-factory` (from the
form or not) and names a repository that has `.cve-factory/factory.yaml`, skip setup: no Findings, no
Done. If the name they gave doesn't exist, run `find-factories --owner <owner> --near <the name>` and ask
"Did you mean …?" about the closest one before doing anything else.

1. Clone the repository (see Rules) and read `factory.yaml` and `remediator.md`; `scan-status --repo <it>`.
2. Do what they ask, in short answers:
   - **Troubleshoot**: the scan's run logs and `scan-status`; the remediator's recent runs through the
     automation API when it is reachable (Phase 2, step 3 says how to find it).
   - **Improve**: edit `factory.yaml` or `remediator.md`.
   - **Add deployment artifacts**: the inventory flow below, for the repositories they name. Changes
     are additive: start from the repository's current `factory.yaml` and add the new targets. Keep
     every existing target unless the user asks to remove it.
3. Show the change as a short diff and push it only after a yes: `seed --repo <it> --name <name> --factory <file>`
   for `factory.yaml`, a plain commit for anything else. The push starts a scan.

Never create a second findings repository for an existing factory. When the automation form is open
beside this conversation, also run `remediator-check` and, if it finds the remediator, say it already
picks up the changes and not to press **Create Automation**.

## `/cve-remediation-factory inventory`

For an existing factory: read its `factory.yaml`, redo the inventory for the repositories the
user names, and merge the result into the file: targets from other repositories stay as they are.
Show what was added or changed, and on a yes run `seed --factory` with the merged file. The push
starts a scan.

## Using a bot account

Only when the user asks. A machine user's fine-grained token: run `token-url --owner <owner>` and
give the user the link. It opens the token form with the name, expiry and every permission filled
in. They choose **All repositories** (or the findings repository plus the repositories you will
fix), check that **Resource owner** shows the organization, and click Generate. If the organization
requires approval for fine-grained tokens, an owner approves it under the organization's
Settings > Personal access tokens. They save it in Settings > Secrets as `CVE_FACTORY_GIT_TOKEN`
and start again from the template.

Files in this skill

  • .plugin/plugin.json633 B
  • README.md134 B
  • SKILL.md23.5 KB
  • commands/cve-remediation-factory.md666 B
  • references/inventory.md4.1 KB
  • scripts/seed.py52.6 KB
  • template/.cve-factory/factory.yaml3 KB
  • template/.cve-factory/remediator.md15.4 KB
  • template/.github/workflows/cve-scan.yml1.5 KB
  • template/.gitlab-ci.yml774 B
  • template/README.md1.7 KB
  • template/bitbucket-pipelines.yml775 B
  • template/docs/RESULTS.md2.9 KB
  • template/docs/registries.md5.7 KB
  • template/scripts/run_scan.sh7.8 KB
  • template/scripts/scan.py22.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in tools →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.