Skip to content

Commit

Permalink
Allow viewing both resolved and unresolved issues
Browse files Browse the repository at this point in the history
  • Loading branch information
fwilhe committed Nov 14, 2024
1 parent e867cfe commit f48e99b
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 10 deletions.
24 changes: 23 additions & 1 deletion src/main/java/io/gardenlinux/glvd/UiController.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.gardenlinux.glvd;

import io.gardenlinux.glvd.db.SourcePackageCve;
import jakarta.annotation.Nonnull;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
Expand Down Expand Up @@ -39,16 +40,37 @@ public String getCveForDistribution(
@RequestParam(defaultValue = "DESC") final String sortOrder,
@RequestParam(required = false) final String pageNumber,
@RequestParam(required = false) final String pageSize,
@RequestParam(required = false, defaultValue = "true") final boolean onlyVulnerable,
Model model
) {
var sourcePackageCves = glvdService.getCveForDistribution(
gardenlinuxVersion, new SortAndPageOptions(sortBy, sortOrder, pageNumber, pageSize)
);
).stream().filter(SourcePackageCve::isVulnerable).toList();
model.addAttribute("sourcePackageCves", sourcePackageCves);
model.addAttribute("gardenlinuxVersion", gardenlinuxVersion);
model.addAttribute("onlyVulnerable", onlyVulnerable);
return "getCveForDistribution";
}

@GetMapping("/getCveForDistributionAll")
public String getCveForDistributionAll(
@RequestParam(name = "gardenlinuxVersion", required = true) String gardenlinuxVersion,
@RequestParam(defaultValue = "baseScore") final String sortBy,
@RequestParam(defaultValue = "DESC") final String sortOrder,
@RequestParam(required = false) final String pageNumber,
@RequestParam(required = false) final String pageSize,
@RequestParam(required = false, defaultValue = "true") final boolean onlyVulnerable,
Model model
) {
var sourcePackageCves = glvdService.getCveForDistribution(
gardenlinuxVersion, new SortAndPageOptions(sortBy, sortOrder, pageNumber, pageSize)
);
model.addAttribute("sourcePackageCves", sourcePackageCves);
model.addAttribute("gardenlinuxVersion", gardenlinuxVersion);
model.addAttribute("onlyVulnerable", onlyVulnerable);
return "getCveForDistributionAll";
}

