[release/5.0] Fix SDL error reporting #7661
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Related issue: #7616
This PR solves the same issue as similar PR for
3.xbranch: #7654This PR introduces the change to fail the build step when SDL reports errors. On 5.0 we have the same problem as on 3.x - we are shadowing
$LASTEXITCODEvariable by calling$LASTEXITCODE = 0at the beginning of scripts. It should be$global:LASTEXITCODE = 0.Example build: https://dev.azure.com/dnceng/internal/_build/results?buildId=1255281
Example build that failed because of SDL error: https://dev.azure.com/dnceng/internal/_build/results?buildId=1255232
Customer Impact
Without fixing the error handling we may miss security issues reported by the SDL scanner.
Regression
There can be possible changes in behavior because we were ignoring all errors in SDL step before. Now they will fail the build.
Risk
The biggest risk is that fixing the error handling will make pipelines fail on SDL stage because of errors that we previously silently ignored.
Workarounds
If our target is to fail the build on SDL errors then I believe this the minimal amount of changes we have to make. The alternative is to keep track of the issues manually but this seems impractical in the long term.