設定 Microsoft 安全性 DevOps Azure DevOps 擴充功能

Microsoft 安全性 DevOps 是命令列應用程式,可將靜態分析整合到您的開發生命週期中。 它透過可攜式配置安裝、設定並執行最新的 SDL、安全與合規分析器,確保所有環境下執行一致且確定性。

Microsoft 安全性 DevOps 會使用下列開放原始碼工具:

Name 語言 License
反惡意軟體 適用於端點的 Microsoft Defender 中的 Windows 惡意程式防護。 掃描惡意軟體,並在偵測到惡意內容時中斷組建。 預設會在 Windows 最新代理程式上執行。 非開源
Bandit Python Apache 授權 2.0
BinSkim 二進位目標:Windows、ELF 麻省理工學院授權
切科夫 Terraform、Terraform 計劃、CloudFormation、AWS SAM、Kubernetes、Helm 圖表、Kustomize、Dockerfile、無伺服器、Bicep、OpenAPI、ARM Apache 授權 2.0
ESLint JavaScript 麻省理工學院授權
IaCFile掃描儀 適用於 Terraform、CloudFormation、ARM 範本和 Bicep 的模板映射工具 非開源
範本分析器 ARM 範本、Bicep 麻省理工學院授權
Terrascan Terraform (HCL2)、Kubernetes (JSON/YAML)、Helm v3、Kustomize、Dockerfiles、CloudFormation Apache 授權 2.0
Trivy 容器映像、基礎結構即程式碼 (IaC) Apache 授權 2.0

備註

截至 2023 年 9 月 20 日,Microsoft 安全性 DevOps (MSDO) Extension for Azure DevOps 中的秘密掃描工具(CredScan)已被棄用。 MSDO 秘密掃描已被 GitHub Advanced Security for Azure DevOps 取代。

Prerequisites

安裝擴充功能前,請確保符合以下先決條件:

  • 您需要 Azure DevOps 組織中的專案集合系統管理員許可權,才能安裝延伸模組。 如果你沒有權限,請向你的 Azure DevOps 管理員申請這些權限。

安裝擴充套件

要安裝 Microsoft 安全性 DevOps 擴充功能:

  1. 登入 Azure DevOps。

  2. 前往 購物袋>管理擴充功能。

    螢幕擷取畫面,顯示如何導覽至管理擴充功能畫面。

  3. 選取 [共用]。

    備註

    如果你已經安裝了 Microsoft 安全性 DevOps 擴充功能,它會在已安裝標籤中列出。

  4. 選取 [Microsoft 安全性 DevOps]。

    顯示如何選擇 Microsoft 安全性 DevOps 的螢幕擷取畫面。

  5. 選擇 安裝。

  6. 從下拉式功能表中選取適當的組織。

  7. 選擇 安裝。

  8. 選取 [繼續前往組織]。

使用 YAML 設定管線

Tip

可選:若想讓 SARIF 分析結果自動出現在管線的 掃描 標籤中,請安裝 SARIF SAST 掃描分頁擴充功能。

要用 YAML 配置管線:

  1. 登入 Azure DevOps。

  2. 選擇你的專案。

  3. 前往管線>新增管線。

    螢幕擷取畫面顯示在 DevOps 中建立管線的位置。

  4. 選取 「Azure Repos Git」。

    螢幕擷取畫面,顯示您要流覽至的位置,以選取 Azure 存放庫 git。

  5. 選取相關的存放庫。

    螢幕擷取畫面顯示選取存放庫的位置。

  6. 選取入門管線。

    螢幕擷取畫面顯示選取入門管線的位置。

  7. 將下列 YAML 貼到管線中:

    # Starter pipeline
    # Start with a minimal pipeline that you can customize to build and deploy your code.
    # Add steps that build, run tests, deploy, and more:
    # https://aka.ms/yaml
    trigger: none
    pool:
      # ubuntu-latest also supported.
      vmImage: 'windows-latest'
    steps:
    - task: MicrosoftSecurityDevOps@1
      displayName: 'Microsoft Security DevOps'
      # inputs:    
        # config: string. Optional. A file path to an MSDO configuration file ('*.gdnconfig'). Vist the MSDO GitHub wiki linked below for additional configuration instructions
        # policy: 'azuredevops' | 'microsoft' | 'none'. Optional. The name of a well-known Microsoft policy to determine the tools/checks to run. If no configuration file or list of tools is provided, the policy may instruct MSDO which tools to run. Default: azuredevops.
        # categories: string. Optional. A comma-separated list of analyzer categories to run. Values: 'code', 'artifacts', 'IaC', 'containers'. Example: 'IaC, containers'. Defaults to all.
        # languages: string. Optional. A comma-separated list of languages to analyze. Example: 'javascript,typescript'. Defaults to all.
        # tools: string. Optional. A comma-separated list of analyzer tools to run. Values: 'bandit', 'binskim', 'checkov', 'eslint', 'templateanalyzer', 'terrascan', 'trivy'. Example 'templateanalyzer, trivy'
        # break: boolean. Optional. If true, will fail this build step if any high severity level results are found. Default: false.
        # publish: boolean. Optional. If true, will publish the output SARIF results file to the chosen pipeline artifact. Default: true.
        # artifactName: string. Optional. The name of the pipeline artifact to publish the SARIF result file to. Default: CodeAnalysisLogs*.
    

    備註

    需要使用 artifactName 'CodeAnalysisLogs' 來與 Microsoft 適用於雲端的 Defender 整合。 如需更多工具設定選項與環境變數,請參閱 Microsoft 安全性 DevOps 維基。

  8. 選取 [儲存並執行] 以提交並執行管線。

    備註

    安裝 SARIF SAST 掃描分頁擴充功能,可自動在管線的 掃描 分頁顯示 SARIF 分析結果。

將第三方安全性工具的結果上傳至雲端版 Defender

適用於雲端的 Defender 可以從其他安全性工具擷取 SARIF 結果,以取得程式碼到雲端的可見度。 若要上傳這些結果,請確定您的 Azure DevOps 存放庫已 上線至適用於雲端的 Defender。 上線後,適用於雲端的 Defender 會持續監視 CodeAnalysisLogs 工件的 SARIF 輸出。

使用作業 PublishBuildArtifacts@1 將 SARIF 檔案發佈至 CodeAnalysisLogs 構件。 以下 YAML 步驟會將 SARIF 結果檔作為建置產物發佈,讓 適用於雲端的 Defender 能夠接收這些發現:

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: 'results.sarif'
    ArtifactName: 'CodeAnalysisLogs'

「適用於雲端的 Defender」會在受影響的存放庫中,於「Azure DevOps 存放庫應解決程式碼掃描發現的問題」評量下顯示這些發現的問題。