你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Microsoft安全 DevOps 是一个命令行应用程序,可将静态分析集成到开发生命周期中。 它通过便携配置安装、配置并运行最新的SDL、安全和合规分析器,确保在所有环境中实现一致且确定性执行。
Microsoft 安全 DevOps 使用以下开源工具:
| Name | 语言 | License |
|---|---|---|
| 反恶意软件 | 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 秘密扫描已被 GitHub Advanced Security for Azure DevOps 取代。
先决条件
在安装扩展之前,请确保满足以下先决条件:
- 需要在 Azure DevOps 组织中拥有 Project Collection 管理员权限才能安装扩展。 如果没有访问权限,请从Azure DevOps管理员请求这些权限。
安装扩展
若要安装 Microsoft 安全 DevOps 扩展,请执行以下操作:
登录到 Azure DevOps。
转到 购物袋>管理扩展。
选择 “共享”。
注释
如果你已经安装了 Microsoft 安全 DevOps 扩展,它会在已安装标签页中列出。
选择 Microsoft 安全 DevOps。
选择“安装”。
从下拉菜单中选择适当的组织。
选择“安装”。
选择“转到组织”。
使用 YAML 配置管道
Tip
可选:如果你希望 SARIF 分析结果自动出现在管道的 扫描 标签页中,请安装 SARIF SAST 扫描标签扩展。
若要使用 YAML 配置管道,请执行以下操作:
登录到 Azure DevOps。
选择你的项目。
转到 “管道>新建管道”。
选择 Azure Repos Git。
选择相关的存储库。
选择启动管道.
将以下 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 安全 DevOps wiki。
选择“ 保存并运行 ”以提交并运行管道。
注释
安装 SARIF SAST 扫描选项卡扩展,以便在管道的 扫描 选项卡中自动显示 SARIF 分析结果。
将第三方安全工具的发现上传到 Defender for Cloud
Defender for Cloud 可以从其他安全工具引入 SARIF 结果,以便实现代码到云的可见性。 若要上传这些结果,请确保 Azure DevOps 存储库 已载入 Defender for Cloud。 载入后,Defender for Cloud 会持续监视 CodeAnalysisLogs 构件的 SARIF 输出。
使用 PublishBuildArtifacts@1 任务将 SARIF 文件发布到 CodeAnalysisLogs 工件。 以下 YAML 步骤将 SARIF 结果文件作为构建工件发布,以便 Defender for Cloud 能够接收这些发现:
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: 'results.sarif'
ArtifactName: 'CodeAnalysisLogs'
Defender for Cloud 会在受影响的存储库的“Azure DevOps 存储库应解决代码扫描发现的问题”评估下显示这些发现。