Skip to content

Commit ee5b523

Browse files
authored
Merge pull request #8257 from maddieclayton/suppressions
Add suppressions file for Policheck
2 parents 92a4574 + bef7d6d commit ee5b523

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

Diff for: tools/CheckPoliCheck.ps1

+14-4
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,18 @@ param(
1010

1111
& "$CIToolsPath\tools\PoliCheck\PoliCheck5.8.1\PoliCheck.exe" /F:"$PSScriptRoot\..\artifacts" /T:"9" /O:"$PSScriptRoot\..\artifacts\PoliCheck-Scan.xml"
1212

13-
$poliCheckReport = Get-Content $PSScriptRoot\..\artifacts\PoliCheck-Scan.xml
14-
if ($poliCheckReport -like "*Severity=`"1`"*")
15-
{
16-
throw "PoliCheck failed with a Severity 1 issue, please check the report at in artifacts/PoliCheck-Scan.html"
13+
[xml]$poliCheckReport = Get-Content $PSScriptRoot\..\artifacts\PoliCheck-Scan.xml
14+
15+
$hits = $poliCheckReport.PLCKRR.Result.Object | Where-Object { $_.Severity -eq 1 }
16+
17+
$suppressions = Get-Content -Raw $PSScriptRoot/PolicheckSuppressions.json | ConvertFrom-Json
18+
19+
$hits | ForEach-Object {
20+
$relativePath = ($_.URL -split "artifacts")[1]
21+
$fileName = "artifacts" + $relativePath
22+
$TermId = $_.TermId
23+
if ($suppressions.$fileName -ne $TermId)
24+
{
25+
throw "PoliCheck failed with a Severity 1 issue, please check the report at in artifacts/PoliCheck-Scan.html"
26+
}
1727
}

Diff for: tools/PolicheckSuppressions.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"artifact\\ExampleFile1.dll": "TermId"
3+
}

0 commit comments

Comments
 (0)