diff --git a/src/main/java/io/gardenlinux/glvd/dto/Configuration.java b/src/main/java/io/gardenlinux/glvd/dto/Configuration.java index c444aa8..b90df38 100644 --- a/src/main/java/io/gardenlinux/glvd/dto/Configuration.java +++ b/src/main/java/io/gardenlinux/glvd/dto/Configuration.java @@ -1,40 +1,7 @@ package io.gardenlinux.glvd.dto; import java.util.List; -import java.util.Objects; -public class Configuration { - private List nodes; +public record Configuration(List nodes) { - public Configuration() { - } - - public Configuration(List nodes) { - this.nodes = nodes; - } - - public List getNodes() { - return nodes; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Configuration that = (Configuration) o; - return Objects.equals(nodes, that.nodes); - } - - @Override - public int hashCode() { - return Objects.hashCode(nodes); - } - - @Override - public String toString() { - return "Configuration{" + - "nodes=" + nodes + - '}'; - } } diff --git a/src/main/java/io/gardenlinux/glvd/dto/CpeMatch.java b/src/main/java/io/gardenlinux/glvd/dto/CpeMatch.java index dc29260..7d6ea3a 100644 --- a/src/main/java/io/gardenlinux/glvd/dto/CpeMatch.java +++ b/src/main/java/io/gardenlinux/glvd/dto/CpeMatch.java @@ -1,81 +1,6 @@ package io.gardenlinux.glvd.dto; -import java.util.Objects; +public record CpeMatch(String criteria, Deb deb, boolean vulnerable, String versionStartIncluding, + String versionEndExcluding, String matchCriteriaId) { -public class CpeMatch { - private String criteria; - private Deb deb; - private boolean vulnerable; - private String versionStartIncluding; - private String versionEndExcluding; - private String matchCriteriaId; - - public CpeMatch() { - } - - - public CpeMatch(String criteria, Deb deb, boolean vulnerable, String versionStartIncluding, String versionEndExcluding, String matchCriteriaId) { - this.criteria = criteria; - this.deb = deb; - this.vulnerable = vulnerable; - this.versionStartIncluding = versionStartIncluding; - this.versionEndExcluding = versionEndExcluding; - this.matchCriteriaId = matchCriteriaId; - } - - public String getVersionStartIncluding() { - return versionStartIncluding; - } - - public String getCriteria() { - return criteria; - } - - public Deb getDeb() { - return deb; - } - - public boolean isVulnerable() { - return vulnerable; - } - - public String getVersionEndExcluding() { - return versionEndExcluding; - } - - public String getMatchCriteriaId() { - return matchCriteriaId; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - CpeMatch cpeMatch = (CpeMatch) o; - return vulnerable == cpeMatch.vulnerable && Objects.equals(criteria, cpeMatch.criteria) && Objects.equals(deb, cpeMatch.deb) && Objects.equals(versionStartIncluding, cpeMatch.versionStartIncluding) && Objects.equals(versionEndExcluding, cpeMatch.versionEndExcluding) && Objects.equals(matchCriteriaId, cpeMatch.matchCriteriaId); - } - - @Override - public int hashCode() { - int result = Objects.hashCode(criteria); - result = 31 * result + Objects.hashCode(deb); - result = 31 * result + Boolean.hashCode(vulnerable); - result = 31 * result + Objects.hashCode(versionStartIncluding); - result = 31 * result + Objects.hashCode(versionEndExcluding); - result = 31 * result + Objects.hashCode(matchCriteriaId); - return result; - } - - @Override - public String toString() { - return "CpeMatch{" + - "criteria='" + criteria + '\'' + - ", deb=" + deb + - ", vulnerable=" + vulnerable + - ", versionStartIncluding='" + versionStartIncluding + '\'' + - ", versionEndExcluding='" + versionEndExcluding + '\'' + - ", matchCriteriaId='" + matchCriteriaId + '\'' + - '}'; - } } diff --git a/src/main/java/io/gardenlinux/glvd/dto/Cve.java b/src/main/java/io/gardenlinux/glvd/dto/Cve.java index 39888d4..b754c23 100644 --- a/src/main/java/io/gardenlinux/glvd/dto/Cve.java +++ b/src/main/java/io/gardenlinux/glvd/dto/Cve.java @@ -1,130 +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 sourceIdentifier; - - private String published; - - private String vulnStatus; - - private List descriptions; - - private Object metrics; - - private List references; - - private List weaknesses; - - private List configurations; - - - public Cve() { - } - public Cve(String id, @Nonnull String lastModified, @Nonnull String sourceIdentifier, String published, String vulnStatus, List descriptions, Object metrics, List references, List weaknesses, List configurations) { - this.id = id; - this.lastModified = lastModified; - this.sourceIdentifier = sourceIdentifier; - this.published = published; - this.vulnStatus = vulnStatus; - this.descriptions = descriptions; - this.metrics = metrics; - this.references = references; - this.weaknesses = weaknesses; - this.configurations = configurations; - } +public record Cve(String id, String lastModified, String sourceIdentifier, String published, String vulnStatus, + List descriptions, Object metrics, List references, List weaknesses, + List configurations) { - public String getId() { - return id; - } - - @Nonnull - public String getLastModified() { - return lastModified; - } - - @Nonnull - public String getSourceIdentifier() { - return sourceIdentifier; - } - - public String getPublished() { - return published; - } - - public String getVulnStatus() { - return vulnStatus; - } - - public List getDescriptions() { - return descriptions; - } - - public Object getMetrics() { - return metrics; - } - - public List getReferences() { - return references; - } - - public List getWeaknesses() { - return weaknesses; - } - - public List getConfigurations() { - return configurations; - } - - @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) && sourceIdentifier.equals(cve.sourceIdentifier) && Objects.equals(published, cve.published) && Objects.equals(vulnStatus, cve.vulnStatus) && Objects.equals(descriptions, cve.descriptions) && Objects.equals(metrics, cve.metrics) && Objects.equals(references, cve.references) && Objects.equals(weaknesses, cve.weaknesses) && Objects.equals(configurations, cve.configurations); - } - - @Override - public int hashCode() { - int result = Objects.hashCode(id); - result = 31 * result + lastModified.hashCode(); - result = 31 * result + sourceIdentifier.hashCode(); - result = 31 * result + Objects.hashCode(published); - result = 31 * result + Objects.hashCode(vulnStatus); - result = 31 * result + Objects.hashCode(descriptions); - result = 31 * result + Objects.hashCode(metrics); - result = 31 * result + Objects.hashCode(references); - result = 31 * result + Objects.hashCode(weaknesses); - result = 31 * result + Objects.hashCode(configurations); - return result; - } - - @Override - public String toString() { - return "Cve{" + - "id='" + id + '\'' + - ", lastModified='" + lastModified + '\'' + - ", sourceIdentifier='" + sourceIdentifier + '\'' + - ", published='" + published + '\'' + - ", vulnStatus='" + vulnStatus + '\'' + - ", descriptions=" + descriptions + - ", metrics=" + metrics + - ", references=" + references + - ", weaknesses=" + weaknesses + - ", configurations=" + configurations + - '}'; - } } + diff --git a/src/main/java/io/gardenlinux/glvd/dto/Deb.java b/src/main/java/io/gardenlinux/glvd/dto/Deb.java index c33713e..5267e32 100644 --- a/src/main/java/io/gardenlinux/glvd/dto/Deb.java +++ b/src/main/java/io/gardenlinux/glvd/dto/Deb.java @@ -1,56 +1,5 @@ package io.gardenlinux.glvd.dto; -import java.util.Objects; +public record Deb(String versionLatest, String versionEndExcluding, String cvssSeverity) { -public class Deb { - private String versionLatest; - private String versionEndExcluding; - private String cvssSeverity; - - public Deb() { - } - - public Deb(String versionLatest, String versionEndExcluding, String cvssSeverity) { - this.versionLatest = versionLatest; - this.versionEndExcluding = versionEndExcluding; - this.cvssSeverity = cvssSeverity; - } - - public String getVersionLatest() { - return versionLatest; - } - - public String getVersionEndExcluding() { - return versionEndExcluding; - } - - public String getCvssSeverity() { - return cvssSeverity; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Deb deb = (Deb) o; - return Objects.equals(versionLatest, deb.versionLatest) && Objects.equals(versionEndExcluding, deb.versionEndExcluding) && Objects.equals(cvssSeverity, deb.cvssSeverity); - } - - @Override - public int hashCode() { - int result = Objects.hashCode(versionLatest); - result = 31 * result + Objects.hashCode(versionEndExcluding); - result = 31 * result + Objects.hashCode(cvssSeverity); - return result; - } - - @Override - public String toString() { - return "Deb{" + - "versionLatest='" + versionLatest + '\'' + - ", versionEndExcluding='" + versionEndExcluding + '\'' + - ", cvssSeverity='" + cvssSeverity + '\'' + - '}'; - } } diff --git a/src/main/java/io/gardenlinux/glvd/dto/Description.java b/src/main/java/io/gardenlinux/glvd/dto/Description.java index ffb704e..48727ee 100644 --- a/src/main/java/io/gardenlinux/glvd/dto/Description.java +++ b/src/main/java/io/gardenlinux/glvd/dto/Description.java @@ -1,42 +1,4 @@ package io.gardenlinux.glvd.dto; -import java.util.Objects; - -public class Description { - - private String lang; - - private String value; - - public Description() { - } - - public Description(String lang, String value) { - this.lang = lang; - this.value = value; - } - - public String getLang() { - return lang; - } - - public String getValue() { - return value; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Description that = (Description) o; - return Objects.equals(lang, that.lang) && Objects.equals(value, that.value); - } - - @Override - public int hashCode() { - int result = Objects.hashCode(lang); - result = 31 * result + Objects.hashCode(value); - return result; - } +public record Description(String lang, String value) { } diff --git a/src/main/java/io/gardenlinux/glvd/dto/Node.java b/src/main/java/io/gardenlinux/glvd/dto/Node.java index a28261d..91c6651 100644 --- a/src/main/java/io/gardenlinux/glvd/dto/Node.java +++ b/src/main/java/io/gardenlinux/glvd/dto/Node.java @@ -1,40 +1,7 @@ package io.gardenlinux.glvd.dto; import java.util.List; -import java.util.Objects; -public class Node { - private List cpeMatch; - private boolean negate; - private String operator; +public record Node(List cpeMatch, boolean negate, String operator) { - public Node() { - } - - public Node(List cpeMatch, boolean negate, String operator) { - this.cpeMatch = cpeMatch; - this.negate = negate; - this.operator = operator; - } - - public List getCpeMatch() { - return cpeMatch; - } - - public boolean isNegate() { - return negate; - } - - public String getOperator() { - return operator; - } - - @Override - public String toString() { - return "Node{" + - "cpeMatch=" + cpeMatch + - ", negate=" + negate + - ", operator='" + operator + '\'' + - '}'; - } } diff --git a/src/main/java/io/gardenlinux/glvd/dto/Readiness.java b/src/main/java/io/gardenlinux/glvd/dto/Readiness.java index 671a24a..04cf1a3 100644 --- a/src/main/java/io/gardenlinux/glvd/dto/Readiness.java +++ b/src/main/java/io/gardenlinux/glvd/dto/Readiness.java @@ -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) { } diff --git a/src/main/java/io/gardenlinux/glvd/dto/Reference.java b/src/main/java/io/gardenlinux/glvd/dto/Reference.java index d5802de..75d10bb 100644 --- a/src/main/java/io/gardenlinux/glvd/dto/Reference.java +++ b/src/main/java/io/gardenlinux/glvd/dto/Reference.java @@ -1,57 +1,7 @@ package io.gardenlinux.glvd.dto; import java.util.List; -import java.util.Objects; -public class Reference { - private String url; - private String source; - private List tags; +public record Reference(String url, String source, List tags) { - public Reference() { - } - - public Reference(String url, String source, List tags) { - this.url = url; - this.source = source; - this.tags = tags; - } - - public String getUrl() { - return url; - } - - public String getSource() { - return source; - } - - public List getTags() { - return tags; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Reference reference = (Reference) o; - return Objects.equals(url, reference.url) && Objects.equals(source, reference.source) && Objects.equals(tags, reference.tags); - } - - @Override - public int hashCode() { - int result = Objects.hashCode(url); - result = 31 * result + Objects.hashCode(source); - result = 31 * result + Objects.hashCode(tags); - return result; - } - - @Override - public String toString() { - return "Reference{" + - "url='" + url + '\'' + - ", source='" + source + '\'' + - ", tags=" + tags + - '}'; - } } diff --git a/src/main/java/io/gardenlinux/glvd/dto/Weakness.java b/src/main/java/io/gardenlinux/glvd/dto/Weakness.java index 5ce34ad..6f62882 100644 --- a/src/main/java/io/gardenlinux/glvd/dto/Weakness.java +++ b/src/main/java/io/gardenlinux/glvd/dto/Weakness.java @@ -1,60 +1,7 @@ package io.gardenlinux.glvd.dto; import java.util.List; -import java.util.Objects; -public class Weakness { +public record Weakness(String source, String type, List description) { - private String source; - - private String type; - - private List description; - - public Weakness() { - } - - public Weakness(String source, String type, List description) { - this.source = source; - this.type = type; - this.description = description; - } - - public String getSource() { - return source; - } - - public String getType() { - return type; - } - - public List getDescription() { - return description; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Weakness weakness = (Weakness) o; - return Objects.equals(source, weakness.source) && Objects.equals(type, weakness.type) && Objects.equals(description, weakness.description); - } - - @Override - public int hashCode() { - int result = Objects.hashCode(source); - result = 31 * result + Objects.hashCode(type); - result = 31 * result + Objects.hashCode(description); - return result; - } - - @Override - public String toString() { - return "Weakness{" + - "source='" + source + '\'' + - ", type='" + type + '\'' + - ", description=" + description + - '}'; - } } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 12930c7..2066b40 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -3,4 +3,4 @@ spring.datasource.url=jdbc:postgresql://localhost:5432/glvd spring.datasource.username=glvd spring.datasource.password=glvd spring.sql.init.mode=never -spring.jpa.properties.javax.persistence.query.timeout=5000 +jakarta.persistence.query.timeout=5000