Skip to content

Commit

Permalink
Add how-to for pull request remediations
Browse files Browse the repository at this point in the history
Signed-off-by: Radoslav Dimitrov <[email protected]>
  • Loading branch information
rdimitrov committed Nov 5, 2023
1 parent 9c3f815 commit 4a4728e
Showing 1 changed file with 97 additions and 0 deletions.
97 changes: 97 additions & 0 deletions docs/docs/how-to/remediate-pullrequest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
title: Auto-remediation via pull request
sidebar_position: 30
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

## Prerequisites

* The `minder` CLI application
* A Minder account
* An enrolled Provider (e.g., GitHub) and registered repositories

## Create a rule type that has support for pull request auto remediation

The pull request auto remediation feature provides the functionality to fix a failed rule type by creating a pull request.
This feature is only available for rule types that support it.

In this example, we will use a rule type that checks if a repository has Dependabot enabled. If it's not enabled, Minder
will create a pull request that enables Dependabot. The rule type is called `dependabot_configured.yaml` and is one of
the reference rule types provided by the Minder team.

Fetch all the reference rules by cloning the [minder-rules-and-profiles repository](https://github.com/stacklok/minder-rules-and-profiles).

```
git clone https://github.com/stacklok/minder-rules-and-profiles.git
```

In that directory you can find all the reference rules and profiles.
```
cd minder-rules-and-profiles
```

Create the `dependabot_configured` rule type in Minder:
```
minder rule_type create -f rule-types/github/dependabot_configured.yaml
```

## Create a profile
Next, create a profile that applies the rule to all registered repositories.

Create a new file called `profile.yaml`.
Based on your source code language, paste the following profile definition into the newly created file.

<Tabs>
<TabItem value="go" label="Go" default>

```yaml
---
version: v1
type: profile
name: dependabot-profile
context:
provider: github
alert: "on"
remediate: "on"
repository:
- type: dependabot_configured
def:
package_ecosystem: gomod
schedule_interval: weekly
apply_if_file: go.mod
```
</TabItem>
<TabItem value="npm" label="NPM">
```yaml
---
version: v1
type: profile
name: dependabot-profile
context:
provider: github
alert: "on"
remediate: "on"
repository:
- type: dependabot_configured
def:
package_ecosystem: npm
schedule_interval: weekly
apply_if_file: package.json
```
</TabItem>
</Tabs>
Create the profile in Minder:
```
minder profile create -f profile.yaml
```

Once the profile is created, Minder will monitor all of your registered repositories matching the expected ecosystem,
i.e., Go, NPM, etc.

If a repository does not have Dependabot enabled, Minder will create a pull request with the necessary configuration
to enable it. Alongside the PR, Minder will also create a Security Advisory alert that will be present until the issue
is resolved.

0 comments on commit 4a4728e

Please sign in to comment.