GitHub Advanced Security for Azure DevOps is a powerful tool that helps you protect your code repository from security threats. It integrates seamlessly with Azure DevOps, providing a comprehensive security solution for your development pipeline.
With GitHub Advanced Security, you can detect vulnerabilities in your code using secret scanning and dependency review. This feature scans your code for sensitive information such as API keys and access tokens.
GitHub Advanced Security also provides a robust security posture for your code repository by automatically enforcing security policies and standards. This ensures that your code meets the required security standards before it's deployed.
By integrating GitHub Advanced Security with Azure DevOps, you can streamline your security workflow and reduce the risk of security breaches. This integration enables you to automate security checks and enforce security policies throughout your development pipeline.
Setup
To set up GitHub Advanced Security for Azure DevOps, you'll need to follow a series of steps. First, select and edit the pipeline you want to add scanning to, eShopOnweb.
There are two main types of scanning you can set up: Dependency Scanning and Code Scanning. Dependency Scanning scans your project's dependencies to identify security vulnerabilities or outdated versions.
To set up Dependency Scanning, you'll need to add the task Advanced Security Dependency Scanning (AdvancedSecurity-Dependency-Scanning@1) directly to your YAML pipeline file. This task should be added after the build steps are defined.
Code Scanning, on the other hand, analyzes the code in an Azure DevOps repository to find security vulnerabilities and coding errors. To set up Code Scanning, you'll need to add the Initialize CodeQL task (ms.advancedsecurity-tasks.codeql.init.AdvancedSecurity-Codeql-Init@1) to your YAML pipeline file, which should be added before the Dotnet build.
Here's a summary of the tasks you'll need to add to your YAML pipeline file:
- Advanced Security Dependency Scanning (AdvancedSecurity-Dependency-Scanning@1)
- Initialize CodeQL (ms.advancedsecurity-tasks.codeql.init.AdvancedSecurity-Codeql-Init@1)
- CodeQL Analysis (ms.advancedsecurity-tasks.codeql.analyze.AdvancedSecurity-Codeql-Analyze@1)
After adding these tasks, click Save to save the pipeline configuration file. The build will run automatically, initiating the scanning tasks and publishing the results to Advanced Security.
Alerts and Detections
Alerts and Detections are crucial for maintaining a secure codebase. To view all the dependencies alerts, go to the Repos tab and click on the Advanced Security menu item at the bottom.
Clicking on Dependencies will show a list of all the dependencies alerts that have been found, including the Alert, Vulnerable package, and First detected date. This makes it easy to clean up the dependencies.
You can also view the details of each alert, including the Recommendation, Locations found, Description, Severity, and the Date it was first detected. This information helps you understand the issue and take action.
To see the different builds that detected an alert, click on Detections. Note that when a vulnerable component is no longer detected in the latest build, the state of the associated alert is automatically changed to Closed.
Here's a summary of the alerts and detections you can view in GHAS:
Regularly reviewing alerts is crucial for maintaining a secure codebase. You can set up regular intervals (such as weekly or bi-weekly) to review alerts generated by GHAS tools. This proactive method helps in spotting and addressing vulnerabilities before they can be exploited.
Secrets and Security
Secret Scanning is a powerful tool that scans your codebase and other resources to identify potential secrets that may have been inadvertently committed. It provides alerts to mitigate the risk of exposure, and push protection prevents any credentials from being leaked in the first place.
The scan doesn't just look at the tip of the main branch, but also looks through all the branches and the entire commit history. This ensures that all potential secrets are caught, not just the ones that are currently visible.
The Advance Security Alert hub is where all alerts are raised and where you gain insights, specifically under the category of Secrets. When a secret is found, you can click on it to access more information.
Here's a step-by-step guide to fixing exposed secrets:
1. Click Cancel to return to the code editor.
2. On line 9, copy the STORAGE_ID value and note it down in a notepad.
3. Replace this value with #{STORAGE_ID}#.
4. Click Commit to save changes.
5. Enter SecretFix for the branch name and link a work item.
6. Update the build pipeline to add a variable.
7. Click on Variables and click + New Variable.
8. Enter STORAGE_ID for the name and paste the URL from Notepad into the value field.
9. Click Keep this value secret to hide the value, then click OK and Save.
10. Add a new build task to replace the #{STORAGE_ID}# with the actual value.
By following these steps, you can fix exposed secrets and prevent them from being leaked in the future. Remember to use a Squash Merge to avoid leaving the exposed credential in the history.
Remediation and Resolution
To resolve vulnerabilities, go to the Azure DevOps Advanced Security dashboard and click on Dependencies. Here, you can view a list of all dependencies alerts that have been found, including the Alert, Vulnerable package, and First detected date.
Automated Alerts and Remediation Guidance provide real-time security alerts as developers write code, offering immediate feedback on potential vulnerabilities. The system also provides recommended fixes, enabling quick resolution of identified issues without requiring extensive research or additional tools.
GHAS provides specific remediation steps for each alert, and it's essential to encourage developers to follow these recommendations closely when resolving vulnerabilities.
To manually update dependencies, you can follow the recommended steps, which include reviewing the alert details, locating the vulnerable code, updating the package, and committing the changes.
Here's a step-by-step guide to fixing dependency alerts:
- Click on the alert to view its details.
- Review the Recommendation, Location, Description, and Severity to understand the vulnerability and how to resolve it.
- Update the package to the recommended version, and commit the changes.
- Push the changes to the remote repository, and create a pull request from the fixalert branch to the main branch.
- Make sure to follow the policies and changes are merged in the main branch.
After fixing vulnerabilities, perform post-mortem analyses to identify the root causes and how similar issues can be prevented going forward. This continuous improvement approach promotes proactive application security.
To fix exposed secrets, you can use a build token to replace the secret value in the code. Here's how:
- Replace the secret value with a build token, such as #{STORAGE_ID}#.
- Update the build pipeline to add a variable for the secret value.
- Add a new build task to replace the build token with the actual secret value.
- Commit the changes and create a pull request to merge the changes into the main branch.
- Use a Squash Merge to merge the changes into the main branch, and delete the temporary branch.
By following these steps, you can effectively remediate and resolve vulnerabilities in your Azure DevOps project using GitHub Advanced Security.
Integration and Management
Integration with Microsoft Defender for Cloud provides unified visibility of security alerts across both Azure repositories and GitHub, centralizing alerts in one interface and making management and response more efficient.
This integration strengthens the security posture of development teams by providing a single interface for managing security alerts. It's a game-changer for teams that need to stay on top of security threats.
GHAS integrates with CI/CD pipelines, automating security checks during every build or deployment and eliminating the need for manual intervention. This is a huge time-saver for developers who want to focus on coding rather than security checks.
Here are some benefits of integrating GHAS with CI/CD pipelines:
- Automated Scanning: Incorporate tasks for secret scanning, dependency scanning, and code scanning into CI/CD pipelines.
- Fail Builds on Vulnerabilities: Establish policies to fail builds when critical vulnerabilities are detected.
- Feedback Loop: Provide real-time feedback through pull request annotations when vulnerabilities are found during scans.
These automated security checks help prevent insecure code from reaching production and encourage developers to resolve issues before merging changes.
Integrate with CI/CD
Integrating with CI/CD pipelines is a game-changer for security and development workflows.
Automated Scanning is a key feature that incorporates tasks for secret scanning, dependency scanning, and code scanning into CI/CD pipelines, eliminating the need for manual intervention.
This automates security checks during every build or deployment, ensuring that vulnerabilities are caught early on.
Fail Builds on Vulnerabilities is another crucial feature that establishes policies to fail builds when critical vulnerabilities are detected, preventing insecure code from reaching production.
Real-time feedback through pull request annotations allows developers to address issues immediately while working on their code, speeding up remediation.
Here are the benefits of integrating GHAS with CI/CD pipelines:
Build Mode Customization
Build Mode Customization is an essential aspect of CodeQL code scanning. Code scanning supports two build modes: none and manual.
Code scanning can be run on interpreted languages like JavaScript, Python, and Ruby without building the codebase, using the none build mode. This mode is also supported for C# and Java.
For compiled languages, you need to define the build steps in the workflow using the manual build mode. If you have a mixed language codebase, you can use the none build mode for interpreted languages and manual for compiled languages.
Here are the supported build modes for different languages:
If you specify the none build mode for C# or Java in conjunction with other compiled languages, the pipeline task will fail. So, be careful when setting up your pipeline to avoid this issue.
Benefits and Features
Github Advanced Security for Azure DevOps offers several benefits that enhance your development process. Enhanced Security is a key benefit, as it integrates security checks directly into the development process, allowing vulnerabilities to be identified early and reducing the risk of deploying insecure code.
Improved Developer Productivity is another advantage, as developers can tackle security issues as they emerge without switching between different tools, optimizing their workflow and minimizing disruptions.
GHAS provides Comprehensive Coverage by combining secret scanning, dependency scanning, and code scanning, addressing various elements of the software supply chain.
The cost-effectiveness of GHAS is a major plus, with a predictable pricing model of $49 per active committer per month that scales with usage, making it a viable solution for organizations of different sizes.
Here are some of the key features of GHAS:
- Secret scanning
- Dependency scanning
- Code scanning
These features work together to provide a well-rounded approach to application security.
Frequently Asked Questions
How to enable GitHub Advanced security in Azure DevOps?
To enable Advanced Security in Azure DevOps, navigate to your Project settings, select the repository, and toggle on Advanced Security. This will begin billing for the feature.
Is GitHub Advanced security good?
GitHub Advanced Security offers robust suppression features at both repo and org levels, making it a powerful tool for managing code vulnerabilities. It also creates actionable GitHub issues for CodeQL code scanning discoveries, helping developers address security concerns efficiently.
How much does GHAzDO cost?
GHAzDO costs $49 per active committer per month, with pricing managed through your Azure subscription. Learn more about GHAzDO pricing and how it works.
Sources
- https://www.azuredevopslabs.com/labs/azuredevops/advancedsecurity/
- https://github.blog/news-insights/product-news/announcing-general-availability-of-github-advanced-security-for-azure-devops/
- https://learn.microsoft.com/en-us/azure/devops/repos/security/github-advanced-security-code-scanning
- https://onlyutkarsh.medium.com/exploring-github-advanced-security-in-azure-devops-f4d8fe565419
- https://bobcares.com/blog/github-advanced-security-for-azure-devops/
Featured Images: pexels.com