-
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.
Parse CVE DB objects into domain objects (#11)
- Loading branch information
Showing
14 changed files
with
84 additions
and
93 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
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,7 @@ | ||
package io.gardenlinux.glvd.dto; | ||
|
||
import java.util.List; | ||
|
||
public record Configuration(List<Node> nodes) { | ||
|
||
} |
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,6 @@ | ||
package io.gardenlinux.glvd.dto; | ||
|
||
public record CpeMatch(String criteria, Deb deb, boolean vulnerable, String versionStartIncluding, | ||
String versionEndExcluding, String matchCriteriaId) { | ||
|
||
} |
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 |
---|---|---|
@@ -1,59 +1,10 @@ | ||
package io.gardenlinux.glvd.dto; | ||
|
||
import jakarta.annotation.Nonnull; | ||
import java.util.List; | ||
|
||
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; | ||
} | ||
public record Cve(String id, String lastModified, String sourceIdentifier, String published, String vulnStatus, | ||
List<Description> descriptions, Object metrics, List<Reference> references, List<Weakness> weaknesses, | ||
List<Configuration> configurations) { | ||
|
||
} | ||
|
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,5 @@ | ||
package io.gardenlinux.glvd.dto; | ||
|
||
public record Deb(String versionLatest, String versionEndExcluding, String cvssSeverity) { | ||
|
||
} |
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,4 @@ | ||
package io.gardenlinux.glvd.dto; | ||
|
||
public record Description(String lang, String value) { | ||
} |
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,7 @@ | ||
package io.gardenlinux.glvd.dto; | ||
|
||
import java.util.List; | ||
|
||
public record Node(List<CpeMatch> cpeMatch, boolean negate, String operator) { | ||
|
||
} |
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 |
---|---|---|
@@ -1,33 +1,5 @@ | ||
package io.gardenlinux.glvd.dto; | ||
|
||
import java.util.Objects; | ||
|
||
public class Readiness { | ||
|
||
private final String dbCheck; | ||
|
||
public Readiness(String dbCheck) { | ||
this.dbCheck = dbCheck; | ||
} | ||
|
||
public String getDbCheck() { | ||
return dbCheck; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) | ||
return true; | ||
if (o == null || getClass() != o.getClass()) | ||
return false; | ||
|
||
Readiness readiness = (Readiness) o; | ||
return Objects.equals(dbCheck, readiness.dbCheck); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hashCode(dbCheck); | ||
} | ||
public record Readiness(String dbCheck) { | ||
|
||
} |
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,7 @@ | ||
package io.gardenlinux.glvd.dto; | ||
|
||
import java.util.List; | ||
|
||
public record Reference(String url, String source, List<String> tags) { | ||
|
||
} |
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,7 @@ | ||
package io.gardenlinux.glvd.dto; | ||
|
||
import java.util.List; | ||
|
||
public record Weakness(String source, String type, List<Description> description) { | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/io/gardenlinux/glvd/exceptions/CantParseJSONException.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; | ||
|
||
public class CantParseJSONException extends RuntimeException{ | ||
|
||
public CantParseJSONException(String message) { | ||
super(message); | ||
} | ||
} |
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