Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a tutorial on automatic remediations #1391

Merged
merged 6 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/docs/tutorials/register_repo_create_profile.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ minder profile create -f profile.yaml

Check the status of the profile:
```
./bin/minder profile_status list --profile github-profile
minder profile_status list --profile github-profile
```
If all registered repositories have secret scanning enabled, you will see the `OVERALL STATUS` is `Success`, otherwise the
overall status is `Failure`.

See a detailed view of which repositories satisfy the secret scanning rule:
```
./bin/minder profile_status list --profile github-profile --detailed
minder profile_status list --profile github-profile --detailed
```

## Viewing alerts
Expand Down
77 changes: 77 additions & 0 deletions docs/docs/tutorials/remediations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
title: Automatic Remediations
sidebar_position: 20
---

## Goal

The goal of this tutorial is to show how can Minder automatically fix
repository settings that do not align with the profile settings and reconcile
the repository with the profile.
jhrozek marked this conversation as resolved.
Show resolved Hide resolved

## Prerequisites

In order to follow the tutorial, ensure that you have completed the tutorial on
[registering repositories](register_repo_create_profile.md) first.

## Creating a profile with `remediate: on`

At the moment, Minder doesn't support editing profiles. In order to create the
same profile just with `remediate: on`, you need to delete the old profile and create
jhrozek marked this conversation as resolved.
Show resolved Hide resolved
a new one.

Get the currently installed profiles:
```shell
minder profile list --provider=github
```

Find the ID of the profile you want to remove and delete it:
```shell
minder profile delete -i $ID
```

Edit the YAML file of the profile you want to change and change the `remediate` attribute
jhrozek marked this conversation as resolved.
Show resolved Hide resolved
to `on`:
```yaml
---
version: v1
type: profile
name: github-profile
context:
provider: github
alert: "on"
remediate: "on"
repository:
- type: secret_scanning
def:
enabled: true
```

Create the profile in Minder:
```
minder profile create -f profile.yaml
```

Check the status of the profile:
```
minder profile_status list --profile github-profile
```

Now regardless of the repository settings, the profile status should be "Success".
jhrozek marked this conversation as resolved.
Show resolved Hide resolved
If you navigate to your repository settings with your browser, you should see that secret scanning
feature is enabled. Toggling the feature off should trigger a new profile status check and the
secret scanning feature should be enabled again in github.

## Current limitations
At the time of writing, not all `rule_type` objects support remediation. To find out which
do, you can run:
```shell
minder rule_type get -i $ID -oyaml
```
and look for the `remediate` attribute. If it's not present, the rule type doesn't support
remediation. Alternatively, browse the [rule types directory](https://github.com/stacklok/minder-rules-and-profiles/tree/main/rule-types/github)
of the minder-rules-and-profiles repository.

Furthermore, remediations that open a pull request such as the `depenabot` rule type only attempt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo on dependabot

to replace the target file, overwriting its contents. This means that if you want to keep the current
changes, you need to merge the contents manually.