From 7f7ba89756341585a38922bc148cd38f26a012a9 Mon Sep 17 00:00:00 2001 From: Romuald Lemesle Date: Mon, 24 Jun 2024 16:40:15 +0200 Subject: [PATCH] [backend] Remove hypersistence type to use native array type --- .../executors/tanium/service/TaniumExecutorService.java | 5 ++++- .../main/java/io/openbas/database/model/AttackPattern.java | 4 ---- .../main/java/io/openbas/database/model/Communication.java | 5 +---- .../src/main/java/io/openbas/database/model/Endpoint.java | 4 ---- .../src/main/java/io/openbas/database/model/Executor.java | 3 --- .../java/io/openbas/database/model/InjectorContract.java | 2 -- .../src/main/java/io/openbas/database/model/Mitigation.java | 1 - .../src/main/java/io/openbas/database/model/Payload.java | 1 - 8 files changed, 5 insertions(+), 20 deletions(-) diff --git a/openbas-framework/src/main/java/io/openbas/executors/tanium/service/TaniumExecutorService.java b/openbas-framework/src/main/java/io/openbas/executors/tanium/service/TaniumExecutorService.java index fc4c53735a..f34c3434ac 100644 --- a/openbas-framework/src/main/java/io/openbas/executors/tanium/service/TaniumExecutorService.java +++ b/openbas-framework/src/main/java/io/openbas/executors/tanium/service/TaniumExecutorService.java @@ -22,7 +22,10 @@ import java.time.LocalDateTime; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; -import java.util.*; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; +import java.util.Optional; import java.util.logging.Level; import static java.time.Instant.now; diff --git a/openbas-model/src/main/java/io/openbas/database/model/AttackPattern.java b/openbas-model/src/main/java/io/openbas/database/model/AttackPattern.java index 5d8bda2f0c..56c535a037 100644 --- a/openbas-model/src/main/java/io/openbas/database/model/AttackPattern.java +++ b/openbas-model/src/main/java/io/openbas/database/model/AttackPattern.java @@ -2,7 +2,6 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import io.hypersistence.utils.hibernate.type.array.StringArrayType; import io.openbas.annotation.Queryable; import io.openbas.database.audit.ModelBaseListener; import io.openbas.helper.MonoIdDeserializer; @@ -10,7 +9,6 @@ import jakarta.persistence.*; import jakarta.validation.constraints.NotBlank; import lombok.Data; -import org.hibernate.annotations.Type; import org.hibernate.annotations.UuidGenerator; import java.time.Instant; @@ -56,12 +54,10 @@ public class AttackPattern implements Base { @NotBlank private String externalId; - @Type(StringArrayType.class) @Column(name = "attack_pattern_platforms", columnDefinition = "text[]") @JsonProperty("attack_pattern_platforms") private String[] platforms = new String[0]; - @Type(StringArrayType.class) @Column(name = "attack_pattern_permissions_required", columnDefinition = "text[]") @JsonProperty("attack_pattern_permissions_required") private String[] permissionsRequired = new String[0]; diff --git a/openbas-model/src/main/java/io/openbas/database/model/Communication.java b/openbas-model/src/main/java/io/openbas/database/model/Communication.java index a233acbaf8..b327138c5c 100644 --- a/openbas-model/src/main/java/io/openbas/database/model/Communication.java +++ b/openbas-model/src/main/java/io/openbas/database/model/Communication.java @@ -3,15 +3,13 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import io.hypersistence.utils.hibernate.type.array.StringArrayType; import io.openbas.database.audit.ModelBaseListener; import io.openbas.helper.MonoIdDeserializer; import io.openbas.helper.MultiIdListDeserializer; +import jakarta.persistence.*; import org.apache.commons.lang3.StringUtils; import org.hibernate.annotations.UuidGenerator; -import org.hibernate.annotations.Type; -import jakarta.persistence.*; import java.time.Instant; import java.util.ArrayList; import java.util.List; @@ -55,7 +53,6 @@ public class Communication implements Base { @JsonProperty("communication_content_html") private String contentHtml; - @Type(StringArrayType.class) @Column(name = "communication_attachments", columnDefinition = "text[]") @JsonProperty("communication_attachments") private String[] attachments; diff --git a/openbas-model/src/main/java/io/openbas/database/model/Endpoint.java b/openbas-model/src/main/java/io/openbas/database/model/Endpoint.java index 6fb96e738f..d7cd7f6c72 100644 --- a/openbas-model/src/main/java/io/openbas/database/model/Endpoint.java +++ b/openbas-model/src/main/java/io/openbas/database/model/Endpoint.java @@ -1,7 +1,6 @@ package io.openbas.database.model; import com.fasterxml.jackson.annotation.JsonProperty; -import io.hypersistence.utils.hibernate.type.array.StringArrayType; import io.openbas.annotation.Ipv4OrIpv6Constraint; import io.openbas.annotation.Queryable; import io.openbas.database.audit.ModelBaseListener; @@ -10,7 +9,6 @@ import jakarta.validation.constraints.NotNull; import lombok.Data; import lombok.EqualsAndHashCode; -import org.hibernate.annotations.Type; @EqualsAndHashCode(callSuper = true) @Data @@ -52,7 +50,6 @@ public enum PLATFORM_TYPE { @Queryable(filterable = true) @NotEmpty @Ipv4OrIpv6Constraint - @Type(StringArrayType.class) @Column(name = "endpoint_ips") @JsonProperty("endpoint_ips") private String[] ips; @@ -81,7 +78,6 @@ public enum PLATFORM_TYPE { @NotNull private PLATFORM_ARCH arch; - @Type(StringArrayType.class) @Column(name = "endpoint_mac_addresses") @JsonProperty("endpoint_mac_addresses") private String[] macAddresses; diff --git a/openbas-model/src/main/java/io/openbas/database/model/Executor.java b/openbas-model/src/main/java/io/openbas/database/model/Executor.java index d128eb1b54..1f23d96094 100644 --- a/openbas-model/src/main/java/io/openbas/database/model/Executor.java +++ b/openbas-model/src/main/java/io/openbas/database/model/Executor.java @@ -2,13 +2,11 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import io.hypersistence.utils.hibernate.type.array.StringArrayType; import io.openbas.database.audit.ModelBaseListener; import jakarta.persistence.*; import jakarta.validation.constraints.NotBlank; import lombok.Getter; import lombok.Setter; -import org.hibernate.annotations.Type; import java.time.Instant; import java.util.Objects; @@ -41,7 +39,6 @@ public class Executor implements Base { private String type; @Getter - @Type(StringArrayType.class) @Column(name = "executor_platforms", columnDefinition = "text[]") @JsonProperty("executor_platforms") private String[] platforms = new String[0]; diff --git a/openbas-model/src/main/java/io/openbas/database/model/InjectorContract.java b/openbas-model/src/main/java/io/openbas/database/model/InjectorContract.java index e0c45cac79..f6426231c1 100644 --- a/openbas-model/src/main/java/io/openbas/database/model/InjectorContract.java +++ b/openbas-model/src/main/java/io/openbas/database/model/InjectorContract.java @@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.node.ObjectNode; -import io.hypersistence.utils.hibernate.type.array.StringArrayType; import io.hypersistence.utils.hibernate.type.basic.PostgreSQLHStoreType; import io.openbas.annotation.Queryable; import io.openbas.database.audit.ModelBaseListener; @@ -63,7 +62,6 @@ public class InjectorContract implements Base { @JsonProperty("injector_contract_needs_executor") private Boolean needsExecutor = false; - @Type(StringArrayType.class) @Column(name = "injector_contract_platforms", columnDefinition = "text[]") @JsonProperty("injector_contract_platforms") private String[] platforms = new String[0]; diff --git a/openbas-model/src/main/java/io/openbas/database/model/Mitigation.java b/openbas-model/src/main/java/io/openbas/database/model/Mitigation.java index 6ca5d295db..5fbb768be1 100644 --- a/openbas-model/src/main/java/io/openbas/database/model/Mitigation.java +++ b/openbas-model/src/main/java/io/openbas/database/model/Mitigation.java @@ -54,7 +54,6 @@ public class Mitigation implements Base { @NotBlank private String externalId; - @Type(StringArrayType.class) @Column(name = "mitigation_log_sources", columnDefinition = "text[]") @JsonProperty("mitigation_log_sources") private String[] logSources = new String[0]; diff --git a/openbas-model/src/main/java/io/openbas/database/model/Payload.java b/openbas-model/src/main/java/io/openbas/database/model/Payload.java index 90d21098e6..1c71cc8822 100644 --- a/openbas-model/src/main/java/io/openbas/database/model/Payload.java +++ b/openbas-model/src/main/java/io/openbas/database/model/Payload.java @@ -65,7 +65,6 @@ public enum PAYLOAD_STATUS { @JsonProperty("payload_description") private String description; - @Type(StringArrayType.class) @Column(name = "payload_platforms", columnDefinition = "text[]") @JsonProperty("payload_platforms") private String[] platforms = new String[0];