|
| 1 | +--- |
| 2 | +permalink: /labs/lab-06-ado |
| 3 | +title: "Lab 06-ADO - SARIF Output and ADO Advanced Security" |
| 4 | +description: "Upload SARIF scan results to Azure DevOps Advanced Security and triage findings." |
| 5 | +--- |
| 6 | + |
| 7 | +## Overview |
| 8 | + |
| 9 | +| | | |
| 10 | +|---|---| |
| 11 | +| **Duration** | 35 minutes | |
| 12 | +| **Level** | Intermediate | |
| 13 | +| **Prerequisites** | [Lab 02](lab-02.md), [Lab 03](lab-03.md), [Lab 04](lab-04.md), or [Lab 05](lab-05.md) (at least one) | |
| 14 | + |
| 15 | +## Learning Objectives |
| 16 | + |
| 17 | +By the end of this lab, you will be able to: |
| 18 | + |
| 19 | +* Explain how ADO Advanced Security (GHAzDO) ingests SARIF results |
| 20 | +* Enable Advanced Security at project and repository level |
| 21 | +* Create an ADO YAML pipeline with `AdvancedSecurity-Publish@1` |
| 22 | +* View and triage findings in the ADO Advanced Security Overview |
| 23 | +* Compare GitHub Security Tab with ADO Advanced Security |
| 24 | + |
| 25 | +## Exercises |
| 26 | + |
| 27 | +### Exercise 6.1: Review SARIF Output |
| 28 | + |
| 29 | +You will review the SARIF v2.1.0 format that all four scanner tools produce. |
| 30 | + |
| 31 | +> [!NOTE] |
| 32 | +> This exercise shares foundations with Lab 06 (GitHub variant). Complete [Lab 06 Exercise 6.1](lab-06.md#exercise-61-sarif-schema-deep-dive) if you haven't already. The following is a brief recap for the ADO track. |
| 33 | +
|
| 34 | +1. Open any SARIF file you generated in a previous lab (for example, `reports/psrule-001.sarif` or `reports/custodian.sarif`). |
| 35 | + |
| 36 | +2. Recall the four main SARIF sections: |
| 37 | + |
| 38 | + | Section | Purpose | |
| 39 | + |---------|---------| |
| 40 | + | `version` / `$schema` | Declares SARIF v2.1.0 compliance | |
| 41 | + | `runs[].tool.driver` | Identifies the scanner tool, version, and rule definitions | |
| 42 | + | `runs[].tool.driver.rules[]` | Defines rule IDs, descriptions, severity, and help URLs | |
| 43 | + | `runs[].results[]` | Contains individual findings with rule ID, severity, message, and location | |
| 44 | + |
| 45 | +3. Note how `physicalLocation` ties a finding to a specific file and line number. ADO Advanced Security uses this location data to surface findings in the security overview and link them to source files. |
| 46 | + |
| 47 | +4. Verify that your SARIF file includes at least one result with a `ruleId`, `level`, `message`, and `locations` array. ADO Advanced Security requires these fields to display alerts correctly. |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | +> [!TIP] |
| 52 | +> SARIF (Static Analysis Results Interchange Format) is an OASIS standard. Both GitHub and Azure DevOps Advanced Security consume SARIF files, so producing SARIF from all 4 tools gives you a unified view regardless of which platform you use. |
| 53 | +
|
| 54 | +### Exercise 6.2: Enable ADO Advanced Security |
| 55 | + |
| 56 | +You will enable Advanced Security (GHAzDO) in the `MngEnvMCAP675646/FinOps` project. |
| 57 | + |
| 58 | +> [!IMPORTANT] |
| 59 | +> ADO Advanced Security requires appropriate licensing. Your organization must have GitHub Advanced Security for Azure DevOps (GHAzDO) enabled. Contact your organization administrator if the toggle is not available. |
| 60 | +
|
| 61 | +1. Open Azure DevOps and navigate to the `MngEnvMCAP675646` organization. |
| 62 | + |
| 63 | +2. Select the **FinOps** project. |
| 64 | + |
| 65 | +3. Click **Project Settings** (bottom-left gear icon). |
| 66 | + |
| 67 | +4. Under **Repos**, click **Repositories**. |
| 68 | + |
| 69 | +5. Select the repository where you want to enable Advanced Security (for example, `finops-demo-app-001`). |
| 70 | + |
| 71 | +6. Click the **Settings** tab for the repository. |
| 72 | + |
| 73 | +7. Scroll to the **Advanced Security** section and toggle it **On**. |
| 74 | + |
| 75 | +8. Repeat for each repository that should report SARIF findings. You can also enable it at the project level to cover all repositories: |
| 76 | + - Go back to **Project Settings → Repos → Repositories** |
| 77 | + - Click **Settings** at the project level |
| 78 | + - Toggle **Advanced Security** to **On** for all repos |
| 79 | + |
| 80 | +9. Verify the toggle is active. You should see a confirmation message that Advanced Security is enabled. |
| 81 | + |
| 82 | +> [!NOTE] |
| 83 | +> Enabling Advanced Security at the project level automatically enables it for all current and future repositories in the project. Per-repo settings override the project default if you need to exclude specific repos. |
| 84 | +
|
| 85 | +### Exercise 6.3: Create SARIF Publish Pipeline |
| 86 | + |
| 87 | +You will create an ADO YAML pipeline that uploads SARIF results to Advanced Security using the `AdvancedSecurity-Publish@1` task. |
| 88 | + |
| 89 | +1. In your repository, create the pipeline file at `.azuredevops/pipelines/publish-sarif.yml`: |
| 90 | + |
| 91 | + ```yaml |
| 92 | + trigger: none |
| 93 | + |
| 94 | + pool: |
| 95 | + vmImage: 'ubuntu-latest' |
| 96 | + |
| 97 | + steps: |
| 98 | + - task: AdvancedSecurity-Publish@1 |
| 99 | + displayName: 'Publish SARIF to ADO Advanced Security' |
| 100 | + inputs: |
| 101 | + SarifsInputDirectory: '$(Build.SourcesDirectory)/results' |
| 102 | + ``` |
| 103 | +
|
| 104 | +2. The pipeline uses `trigger: none` so it runs only on manual trigger or when called from another pipeline. |
| 105 | + |
| 106 | +3. The `AdvancedSecurity-Publish@1` task scans the specified directory for `.sarif` files and uploads them to ADO Advanced Security. Place your SARIF files in the `results/` directory at the repository root. |
| 107 | + |
| 108 | +4. Register the pipeline in ADO: |
| 109 | + - Navigate to **Pipelines → Pipelines** in the FinOps project |
| 110 | + - Click **New Pipeline** |
| 111 | + - Select **Azure Repos Git** as the source |
| 112 | + - Select the repository containing the YAML file |
| 113 | + - Choose **Existing Azure Pipelines YAML file** |
| 114 | + - Set the path to `.azuredevops/pipelines/publish-sarif.yml` |
| 115 | + - Click **Save** (not Run — you will run it in the next exercise) |
| 116 | + |
| 117 | + |
| 118 | + |
| 119 | +> [!TIP] |
| 120 | +> The `AdvancedSecurity-Publish@1` task is the ADO equivalent of GitHub's `github/codeql-action/upload-sarif@v4`. Both consume SARIF files, but the ADO task publishes directly to the ADO Advanced Security backend rather than the GitHub Code Scanning API. |
| 121 | + |
| 122 | +### Exercise 6.4: Run Pipeline and Upload SARIF |
| 123 | + |
| 124 | +You will queue the publish-sarif pipeline and upload SARIF results to ADO Advanced Security. |
| 125 | + |
| 126 | +1. Make sure you have at least one `.sarif` file in the `results/` directory of your repository. You can copy a file from a previous lab: |
| 127 | + |
| 128 | + ```bash |
| 129 | + mkdir -p results |
| 130 | + cp reports/psrule-001.sarif results/ |
| 131 | + git add results/ |
| 132 | + git commit -m "chore: add SARIF results for ADO upload" |
| 133 | + git push |
| 134 | + ``` |
| 135 | + |
| 136 | +2. Queue the pipeline from the ADO web UI: |
| 137 | + - Navigate to **Pipelines → Pipelines** |
| 138 | + - Find the **publish-sarif** pipeline |
| 139 | + - Click **Run pipeline** |
| 140 | + - Select the branch containing your SARIF files |
| 141 | + - Click **Run** |
| 142 | + |
| 143 | +3. Alternatively, trigger the pipeline from the command line: |
| 144 | + |
| 145 | + ```bash |
| 146 | + az pipelines run --name publish-sarif --organization https://dev.azure.com/MngEnvMCAP675646 --project FinOps |
| 147 | + ``` |
| 148 | + |
| 149 | +4. Monitor the pipeline execution. Click on the running pipeline to see the job logs. |
| 150 | + |
| 151 | +5. Verify the `AdvancedSecurity-Publish@1` step completed successfully. The logs should show the number of SARIF files processed and results uploaded. |
| 152 | + |
| 153 | + |
| 154 | + |
| 155 | +> [!NOTE] |
| 156 | +> If the pipeline fails with a permissions error, verify that Advanced Security is enabled for the repository (Exercise 6.2) and that the pipeline has the required permissions to publish security results. |
| 157 | + |
| 158 | +### Exercise 6.5: View ADO Advanced Security Overview |
| 159 | + |
| 160 | +You will navigate to the ADO Advanced Security overview to review the uploaded findings. |
| 161 | + |
| 162 | +1. In the FinOps project, navigate to **Repos** in the left sidebar. |
| 163 | + |
| 164 | +2. Click **Advanced Security** to open the security overview. |
| 165 | + |
| 166 | +3. Review the findings dashboard. Findings are grouped by: |
| 167 | + - **Severity** — Critical, High, Medium, Low |
| 168 | + - **Tool** — the scanner that produced the finding |
| 169 | + - **State** — Active, Dismissed |
| 170 | + |
| 171 | +4. Click on an individual alert to see the detail view: |
| 172 | + - Rule ID and description |
| 173 | + - Severity level |
| 174 | + - Source file location with line number |
| 175 | + - First detected and last seen timestamps |
| 176 | + |
| 177 | +5. Use the **State** dropdown on an alert to triage it: |
| 178 | + - **Active** — the finding needs attention |
| 179 | + - **Dismissed** — mark as false positive or won't fix |
| 180 | + |
| 181 | +6. Use the filter controls at the top to narrow results by severity, tool, or state. |
| 182 | + |
| 183 | + |
| 184 | + |
| 185 | + |
| 186 | + |
| 187 | +> [!TIP] |
| 188 | +> ADO Advanced Security retains alert history across pipeline runs. If you fix a violation and re-scan, the alert state changes to **Fixed** automatically. This is similar to how GitHub Code Scanning tracks alert lifecycle across commits. |
| 189 | + |
| 190 | +### Exercise 6.6: Compare GitHub vs ADO |
| 191 | + |
| 192 | +You will compare the security alert experience across both platforms. |
| 193 | + |
| 194 | +Review the following comparison table: |
| 195 | + |
| 196 | +| Feature | GitHub | Azure DevOps | |
| 197 | +|---------|--------|--------------| |
| 198 | +| SARIF Upload | REST API / `codeql-action/upload-sarif@v4` | `AdvancedSecurity-Publish@1` | |
| 199 | +| Alert Viewer | Security Tab → Code Scanning | Repos → Advanced Security | |
| 200 | +| Alert Triage | Dismiss dropdown (false positive, won't fix, used in tests) | State management (Active, Dismissed) | |
| 201 | +| Auto-Fix | Dependabot / Copilot Autofix | Not available | |
| 202 | +| PR Integration | Check runs + status checks | Branch policies | |
| 203 | +| API Access | Code Scanning REST API | ADO REST API | |
| 204 | + |
| 205 | +Key differences to note: |
| 206 | + |
| 207 | +1. **Upload mechanism** — GitHub uses a REST API with gzip+base64 encoding. ADO uses a dedicated pipeline task that reads SARIF files from a directory. |
| 208 | + |
| 209 | +2. **Triage granularity** — GitHub offers three dismiss reasons (false positive, won't fix, used in tests). ADO uses a simpler Active/Dismissed state model. |
| 210 | + |
| 211 | +3. **Auto-remediation** — GitHub has Dependabot and Copilot Autofix for automated fixes. ADO Advanced Security does not offer automated fix suggestions. |
| 212 | + |
| 213 | +4. **PR integration** — GitHub uses check runs and status checks. ADO uses branch policies that can gate PR completion on security findings. |
| 214 | + |
| 215 | +5. **Both platforms** consume the same SARIF v2.1.0 standard, so you can use the same scanner output for both. |
| 216 | + |
| 217 | + |
| 218 | + |
| 219 | +> [!IMPORTANT] |
| 220 | +> In a dual-platform environment, run your scanners once and upload the same SARIF output to both GitHub and ADO. This eliminates result divergence and ensures consistent governance across platforms. |
| 221 | + |
| 222 | +## Verification Checkpoint |
| 223 | + |
| 224 | +Before proceeding, verify: |
| 225 | + |
| 226 | +* [ ] Can describe how ADO Advanced Security ingests SARIF results |
| 227 | +* [ ] Enabled Advanced Security on at least one repository |
| 228 | +* [ ] Created and ran the publish-sarif pipeline successfully |
| 229 | +* [ ] Viewed and triaged findings in the ADO Advanced Security Overview |
| 230 | +* [ ] Can articulate 3 differences between GitHub Security Tab and ADO Advanced Security |
| 231 | + |
| 232 | +## Next Steps |
| 233 | + |
| 234 | +Continue to [Lab 07-ADO — ADO YAML Pipelines and Cost Gates](lab-07-ado.md). |
| 235 | + |
| 236 | +> [!NOTE] |
| 237 | +> For the GitHub variant of this lab, see [Lab 06 — SARIF Output and GitHub Security Tab](lab-06.md). |
0 commit comments