microsoft / GHAzDO-Resources

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

Fix PR annotations when CodeQL finds error on a single line #21

Closed tjcorr closed 7 months ago

tjcorr commented 8 months ago

The GHAzDO alerts APIs can return back a lineEnd of 0 when the finding occurs on a single line:

 "region": {
    "lineStart": 71,
    "lineEnd": 0,
    "columnStart": 52,
    "columnEnd": 57,
    "snippet": "",
    "highlightSnippet": ""
}

This PR adds a small fix to detect lineEnd=0 and replace it with the lineStart so that annotations properly show up on PRs.

Error Handling Improvements: