From a4517d3c5bdd00271137ef2c9ada72a8a6c1f37d Mon Sep 17 00:00:00 2001 From: Florian Wilhelm Date: Wed, 11 Sep 2024 13:57:35 +0200 Subject: [PATCH] ui --- .../io/gardenlinux/glvd/GlvdController.java | 33 +++++++++-------- .../java/io/gardenlinux/glvd/GlvdService.java | 16 ++++----- .../io/gardenlinux/glvd/UiController.java | 36 ++++++++----------- src/main/resources/static/index.html | 26 +++++++------- .../templates/getCveForDistribution.html | 17 +++++++-- .../templates/getCveForPackages.html | 17 +++++++-- .../templates/getPackagesByVulnerability.html | 24 +++++++++---- .../templates/getPackagesForDistro.html | 11 ++++-- 8 files changed, 108 insertions(+), 72 deletions(-) diff --git a/src/main/java/io/gardenlinux/glvd/GlvdController.java b/src/main/java/io/gardenlinux/glvd/GlvdController.java index f0bb269..da2219f 100644 --- a/src/main/java/io/gardenlinux/glvd/GlvdController.java +++ b/src/main/java/io/gardenlinux/glvd/GlvdController.java @@ -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; @@ -20,22 +23,22 @@ public GlvdController(@Nonnull GlvdService glvdService) { this.glvdService = glvdService; } - @GetMapping("/cves/{distro}/{distroVersion}") - ResponseEntity> getCveDistro(@PathVariable final String distro, - @PathVariable final String distroVersion) { - return ResponseEntity.ok().body(glvdService.getCveForDistribution(distro, distroVersion)); + @GetMapping("/cves/{distro}/{gardenlinuxVersion}") + ResponseEntity> getCveDistro( + @PathVariable final String gardenlinuxVersion) { + return ResponseEntity.ok().body(glvdService.getCveForDistribution(gardenlinuxVersion)); } - @GetMapping("/cves/{distro}/{distroVersion}/packages/{packageList}") - ResponseEntity> 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> 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> packagesForDistro(@PathVariable final String distro, @PathVariable final String distroVersion) { - return ResponseEntity.ok(glvdService.getPackagesForDistro(distro, distroVersion)); + @GetMapping("/packages/distro/{distro}/{gardenlinuxVersion}") + ResponseEntity> packagesForDistro(@PathVariable final String gardenlinuxVersion) { + return ResponseEntity.ok(glvdService.getPackagesForDistro(gardenlinuxVersion)); } @GetMapping("/packages/{sourcePackage}") @@ -48,9 +51,9 @@ ResponseEntity> packageWithVulnerabilitiesByVersion(@Path return ResponseEntity.ok(glvdService.getPackageWithVulnerabilitiesByVersion(sourcePackage, sourcePackageVersion)); } - @GetMapping("/packages/distro/{distro}/{distroVersion}/{cveId}") - ResponseEntity> 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> packagesByVulnerability(@PathVariable final String gardenlinuxVersion, @PathVariable final String cveId) { + return ResponseEntity.ok(glvdService.getPackagesByVulnerability(gardenlinuxVersion, cveId)); } } diff --git a/src/main/java/io/gardenlinux/glvd/GlvdService.java b/src/main/java/io/gardenlinux/glvd/GlvdService.java index 5f515c6..c2f6423 100644 --- a/src/main/java/io/gardenlinux/glvd/GlvdService.java +++ b/src/main/java/io/gardenlinux/glvd/GlvdService.java @@ -20,16 +20,16 @@ public GlvdService(@Nonnull SourcePackageCveRepository sourcePackageCveRepositor this.sourcePackageRepository = sourcePackageRepository; } - public List getCveForDistribution(String distro, String distroVersion) { - return sourcePackageCveRepository.findByGardenlinuxVersion(distroVersion); + public List getCveForDistribution(String gardenlinuxVersion) { + return sourcePackageCveRepository.findByGardenlinuxVersion(gardenlinuxVersion); } - public List getCveForPackages(String distro, String distroVersion, String packages) { - return sourcePackageCveRepository.findBySourcePackageNameInAndGardenlinuxVersion("{"+packages+"}", distroVersion); + public List getCveForPackages(String gardenlinuxVersion, String packages) { + return sourcePackageCveRepository.findBySourcePackageNameInAndGardenlinuxVersion("{"+packages+"}", gardenlinuxVersion); } - public List getPackagesForDistro(String distro, String distroVersion) { - return sourcePackageRepository.findByGardenlinuxVersion(distroVersion); + public List getPackagesForDistro(String gardenlinuxVersion) { + return sourcePackageRepository.findByGardenlinuxVersion(gardenlinuxVersion); } public List getPackageWithVulnerabilities(String sourcePackage) { @@ -40,7 +40,7 @@ public List getPackageWithVulnerabilitiesByVersion(String sour return sourcePackageCveRepository.findBySourcePackageNameAndSourcePackageVersion(sourcePackage, sourcePackageVersion); } - public List getPackagesByVulnerability(String distro, String distroVersion, String cveId) { - return sourcePackageCveRepository.findByCveIdAndGardenlinuxVersion(cveId, distroVersion); + public List getPackagesByVulnerability(String gardenlinuxVersion, String cveId) { + return sourcePackageCveRepository.findByCveIdAndGardenlinuxVersion(cveId, gardenlinuxVersion); } } diff --git a/src/main/java/io/gardenlinux/glvd/UiController.java b/src/main/java/io/gardenlinux/glvd/UiController.java index a80fb3e..54e5961 100644 --- a/src/main/java/io/gardenlinux/glvd/UiController.java +++ b/src/main/java/io/gardenlinux/glvd/UiController.java @@ -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"; } diff --git a/src/main/resources/static/index.html b/src/main/resources/static/index.html index 20db44d..52ad7bf 100644 --- a/src/main/resources/static/index.html +++ b/src/main/resources/static/index.html @@ -10,23 +10,23 @@ (Under Construction) -

List Packages in Garden Linux 1592.1

-

List Packages in Garden Linux 1592.0

-

List Packages in Garden Linux 1443.10

-

List Packages in Garden Linux 1443.9

+

List Packages in Garden Linux 1592.1

+

List Packages in Garden Linux 1592.0

+

List Packages in Garden Linux 1443.10

+

List Packages in Garden Linux 1443.9

-

Vulnerable packages in Garden Linux 1592.1

-

Vulnerable packages in Garden Linux 1592.0

-

Vulnerable packages in Garden Linux 1443.10

-

Vulnerable packages in Garden Linux 1443.9

+

Vulnerable packages in Garden Linux 1592.1

+

Vulnerable packages in Garden Linux 1592.0

+

Vulnerable packages in Garden Linux 1443.10

+

Vulnerable packages in Garden Linux 1443.9

-

Vulnerabilities in packages vim,crun,bash in Garden Linux 1592.1

-

Vulnerabilities in packages vim,crun,bash in Garden Linux 1443.10

+

Vulnerabilities in packages vim,crun,bash in Garden Linux 1592.1

+

Vulnerabilities in packages vim,crun,bash in Garden Linux 1443.10

-

Packages affected by CVE-2023-50387 in Garden Linux 1592.0

-

Packages affected by CVE-2022-40303 in Garden Linux 1592.0

-

Packages affected by CVE-2024-8088 in Garden Linux 1592.0

+

Packages affected by CVE-2023-50387 in Garden Linux 1592.0

+

Packages affected by CVE-2022-40303 in Garden Linux 1592.0

+

Packages affected by CVE-2024-8088 in Garden Linux 1592.0

diff --git a/src/main/resources/templates/getCveForDistribution.html b/src/main/resources/templates/getCveForDistribution.html index 7cd3f8a..01bf77e 100644 --- a/src/main/resources/templates/getCveForDistribution.html +++ b/src/main/resources/templates/getCveForDistribution.html @@ -5,13 +5,24 @@ -

+

+ + + + + + + + + -
CVE IDCVE Published DateSource PackageVersionIs Vulnerable?
+ - + + +
diff --git a/src/main/resources/templates/getCveForPackages.html b/src/main/resources/templates/getCveForPackages.html index 3b580a3..fa1e67f 100644 --- a/src/main/resources/templates/getCveForPackages.html +++ b/src/main/resources/templates/getCveForPackages.html @@ -5,13 +5,24 @@ -

+

+ + + + + + + + + -
CVE IDCVE Published DateSource PackageVersionIs Vulnerable?
+ - + + +
diff --git a/src/main/resources/templates/getPackagesByVulnerability.html b/src/main/resources/templates/getPackagesByVulnerability.html index 76bf9fb..ddb8011 100644 --- a/src/main/resources/templates/getPackagesByVulnerability.html +++ b/src/main/resources/templates/getPackagesByVulnerability.html @@ -2,17 +2,27 @@ GLVD: List vulnerabilities in distro - + -

+

- - + + + + + + + + + +
- - - +
CVE IDCVE Published DateSource PackageVersionIs Vulnerable?
+ + + +
diff --git a/src/main/resources/templates/getPackagesForDistro.html b/src/main/resources/templates/getPackagesForDistro.html index b4efda0..08ff51b 100644 --- a/src/main/resources/templates/getPackagesForDistro.html +++ b/src/main/resources/templates/getPackagesForDistro.html @@ -5,11 +5,18 @@ -

+

+ + + + + + -
Source PackageVersion
+ +