From 230beec7b6ec42b7952db896593200f2018eecfb Mon Sep 17 00:00:00 2001 From: Frank Viernau Date: Tue, 28 May 2024 12:14:18 +0200 Subject: [PATCH] feat(evaluated-model): Re-filter scan summary by VCS path Analog to [1], re-filter all scan results by VCS path, so that the effect of narrowing down a VCS path via a package curation is reflected in the evaluated model (and WebApp). [1]: https://github.com/oss-review-toolkit/ort/commit/2ec49c792ef6c3afe4c6ca5127737b1eb6d08555 Signed-off-by: Frank Viernau --- .../src/main/kotlin/EvaluatedModelMapper.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/reporters/evaluated-model/src/main/kotlin/EvaluatedModelMapper.kt b/plugins/reporters/evaluated-model/src/main/kotlin/EvaluatedModelMapper.kt index a1f705083b88..e0f4843811e8 100644 --- a/plugins/reporters/evaluated-model/src/main/kotlin/EvaluatedModelMapper.kt +++ b/plugins/reporters/evaluated-model/src/main/kotlin/EvaluatedModelMapper.kt @@ -49,6 +49,7 @@ import org.ossreviewtoolkit.model.toYaml import org.ossreviewtoolkit.model.utils.FindingCurationMatcher import org.ossreviewtoolkit.model.utils.FindingsMatcher import org.ossreviewtoolkit.model.utils.RootLicenseMatcher +import org.ossreviewtoolkit.model.utils.filterByVcsPath import org.ossreviewtoolkit.model.vulnerabilities.Vulnerability import org.ossreviewtoolkit.reporter.ReporterInput import org.ossreviewtoolkit.reporter.StatisticsCalculator.getStatistics @@ -411,6 +412,12 @@ internal class EvaluatedModelMapper(private val input: ReporterInput) { findings: MutableList ): List = input.ortResult.getScanResultsForId(pkg.id).map { scanResult -> + // If a VCS path curation has been applied after the scanning stage, it is possible to apply that curation + // without re-scanning in case the new VCS path is a subdirectory of the scanned VCS path. So, filter by VCS + // path to enable the user to see the effect on the detected license with a shorter turn around time / + // without re-scanning. + scanResult.filterByVcsPath(input.ortResult.getPackage(pkg.id)?.metadata?.vcsProcessed?.path.orEmpty()) + }.map { scanResult -> convertScanResult(scanResult, findings, pkg) }