@GetMapping("/getCveForPackages")
public String getCveForPackages(
@RequestParam(name = "gardenlinuxVersion", required = true) String gardenlinuxVersion,
Expand Down
20 changes: 11 additions & 9 deletions src/main/resources/templates/getCveForDistribution.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,35 @@
<link href="style.css" rel="stylesheet" media="screen" />
</head>
<body>
<h1 th:text="|Vulnerabilities list for Garden Linux ${gardenlinuxVersion}|" />
<h1 th:text="|Vulnerabilities list for Garden Linux ${gardenlinuxVersion} (ignoring resolved issues)|" />

<p th:text="|Found ${#lists.size(sourcePackageCves)} potential security issues|"></p>

<a th:href="@{/getCveForDistributionAll(gardenlinuxVersion=${gardenlinuxVersion},onlyVulnerable=false)}">Show all potential issues</a>

<table>
<thead>
<tr>
<th>CVE ID
<a th:href="@{/getCveForDistribution(gardenlinuxVersion=${gardenlinuxVersion},sortBy=cveId,sortOrder=ASC)}">&uarr;</a>
<a th:href="@{/getCveForDistribution(gardenlinuxVersion=${gardenlinuxVersion},sortBy=cveId,sortOrder=DESC)}">&darr;</a>
<a th:href="@{/getCveForDistribution(gardenlinuxVersion=${gardenlinuxVersion},sortBy=cveId,sortOrder=ASC,onlyVulnerable=true)}">&uarr;</a>
<a th:href="@{/getCveForDistribution(gardenlinuxVersion=${gardenlinuxVersion},sortBy=cveId,sortOrder=DESC,onlyVulnerable=true)}">&darr;</a>
</th>

<th>CVE Base Score
<a th:href="@{/getCveForDistribution(gardenlinuxVersion=${gardenlinuxVersion},sortBy=baseScore,sortOrder=ASC)}">&uarr;</a>
<a th:href="@{/getCveForDistribution(gardenlinuxVersion=${gardenlinuxVersion},sortBy=baseScore,sortOrder=DESC)}">&darr;</a>
<a th:href="@{/getCveForDistribution(gardenlinuxVersion=${gardenlinuxVersion},sortBy=baseScore,sortOrder=ASC,onlyVulnerable=true)}">&uarr;</a>
<a th:href="@{/getCveForDistribution(gardenlinuxVersion=${gardenlinuxVersion},sortBy=baseScore,sortOrder=DESC,onlyVulnerable=true)}">&darr;</a>
</th>

<th>Vector String</th>

<th>CVE Published Date
<a th:href="@{/getCveForDistribution(gardenlinuxVersion=${gardenlinuxVersion},sortBy=cvePublishedDate,sortOrder=ASC)}">&uarr;</a>
<a th:href="@{/getCveForDistribution(gardenlinuxVersion=${gardenlinuxVersion},sortBy=cvePublishedDate,sortOrder=DESC)}">&darr;</a>
<a th:href="@{/getCveForDistribution(gardenlinuxVersion=${gardenlinuxVersion},sortBy=cvePublishedDate,sortOrder=ASC,onlyVulnerable=true)}">&uarr;</a>
<a th:href="@{/getCveForDistribution(gardenlinuxVersion=${gardenlinuxVersion},sortBy=cvePublishedDate,sortOrder=DESC,onlyVulnerable=true)}">&darr;</a>
</th>

<th>Source Package
<a th:href="@{/getCveForDistribution(gardenlinuxVersion=${gardenlinuxVersion},sortBy=sourcePackageName,sortOrder=ASC)}">&uarr;</a>
<a th:href="@{/getCveForDistribution(gardenlinuxVersion=${gardenlinuxVersion},sortBy=sourcePackageName,sortOrder=DESC)}">&darr;</a>
<a th:href="@{/getCveForDistribution(gardenlinuxVersion=${gardenlinuxVersion},sortBy=sourcePackageName,sortOrder=ASC,onlyVulnerable=true)}">&uarr;</a>
<a th:href="@{/getCveForDistribution(gardenlinuxVersion=${gardenlinuxVersion},sortBy=sourcePackageName,sortOrder=DESC,onlyVulnerable=true)}">&darr;</a>
</th>

<th>Version</th>
Expand Down
56 changes: 56 additions & 0 deletions src/main/resources/templates/getCveForDistributionAll.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>GLVD: List vulnerabilities in distro</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="style.css" rel="stylesheet" media="screen" />
</head>
<body>
<h1 th:text="|Vulnerabilities list for Garden Linux ${gardenlinuxVersion} (showing resolved issues)|" />

<p th:text="|Found ${#lists.size(sourcePackageCves)} potential security issues|"></p>

<a th:href="@{/getCveForDistribution(gardenlinuxVersion=${gardenlinuxVersion},onlyVulnerable=true)}">Show only unresolved potential issues</a>

<table>
<thead>
<tr>
<th>CVE ID
<a th:href="@{/getCveForDistributionAll(gardenlinuxVersion=${gardenlinuxVersion},sortBy=cveId,sortOrder=ASC,onlyVulnerable=false)}">&uarr;</a>
<a th:href="@{/getCveForDistributionAll(gardenlinuxVersion=${gardenlinuxVersion},sortBy=cveId,sortOrder=DESC,onlyVulnerable=false)}">&darr;</a>
</th>

<th>CVE Base Score
<a th:href="@{/getCveForDistributionAll(gardenlinuxVersion=${gardenlinuxVersion},sortBy=baseScore,sortOrder=ASC,onlyVulnerable=false)}">&uarr;</a>
<a th:href="@{/getCveForDistributionAll(gardenlinuxVersion=${gardenlinuxVersion},sortBy=baseScore,sortOrder=DESC,onlyVulnerable=false)}">&darr;</a>
</th>

<th>Vector String</th>

<th>CVE Published Date
<a th:href="@{/getCveForDistributionAll(gardenlinuxVersion=${gardenlinuxVersion},sortBy=cvePublishedDate,sortOrder=ASC,onlyVulnerable=false)}">&uarr;</a>
<a th:href="@{/getCveForDistributionAll(gardenlinuxVersion=${gardenlinuxVersion},sortBy=cvePublishedDate,sortOrder=DESC,onlyVulnerable=false)}">&darr;</a>
</th>

<th>Source Package
<a th:href="@{/getCveForDistributionAll(gardenlinuxVersion=${gardenlinuxVersion},sortBy=sourcePackageName,sortOrder=ASC,onlyVulnerable=false)}">&uarr;</a>
<a th:href="@{/getCveForDistributionAll(gardenlinuxVersion=${gardenlinuxVersion},sortBy=sourcePackageName,sortOrder=DESC,onlyVulnerable=false)}">&darr;</a>
</th>

<th>Version</th>
<th>Is Vulnerable?</th>
</tr>
</thead>
<tr th:each="item: ${sourcePackageCves}">
<td><a th:href="@{/getCveDetails(cveId=${item.cveId})}"> <div th:text="${item.cveId}"/> </a></td>
<td th:text="${item.baseScore}" />
<td th:text="${item.vectorString}" />
<td th:text="${item.cvePublishedDate}" />
<td th:text="${item.sourcePackageName}" />
<td th:text="${item.sourcePackageVersion}" />
<td th:text="${item.isVulnerable}" />
</tr>
</table>

</body>
</html>

0 comments on commit f48e99b

Please sign in to comment.