-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement endpoint to get CVEs per distro (#5)
- Loading branch information
Showing
11 changed files
with
210 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
= Garden Linux Vulnerability Database Rest API | ||
Garden Linux Authors; | ||
:doctype: book | ||
:icons: font | ||
:source-highlighter: highlightjs | ||
|
||
== Lorem Ipsum | ||
|
||
=== Get a CVE by id | ||
|
||
Request | ||
|
||
include::{snippets}/getCve/curl-request.adoc[] | ||
|
||
Response | ||
|
||
include::{snippets}/getCve/http-response.adoc[] | ||
|
||
=== Get a list of CVEs by distro | ||
|
||
Request | ||
|
||
include::{snippets}/getCveForDistro/curl-request.adoc[] | ||
|
||
Response | ||
|
||
include::{snippets}/getCveForDistro/http-response.adoc[] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.gardenlinux.glvd.db; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
import java.util.List; | ||
|
||
public interface CveRepository extends JpaRepository<CveEntity, String> { | ||
|
||
@Query(value = """ | ||
SELECT | ||
all_cve.data AS cveEntity | ||
FROM | ||
all_cve | ||
INNER JOIN deb_cve USING (cve_id) | ||
INNER JOIN dist_cpe ON (deb_cve.dist_id = dist_cpe.id) | ||
WHERE | ||
dist_cpe.cpe_vendor = ?1 AND | ||
dist_cpe.cpe_product = ?2 and | ||
dist_cpe.deb_codename = ?3 | ||
ORDER BY | ||
all_cve.cve_id | ||
""", nativeQuery = true) | ||
List<String> cvesForDistribution(String vendor, String product, String codename); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package io.gardenlinux.glvd.dto; | ||
|
||
import jakarta.annotation.Nonnull; | ||
|
||
import java.util.Objects; | ||
|
||
public class Cve { | ||
private String id; | ||
@Nonnull | ||
private String lastModified; | ||
@Nonnull | ||
private String data; | ||
|
||
public Cve() { | ||
} | ||
|
||
public Cve(String id, @Nonnull String lastModified, @Nonnull String data) { | ||
this.id = id; | ||
this.lastModified = lastModified; | ||
this.data = data; | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
@Nonnull | ||
public String getLastModified() { | ||
return lastModified; | ||
} | ||
|
||
@Nonnull | ||
public String getData() { | ||
return data; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
Cve Cve = (Cve) o; | ||
return Objects.equals(id, Cve.id) && lastModified.equals(Cve.lastModified) && data.equals(Cve.data); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = Objects.hashCode(id); | ||
result = 31 * result + lastModified.hashCode(); | ||
result = 31 * result + data.hashCode(); | ||
return result; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/io/gardenlinux/glvd/exceptions/NotFoundException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.gardenlinux.glvd.exceptions; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
|
||
@ResponseStatus(code = HttpStatus.NOT_FOUND, reason = "Not Found") | ||
public class NotFoundException extends Exception{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.