microsoft / GHAzDO-Resources

Resources, Scripts, etc. for GitHub Advanced Security on Azure DevOps
MIT License
31 stars 14 forks source link

PR CIGate.ps1 support for Dependency scanning alerts (and a severity based policy) #22

Closed felickz closed 4 months ago

felickz commented 7 months ago

This pull request includes significant changes to the src/pr-gating/CIGate.ps1 script, which is used for PR gating strategy. The changes enhance the script's functionality by improving alert handling and logging, and by modifying the script's variables and methods for better clarity and efficiency.

Key changes include:

These changes improve the script's ability to handle and report alerts, making it easier for developers to identify and fix potential issues in their code.

PR comment example:

image
davidcatriel commented 5 months ago

TODO: look into this here

27

The fix for handling empty target branch alerts (https://github.com/microsoft/GHAzDO-Resources/issues/27) worked well on my end. Consider changing line 172 from this:

# Check for alert ids that are reported in the PR source branch but not the pr target branch
$newAlertIds = Compare-Object $prSourceAlertIds $prTargetAlertIds -PassThru | Where-Object { $_.SideIndicator -eq '<=' }

To this:

# Fix for cases where the garget branch does not contain any alerts. Source: https://github.com/microsoft/GHAzDO-Resources/issues/27 
if ($null -eq $prTargetAlertIds) {
    $newAlertIds = $prSourceAlertIds 
} else {
# Check for alert ids that are reported in the PR source branch but not the pr target branch
    $newAlertIds = Compare-Object $prSourceAlertIds $prTargetAlertIds -PassThru | Where-Object { $_.SideIndicator -eq '<=' }
}