Skip to content

Commit d4aa54a

Browse files
authored
Merge pull request #214855 from ElazarK/pr-annotations
pr annotation fixes
2 parents 7cb14f3 + 67a6c7d commit d4aa54a

File tree

9 files changed

+65
-52
lines changed

9 files changed

+65
-52
lines changed
65.2 KB
Loading
128 KB
Loading
29 KB
Loading
43.9 KB
Loading
15.4 KB
Loading
24.1 KB
Loading
-25.8 KB
Loading
43 KB
Loading

articles/defender-for-cloud/tutorial-enable-pull-request-annotations.md

Lines changed: 65 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ title: Tutorial Enable pull request annotations in GitHub or in Azure DevOps
33
description: Add pull request annotations in GitHub or in Azure DevOps. By adding pull request annotations, your SecOps and developer teams so that they can be on the same page when it comes to mitigating issues.
44
ms.topic: overview
55
ms.custom: ignite-2022
6-
ms.date: 09/20/2022
6+
ms.date: 10/20/2022
77
---
88

99
# Tutorial: Enable pull request annotations in GitHub and Azure DevOps
1010

11-
With Microsoft Defender for Cloud, you can configure pull request annotations in Azure DevOps. Pull request annotations are enabled in Microsoft Defender for Cloud by security operators and are sent to the developers who can then take action directly in their pull requests. This allows both security operators and developers to see the same security issue information in the systems they're accustomed to working in. Security operators see unresolved findings in Defender for Cloud and developers see them in their source code management systems. These issues can then be acted upon by developers when they submit their pull requests. This helps prevent and fix potential security vulnerabilities and misconfigurations before they enter the production stage.
11+
Defender for DevOps exposes security findings as annotations in Pull Requests (PR). Security operators can enable PR annotations in Microsoft Defender for Cloud. Any exposed issues can then be remedied by developers. This process can prevent and fix potential security vulnerabilities and misconfigurations before they enter the production stage. Defender for DevOps annotates the vulnerabilities within the differences in the file rather than all the vulnerabilities detected across the entire file. Developers are able to see annotations in their source code management systems and Security operators can see any unresolved findings in Microsoft Defender for Cloud.
1212

13-
You can get pull request annotations in GitHub if you're a customer of GitHub Advanced Security.
13+
With Microsoft Defender for Cloud, you can configure PR annotations in Azure DevOps. You can get PR annotations in GitHub if you're a GitHub Advanced Security customer.
1414

1515
> [!NOTE]
16-
> During the Defender for DevOps preview period, GitHub Advanced Security for Azure DevOps (GHAS for AzDO) is also providing a free trial of pull request annotations.
16+
> GitHub Advanced Security for Azure DevOps (GHAzDO) is providing a free trial of PR annotations during the Defender for DevOps preview.
1717
1818
In this tutorial you'll learn how to:
1919

@@ -27,55 +27,47 @@ Before you can follow the steps in this tutorial, you must:
2727

2828
**For GitHub**:
2929

