Loading...

Monitor git secrets on Azure DevOps with Gitleaks

Monitor git secrets on Azure DevOps with Gitleaks

Introduction

In this article we will see how to scan all repos of an Azure DevOps project.

 

The secret scanning solution will respect the following guidelines:

  • 1 single DevOps pipeline per DevOps project that launches Gitleaks and sends its scan results to an Azure Application Insights.
  • This pipeline can be triggered manually for a spot check or through any supported scheduled triggers provided by Microsoft.
  • Developers are able to declare a secret as a false positive following Gitleaks procedure.
  • 1 Azure monitoring Workbook where you can find:
  1. An overview tab that displays the total number of secrets found.
  2. A “Secrets” tab which gives more metrics such as
  3. the secret trends -> number of secrets observed during each scan,
  4. count of secrets per repository,
  5. a complete inventory of results exportable to Excel.
Jamesdld23_0-1701460856306.png

 

 

 

Prerequisite

  • Disable the option “Protect access to repositories in YAML pipelines” to allow the Azure DevOps Build Service to pull remote repositories. You can find this option by navigating to the project settings page under “Pipeline” > “Settings”.
  • Grant version control permissions to the build service as described in the following procedure.
  • You have an Azure Application Insights and are able to read its connection string.

 

Pipeline

Create an Azure DevOps repo following this procedure and add on this repo the 3 following files (all the source code is available here: azure-devops-secret-scanning).

 

You can now create the Azure DevOps pipeline based on the yaml file you just pushed, for more details on this procedure you can consult the following article.

 

Jamesdld23_1-1701460856389.png

 

 

 

You can now run the pipeline manually from Azure DevOps by providing the following information:

  • Your Azure Application Insights connection string.
  • A valid email and name of a git user in your organisation that will be in charge of the secret scanning.

 

Jamesdld23_2-1701460856788.png

 

 

Monitoring Workbook

We can now publish the Azure Monitoring Workbook to find:

  • An overview tab that displays the total number of secrets found.

 

Jamesdld23_3-1701460855777.png

 

 

  • A “Secrets” tab which gives more metrics such as
  1. the secret trends -> number of secrets observed during each scan,
  2. count of secrets per repository,
  3. a complete inventory of results exportable to Excel.

 

Jamesdld23_4-1701460856319.png

 

 

Jamesdld23_5-1701460856335.png

 

 

You can publish the Azure Monitoring workbook following this procedure “Creating a new workbook” and by copy pasting the json code available here: azure-devops-secret-scanning/workbook.json.

 

 

Conclusion

Exposed credentials in engineering systems provide easily exploitable opportunities for attackers. To defend against this threat, we demonstrate here how to use a free monitoring workflow that prevents any credentials from being leaked.

Feel free to use it, share it and improve it.

 

See You in the Cloud

Jamesdld

Published on:

Learn more
Azure Developer Community Blog articles
Azure Developer Community Blog articles

Azure Developer Community Blog articles

Share post:

Related posts

This Month in Azure Static Web Apps | 09/2024

    We are back with another edition of the Azure Static Web Apps Community! :party_popper:   September was yet another month ...

1 year ago

GitHub Copilot for Azure: 6 Must-Try Features

As developers, we are constantly seeking tools that streamline our workflows and boost productivity. … Enter GitHub Copilot for Azure, now in ...

1 year ago

Responsible AI Mitigation Layers

Generative AI is increasingly being used in various kinds of systems to augment humans and infuse intelligent behavior into existing and new a...

1 year ago

Streamline Your Azure Workflow: Introducing GitHub Copilot for Azure in VS Code

I'm excited to announce the public preview of GitHub Copilot for Azure - a new addition to your toolkit that seamlessly integrates with G...

1 year ago

Build Intelligent Apps Code-First with Prompty and Azure AI

      Building Generative AI applications can feel daunting for traditional app developers. What does the end-to-end applicati...

1 year ago

Certificación AI-900 (Fundamentos de IA) con Chicas en IA

La inteligencia artificial ha llegado para quedarse, ¡y más aún con la revolucionaria IA generativa! Para ayudar a los profesionales a especia...

1 year ago

Get certified with Learn Live GitHub series!

GitHub Universe is coming, and Microsoft and GitHub are partnering to offer a new special Learn Live series in Brazilian Portuguese, English a...

1 year ago

Certifícate con Learn Live GitHub en Español

Microsoft y GitHub se han unido para ofrecer una nueva serie especial de Learn Live en inglés y español: GitHub 2024. Del 10 al 24 de Octubre,...

1 year ago

Evaluating generative AI: Best practices for developers

As a developer working with generative AI, you've likely marveled at the impressive outputs your models can produce. But how do you ensure the...

1 year ago

Introducing Azure Product Retirement Livestreams

The Azure Retirements team, in collaboration with key partner groups, is excited t...

1 year ago

Newsletter

Get the latest Dynamics 365 and Power Platform content in your inbox

A curated digest of community blogs, product news, videos, and podcasts — delivered without the noise.

Weekly updates Unsubscribe anytime Fresh community picks
We use your email only for the newsletter and you can unsubscribe at any time.
By subscribing, you agree to the privacy policy.