diff --git a/tools/Test-ReviewContract.ps1 b/tools/Test-ReviewContract.ps1 index ca8593a..adacb36 100644 --- a/tools/Test-ReviewContract.ps1 +++ b/tools/Test-ReviewContract.ps1 @@ -361,6 +361,14 @@ try { -SourceRoot $tmp -SourcePaths $sourcePath -RetrievedArticlePaths $articlePath, $supportingArticlePath } + $omittedConflictingCorrectionMerge = $conflictingCorrectionMerge | ConvertTo-Json -Depth 20 | ConvertFrom-Json + $omittedConflictingCorrectionMerge.findings[0].PSObject.Properties.Remove('suggested-code') + Set-Content -LiteralPath $reportPath -Value ($omittedConflictingCorrectionMerge | ConvertTo-Json -Depth 20) -Encoding utf8NoBOM + Assert-ThrowsLike -Pattern '*SUPER_FINDING_MISMATCH*' -Action { + & $validator -ReportPath $reportPath -BCQualityRoot $Root -SkillKind super ` + -SourceRoot $tmp -SourcePaths $sourcePath -RetrievedArticlePaths $articlePath, $supportingArticlePath + } + $unmergedSupportingFinding = $supportingFindingLeaf.findings[0] | ConvertTo-Json -Depth 20 | ConvertFrom-Json $unmergedSupportingFinding | Add-Member -NotePropertyName 'from-sub-skill' -NotePropertyValue 'al-security-review' $unmergedDuplicates = $mergedSuperReport | ConvertTo-Json -Depth 20 | ConvertFrom-Json diff --git a/tools/Validate-FindingsReport.ps1 b/tools/Validate-FindingsReport.ps1 index bbfecf3..d3442d3 100644 --- a/tools/Validate-FindingsReport.ps1 +++ b/tools/Validate-FindingsReport.ps1 @@ -409,6 +409,17 @@ function Get-SemanticErrors { $representedLeafFindings = @($eligibleFindings | Where-Object { Test-RolledFindingRepresents $finding $_.Finding $_.ProducerId }) + $representedCorrections = @( + $representedLeafFindings | + Where-Object { Test-HasProperty $_.Finding 'suggested-code' } | + ForEach-Object { $_.Finding.'suggested-code' } | + Sort-Object -CaseSensitive -Unique + ) + if ($representedCorrections.Count -gt 1) { + Add-Error 'SUPER_FINDING_MISMATCH' "$ReportPathPrefix.findings[$index]" ` + "Rolled-up finding '$($finding.id)' represents leaf findings with conflicting suggested-code replacements." + continue + } $expectedSeverityRank = ($representedLeafFindings | ForEach-Object { Get-SeverityRank $_.Finding.severity } | Measure-Object -Maximum).Maximum $expectedConfidenceRank = ($representedLeafFindings | ForEach-Object { Get-ConfidenceRank $_.Finding.confidence } | Measure-Object -Maximum).Maximum if ((Get-SeverityRank $finding.severity) -ne $expectedSeverityRank -or