30-
- Have an Azure subscription, create a [free account](https://azure.microsoft.com/free/) before you begin
31-
- [Enable Defender for Cloud](get-started.md)
32-
- Have [enhanced security features](enhanced-security-features-overview.md) enabled on your Azure subscriptions
33-
- [Connect your GitHub repositories to Microsoft Defender for Cloud](quickstart-onboard-github.md)
34-
- [Configure the Microsoft Security DevOps GitHub action](github-action.md)
35-
- Be a [GitHub Advanced Security customer](https://docs.github.com/en/get-started/learning-about-github/about-github-advanced-security)
30+
- An Azure account. If you don't already have an Azure account, you can [create your Azure free account today](https://azure.microsoft.com/free/).
31+
- Be a [GitHub Advanced Security](https://docs.github.com/en/get-started/learning-about-github/about-github-advanced-security) customer.
32+
- [Connect your GitHub repositories to Microsoft Defender for Cloud](quickstart-onboard-github.md).
33+
- [Configure the Microsoft Security DevOps GitHub action](github-action.md).
3634

3735
**For Azure DevOps**:
3836

39-
- Have an Azure subscription, create a [free account](https://azure.microsoft.com/free/) before you begin
40-
- [Enable Defender for Cloud](get-started.md)
41-
- Have [enhanced security features](enhanced-security-features-overview.md) enabled on your Azure subscriptions
42-
- [Connect your Azure DevOps repositories to Microsoft Defender for Cloud](quickstart-onboard-devops.md)
43-
- [Configure the Microsoft Security DevOps Azure DevOps extension](azure-devops-extension.md)
44-
- [Setup secret scanning in Azure DevOps](detect-credential-leaks.md#setup-secret-scanning-in-azure-devops)
37+
- An Azure account. If you don't already have an Azure account, you can [create your Azure free account today](https://azure.microsoft.com/free/).
38+
- [Connect your Azure DevOps repositories to Microsoft Defender for Cloud](quickstart-onboard-devops.md).
39+
- [Configure the Microsoft Security DevOps Azure DevOps extension](azure-devops-extension.md).
40+
- [Setup secret scanning in Azure DevOps](detect-credential-leaks.md#setup-secret-scanning-in-azure-devops).
4541

4642
## Enable pull request annotations in GitHub
4743

48-
By enabling pull request annotations in GitHub, your developers gain the ability to see their security issues when they submit their pull requests directly to the main branch.
44+
By enabling pull request annotations in GitHub, your developers gain the ability to see their security issues when they create a PR directly to the main branch.
4945

5046
**To enable pull request annotations in GitHub**:
5147

52-
1. Sign in to [GitHub](https://github.com/).
48+
1. Navigate to [GitHub](https://github.com/) and sign in.
5349

54-
1. Select the relevant repository.
50+
1. Select a repository that you've onboarded to Defender for Cloud.
5551

56-
1. Select **.github/workflows**.
52+
1. Navigate to **`Your repository's home page`** > **.github/workflows**.
5753

58-
:::image type="content" source="media/tutorial-enable-pr-annotations/workflow-folder.png" alt-text="Screenshot that shows where to navigate to, to select the GitHub workflow folder.":::
54+
:::image type="content" source="media/tutorial-enable-pr-annotations/workflow-folder.png" alt-text="Screenshot that shows where to navigate to, to select the GitHub workflow folder." lightbox="media/tutorial-enable-pr-annotations/workflow-folder.png":::
5955

60-
1. Select **msdevopssec.yml**.
56+
1. Select **msdevopssec.yml**, which was created in the [prerequisites](#prerequisites).
6157

62-
:::image type="content" source="media/tutorial-enable-pr-annotations/devopssec.png" alt-text="Screenshot that shows you where on the screen to select the msdevopssec.yml file.":::
58+
:::image type="content" source="media/tutorial-enable-pr-annotations/devopssec.png" alt-text="Screenshot that shows you where on the screen to select the msdevopssec.yml file." lightbox="media/tutorial-enable-pr-annotations/devopssec.png":::
6359

6460
1. Select **edit**.
6561

66-
:::image type="content" source="media/tutorial-enable-pr-annotations/edit-button.png" alt-text="Screenshot that shows you what the edit button looks like.":::
62+
:::image type="content" source="media/tutorial-enable-pr-annotations/edit-button.png" alt-text="Screenshot that shows you what the edit button looks like." lightbox="media/tutorial-enable-pr-annotations/edit-button.png":::
6763

6864
1. Locate and update the trigger section to include:
6965

7066
```yml
7167
# Triggers the workflow on push or pull request events but only for the main branch
72-
push:
73-
branches: [ main ]
7468
pull_request:
75-
branches: [ main ]
69+
branches: ["main"]
7670
```
77-
78-
By adding these lines to your yaml file, you'll configure the action to run when either a push or pull request event occurs on the designated repository. 
7971
8072
You can also view a [sample repository](https://github.com/microsoft/security-devops-action/tree/main/samples).
8173
@@ -85,19 +77,15 @@ By enabling pull request annotations in GitHub, your developers gain the ability
8577
8678
1. Select **Commit changes**.
8779
88-
1. Select **Files changed**.
80+
Any issues that are discovered by the scanner will be viewable in the Files changed section of your pull request.
8981
90-
You'll now be able to see all the issues that were discovered by the scanner.
82+
### Resolve security issues in GitHub
9183
92-
### Mitigate GitHub issues found by the scanner
93-
94-
Once you've configured the scanner, you'll be able to view all issues that were detected.
95-
96-
**To mitigate GitHub issues found by the scanner**:
84+
**To resolve security issues in GitHub**:
9785
9886
1. Navigate through the page and locate an affected file with an annotation.
9987
100-
1. Select **Dismiss alert**.
88+
1. Follow the remediation steps in the annotation. If you choose not remediate the annotation, select **Dismiss alert**.
10189
10290
1. Select a reason to dismiss:
10391
@@ -107,7 +95,7 @@ Once you've configured the scanner, you'll be able to view all issues that were
10795
10896
## Enable pull request annotations in Azure DevOps
10997
110-
By enabling pull request annotations in Azure DevOps, your developers gain the ability to see their security issues when they submit their pull requests directly to the main branch.
98+
By enabling pull request annotations in Azure DevOps, your developers gain the ability to see their security issues when they create PRs directly to the main branch.
11199
112100
### Enable Build Validation policy for the CI Build
113101
@@ -119,13 +107,27 @@ Before you can enable pull request annotations, your main branch must have enabl
119107
120108
1. Navigate to **Project settings** > **Repositories**.
121109
110+
:::image type="content" source="media/tutorial-enable-pr-annotations/project-settings.png" alt-text="Screenshot that shows you where to navigate to, to select repositories.":::
111+
122112
1. Select the repository to enable pull requests on.
123113
124114
1. Select **Policies**.
125115
126-
1. Navigate to **Branch Policies** > **Build Validation**.
116+
1. Navigate to **Branch Policies** > **Main branch**.
117+
118+
:::image type="content" source="media/tutorial-enable-pr-annotations/branch-policies.png" alt-text="Screenshot that shows where to locate the branch policies." lightbox="media/tutorial-enable-pr-annotations/branch-policies.png":::
119+
120+
1. Locate the Build Validation section.
121+
122+
1. Ensure the CI Build is toggled to **On**.
123+
124+
:::image type="content" source="media/tutorial-enable-pr-annotations/build-validation.png" alt-text="Screenshot that shows where the CI Build toggle is located.":::
125+
126+
1. Select **Save**.
127127
128-
1. Toggle the CI Build to **On**.
128+
:::image type="content" source="media/tutorial-enable-pr-annotations/validation-policy.png" alt-text="Screenshot that shows the build validation.":::
129+
130+
Once you have completed these steps you can select the build pipeline you created previously and customize it's settings to suit your needs.
129131
130132
### Enable pull request annotations
131133
@@ -143,48 +145,59 @@ Before you can enable pull request annotations, your main branch must have enabl
143145
144146
1. Toggle Pull request annotations to **On**.
145147
146-
1. Select a category from the drop-down menu.
148+
:::image type="content" source="media/tutorial-enable-pr-annotations/annotation-on.png" alt-text="Screenshot that shows the toggle switched to on.":::
149+
150+
1. (Optional) Select a category from the drop-down menu.
147151
148152
> [!NOTE]
149-
> Only secret scan results is currently supported.
153+
> Only secret scan results are currently supported.
150154
151-
1. Select a severity level from the drop-down menu.
155+
1. (Optional) Select a severity level from the drop-down menu.
156+
157+
> [!NOTE]
158+
> Only high-level severity findings are currently supported.
152159
153160
1. Select **Save**.
154161
155-
All annotations will now be displayed based on your configurations with the relevant line of code.
162+
All annotations on your main branch will be displayed from now on based on your configurations with the relevant line of code.
156163
157-
### Mitigate Azure DevOps issues found by the scanner
164+
### Resolve security issues in Azure DevOps
158165
159166
Once you've configured the scanner, you'll be able to view all issues that were detected.
160167
161-
**To mitigate Azure DevOps issues found by the scanner**:
168+
**To resolve security issues in Azure DevOps**:
162169
163-
1. Sign in to the [Azure portal](https://portal.azure.com).
170+
1. Sign in to the [Azure DevOps](https://azure.microsoft.com/products/devops).
164171
165172
1. Navigate to **Pull requests**.
166173
167-
1. Scroll through the Overview page and locate an affected line with an annotation.
174+
:::image type="content" source="media/tutorial-enable-pr-annotations/pull-requests.png" alt-text="Screenshot showing where to go to navigate to pull requests.":::
175+
176+
1. On the Overview, or files page, locate an affected line with an annotation.
168177
169-
1. Select **Active**.
178+
1. Follow the remediation steps in the annotation.
170179
171-
1. Select action to take:
180+
1. Select **Active** to change the status of the annotation and access the dropdown menu.
181+
182+
1. Select an action to take:
172183
173184
- **Active** - The default status for new annotations.
174185
- **Pending** - The finding is being worked on.
175186
- **Resolved** - The finding has been addressed.
176187
- **Won't fix** - The finding is noted but won't be fixed.
177188
- **Closed** - The discussion in this annotation is closed.
178189
190+
Defender for DevOps will re-activate an annotation if the security issue is not fixed in a new iteration.
191+
179192
## Learn more
180193
181194
In this tutorial, you learned how to enable pull request annotations in GitHub and Azure DevOps.
182195
183196
Learn more about [Defender for DevOps](defender-for-devops-introduction.md).
184197
185-
Learn how to [connect your GitHub](quickstart-onboard-github.md) to Defender for Cloud.
198+
Learn how to [Discover misconfigurations in Infrastructure as Code](iac-vulnerabilities.md).
186199
187-
Learn how to [connect your Azure DevOps](quickstart-onboard-devops.md) to Defender for Cloud.
200+
Learn how to [detect exposed secrets in code](detect-credential-leaks.md).
188201
189202
## Next steps
190203

0 commit comments

Comments
 (0)