# Automation examples
Here, we show a bunch of examples of how to use the automation engine for different tasks.
# Create your first rule
You now find yourself inside the automations system where you will be creating the rules.
To get started, add an if-statement. Here, you get multiple options to chose from, based on what you want to be a trigger. In this case, we want to create a rule that triggers if the CVSS score of a vulnerability is ranked as high:
You can modify the condition by using and/or operators like this.
If this example, we have created a rule that triggers if dependency is new AND CVSS is high. Next, we want to add the action to execute when the condition is true. There are multiple options including
- Failing pipeline -- Fails your pipeline if the rule conditions are met.
- Pipeline warning
- GitHub -- Pipeline check is set to neutral if the rule conditions are met and a warning is printed. The pipeline passes.
- GitLab, Bitbucket and Azure Devops -- Pipeline passes but a warning is printed.
- Notification by email
- Mark as unaffected -- Vulnerabilities that meet the conditions are marked as unaffected in the Debricked tool.
- Flag as vulnerable -- Vulnerabilities that meet the conditions are flagged as vulnerable in the Debricked tool.
In this example, we want to fail the pipeline if the condition is true.
If you don’t want the rule to apply for vulnerabilities that have been marked as unaffected by you or someone on your team, leave the checkbox in the bottom right checked:
Once you have configured your rule it’s time to generate it. Clicking the button (see above) will create a written statement below the rule maker:
Make sure that the statement corresponds to what you were looking to achieve with your rule. There might be changes that need to be made to fulfill the purpose. For example, when creating a rule such as above, where any vulnerabilities with CVSS high will fail your pipeline, but vulnerabilities that lack a cvss score. Once you are happy with the statement it’s time to hit the save button. Please note that saving your rule will make it apply immediately. Once you have saved your rule, it will appear in the "Data Management" view for the selected repository.
Congratulations, you have created your first rule 😃
# Create a global automation rule
To create a rule that affects multiple repos, click the automations link in the left menu.
In this case, we are going to create a rule that affects 3 repositories. We start by adding the repositories in the list at the top. If you do not select repositories before clicking the add button, all repositories will be selected.
Then, we add a new rule for those repos by clicking the plus sign. After the rule is added, we can see the newly created rule in the list, along with the repos connected to the rule.
# Add a repo to existing global rule
Assume that we forgot one repository to the rule we created above. To add yet another repository to an already created rule, click on the rule to open the "Edit" view. Then, just add the missing repo in the drop-down list, hit "Generate rule" and save.
Of course, the same method applies if you want to remove a specific repository from a rule.
Another approach is to go into the specific repository that you want to add to an existing rule, and add a rule with the same "signature" (the rule in plain text) as the existing rule. The rules will then be merged into a single rule, covering all added repositories.
# View affected repos for a global rule
You can use the drop-down list as a filter to see which rules apply to one or more repositories by selecting repositories in the list. The filtered rules show all repos affected by the rules.
# Prevent new dependencies with vulnerabilities
Imagine you have a developer branch called dev
where you add new exciting features. Being security-aware, you want to fail the pipeline if a new commit introduces a new vulnerability with a severity of high or more. You also want to be notified of this incident.
This is how you would go about setting up that rule in our automation engine.
# CVSS score is missing
The rule we just created will not trigger for vulnerabilities that lack a CVSS score. This does not mean that the vulnerability is not severe, but that the data source lacked the CVSS score information. To account for this, you can add the statement:
OR CVSS is missing
.
Keep in mind that adding the OR statement does not take previous if or AND statements into consideration. In this example we therefore also want to add the statement:
AND dependency is new
to keep the rule from applying to existing dependencies when CVSS is missing. See condition precedents for more on this.
# Prevent unknown license families and GPL
In this scenario, we want to fail the pipelines if we include dependencies with either an unknown license family, or if the dependencies has any of the GPL-2.0 and AGPL-3.0 licenses. We also wish to notify all the administrators for the company account.
# Edit a rule
If you wish to edit a rule, click the three dots on the right-hand side of the rule and select "edit rule".
You’ll now be able to add or remove one or multiple conditions and actions. To enable the changes, press "Generate rule" and "Save".
# Disable a rule
To disable a rule, simply drag the button to the left.
# Delete a rule
To permanently delete a rule, click the three dots on the right hand side of the rule and select "delete rule".
Tip
If you want to deactivate or disable the rule for only a few affected repositories:
- Click
Edit rule
- Remove repo from the top dropdown