Fix Findings with Remediation Pull Requests
Set up a GitHub repository for remediation, then have Mondoo open pull requests that patch your hosts and track each fix until scans confirm it.
Summary
Mondoo's security pipeline turns the vulnerabilities it finds on your hosts into pull requests in a GitHub repository you own. Instead of pushing changes directly to systems, Mondoo opens a pull request with the patches for the findings you select. You see exactly what it changes, and you approve it through the same review and merge process your team already uses. Mondoo then tracks the fix until scans confirm it.
The result: faster, safer remediation without bypassing the controls you already have in place.
What you get
- Patches delivered as pull requests. Every fix lands as a reviewable, auditable pull request for the findings you selected and the hosts they affect.
- Your review process stays in control. You review every change as a pull request and decide whether to merge it.
- Fixes tracked to the end. Mondoo follows each pull request until scans confirm that every finding in it is fixed.
How it works
- A remediation repository is a GitHub repository that holds an Ansible project: an
inventory.ymlthat lists your hosts, a playbook with a patching role, and GitHub Actions workflows. The repository's GitHub Actions apply the fixes to the hosts listed in its inventory, and its cnspec scan reports those hosts to Mondoo. - You set the repository up on your organization's GitHub integration and pair it with one space. The repository's scans report its hosts into that space.
- In that space, you select findings and choose Create Remediation PR. Mondoo opens one pull request with the patches for the selected findings on the affected hosts.
- A Remediation Pull Request workflow run follows the pull request: it waits for your review and, after you merge, until scans confirm the fix.
There is no separate Security Pipeline integration or Security Pipeline page in the Mondoo App. You set up and manage remediation repositories on the GitHub integration.
Before you begin
- An organization-level GitHub integration that authenticates through the Mondoo GitHub App. Repository setup pushes files and Actions secrets through the app, so a GitHub integration that uses a personal access token can't set up a remediation repository. To add a GitHub integration, read Secure GitHub.
- A repository in your GitHub organization that the Mondoo GitHub App can access. Mondoo doesn't create the repository, so create it in GitHub first. If the GitHub integration has an Allow list or a Deny list, the repository must not be excluded by them.
- Hosts that the repository's workflows can reach over SSH, with the key stored in the repository's
SSH_KEYActions secret. To have the workflows connect as a specific user, set the repository'sSSH_USERNAMEActions variable. - The right access in Mondoo:
- To set up, change, rotate, or remove a remediation repository, you need the Editor or Admin (Owner) role on the organization, or the Integrations Manager permission.
- To create a remediation pull request, you need the Editor or Admin (Owner) role on the space, or the Workflow Manager permission.
Set up a remediation repository
-
In the Mondoo App, navigate to the organization and, in the side navigation, select Integrations.
-
Select GitHub, select your GitHub integration, and then select the Remediation tab. The tab appears only on GitHub integrations that authenticate through the Mondoo GitHub App (the integration's page shows GitHub App under its name).
-
Select Set up repository.
-
In the Set up a remediation repository dialog:
- In Repository, enter the repository as
owner/name, such asmy-org/remediation. - In Space, select the space whose findings you want to fix through this repository.
- Under SSH key, choose how the repository gets its key:
- Mondoo generates and installs the key: Mondoo stores the private key as the repository's
SSH_KEYsecret and keeps only the public key, which you add to your hosts. - I manage the key: You set the repository's
SSH_KEYsecret yourself. Mondoo stores no key.
- Mondoo generates and installs the key: Mondoo stores the private key as the repository's
- In Repository, enter the repository as
-
Select Set up repository.
Setup does these things:
- If the repository has no
inventory.yml, Mondoo pushes its Ansible template to the repository. If the repository already has the template, Mondoo leaves its files as they are. - Mondoo creates a service account in the space and stores its credentials as the repository's
MONDOO_CONFIG_BASE64Actions secret, so the repository's scans report its hosts into the space. - If you chose Mondoo generates and installs the key, Mondoo generates a key pair for this repository and stores the private key as the
SSH_KEYActions secret.
When setup finishes, Mondoo says whether it pushed the template and shows what your hosts need. Select Done.
- If the repository has no
-
List your hosts in the repository's
inventory.yml. -
Give the hosts the key:
- If Mondoo generated the key, add the public key to
~/.ssh/authorized_keysfor the remediation user on every host in the repository's inventory. To see the public key again, select Public key in the repository's row. - If you manage the key, set the repository's
SSH_KEYActions secret to a private key that can reach every host in its inventory. To see these instructions again, select Key setup in the repository's row.
- If Mondoo generated the key, add the public key to
The Remediation tab lists every repository set up for remediation, with its Space, its SSH key (Mondoo-managed or Managed by you), and its Status. Ready means setup finished. Setup unfinished means setup stopped partway; select Finish setup to run it again. Setup picks up where it stopped, so it doesn't create a second service account or push the template twice.
Manage a remediation repository
On the GitHub integration's Remediation tab, use the buttons in the repository's row:
- Rotate key (keys that Mondoo generated only): Mondoo generates a new key pair and replaces the repository's
SSH_KEYsecret. Remediation runs fail until every host in the inventory has the new public key. - Change key: Switch between a key that Mondoo generates and a key you manage. Switching to a Mondoo-generated key replaces the
SSH_KEYsecret you set, so you must also select the Replace the SSH_KEY secret checkbox, and your hosts need the new public key. Switching to a key you manage leaves the currentSSH_KEYsecret in place until you replace it. - Remove: Remediation workflows stop opening pull requests in this repository. The repository, its secrets, and its service account stay as they are; remove them in GitHub and Mondoo if you no longer need them.
A repository is set up for one space. To use it for a different space, remove it and set it up again for that space.
Create a remediation pull request
-
In the Mondoo App, navigate to the space that the repository is set up for, and select Findings.
-
Select the checkbox beside each finding you want to fix.
-
In the selection bar, select Create Remediation PR.
The action appears only in the findings of a space that has a remediation repository, not in a workspace or the organization's findings. It's available only when every selected finding is a vulnerability, advisory, or end-of-life finding with at least one affected asset. Mondoo can't create pull requests for check findings.
-
The Create Remediation PR dialog lists the findings the pull request fixes, with their risk and the number of affected assets. If the space has more than one remediation repository, choose one in Repository.
-
Select Generate PR.
Mondoo starts the space's workflow for that repository and opens its run, where you can follow the pull request. The first time you create a remediation pull request for a repository in a space, Mondoo creates this workflow from the Remediation Pull Request template and names it Remediation pull requests: OWNER/NAME. It's read-only: you can follow its runs, but only Mondoo can change it. To learn more, read Workflows that Mondoo manages.
Review and track the pull request
The pull request contains the patches for the selected findings on the affected hosts. If Mondoo can't patch some of the selected findings, it leaves them out of the pull request, and the run tracks only the ones the pull request covers. Review the pull request like any other change: approve it, change it, or close it.
While the run is open, the findings it tracks show the In progress status. When the run ends, for any reason, they leave that status unless another run still tracks them.
Merging the pull request doesn't patch the hosts by itself. The playbook still has to run on them, for example through the repository's Ansible Apply Patches workflow in GitHub Actions, and a scan has to report the hosts as fixed, for example through its Ansible Inventory Scan with Mondoo cnspec workflow.
The workflow run follows the pull request:
- You merge the pull request. The run waits until scans confirm that every finding in it is fixed, then ends.
- You close the pull request without merging it. The run ends.
- The findings are fixed another way before you merge. Mondoo closes the pull request, and the run ends.
Neither wait has a time limit. To stop waiting for a review, close the pull request. To see the run's steps, select Workflows > Executions in the space. To learn more, read See workflow runs.
Next steps
Remediation pull requests are one of two ways to act on findings. To route remediation work into your existing project management tools instead, read Track and Fix Findings with Ticketing.
Last updated on