分享方式:


設定 Microsoft 安全性 DevOps GitHub 動作

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

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

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

必要條件

設定 Microsoft 安全性 DevOps GitHub 動作

若要設定 GitHub 動作

  1. 登入 GitHub

  2. 選取您要用來設定 GitHub 動作的存放庫。

  3. 選取動作

    顯示 [動作] 按鈕所在位置的螢幕快照。

  4. 選取 [新增工作流程]

  5. 在 [開始使用 GitHub Actions] 頁面上,選取 [自行設定工作流程]

    顯示選取新工作流程按鈕位置的螢幕快照。

  6. 在文字方塊中,輸入工作流程檔案的名稱。 例如: msdevopssec.yml

    此螢幕快照顯示輸入新工作流程名稱的位置。

  7. 將下列範例動作工作流程 複製並貼到 [編輯新檔案] 索引標籤中。

    name: MSDO
    on:
      push:
        branches:
          - master
    
    jobs:
      sample:
        name: Microsoft Security DevOps
    
        # MSDO runs on windows-latest.
        # ubuntu-latest also supported
        runs-on: windows-latest
    
        permissions:
          contents: read
          id-token: write
          actions: read
          security-events: write
    
        steps:
    
          # Checkout your code repository to scan
        - uses: actions/checkout@v3
    
          # Run analyzers
        - name: Run Microsoft Security DevOps Analysis
          uses: microsoft/security-devops-action@latest
          id: msdo
        # with:
          # config: string. Optional. A file path to an MSDO configuration file ('*.gdnconfig').
          # policy: 'GitHub' | '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: GitHub.
          # 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'.
    
          # Upload alerts to the Security tab
        - name: Upload alerts to Security tab
          uses: github/codeql-action/upload-sarif@v2
          with:
            sarif_file: ${{ steps.msdo.outputs.sarifFile }}
    
          # Upload alerts file as a workflow artifact
        - name: Upload alerts file as a workflow artifact
          uses: actions/upload-artifact@v3
          with:  
            name: alerts
            path: ${{ steps.msdo.outputs.sarifFile }}
    

    注意

    如需其他工具組態選項和指示,請參閱 Microsoft Security DevOps Wiki

  8. 選取 [開始認可]

    顯示您選取開始認可位置的螢幕快照。

  9. 選取 [認可新檔案]

    顯示如何認可新檔案的螢幕快照。

    該程序最多可能需要一分鐘才能完成。

  10. 選取 [動作],並確認新動作正在執行。

    顯示流覽至何處的螢幕快照,以查看您的新動作正在執行。

檢視掃描結果

若要檢視掃描結果

  1. 登入 GitHub

  2. 瀏覽至 [安全性]>[代碼掃描警示]>[工具]

  3. 從下拉式功能表中,選取 [依工具篩選]

程式碼掃描結果會依 GitHub 中的特定 MSDO 工具進行篩選。 這些程式碼掃描結果也會提取至適用於雲端的 Defender 建議。

深入了解

深入了解適用於雲端的 Defender 中的 DevOps 安全性

了解如何將 GitHub 組織連線至適用於雲端的 Defender。