Skip to content

Commit

Permalink
feat(static-html): Add an advisor issue summary table
Browse files Browse the repository at this point in the history
Show advisor issues analog to analyzer and scanner issues.

Signed-off-by: Frank Viernau <[email protected]>
  • Loading branch information
fviernau committed Apr 30, 2024
1 parent bf3cb5e commit 237f3e2
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ <h2>Index</h2>
<li><a href="#rule-violation-summary">Rule Violation Summary (1 errors, 1 warnings, 0 hints to resolve)</a></li>
<li><a href="#analyzer-issue-summary">Analyzer Issue Summary (1 errors, 2 warnings, 1 hints to resolve)</a></li>
<li><a href="#scanner-issue-summary">Scanner Issue Summary (3 errors, 1 warnings, 1 hints to resolve)</a></li>
<li><a href="#advisor-issue-summary">Advisor Issue Summary (1 errors, 1 warnings, 1 hints to resolve)</a></li>
<li><a href="#Gradle:org.ossreviewtoolkit:nested-fake-project:1.0.0">Gradle:org.ossreviewtoolkit:nested-fake-project:1.0.0
<div class="ort-reason">Excluded: EXAMPLE_OF - The project is an example.</div></a></li>
<li><a href="#Gradle:org.ossreviewtoolkit.gradle.example:lib:1.0.0">Gradle:org.ossreviewtoolkit.gradle.example:lib:1.0.0</a></li>
Expand Down Expand Up @@ -733,6 +734,76 @@ <h2 id="scanner-issue-summary">Scanner Issue Summary (3 errors, 1 warnings, 1 hi
</tr>
</tbody>
</table>
<h2 id="advisor-issue-summary">Advisor Issue Summary (1 errors, 1 warnings, 1 hints to resolve)</h2>
<p>Issues from excluded components are not shown in this summary.</p>
<table class="ort-report-table">
<thead>
<tr>
<th>#</th>
<th>Package</th>
<th>Message</th>
</tr>
</thead>
<tbody>
<tr class="ort-error" id="advisor-issue-summary-1">
<td><a href="#advisor-issue-summary-1">1</a></td>
<td>Maven:org.apache.commons:commons-text:1.1</td>
<td>
<p>Unknown time [ERROR]: VulnerableCode - Example advisor error.</p>
<details>
<summary>How to fix</summary>
<ul>

<li><em>Step 1</em></li>

<li><strong>Step 2</strong></li>

<li><em><strong>Step 3</strong></em>
<code>Some long issue resolution text to verify that overflow:scroll is working as expected.</code></li>
</ul>
</details>
</td>
</tr>
<tr class="ort-warning" id="advisor-issue-summary-2">
<td><a href="#advisor-issue-summary-2">2</a></td>
<td>Maven:org.apache.commons:commons-text:1.1</td>
<td>
<p>Unknown time [WARNING]: VulnerableCode - Example advisor warning.</p>
<details>
<summary>How to fix</summary>
<ul>

<li><em>Step 1</em></li>

<li><strong>Step 2</strong></li>

<li><em><strong>Step 3</strong></em>
<code>Some long issue resolution text to verify that overflow:scroll is working as expected.</code></li>
</ul>
</details>
</td>
</tr>
<tr class="ort-hint" id="advisor-issue-summary-3">
<td><a href="#advisor-issue-summary-3">3</a></td>
<td>Maven:org.apache.commons:commons-text:1.1</td>
<td>
<p>Unknown time [HINT]: VulnerableCode - Example advisor hint.</p>
<details>
<summary>How to fix</summary>
<ul>

<li><em>Step 1</em></li>

<li><strong>Step 2</strong></li>

<li><em><strong>Step 3</strong></em>
<code>Some long issue resolution text to verify that overflow:scroll is working as expected.</code></li>
</ul>
</details>
</td>
</tr>
</tbody>
</table>
<h2 id="Gradle:org.ossreviewtoolkit:nested-fake-project:1.0.0">Gradle:org.ossreviewtoolkit:nested-fake-project:1.0.0 (sub/module/project/build.gradle)</h2>
<h3>Project is Excluded</h3>
<p>The project is excluded for the following reason(s):</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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].
*/
Expand Down Expand Up @@ -156,7 +161,8 @@ internal data class ReportTableModel(

enum class Type {
ANALYZER,
SCANNER
SCANNER,
ADVISOR
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ internal object ReportTableModelMapper {
ruleViolations,
getAnalyzerIssueSummaryTable(input),
getScannerIssueSummaryTable(input),
getAdvisorIssueSummaryTable(input),
projectTables,
labels
)
Expand Down Expand Up @@ -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<Identifier, Set<Issue>>.toIssueSummaryTable(type: IssueTable.Type, input: ReporterInput): IssueTable {
val rows = flatMap { (id, issues) ->
issues.map { issue ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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()}") {
Expand Down

0 comments on commit 237f3e2

Please sign in to comment.