Skip to content

Commit fe6e3de

Browse files
authored
Merge pull request #45 from advanced-security/fix_errors
fix error and improve comparaison for PR alerts
2 parents f57c468 + ef140a2 commit fe6e3de

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/kotlin/com/github/adrienpessu/sarifviewer/toolWindow/SarifViewerWindowFactory.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,11 @@ class SarifViewerWindowFactory : ToolWindowFactory {
459459
if (e != null && e.isAddedPath) {
460460
val leaves = map[e.path.parentPath.lastPathComponent.toString()]
461461
if (!leaves.isNullOrEmpty()) {
462-
val leaf = leaves.first { it.address == e.path.lastPathComponent.toString() }
462+
val leaf = try {
463+
leaves.first { it.address == ((e.path.lastPathComponent as DefaultMutableTreeNode).userObject as Leaf).address }
464+
} catch (e: Exception) {
465+
leaves.first()
466+
}
463467

464468
val githubAlertUrl = leaf.githubAlertUrl
465469
.replace("api.", "")
@@ -588,7 +592,8 @@ class SarifViewerWindowFactory : ToolWindowFactory {
588592
val mainResults: List<Result> = sarifMainBranch.flatMap { it.runs?.get(0)?.results ?: emptyList() }
589593

590594
for (currentResult in results) {
591-
if (mainResults.none { it.ruleId == currentResult.ruleId && it.message.text == currentResult.message.text }) {
595+
if (mainResults.none { it.ruleId == currentResult.ruleId
596+
&& ("${currentResult.locations[0].physicalLocation.artifactLocation.uri}:${currentResult.locations[0].physicalLocation.region.startLine}" == "${it.locations[0].physicalLocation.artifactLocation.uri}:${it.locations[0].physicalLocation.region.startLine}") }) {
592597
resultsToDisplay.add(currentResult)
593598
}
594599
}

0 commit comments

Comments
 (0)