Skip to content

Commit

Permalink
ui
Browse files Browse the repository at this point in the history
  • Loading branch information
fwilhe committed Sep 11, 2024
1 parent dec7848 commit a4517d3
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 72 deletions.
33 changes: 18 additions & 15 deletions src/main/java/io/gardenlinux/glvd/GlvdController.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
import jakarta.annotation.Nonnull;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

Expand All @@ -20,22 +23,22 @@ public GlvdController(@Nonnull GlvdService glvdService) {
this.glvdService = glvdService;
}

@GetMapping("/cves/{distro}/{distroVersion}")
ResponseEntity<List<SourcePackageCve>> getCveDistro(@PathVariable final String distro,
@PathVariable final String distroVersion) {
return ResponseEntity.ok().body(glvdService.getCveForDistribution(distro, distroVersion));
@GetMapping("/cves/{distro}/{gardenlinuxVersion}")
ResponseEntity<List<SourcePackageCve>> getCveDistro(
@PathVariable final String gardenlinuxVersion) {
return ResponseEntity.ok().body(glvdService.getCveForDistribution(gardenlinuxVersion));
}

@GetMapping("/cves/{distro}/{distroVersion}/packages/{packageList}")
ResponseEntity<List<SourcePackageCve>> getCvePackages(@PathVariable final String distro,
@PathVariable final String distroVersion, @PathVariable final String packageList) {
var cveForPackages = glvdService.getCveForPackages(distro, distroVersion, packageList);
@GetMapping("/cves/{distro}/{gardenlinuxVersion}/packages/{packageList}")
ResponseEntity<List<SourcePackageCve>> getCvePackages(
@PathVariable final String gardenlinuxVersion, @PathVariable final String packageList) {
var cveForPackages = glvdService.getCveForPackages(gardenlinuxVersion, packageList);
return ResponseEntity.ok().body(cveForPackages);
}

@GetMapping("/packages/distro/{distro}/{distroVersion}")
ResponseEntity<List<SourcePackage>> packagesForDistro(@PathVariable final String distro, @PathVariable final String distroVersion) {
return ResponseEntity.ok(glvdService.getPackagesForDistro(distro, distroVersion));
@GetMapping("/packages/distro/{distro}/{gardenlinuxVersion}")
ResponseEntity<List<SourcePackage>> packagesForDistro(@PathVariable final String gardenlinuxVersion) {
return ResponseEntity.ok(glvdService.getPackagesForDistro(gardenlinuxVersion));
}

@GetMapping("/packages/{sourcePackage}")
Expand All @@ -48,9 +51,9 @@ ResponseEntity<List<SourcePackageCve>> packageWithVulnerabilitiesByVersion(@Path
return ResponseEntity.ok(glvdService.getPackageWithVulnerabilitiesByVersion(sourcePackage, sourcePackageVersion));
}

@GetMapping("/packages/distro/{distro}/{distroVersion}/{cveId}")
ResponseEntity<List<SourcePackageCve>> packagesByVulnerability(@PathVariable final String distro, @PathVariable final String distroVersion, @PathVariable final String cveId) {
return ResponseEntity.ok(glvdService.getPackagesByVulnerability(distro, distroVersion, cveId));
@GetMapping("/packages/distro/{distro}/{gardenlinuxVersion}/{cveId}")
ResponseEntity<List<SourcePackageCve>> packagesByVulnerability(@PathVariable final String gardenlinuxVersion, @PathVariable final String cveId) {
return ResponseEntity.ok(glvdService.getPackagesByVulnerability(gardenlinuxVersion, cveId));
}

}
16 changes: 8 additions & 8 deletions src/main/java/io/gardenlinux/glvd/GlvdService.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ public GlvdService(@Nonnull SourcePackageCveRepository sourcePackageCveRepositor
this.sourcePackageRepository = sourcePackageRepository;
}

public List<SourcePackageCve> getCveForDistribution(String distro, String distroVersion) {
return sourcePackageCveRepository.findByGardenlinuxVersion(distroVersion);
public List<SourcePackageCve> getCveForDistribution(String gardenlinuxVersion) {
return sourcePackageCveRepository.findByGardenlinuxVersion(gardenlinuxVersion);
}

public List<SourcePackageCve> getCveForPackages(String distro, String distroVersion, String packages) {
return sourcePackageCveRepository.findBySourcePackageNameInAndGardenlinuxVersion("{"+packages+"}", distroVersion);
public List<SourcePackageCve> getCveForPackages(String gardenlinuxVersion, String packages) {
return sourcePackageCveRepository.findBySourcePackageNameInAndGardenlinuxVersion("{"+packages+"}", gardenlinuxVersion);
}

public List<SourcePackage> getPackagesForDistro(String distro, String distroVersion) {
return sourcePackageRepository.findByGardenlinuxVersion(distroVersion);
public List<SourcePackage> getPackagesForDistro(String gardenlinuxVersion) {
return sourcePackageRepository.findByGardenlinuxVersion(gardenlinuxVersion);
}

public List<SourcePackageCve> getPackageWithVulnerabilities(String sourcePackage) {
Expand All @@ -40,7 +40,7 @@ public List<SourcePackageCve> getPackageWithVulnerabilitiesByVersion(String sour
return sourcePackageCveRepository.findBySourcePackageNameAndSourcePackageVersion(sourcePackage, sourcePackageVersion);
}

public List<SourcePackageCve> getPackagesByVulnerability(String distro, String distroVersion, String cveId) {
return sourcePackageCveRepository.findByCveIdAndGardenlinuxVersion(cveId, distroVersion);
public List<SourcePackageCve> getPackagesByVulnerability(String gardenlinuxVersion, String cveId) {
return sourcePackageCveRepository.findByCveIdAndGardenlinuxVersion(cveId, gardenlinuxVersion);
}
}
36 changes: 15 additions & 21 deletions src/main/java/io/gardenlinux/glvd/UiController.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,55 +18,49 @@ public UiController(@Nonnull GlvdService glvdService) {

@GetMapping("/getPackagesForDistro")
public String getPackagesForDistro(
@RequestParam(name = "distro", required = false, defaultValue = "gardenlinux") String distro,
@RequestParam(name = "version", required = true) String version,
@RequestParam(name = "gardenlinuxVersion", required = true) String gardenlinuxVersion,
Model model) {
var packages = glvdService.getPackagesForDistro(distro, version);
var packages = glvdService.getPackagesForDistro(gardenlinuxVersion);
model.addAttribute("packages", packages);
model.addAttribute("distro", distro);
model.addAttribute("version", version);
model.addAttribute("gardenlinuxVersion", gardenlinuxVersion);
return "getPackagesForDistro";
}

@GetMapping("/getCveForDistribution")
public String getCveForDistribution(
@RequestParam(name = "distro", required = false, defaultValue = "gardenlinux") String distro,
@RequestParam(name = "version", required = true) String version,
@RequestParam(name = "gardenlinuxVersion", required = true) String gardenlinuxVersion,
Model model
) {
var sourcePackageCves = glvdService.getCveForDistribution(distro, version);
var sourcePackageCves = glvdService.getCveForDistribution(gardenlinuxVersion);
model.addAttribute("sourcePackageCves", sourcePackageCves);
model.addAttribute("distro", distro);
model.addAttribute("version", version);
model.addAttribute("gardenlinuxVersion", gardenlinuxVersion);
return "getCveForDistribution";
}

@GetMapping("/getCveForPackages")
public String getCveForPackages(
@RequestParam(name = "distro", required = false, defaultValue = "gardenlinux") String distro,
@RequestParam(name = "version", required = true) String version,

@RequestParam(name = "gardenlinuxVersion", required = true) String gardenlinuxVersion,
@RequestParam(name = "packages", required = true) String packages,
Model model
) {
var sourcePackageCves = glvdService.getCveForPackages(distro, version, packages);
var sourcePackageCves = glvdService.getCveForPackages(gardenlinuxVersion, packages);
model.addAttribute("sourcePackageCves", sourcePackageCves);
model.addAttribute("distro", distro);
model.addAttribute("version", version);
model.addAttribute("gardenlinuxVersion", gardenlinuxVersion);
model.addAttribute("packages", packages);
return "getCveForPackages";
}

@GetMapping("/getPackagesByVulnerability")
public String getPackagesByVulnerability(
@RequestParam(name = "distro", required = false, defaultValue = "gardenlinux") String distro,
@RequestParam(name = "version", required = true) String version,

@RequestParam(name = "gardenlinuxVersion", required = true) String gardenlinuxVersion,
@RequestParam(name = "cveId", required = true) String cveId,
Model model
) {
var packageEntities = glvdService.getPackagesByVulnerability(distro, version, cveId);
model.addAttribute("packageEntities", packageEntities);
model.addAttribute("distro", distro);
model.addAttribute("version", version);
var sourcePackageCves = glvdService.getPackagesByVulnerability(gardenlinuxVersion, cveId);
model.addAttribute("sourcePackageCves", sourcePackageCves);
model.addAttribute("gardenlinuxVersion", gardenlinuxVersion);
model.addAttribute("cveId", cveId);
return "getPackagesByVulnerability";
}
Expand Down
26 changes: 13 additions & 13 deletions src/main/resources/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@

(Under Construction)

<p><a href="/getPackagesForDistro?version=1592.1">List Packages in Garden Linux 1592.1</a> </p>
<p><a href="/getPackagesForDistro?version=1592.0">List Packages in Garden Linux 1592.0</a> </p>
<p><a href="/getPackagesForDistro?version=1443.10">List Packages in Garden Linux 1443.10</a> </p>
<p><a href="/getPackagesForDistro?version=1443.9">List Packages in Garden Linux 1443.9</a> </p>
<p><a href="/getPackagesForDistro?gardenlinuxVersion=1592.1">List Packages in Garden Linux 1592.1</a> </p>
<p><a href="/getPackagesForDistro?gardenlinuxVersion=1592.0">List Packages in Garden Linux 1592.0</a> </p>
<p><a href="/getPackagesForDistro?gardenlinuxVersion=1443.10">List Packages in Garden Linux 1443.10</a> </p>
<p><a href="/getPackagesForDistro?gardenlinuxVersion=1443.9">List Packages in Garden Linux 1443.9</a> </p>

<p><a href="/getCveForDistribution?version=1592.1">Vulnerable packages in Garden Linux 1592.1</a> </p>
<p><a href="/getCveForDistribution?version=1592.0">Vulnerable packages in Garden Linux 1592.0</a> </p>
<p><a href="/getCveForDistribution?version=1443.10">Vulnerable packages in Garden Linux 1443.10</a> </p>
<p><a href="/getCveForDistribution?version=1443.9">Vulnerable packages in Garden Linux 1443.9</a> </p>
<p><a href="/getCveForDistribution?gardenlinuxVersion=1592.1">Vulnerable packages in Garden Linux 1592.1</a> </p>
<p><a href="/getCveForDistribution?gardenlinuxVersion=1592.0">Vulnerable packages in Garden Linux 1592.0</a> </p>
<p><a href="/getCveForDistribution?gardenlinuxVersion=1443.10">Vulnerable packages in Garden Linux 1443.10</a> </p>
<p><a href="/getCveForDistribution?gardenlinuxVersion=1443.9">Vulnerable packages in Garden Linux 1443.9</a> </p>

<p><a href="/getCveForPackages?version=1592.1&packages=vim,crun,bash">Vulnerabilities in packages vim,crun,bash in Garden Linux 1592.1</a> </p>
<p><a href="/getCveForPackages?version=1443.10&packages=vim,crun,bash">Vulnerabilities in packages vim,crun,bash in Garden Linux 1443.10</a> </p>
<p><a href="/getCveForPackages?gardenlinuxVersion=1592.1&packages=vim,crun,bash">Vulnerabilities in packages vim,crun,bash in Garden Linux 1592.1</a> </p>
<p><a href="/getCveForPackages?gardenlinuxVersion=1443.10&packages=vim,crun,bash">Vulnerabilities in packages vim,crun,bash in Garden Linux 1443.10</a> </p>


<p><a href="/getPackagesByVulnerability?version=1592.0&cveId=CVE-2023-50387">Packages affected by CVE-2023-50387 in Garden Linux 1592.0</a> </p>
<p><a href="/getPackagesByVulnerability?version=1592.0&cveId=CVE-2022-40303">Packages affected by CVE-2022-40303 in Garden Linux 1592.0</a> </p>
<p><a href="/getPackagesByVulnerability?version=1592.0&cveId=CVE-2024-8088">Packages affected by CVE-2024-8088 in Garden Linux 1592.0</a> </p>
<p><a href="/getPackagesByVulnerability?gardenlinuxVersion=1592.0&cveId=CVE-2023-50387">Packages affected by CVE-2023-50387 in Garden Linux 1592.0</a> </p>
<p><a href="/getPackagesByVulnerability?gardenlinuxVersion=1592.0&cveId=CVE-2022-40303">Packages affected by CVE-2022-40303 in Garden Linux 1592.0</a> </p>
<p><a href="/getPackagesByVulnerability?gardenlinuxVersion=1592.0&cveId=CVE-2024-8088">Packages affected by CVE-2024-8088 in Garden Linux 1592.0</a> </p>


</body>
Expand Down
17 changes: 14 additions & 3 deletions src/main/resources/templates/getCveForDistribution.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,24 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<p th:text="|Vulnerabilities list for ${distro} ${version}|" />
<p th:text="|Vulnerabilities list for Garden Linux ${gardenlinuxVersion}|" />

<table>
<thead>
<tr>
<th>CVE ID</th>
<th>CVE Published Date</th>
<th>Source Package</th>
<th>Version</th>
<th>Is Vulnerable?</th>
</tr>
</thead>
<tr th:each="item: ${sourcePackageCves}">
<td th:text="${item.id}" />
<td th:text="${item.cveId}" />
<td th:text="${item.cvePublishedDate}" />
<td th:text="${item.sourcePackage}" />
<td th:text="${item.sourcePackageName}" />
<td th:text="${item.sourcePackageVersion}" />
<td th:text="${item.isVulnerable}" />
</tr>
</table>

Expand Down
17 changes: 14 additions & 3 deletions src/main/resources/templates/getCveForPackages.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,24 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<p th:text="|Vulnerabilities list for ${distro} ${version} in packages ${packages}|" />
<p th:text="|Vulnerabilities list for Garden Linux ${gardenlinuxVersion} in packages ${packages}|" />

<table>
<thead>
<tr>
<th>CVE ID</th>
<th>CVE Published Date</th>
<th>Source Package</th>
<th>Version</th>
<th>Is Vulnerable?</th>
</tr>
</thead>
<tr th:each="item: ${sourcePackageCves}">
<td th:text="${item.id}" />
<td th:text="${item.cveId}" />
<td th:text="${item.cvePublishedDate}" />
<td th:text="${item.sourcePackage}" />
<td th:text="${item.sourcePackageName}" />
<td th:text="${item.sourcePackageVersion}" />
<td th:text="${item.isVulnerable}" />
</tr>
</table>

Expand Down
24 changes: 17 additions & 7 deletions src/main/resources/templates/getPackagesByVulnerability.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,27 @@
<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" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<p th:text="|Packages affected by ${cveId} in ${distro} ${version}|" />
<p th:text="|Packages affected by ${cveId} in Garden Linux ${gardenlinuxVersion}|"/>

<table>
<tr th:each="item: ${packageEntities}">
<td th:text="${item.cveId}" />
<td th:text="${item.debSource}" />
<td th:text="${item.debVersion}" />
<td th:text="${item.debsecVulnerable}" />
<thead>
<tr>
<th>CVE ID</th>
<th>CVE Published Date</th>
<th>Source Package</th>
<th>Version</th>
<th>Is Vulnerable?</th>
</tr>
</thead>
<tr th:each="item: ${sourcePackageCves}">
<td th:text="${item.cveId}"/>
<td th:text="${item.cvePublishedDate}"/>
<td th:text="${item.sourcePackageName}"/>
<td th:text="${item.sourcePackageVersion}"/>
<td th:text="${item.isVulnerable}"/>
</tr>
</table>

Expand Down
11 changes: 9 additions & 2 deletions src/main/resources/templates/getPackagesForDistro.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<p th:text="|Package list for ${distro} ${version}|" />
<p th:text="|Package list for Garden Linux ${gardenlinuxVersion}|" />

<table>
<thead>
<tr>
<th>Source Package</th>
<th>Version</th>
</tr>
</thead>
<tr th:each="package: ${packages}">
<td th:text="${package}" />
<td th:text="${package.sourcePackageName}" />
<td th:text="${package.sourcePackageVersion}" />
</tr>
</table>

Expand Down

0 comments on commit a4517d3

Please sign in to comment.