你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

配置 Microsoft Security DevOps Azure DevOps 扩展

Microsoft安全 DevOps 是一个命令行应用程序,可将静态分析集成到开发生命周期中。 它使用便携式配置安装、配置和运行最新的 SDL、安全性和符合性分析器,以确保跨环境执行一致、确定性。

Microsoft 安全 DevOps 使用以下开源工具:

Name 语言 许可证
反恶意软件 Windows 中的反恶意软件防护来自 Microsoft Defender for Endpoint。 扫描恶意软件,并在检测到恶意内容时中断生成。 默认情况下,在 Windows 最新代理上运行。 未开放源代码
Bandit Python Apache 许可证 2.0
BinSkim 二进制目标:Windows、ELF MIT 许可证
Checkov Terraform、Terraform plan、CloudFormation、AWS SAM、Kubernetes、Helm Chart、Kustomize、Dockerfile、Serverless、Bicep、OpenAPI、ARM Apache 许可证 2.0
ESLint JavaScript MIT 许可证
IaCFileScanner 适用于 Terraform、CloudFormation、ARM 模板和 Bicep 的模板映射工具 未开放源代码
模板分析器 ARM 模板,Bicep MIT 许可证
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 高级安全性

先决条件

  • 需要在 Azure DevOps 组织中拥有 Project Collection 管理员权限才能安装扩展。 如果没有访问权限,请在安装期间从 Azure DevOps 管理员请求它。

配置 Microsoft Security DevOps Azure DevOps 扩展

  1. 登录到 Azure DevOps

  2. 转到 购物袋>管理扩展

    显示如何导航到“管理扩展”屏幕的屏幕截图。

  3. 选择 “共享”。

    注释

    如果已安装 Microsoft安全 DevOps 扩展,则会在“已安装”选项卡中列出。

  4. 选择 Microsoft Security DevOps

    显示在何处选择 Microsoft Security 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*.
    

    注释

    要与 Defender for Cloud 集成,必须提供工件名称“CodeAnalysisLogs”。 有关其他工具配置选项和环境变量,请参阅 Microsoft Security DevOps Wiki。

  8. 选择“ 保存并运行 ”以提交并运行管道。

    注释

    安装 SARIF SAST 扫描选项卡扩展,以自动在管道的 “扫描 ”选项卡中显示 SARIF 分析结果。

将第三方安全工具的发现上传到 Defender for Cloud

Defender for Cloud 可以从其他安全工具引入 SARIF 结果,以便实现代码到云的可见性。 若要上传这些结果,请确保 Azure DevOps 存储库 已载入 Defender for Cloud。 载入后,Defender for Cloud 会持续监视 CodeAnalysisLogs 构件的 SARIF 输出。

使用 PublishBuildArtifacts@1 任务将 SARIF 文件发布到 CodeAnalysisLogs 工件。 例如:

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

Defender for Cloud 会在受影响的存储库的“Azure DevOps 存储库应解决代码扫描发现的问题”评估下显示这些发现