From dfc13e5231854844887d24e51ae63dbbe72d12e6 Mon Sep 17 00:00:00 2001 From: To-om Date: Mon, 22 Mar 2021 13:42:43 +0100 Subject: [PATCH] #1861 Remove whole text index on potential large text field --- ScalliGraph | 2 +- thehive/app/org/thp/thehive/models/Alert.scala | 2 +- thehive/app/org/thp/thehive/models/Case.scala | 4 ++-- thehive/app/org/thp/thehive/models/Log.scala | 2 +- thehive/app/org/thp/thehive/models/Observable.scala | 2 +- thehive/app/org/thp/thehive/models/Tag.scala | 3 ++- thehive/app/org/thp/thehive/models/Task.scala | 2 +- .../org/thp/thehive/models/TheHiveSchemaDefinition.scala | 8 ++++++++ .../org/thp/thehive/controllers/v0/StatusCtrlTest.scala | 2 +- 9 files changed, 18 insertions(+), 9 deletions(-) diff --git a/ScalliGraph b/ScalliGraph index b403c2c2db..7eace99b4d 160000 --- a/ScalliGraph +++ b/ScalliGraph @@ -1 +1 @@ -Subproject commit b403c2c2db7e163550022283512c1f6d0c9fe91a +Subproject commit 7eace99b4d7bd6605afff82c9fb7cd316a04abaf diff --git a/thehive/app/org/thp/thehive/models/Alert.scala b/thehive/app/org/thp/thehive/models/Alert.scala index 9a4dc54f03..4520dfd231 100644 --- a/thehive/app/org/thp/thehive/models/Alert.scala +++ b/thehive/app/org/thp/thehive/models/Alert.scala @@ -43,7 +43,7 @@ case class AlertTag() @DefineIndex(IndexType.standard, "source") @DefineIndex(IndexType.standard, "sourceRef") @DefineIndex(IndexType.fulltext, "title") -@DefineIndex(IndexType.fulltext, "description") +@DefineIndex(IndexType.fulltextOnly, "description") @DefineIndex(IndexType.standard, "severity") @DefineIndex(IndexType.standard, "date") @DefineIndex(IndexType.standard, "lastSyncDate") diff --git a/thehive/app/org/thp/thehive/models/Case.scala b/thehive/app/org/thp/thehive/models/Case.scala index bb3408bd1f..2d12f92754 100644 --- a/thehive/app/org/thp/thehive/models/Case.scala +++ b/thehive/app/org/thp/thehive/models/Case.scala @@ -83,7 +83,7 @@ case class CaseProcedure() @BuildVertexEntity @DefineIndex(IndexType.unique, "number") @DefineIndex(IndexType.fulltext, "title") -@DefineIndex(IndexType.fulltext, "description") +@DefineIndex(IndexType.fulltextOnly, "description") @DefineIndex(IndexType.standard, "severity") @DefineIndex(IndexType.standard, "startDate") @DefineIndex(IndexType.standard, "endDate") @@ -91,7 +91,7 @@ case class CaseProcedure() @DefineIndex(IndexType.standard, "tlp") @DefineIndex(IndexType.standard, "pap") @DefineIndex(IndexType.standard, "status") -@DefineIndex(IndexType.fulltext, "summary") +@DefineIndex(IndexType.fulltextOnly, "summary") @DefineIndex(IndexType.standard, "tags") @DefineIndex(IndexType.standard, "assignee") @DefineIndex(IndexType.standard, "organisationIds") diff --git a/thehive/app/org/thp/thehive/models/Log.scala b/thehive/app/org/thp/thehive/models/Log.scala index f1f48bf5f2..aad8f6b651 100644 --- a/thehive/app/org/thp/thehive/models/Log.scala +++ b/thehive/app/org/thp/thehive/models/Log.scala @@ -8,7 +8,7 @@ import java.util.Date @BuildEdgeEntity[Log, Attachment] case class LogAttachment() -@DefineIndex(IndexType.fulltext, "message") +@DefineIndex(IndexType.fulltextOnly, "message") @DefineIndex(IndexType.standard, "date") @DefineIndex(IndexType.standard, "taskId") @DefineIndex(IndexType.standard, "organisationIds") diff --git a/thehive/app/org/thp/thehive/models/Observable.scala b/thehive/app/org/thp/thehive/models/Observable.scala index 8b3201d41f..aa39712f10 100644 --- a/thehive/app/org/thp/thehive/models/Observable.scala +++ b/thehive/app/org/thp/thehive/models/Observable.scala @@ -17,7 +17,7 @@ case class ObservableData() @BuildEdgeEntity[Observable, Tag] case class ObservableTag() -@DefineIndex(IndexType.fulltext, "message") +@DefineIndex(IndexType.fulltextOnly, "message") @DefineIndex(IndexType.standard, "tlp") @DefineIndex(IndexType.standard, "ioc") @DefineIndex(IndexType.standard, "sighted") diff --git a/thehive/app/org/thp/thehive/models/Tag.scala b/thehive/app/org/thp/thehive/models/Tag.scala index 2acb23cc0f..ee98cc4f0e 100644 --- a/thehive/app/org/thp/thehive/models/Tag.scala +++ b/thehive/app/org/thp/thehive/models/Tag.scala @@ -4,7 +4,8 @@ import org.thp.scalligraph.BuildVertexEntity import org.thp.scalligraph.models.{DefineIndex, IndexType} @DefineIndex(IndexType.unique, "namespace", "predicate", "value") -@DefineIndex(IndexType.fulltext, "namespace", "predicate", "value", "description") +@DefineIndex(IndexType.fulltext, "namespace", "predicate", "value") +@DefineIndex(IndexType.fulltextOnly, "description") @BuildVertexEntity case class Tag( namespace: String, diff --git a/thehive/app/org/thp/thehive/models/Task.scala b/thehive/app/org/thp/thehive/models/Task.scala index 300f2f20e4..335580a0a2 100644 --- a/thehive/app/org/thp/thehive/models/Task.scala +++ b/thehive/app/org/thp/thehive/models/Task.scala @@ -21,7 +21,7 @@ case class TaskLog() @BuildVertexEntity @DefineIndex(IndexType.fulltext, "title") @DefineIndex(IndexType.standard, "group") -@DefineIndex(IndexType.fulltext, "description") +@DefineIndex(IndexType.fulltextOnly, "description") @DefineIndex(IndexType.standard, "status") @DefineIndex(IndexType.standard, "flag") @DefineIndex(IndexType.standard, "startDate") diff --git a/thehive/app/org/thp/thehive/models/TheHiveSchemaDefinition.scala b/thehive/app/org/thp/thehive/models/TheHiveSchemaDefinition.scala index e5e0e55460..c56932088d 100644 --- a/thehive/app/org/thp/thehive/models/TheHiveSchemaDefinition.scala +++ b/thehive/app/org/thp/thehive/models/TheHiveSchemaDefinition.scala @@ -391,6 +391,14 @@ class TheHiveSchemaDefinition @Inject() extends Schema with UpdatableSchema { traversal.outE("OrganisationDashboard").raw.property("writable", true).iterate() Success(()) } + //=====[release 4.1.0]===== + .removeIndex("Alert", IndexType.fulltext, "description") + .removeIndex("Case", IndexType.fulltext, "description", "summary") + .removeIndex("Log", IndexType.fulltext, "message") + .removeIndex("Observable", IndexType.fulltext, "message") + .removeIndex("Log", IndexType.fulltext, "message") + .removeIndex("Tag", IndexType.fulltext, "description") + .removeIndex("Task", IndexType.fulltext, "description") val reflectionClasses = new Reflections( new ConfigurationBuilder() diff --git a/thehive/test/org/thp/thehive/controllers/v0/StatusCtrlTest.scala b/thehive/test/org/thp/thehive/controllers/v0/StatusCtrlTest.scala index 77121cd741..e230120e39 100644 --- a/thehive/test/org/thp/thehive/controllers/v0/StatusCtrlTest.scala +++ b/thehive/test/org/thp/thehive/controllers/v0/StatusCtrlTest.scala @@ -70,7 +70,7 @@ class StatusCtrlTest extends PlaySpecification with TestAppBuilder { "pollingDuration" -> 1000 ), "schemaStatus" -> Json.arr( - Json.obj("name" -> "thehive", "currentVersion" -> 59, "expectedVersion" -> 59, "error" -> JsNull) + Json.obj("name" -> "thehive", "currentVersion" -> 66, "expectedVersion" -> 66, "error" -> JsNull) ) )