From 237f3e2555959451e292addeef8b0473c5f2f9de Mon Sep 17 00:00:00 2001 From: Frank Viernau Date: Tue, 30 Apr 2024 10:20:52 +0200 Subject: [PATCH] feat(static-html): Add an advisor issue summary table Show advisor issues analog to analyzer and scanner issues. Signed-off-by: Frank Viernau --- ...ic-html-reporter-test-expected-output.html | 71 +++++++++++++++++++ .../src/main/kotlin/ReportTableModel.kt | 8 ++- .../src/main/kotlin/ReportTableModelMapper.kt | 5 ++ .../src/main/kotlin/StaticHtmlReporter.kt | 12 ++++ 4 files changed, 95 insertions(+), 1 deletion(-) diff --git a/plugins/reporters/static-html/src/funTest/assets/static-html-reporter-test-expected-output.html b/plugins/reporters/static-html/src/funTest/assets/static-html-reporter-test-expected-output.html index 94c911c1c0bc..fa3770fb497f 100644 --- a/plugins/reporters/static-html/src/funTest/assets/static-html-reporter-test-expected-output.html +++ b/plugins/reporters/static-html/src/funTest/assets/static-html-reporter-test-expected-output.html @@ -456,6 +456,7 @@

Index

  • Rule Violation Summary (1 errors, 1 warnings, 0 hints to resolve)
  • Analyzer Issue Summary (1 errors, 2 warnings, 1 hints to resolve)
  • Scanner Issue Summary (3 errors, 1 warnings, 1 hints to resolve)
  • +
  • Advisor Issue Summary (1 errors, 1 warnings, 1 hints to resolve)
  • Gradle:org.ossreviewtoolkit:nested-fake-project:1.0.0
    Excluded: EXAMPLE_OF - The project is an example.
  • Gradle:org.ossreviewtoolkit.gradle.example:lib:1.0.0
  • @@ -733,6 +734,76 @@

    Scanner Issue Summary (3 errors, 1 warnings, 1 hi +

    Advisor Issue Summary (1 errors, 1 warnings, 1 hints to resolve)

    +

    Issues from excluded components are not shown in this summary.

    + + + + + + + + + + + + + + + + + + + + + + + + + +
    #PackageMessage
    1Maven:org.apache.commons:commons-text:1.1 +

    Unknown time [ERROR]: VulnerableCode - Example advisor error.

    +
    + How to fix +
      + +
    • Step 1
    • + +
    • Step 2
    • + +
    • Step 3 + Some long issue resolution text to verify that overflow:scroll is working as expected.
    • +
    +
    +
    2Maven:org.apache.commons:commons-text:1.1 +

    Unknown time [WARNING]: VulnerableCode - Example advisor warning.

    +
    + How to fix +
      + +
    • Step 1
    • + +
    • Step 2
    • + +
    • Step 3 + Some long issue resolution text to verify that overflow:scroll is working as expected.
    • +
    +
    +
    3Maven:org.apache.commons:commons-text:1.1 +

    Unknown time [HINT]: VulnerableCode - Example advisor hint.

    +
    + How to fix +
      + +
    • Step 1
    • + +
    • Step 2
    • + +
    • Step 3 + Some long issue resolution text to verify that overflow:scroll is working as expected.
    • +
    +
    +

    Gradle:org.ossreviewtoolkit:nested-fake-project:1.0.0 (sub/module/project/build.gradle)

    Project is Excluded

    The project is excluded for the following reason(s):

    diff --git a/plugins/reporters/static-html/src/main/kotlin/ReportTableModel.kt b/plugins/reporters/static-html/src/main/kotlin/ReportTableModel.kt index c663377d5e0f..abca3a7d3d07 100644 --- a/plugins/reporters/static-html/src/main/kotlin/ReportTableModel.kt +++ b/plugins/reporters/static-html/src/main/kotlin/ReportTableModel.kt @@ -63,6 +63,11 @@ internal data class ReportTableModel( */ val scannerIssueSummary: IssueTable, + /** + * A [IssueTable] containing all advisor issues. + */ + val advisorIssueSummary: IssueTable, + /** * The [ProjectTable]s containing the dependencies for each [Project]. */ @@ -156,7 +161,8 @@ internal data class ReportTableModel( enum class Type { ANALYZER, - SCANNER + SCANNER, + ADVISOR } } diff --git a/plugins/reporters/static-html/src/main/kotlin/ReportTableModelMapper.kt b/plugins/reporters/static-html/src/main/kotlin/ReportTableModelMapper.kt index b3c31b55c5b3..448390d2727c 100644 --- a/plugins/reporters/static-html/src/main/kotlin/ReportTableModelMapper.kt +++ b/plugins/reporters/static-html/src/main/kotlin/ReportTableModelMapper.kt @@ -116,6 +116,7 @@ internal object ReportTableModelMapper { ruleViolations, getAnalyzerIssueSummaryTable(input), getScannerIssueSummaryTable(input), + getAdvisorIssueSummaryTable(input), projectTables, labels ) @@ -191,6 +192,10 @@ private fun getScannerIssueSummaryTable(input: ReporterInput): IssueTable = input.ortResult.getScannerIssues(omitExcluded = true, omitResolved = true) .toIssueSummaryTable(IssueTable.Type.SCANNER, input) +private fun getAdvisorIssueSummaryTable(input: ReporterInput): IssueTable = + input.ortResult.getAdvisorIssues(omitExcluded = true, omitResolved = true) + .toIssueSummaryTable(IssueTable.Type.ADVISOR, input) + private fun Map>.toIssueSummaryTable(type: IssueTable.Type, input: ReporterInput): IssueTable { val rows = flatMap { (id, issues) -> issues.map { issue -> diff --git a/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt b/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt index 35f35f51234f..3718c13fa09a 100644 --- a/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt +++ b/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt @@ -161,6 +161,10 @@ class StaticHtmlReporter : Reporter { issueTable(reportTableModel.scannerIssueSummary) } + if (reportTableModel.advisorIssueSummary.rows.isNotEmpty()) { + issueTable(reportTableModel.advisorIssueSummary) + } + reportTableModel.projectDependencies.forEach { (project, table) -> projectTable(project, table) } @@ -224,6 +228,14 @@ class StaticHtmlReporter : Reporter { } } + if (reportTableModel.advisorIssueSummary.rows.isNotEmpty()) { + li { + a("#${reportTableModel.advisorIssueSummary.id()}") { + +reportTableModel.advisorIssueSummary.title() + } + } + } + reportTableModel.projectDependencies.forEach { (project, projectTable) -> li { a("#${project.id.toCoordinates()}") {