-
Notifications
You must be signed in to change notification settings - Fork 42
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
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b766ebc
Add a tutorial on automatic remediations
jhrozek 17a47d2
Accept Evan's review suggestion
jhrozek 810323b
Accept Evan's review suggestion
jhrozek 611eae0
Accept Evan't review suggestions
jhrozek ec9ed58
Accept Evan's review suggestions
jhrozek 62541c0
Address review comments
jhrozek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
--- | ||
title: Automatic Remediations | ||
sidebar_position: 20 | ||
--- | ||
|
||
## Goal | ||
|
||
The goal of this tutorial is to show how show how Minder can ensure | ||
that enrolled repos have secret scanning enabled. Secret scanning is | ||
one of several settings which can be managed by Minder. When you | ||
apply a Minder policy to enrolled repositories, it will remediate (fix) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we use profile instead on this and the next line? |
||
the setting if it is changed to violate the policy. | ||
|
||
## 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 with `remediate: on`, you need to delete the existing profile and create | ||
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 use and set the `remediate` attribute to | ||
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 | ||
``` | ||
|
||
With remediation on, the profile status should be "Success" when the repository has been updated to match the policy. | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicated show how