共用方式為


設定 Microsoft 安全性 DevOps 的 Azure DevOps 延伸模組

Microsoft 安全性 DevOps 是命令列應用程式,可將靜態分析整合到您的開發生命週期中。 它使用可攜式配置安裝、配置和運行最新的 SDL、安全性和合規性分析器,以確保跨環境的一致、確定性執行。

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

名稱 語言 許可證
反惡意軟體 Microsoft Defender for Endpoint 中的 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 日起,適用於 Azure DevOps 的 Microsoft 安全性 DevOps (MSDO) 延伸模組內的秘密掃描 (CredScan) 工具已被取代。 MSDO 秘密掃描已被適用於 Azure DevOps 的 GitHub Advanced Security 取代。

先決條件

  • 您需要 Azure DevOps 組織中的專案集合系統管理員許可權,才能安裝延伸模組。 如果您沒有存取權,請在安裝期間向 Azure DevOps 系統管理員要求。

設定 Microsoft 安全性 DevOps 的 Azure DevOps 延伸模組

  1. 登入 Azure DevOps

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

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

  3. 選取 [共用]。

    備註

    如果您已 安裝 Microsoft 安全性 DevOps 延伸模組,它會列在 [已安裝] 索引標籤中。

  4. 選取 [Microsoft 安全性 DevOps]

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

  5. 選取安裝

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

  7. 選取安裝

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

使用 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 for Cloud 整合。 如需其他工具設定選項和環境變數,請參閱 Microsoft 安全性 DevOps Wiki

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

    備註

    安裝 SARIF SAST 掃描索引標籤擴充功能,以在管線的 掃描 索引標籤中自動顯示 SARIF 分析結果。

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

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

使用作業 PublishBuildArtifacts@1 將 SARIF 檔案發佈至 CodeAnalysisLogs 構件。 例如:

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

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