diff --git a/README.md b/README.md index 611bb055a..9e873c0f8 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ The JS and Python versions are kept in lock-step by `release-please` and guarded ## Extensions Catalog -This repository contains **2 marketplace(s)** with **82 extensions** (71 skills, 11 plugins). +This repository contains **2 marketplace(s)** with **83 extensions** (72 skills, 11 plugins). ### large-codebase @@ -119,7 +119,7 @@ OpenHands skills for interacting, improving, and refactoring large codebases Official skills and plugins for OpenHands — the open-source AI software engineer. -**78 extensions** (69 skills, 9 plugins) +**79 extensions** (70 skills, 9 plugins) | Name | Type | Description | Commands | |------|------|-------------|----------| @@ -138,6 +138,7 @@ Official skills and plugins for OpenHands — the open-source AI software engine | code-simplifier | skill | Simplifies and refines code across three dimensions - code reuse, code quality, and efficiency - while preserving all... | `/simplify` | | comment-cleanup | skill | Remove comments that restate adjacent code, delete comments that narrate removed functionality or past PRs, and conde... | — | | cortex-training-rl | skill | Run reinforcement-learning post-training of a model inside the OpenHands harness on Snowflake Cortex Training for any... | `/cortex-training-rl` | +| cve-remediation-factory | skill | Set up a private CVE remediation factory on GitHub: inventory and scan the container images you ship, then open small... | `/cve-remediation-factory` | | datadog | skill | Query and analyze Datadog logs, metrics, APM traces, and monitors using the Datadog API. Use when debugging productio... | — | | deno | skill | Common project operations using Deno (tasks, run/test/lint/fmt, and dependency management). | — | | discord | skill | Build and automate Discord integrations (bots, webhooks, slash commands, and REST API workflows). Use when the user m... | — | diff --git a/automations/catalog-index.js b/automations/catalog-index.js index d79a5252d..2dae2a0ff 100644 --- a/automations/catalog-index.js +++ b/automations/catalog-index.js @@ -2,32 +2,33 @@ // Do not edit it manually. To update it after changing automations/catalog/*/manifest.json, // run: npm run build:automations -import entry0 from "./catalog/github-pr-reviewer/manifest.json" with { type: "json" }; -import entry1 from "./catalog/custom-automation/manifest.json" with { type: "json" }; -import entry2 from "./catalog/github-repo-monitor/manifest.json" with { type: "json" }; -import entry3 from "./catalog/github-issue-to-pr/manifest.json" with { type: "json" }; -import entry4 from "./catalog/slack-standup-digest/manifest.json" with { type: "json" }; -import entry5 from "./catalog/slack-channel-monitor/manifest.json" with { type: "json" }; -import entry6 from "./catalog/linear-triage-assistant/manifest.json" with { type: "json" }; -import entry7 from "./catalog/linear-issue-to-github-pr/manifest.json" with { type: "json" }; -import entry8 from "./catalog/gitlab-issue-to-mr/manifest.json" with { type: "json" }; -import entry9 from "./catalog/linear-issue-to-gitlab-mr/manifest.json" with { type: "json" }; -import entry10 from "./catalog/linear-issue-to-bitbucket-pr/manifest.json" with { type: "json" }; -import entry11 from "./catalog/jira-issue-to-pr/manifest.json" with { type: "json" }; -import entry12 from "./catalog/qa-changes/manifest.json" with { type: "json" }; -import entry13 from "./catalog/jira-data-center-issue-to-bitbucket-data-center-pr/manifest.json" with { type: "json" }; -import entry14 from "./catalog/jira-issue-to-gitlab-mr/manifest.json" with { type: "json" }; -import entry15 from "./catalog/research-brief-writer/manifest.json" with { type: "json" }; -import entry16 from "./catalog/bitbucket-data-center-pr-reviewer/manifest.json" with { type: "json" }; -import entry17 from "./catalog/jira-issue-to-bitbucket-pr/manifest.json" with { type: "json" }; -import entry18 from "./catalog/github-agents-md-maintainer/manifest.json" with { type: "json" }; -import entry19 from "./catalog/github-delivery-watchdog/manifest.json" with { type: "json" }; -import entry20 from "./catalog/github-issue-triage/manifest.json" with { type: "json" }; -import entry21 from "./catalog/upstream-fork-sync/manifest.json" with { type: "json" }; -import entry22 from "./catalog/incident-retrospective-drafter/manifest.json" with { type: "json" }; -import entry23 from "./catalog/news-digest/manifest.json" with { type: "json" }; -import entry24 from "./catalog/github-stale-ci-pr-closer/manifest.json" with { type: "json" }; -import entry25 from "./catalog/github-comment-cleanup/manifest.json" with { type: "json" }; +import entry0 from "./catalog/cve-remediation-factory/manifest.json" with { type: "json" }; +import entry1 from "./catalog/github-pr-reviewer/manifest.json" with { type: "json" }; +import entry2 from "./catalog/custom-automation/manifest.json" with { type: "json" }; +import entry3 from "./catalog/github-repo-monitor/manifest.json" with { type: "json" }; +import entry4 from "./catalog/github-issue-to-pr/manifest.json" with { type: "json" }; +import entry5 from "./catalog/slack-standup-digest/manifest.json" with { type: "json" }; +import entry6 from "./catalog/slack-channel-monitor/manifest.json" with { type: "json" }; +import entry7 from "./catalog/linear-triage-assistant/manifest.json" with { type: "json" }; +import entry8 from "./catalog/linear-issue-to-github-pr/manifest.json" with { type: "json" }; +import entry9 from "./catalog/gitlab-issue-to-mr/manifest.json" with { type: "json" }; +import entry10 from "./catalog/linear-issue-to-gitlab-mr/manifest.json" with { type: "json" }; +import entry11 from "./catalog/linear-issue-to-bitbucket-pr/manifest.json" with { type: "json" }; +import entry12 from "./catalog/jira-issue-to-pr/manifest.json" with { type: "json" }; +import entry13 from "./catalog/qa-changes/manifest.json" with { type: "json" }; +import entry14 from "./catalog/jira-data-center-issue-to-bitbucket-data-center-pr/manifest.json" with { type: "json" }; +import entry15 from "./catalog/jira-issue-to-gitlab-mr/manifest.json" with { type: "json" }; +import entry16 from "./catalog/research-brief-writer/manifest.json" with { type: "json" }; +import entry17 from "./catalog/bitbucket-data-center-pr-reviewer/manifest.json" with { type: "json" }; +import entry18 from "./catalog/jira-issue-to-bitbucket-pr/manifest.json" with { type: "json" }; +import entry19 from "./catalog/github-agents-md-maintainer/manifest.json" with { type: "json" }; +import entry20 from "./catalog/github-delivery-watchdog/manifest.json" with { type: "json" }; +import entry21 from "./catalog/github-issue-triage/manifest.json" with { type: "json" }; +import entry22 from "./catalog/upstream-fork-sync/manifest.json" with { type: "json" }; +import entry23 from "./catalog/incident-retrospective-drafter/manifest.json" with { type: "json" }; +import entry24 from "./catalog/news-digest/manifest.json" with { type: "json" }; +import entry25 from "./catalog/github-stale-ci-pr-closer/manifest.json" with { type: "json" }; +import entry26 from "./catalog/github-comment-cleanup/manifest.json" with { type: "json" }; export const AUTOMATION_CATALOG_ENTRIES = [ entry0, @@ -56,4 +57,5 @@ export const AUTOMATION_CATALOG_ENTRIES = [ entry23, entry24, entry25, + entry26, ]; diff --git a/automations/catalog.schema.json b/automations/catalog.schema.json index bd75b28ed..0d80e32a0 100644 --- a/automations/catalog.schema.json +++ b/automations/catalog.schema.json @@ -30,7 +30,7 @@ "category": { "type": "string", "minLength": 1 }, "icon": { "description": "The glyph the card shows, named from the same closed set the interface manifest's navigation uses. Absent means the host derives one from requires.integrations, which is right for an automation whose identity is the service it talks to and wrong for one whose identity is the work itself.", - "enum": ["layout-dashboard", "sparkles", "bot", "circle-alert", "activity", "timer"] + "enum": ["layout-dashboard", "sparkles", "bot", "circle-alert", "activity", "timer", "shield-check"] }, "description": { "type": "string", "minLength": 1 }, "diagram": { diff --git a/automations/catalog/cve-remediation-factory/manifest.json b/automations/catalog/cve-remediation-factory/manifest.json new file mode 100644 index 000000000..6681508e8 --- /dev/null +++ b/automations/catalog/cve-remediation-factory/manifest.json @@ -0,0 +1,88 @@ +{ + "id": "cve-remediation-factory", + "name": "GitHub CVE Remediation Factory", + "category": "Security", + "description": "Deploy scanners and agents to remediate vulnerabilities as soon as they are detected.", + "diagram": "flowchart TD\n A([\"Daily scan\"]) --> B[\"Trivy + Grype results in a new repo\"]\n B --> C[\"Agent ranks fixable CVEs and submits PRs\"]\n C --> D[\"(Optional) Slack status report\"]", + "requires": { + "integrations": { + "github": { + "message": "Used to read your repositories, create the private findings repository, and open upgrade pull requests." + } + }, + "features": [ + "presetPrompt", + "conversationDispatch" + ] + }, + "icon": "shield-check", + "popularityRank": 101, + "estimatedSetupMinutes": 20, + "triggers": [ + "cron" + ], + "exampleImplementation": "Trigger: cron, daily scan then weekday remediation\nRequired secrets: none (uses your GitHub connection); optionally CVE_FACTORY_GIT_TOKEN for a bot account and SLACK_BOT_TOKEN\n\n1. Build an inventory of what you ship: container images from Helm charts, manifests and compose files, and source repositories with lockfiles.\n2. Seed a private findings repository with factory.yaml and the scanner.\n3. Scan every image and repository with Trivy and Grype and store the results on a branch.\n4. Rank fixable CRITICAL and HIGH findings and open bundled upgrade pull requests.\n5. Track each fix in a work log until the scan stops reporting it, and write a short status report (and Slack, when configured).", + "setup": { + "version": "1.0", + "mode": "assisted", + "form": { + "note": "The bot will act as your identity through your GitHub connection. To use a separate identity (recommended), create a bot account and its token, and save the token as a secret named CVE_FACTORY_GIT_TOKEN.", + "args": { + "repositories": { + "type": "repo-picker", + "label": "Repositories to protect", + "help": "Optional. If you add none, the agent covers every active repository your GitHub connection can read.", + "provider": "github", + "multiple": true, + "required": false + }, + "shipType": { + "type": "select", + "label": "What do you ship?", + "help": "The types of deployable artifacts the agent will look for.", + "default": "Let the agent figure it out", + "required": false, + "options": [ + { + "value": "Let the agent figure it out", + "label": "Let the agent figure it out" + }, + { + "value": "Container images (Docker, Kubernetes, Helm, Compose)", + "label": "Container images (Docker, Kubernetes, Helm, Compose)" + }, + { + "value": "Libraries and packages (npm, PyPI, Maven/Gradle JARs, Go modules)", + "label": "Libraries and packages (npm, PyPI, Maven/Gradle JARs, Go modules)" + }, + { + "value": "Code deployed from the repo (serverless, VMs, PaaS)", + "label": "Code deployed from the repo (serverless, VMs, PaaS)" + } + ] + }, + "notes": { + "type": "textarea", + "label": "Which repo best shows what you deploy? Anything else to know?", + "help": "The repo that represents your most prominent security concern, also add anything else the agent might need to know", + "placeholder": "Start with owner/repo, it showcases our primary deployment pipeline", + "required": false, + "constraints": { + "maxLength": 2000 + } + }, + "slackChannel": { + "type": "text", + "label": "Slack channel for the daily status", + "help": "Recommended. Leave blank to keep the daily status only in the findings repository.", + "placeholder": "#cve-automation", + "required": false, + "constraints": { + "maxLength": 100 + } + } + } + }, + "message": "Time to set up a GitHub CVE Remediation Factory. Here's what happens next:\n\n1. The agent explores your repositories to work out what to scan, based on your answers below.\n2. It presents a plan for you to approve.\n3. Once you approve, it creates the scanning repository, the first scan starts, and you create the automation on the right.\n\nYour answers:\n\n- Repositories to protect (blank = all repos in the org): {{form.repositories}}\n- Ships: {{form.shipType}}\n- Start with (blank = the agent decides): {{form.notes}}\n- Slack channel (blank = no Slack): {{form.slackChannel}}" + } +} diff --git a/automations/index.d.ts b/automations/index.d.ts index f8b1004ee..e02b3b4c3 100644 --- a/automations/index.d.ts +++ b/automations/index.d.ts @@ -18,7 +18,8 @@ export interface RecommendedAutomation { | "bot" | "circle-alert" | "activity" - | "timer"; + | "timer" + | "shield-check"; description: string; /** * Mermaid source for a small diagram of what the automation does. The host @@ -296,7 +297,8 @@ export type AutomationIconSlug = | "bot" | "circle-alert" | "activity" - | "timer"; + | "timer" + | "shield-check"; /** The pages a sub-page navigation item may point at. */ export type AutomationSubPageId = "list" | "events" | "templates"; diff --git a/automations/interface.json b/automations/interface.json index 8edc3474b..08bc32863 100644 --- a/automations/interface.json +++ b/automations/interface.json @@ -172,6 +172,7 @@ "webhooks": "/v1/webhooks" }, "featuredAutomationIds": [ + "cve-remediation-factory", "github-pr-reviewer", "github-agents-md-maintainer", "news-digest", diff --git a/automations/interface.schema.json b/automations/interface.schema.json index 600def3a1..775e3b93f 100644 --- a/automations/interface.schema.json +++ b/automations/interface.schema.json @@ -309,7 +309,8 @@ "bot", "circle-alert", "activity", - "timer" + "timer", + "shield-check" ] }, "subPageNavItem": { diff --git a/marketplaces/openhands-extensions.json b/marketplaces/openhands-extensions.json index c2936188e..f6d3282f4 100644 --- a/marketplaces/openhands-extensions.json +++ b/marketplaces/openhands-extensions.json @@ -119,6 +119,20 @@ "pull-request" ] }, + { + "name": "cve-remediation-factory", + "source": "./skills/cve-remediation-factory", + "description": "Set up a private CVE remediation factory on GitHub: inventory and scan the container images you ship, then open small upgrade pull requests for fixable CRITICAL and HIGH vulnerabilities.", + "category": "automations", + "defaultEnabled": true, + "keywords": [ + "security", + "cve", + "trivy", + "vulnerability", + "automation" + ] + }, { "name": "agent-canvas-environment", "source": "./skills/agent-canvas-environment", diff --git a/skills/cve-remediation-factory/.claude-plugin b/skills/cve-remediation-factory/.claude-plugin new file mode 120000 index 000000000..665797f0a --- /dev/null +++ b/skills/cve-remediation-factory/.claude-plugin @@ -0,0 +1 @@ +.plugin \ No newline at end of file diff --git a/skills/cve-remediation-factory/.codex-plugin b/skills/cve-remediation-factory/.codex-plugin new file mode 120000 index 000000000..665797f0a --- /dev/null +++ b/skills/cve-remediation-factory/.codex-plugin @@ -0,0 +1 @@ +.plugin \ No newline at end of file diff --git a/skills/cve-remediation-factory/.plugin/plugin.json b/skills/cve-remediation-factory/.plugin/plugin.json new file mode 100644 index 000000000..5245bd314 --- /dev/null +++ b/skills/cve-remediation-factory/.plugin/plugin.json @@ -0,0 +1,19 @@ +{ + "name": "cve-remediation-factory", + "version": "1.0.0", + "description": "Set up a private CVE remediation factory on GitHub: inventory and scan what you ship (container images and source repositories) with Trivy and Grype, then open small upgrade pull requests for fixable CRITICAL and HIGH vulnerabilities.", + "author": { + "name": "OpenHands", + "email": "contact@all-hands.dev" + }, + "homepage": "https://github.com/OpenHands/extensions", + "repository": "https://github.com/OpenHands/extensions", + "license": "MIT", + "keywords": [ + "security", + "cve", + "trivy", + "vulnerability", + "automation" + ] +} diff --git a/skills/cve-remediation-factory/README.md b/skills/cve-remediation-factory/README.md new file mode 100644 index 000000000..01debb3e5 --- /dev/null +++ b/skills/cve-remediation-factory/README.md @@ -0,0 +1,3 @@ +# CVE Remediation Factory + +Sets up a scan-and-remediate pipeline for container image vulnerabilities. Run `/cve-remediation-factory`. diff --git a/skills/cve-remediation-factory/SKILL.md b/skills/cve-remediation-factory/SKILL.md new file mode 100644 index 000000000..e11698519 --- /dev/null +++ b/skills/cve-remediation-factory/SKILL.md @@ -0,0 +1,302 @@ +--- +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:** . .` 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 /scripts/seed.py ... +``` + +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, `` being `whoami`'s `token_env`: + `GIT_TERMINAL_PROMPT=0 git -c credential.helper= -c http.extraHeader="Authorization: Basic $(printf 'x-access-token:%s' "$" | base64 | tr -d '\n')" clone -q --depth 1 https://github.com//.git ` +- **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 > /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 --org > /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: `/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 --near `. If it lists a factory with a similar name, send + only `I couldn't find ****. Did you mean ****? Reply **yes** to add to it, + or **go ahead** to create .` and end the turn. `whoami --repo `. If it + already exists, someone else may own it: use `/cve-remediation-factory-` instead + (`` 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 `/cve-remediation-factory--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" remediator-check --repo `. + Keep the result for Done's first line. + - With the form, update `name` to `"CVE remediator · "` (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 **@**: commits and pull requests show as yours. +- I will create 1 new private repository, called **/**, with workflows that scan for vulnerabilities daily at 06:00 UTC. +- I'll scan from . more are saved for later."> +- + +- 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. +- + +Green light? Reply **go ahead**, or tell me what to change. +``` + +`` is `** images**`, `** repositories**`, or `** images** and ** repositories**`: +`` counts the public images in `images`, `` the public repositories in `repos`. `` counts `suggested` entries other than the ones moved +there for registry access, which the ACCESS LINE already counts. + +``, one line for everything private: every `find-access` group, plus private repository +targets labelled `GitHub repositories`: +`**** in need an access change before I can scan them; I'll give you the exact steps when I'm done.` +`` is ` private images`, ` private repositories`, or both joined by "and". + +`` appears only when `can_create_repos` is `false`: `- Create **/** with [this prefilled link](), then reply **go ahead**.` When `app_installation.repository_selection` is `selected`, append ` Also add it to the [OpenHands app]().` Otherwise leave it out: the second bullet already names the repository. + +`` 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 ****.` +- a channel, Slack not connected: `To post the daily status to ****, 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 **@** (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 / --name --factory `, 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, `` being `whoami`'s `token_env`: + + `Clone / into ./findings with the token in $, 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' "$" | base64 | tr -d '\n')" clone -q --depth 1 https://github.com//.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 /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 /preset/prompt` with `{"name": "CVE remediator · ", + "description": "Opens upgrade pull requests for fixable CRITICAL and HIGH findings. Policy: .cve-factory/factory.yaml in /.", + "prompt": , "trigger": {"type": "cron", "schedule": "0 9 * * 1-5", "timezone": "UTC"}, "timeout": 1800}`, + without `repos`. Then `PATCH /` 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 + +``` + + +**Overview and links to review in order** +- [/]() is now where your scanning workflows run. +- Daily vulnerability scans run as GitHub workflow actions; [the first one is running now](/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](/tree/scan-results) when the scan finishes. +- The agent tracks its work on [its own branch called automation-worklog](/tree/automation-worklog): the daily status message and the CVEs it's working on. It fills in after the remediator's first run. + + + +**Later:** come back to this conversation or run `/cve-remediation-factory` again and point me at / to troubleshoot issues (agents can make mistakes), change what's scanned, or adjust the remediator's prompt. +``` + +Keep the blank lines exactly as shown. + +`` 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 **** already uses / 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 and picks up these changes on its next run. Only press Create Automation if you don't have one for /.` +- 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 /.** Once the first scan finishes, press **Run now** on it to see it open pull requests.` + +`` is the line `**To scan private images and repositories**` followed by one `` bullet per +group that needs one, in the Findings order. + +``, `` being `/blob/main/docs/registries.md`: +- `grant`: ``To scan GitHub Packages images, give `` **Read** under **Manage Actions access** on each: [](), []().`` (from the group's `fix_urls`) +- `reuse`, `oidc`, Amazon ECR: ``To scan Amazon ECR images, add `repo:/:*` to the trust policy of `` ([how](#amazon-ecr)).`` +- `reuse`, `oidc`, Google Artifact Registry: ``To scan Google Artifact Registry images, let `/` use `` through your workload identity pool ([how](#google-artifact-registry)).`` +- `reuse`, `oidc`, any other registry: ``To scan