設定 Microsoft Security DevOps Azure DevOps 擴充功能

Microsoft Security DevOps 是命令列應用程式,可將靜態分析工具整合到開發生命週期中。 Microsoft Security DevOps 會安裝、設定和執行最新版的靜態分析工具 (包括 SDL/安全性和合規性工具)。 Microsoft Security DevOps 是由可攜式設定所驅動,可跨多個環境啟用決定性執行。

Microsoft Security DevOps 使用下列開放原始碼工具:

名稱 語言 授權
反惡意程式碼軟體 Windows 中的反惡意程式碼軟體保護會從適用於端點的 Microsoft Defender 掃描惡意程式碼,並在找到惡意程式碼時中斷組建。 此工具預設會在 Windows 最新代理程式上進行掃描。 不是開放原始碼
Bandit Python Apache License 2.0
BinSkim Binary--Windows、ELF MIT 授權
ESlint JavaScript MIT 授權
IaCFileScanner Terraform、CloudFormation、ARM 範本、Bicep 不是開放原始碼
範本分析器 ARM 範本、Bicep MIT 授權
Terrascan Terraform (HCL2)、Kubernetes (JSON/YAML)、Helm v3、Kustomize、Dockerfiles、CloudFormation Apache License 2.0
Trivy 容器映像,基礎結構即程式碼 (IaC) Apache License 2.0

注意

自 2023 年 9 月 20 日起,適用於 Azure DevOps 的 Microsoft Security DevOps (MSDO) 擴充功能內的秘密掃描 (CredScan) 工具已被取代。 MSDO 秘密掃描將會取代為適用於 Azure DevOps 的 GitHub Advanced Security

必要條件

  • 需要 Azure DevOps 組織的專案集合管理員權限,才能安裝擴充功能。

如果您沒有安裝擴充功能的存取權,您必須在安裝程式期間向 Azure DevOps 組織的管理員要求存取權。

設定 Microsoft Security DevOps Azure DevOps 擴充功能

若要設定 Microsoft Security DevOps Azure DevOps 延伸模組

  1. 登入 Azure DevOps

  2. 瀏覽至購物包>管理擴充功能

    顯示如何流覽至 [管理延伸模組] 畫面的螢幕快照。

  3. 選取 [共用]

    注意

    如果您已安裝 Microsoft Security DevOps 擴充功能,則會列在 [已安裝] 索引標籤中。

  4. 選取 [Microsoft 安全性 DevOps]

    顯示選取 Microsoft Security DevOps 位置的螢幕快照。

  5. 選取 [安裝]。

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

  7. 選取安裝

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

使用 YAML 設定管線

若要使用 YAML 設定管線

  1. 登入 Azure DevOps

  2. 選取您的專案

  3. 瀏覽至 [管線]

  4. 選取 [新增管線]

    顯示在 DevOps 中尋找建立管線位置的螢幕快照。

  5. 選取 [Azure Repos Git]

    顯示流覽至何處的螢幕快照,以選取 Azure 存放庫 Git。

  6. 選取相關的存放庫。

    顯示要選取存放庫位置的螢幕快照。

  7. 選取 [入門管線]。

    顯示選取入門管線位置的螢幕快照。

  8. 將下列 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:    
      # command: 'run' | 'pre-job' | 'post-job'. Optional. The command to run. Default: run
      # config: string. Optional. A file path to an MSDO configuration file ('*.gdnconfig').
      # policy: 'azuredevops' | 'microsoft' | 'none'. Optional. The name of a well-known Microsoft policy. 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', 'eslint', 'templateanalyzer', 'terrascan', 'trivy'.
      # break: boolean. Optional. If true, will fail this build step if any error 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*.
    
    

    注意

    與適用於雲端的 Defender 整合需要 artifactName 'CodeAnalysisLogs'。 如需其他工具組態選項和環境變數,請參閱 Microsoft Security DevOps Wiki

  9. 若要認可管線,請選取 [儲存並執行]

    管線會執行幾分鐘,並儲存結果。

    注意

    在 Azure DevOps 組織上安裝 SARIF SAST 掃描索引標籤擴充功能,以確保產生的分析結果會自動顯示在 [掃描] 索引標籤下。

將第三方安全性工具的調查結果上傳至 適用於雲端的 Defender

雖然 適用於雲端的 Defender 為一組 開放原始碼 安全性分析器中的標準化功能和原則控制提供 MSDO CLI,但您可以彈性地將 CI/CD 管線中設定的其他第三方安全性工具的結果上傳至 適用於雲端的 Defender,以進行完整的程式代碼到雲端內容化。 上傳至 適用於雲端的 Defender 的所有結果都必須使用標準 SARIF 格式。

首先,請確定您的 Azure DevOps 存放庫已上線至 適用於雲端的 Defender。 成功上線 適用於雲端的 Defender 之後,它會持續監視 SARIF 輸出的 『CodeAnalysisLogs』 成品。

您可以使用「PublishBuildArtifacts@1」工作來確保 SARIF 輸出已發行至正確的成品。 例如,如果安全性分析器輸出 'results.sarif',您可以在作業中設定下列工作,以確保結果會上傳至 適用於雲端的 Defender:

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

Findings from third-party security tools will appear as 'Azure DevOps repositories should have code scanning findings resolved' assessments associated with the repository the secuirty finding was identified in.