Azure DevOps Repo中的秘密扫描仪扫描仪、秘密、Azure、DevOps

2023-09-03 14:25:05 作者:Nuisance讨厌鬼

你能推荐一个高效的扫描器来扫描Azure DevOps Repo和管道中的代码中的秘密吗?希望能够在提交时或在接受推送之前进行本地扫描,还可以定期扫描报告和管道。但是,对于如何以其他方式扫描机密的建议,我们是开放的。

推荐答案

您可以检查this blog中提到的秘密扫描仪。

Azure DevOps Server下载 Azure DevOps Serverv1.0最新下载

例如AWS实验室发布的Git Secrets。您可以将其安装在本地计算机上,以扫描本地提交和非快进合并。请参见--install command

在azure管道中使用Git Secrets扫描azure devops报告。您可以查看以下步骤:

%1,创建azure devops pipeline。

2,如果要在Microsoft云代理上使用扫描仪。您需要在您的管道中的云代理计算机中安装这些扫描仪工具。参见下面的示例:在云代理上使用Git Secrets

在您的管道中添加脚本任务以在云代理上安装Git Secrets

steps:
- powershell: |
   #clone git-secrets repo in $(Agent.TempDirectory) folder
   cd $(Agent.TempDirectory)
   git clone "https://github.com/awslabs/git-secrets.git"
   cd git-secrets
   #install git-secrets
    ./install.ps1

   cd $(System.DefaultWorkingDirectory)
   # Installs git hooks for source repository
   git secrets --install 
   #Adds a prohibited  pattern
   git secrets --add --literal 'iamthesecrecttoscan'
   #Scans for secrets
   git secrets --scan
   
  displayName: 'PowerShell Script'
您还可以在安装了Git Secrets(或安装了其他扫描仪工具)的计算机上创建self-hosted agent。然后,当您在此自托管代理上运行管道时,您可以直接在管道中使用扫描仪,而无需将其安装在管道中。

3、定期扫描报告和管道

您可以在管道中使用scheduled triggers定期扫描您的Repos。

schedules:
- cron: "0 12 * * 0"
  displayName: Weekly Sunday build
  branches:
    include:
    - releases/*
  always: true