【发布时间】:2021-02-02 18:10:30
【问题描述】:
您能否推荐一个有效的扫描器来扫描 Azure DevOps 存储库和管道中的代码中的机密?希望能够在提交时或在接受推送之前进行本地扫描,并定期扫描存储库和管道。但是,对于如何以其他方式扫描秘密,我们愿意提供建议。
【问题讨论】:
-
嗨,您有机会查看以下工具吗?你试过了吗
标签: azure-devops credentials repo
您能否推荐一个有效的扫描器来扫描 Azure DevOps 存储库和管道中的代码中的机密?希望能够在提交时或在接受推送之前进行本地扫描,并定期扫描存储库和管道。但是,对于如何以其他方式扫描秘密,我们愿意提供建议。
【问题讨论】:
标签: azure-devops credentials repo
你可以查看this blog中提到的秘密扫描器。
例如 AWS Labs 发布的Git Secrets。您可以将其安装在本地计算机上以扫描本地提交和非快进合并。见--install command
在 azure 管道中使用 Git Secrets 来扫描 azure devops repos。您可以查看以下步骤:
2、如果你想在微软云代理上使用扫描仪。您需要在管道中的云代理机器中安装这些扫描仪工具。请参见下面的示例:在云代理上使用 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、定期扫描repos和管道
您可以在管道中使用scheduled triggers 定期扫描您的存储库。
schedules:
- cron: "0 12 * * 0"
displayName: Weekly Sunday build
branches:
include:
- releases/*
always: true
【讨论】: