diff --git a/ScalliGraph b/ScalliGraph index 8a7900ffdb..b2a923dc4c 160000 --- a/ScalliGraph +++ b/ScalliGraph @@ -1 +1 @@ -Subproject commit 8a7900ffdbf11ed6e29e0dfa450e3e1ca776af35 +Subproject commit b2a923dc4c6d997ececf8d22c7b04abdbdeac40a diff --git a/migration/src/main/scala/org/thp/thehive/migration/th3/DBGet.scala b/migration/src/main/scala/org/thp/thehive/migration/th3/DBGet.scala index d6f6983175..7994058184 100644 --- a/migration/src/main/scala/org/thp/thehive/migration/th3/DBGet.scala +++ b/migration/src/main/scala/org/thp/thehive/migration/th3/DBGet.scala @@ -19,19 +19,18 @@ class DBGet @Inject() (db: DBConfiguration, implicit val ec: ExecutionContext) { */ def apply(modelName: String, id: String): Future[JsObject] = db.execute { - // Search by id is not possible on child entity without routing information ⇒ id query - search(db.indexName) - .query(idsQuery(id) /*.types(modelName)*/ ) - .size(1) - .version(true) - } - .map { searchResponse => - searchResponse - .hits - .hits - .headOption - .fold[JsObject](throw NotFoundError(s"$modelName $id not found")) { hit => - DBUtils.hit2json(hit) - } - } + // Search by id is not possible on child entity without routing information => id query + search(db.indexName) + .query(idsQuery(id) /*.types(modelName)*/ ) + .size(1) + .version(true) + }.map { searchResponse => + searchResponse + .hits + .hits + .headOption + .fold[JsObject](throw NotFoundError(s"$modelName $id not found")) { hit => + DBUtils.hit2json(hit) + } + } } diff --git a/thehive/app/org/thp/thehive/controllers/v0/Router.scala b/thehive/app/org/thp/thehive/controllers/v0/Router.scala index 2f219da332..96f8327e37 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/Router.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/Router.scala @@ -75,7 +75,7 @@ class Router @Inject() ( // case GET(p"/case/task/log/$logId") => logCtrl.get(logId) case POST(p"/case/artifact/_search") => observableCtrl.search - // case POST(p"/case/:caseId/artifact/_search") ⇒ observableCtrl.findInCase(caseId) + // case POST(p"/case/:caseId/artifact/_search") => observableCtrl.findInCase(caseId) case POST(p"/case/artifact/_stats") => observableCtrl.stats case POST(p"/case/$caseId/artifact") => observableCtrl.create(caseId) // Audit ok case GET(p"/case/artifact/$observableId") => observableCtrl.get(observableId) diff --git a/thehive/app/org/thp/thehive/controllers/v1/Conversion.scala b/thehive/app/org/thp/thehive/controllers/v1/Conversion.scala index f7f2db0dbc..53c6e2c158 100644 --- a/thehive/app/org/thp/thehive/controllers/v1/Conversion.scala +++ b/thehive/app/org/thp/thehive/controllers/v1/Conversion.scala @@ -48,13 +48,13 @@ object Conversion { .withFieldComputed(_._createdAt, _._createdAt) .withFieldComputed(_._createdBy, _._createdBy) .withFieldComputed(_.obj, a => a.`object`.map(OutputEntity.apply)) - // .withFieldComputed(_.obj, a ⇒ OutputEntity(a.obj)) + // .withFieldComputed(_.obj, a => OutputEntity(a.obj)) // .withFieldComputed( // _.summary, // _.summary.mapValues( - // opCount ⇒ + // opCount => // opCount.map { - // case (op, count) ⇒ op.toString → count + // case (op, count) => op.toString → count // } // ) .withFieldConst(_.attributeName, None) // FIXME diff --git a/thehive/app/org/thp/thehive/controllers/v1/Router.scala b/thehive/app/org/thp/thehive/controllers/v1/Router.scala index 3549028b14..a04cc7769d 100644 --- a/thehive/app/org/thp/thehive/controllers/v1/Router.scala +++ b/thehive/app/org/thp/thehive/controllers/v1/Router.scala @@ -36,16 +36,16 @@ class Router @Inject() ( case PATCH(p"/case/$caseId") => caseCtrl.update(caseId) case POST(p"/case/_merge/$caseIds") => caseCtrl.merge(caseIds) case DELETE(p"/case/$caseId") => caseCtrl.delete(caseId) -// case PATCH(p"api/case/_bulk") ⇒ caseCtrl.bulkUpdate() -// case POST(p"/case/_stats") ⇒ caseCtrl.stats() -// case DELETE(p"/case/$caseId/force") ⇒ caseCtrl.realDelete(caseId) -// case GET(p"/case/$caseId/links") ⇒ caseCtrl.linkedCases(caseId) +// case PATCH(p"api/case/_bulk") => caseCtrl.bulkUpdate() +// case POST(p"/case/_stats") => caseCtrl.stats() +// case DELETE(p"/case/$caseId/force") => caseCtrl.realDelete(caseId) +// case GET(p"/case/$caseId/links") => caseCtrl.linkedCases(caseId) case GET(p"/caseTemplate") => caseTemplateCtrl.list case POST(p"/caseTemplate") => caseTemplateCtrl.create case GET(p"/caseTemplate/$caseTemplateId") => caseTemplateCtrl.get(caseTemplateId) case PATCH(p"/caseTemplate/$caseTemplateId") => caseTemplateCtrl.update(caseTemplateId) - //case DELETE(p"/caseTemplate/$caseTemplateId") ⇒ caseTemplateCtrl.delete(caseTemplateId) + //case DELETE(p"/caseTemplate/$caseTemplateId") => caseTemplateCtrl.delete(caseTemplateId) case POST(p"/user") => userCtrl.create case GET(p"/user/current") => userCtrl.current @@ -64,10 +64,10 @@ class Router @Inject() ( case GET(p"/organisation/$organisationId") => organisationCtrl.get(organisationId) case PATCH(p"/organisation/$organisationId") => organisationCtrl.update(organisationId) -// case GET(p"/share") ⇒ shareCtrl.list -// case POST(p"/share") ⇒ shareCtrl.create -// case GET(p"/share/$shareId") ⇒ shareCtrl.get(shareId) -// case PATCH(p"/share/$shareId") ⇒ shareCtrl.update(shareId) +// case GET(p"/share") => shareCtrl.list +// case POST(p"/share") => shareCtrl.create +// case GET(p"/share/$shareId") => shareCtrl.get(shareId) +// case PATCH(p"/share/$shareId") => shareCtrl.update(shareId) case GET(p"/task") => taskCtrl.list case POST(p"/task") => taskCtrl.create diff --git a/thehive/app/org/thp/thehive/services/CaseSrv.scala b/thehive/app/org/thp/thehive/services/CaseSrv.scala index 69b4bd66a3..c58479fdee 100644 --- a/thehive/app/org/thp/thehive/services/CaseSrv.scala +++ b/thehive/app/org/thp/thehive/services/CaseSrv.scala @@ -310,8 +310,8 @@ class CaseSrv @Inject() ( // .flatMap(_.customFields().toList // .groupBy(_.name) // .foreach { -// case (name, l) ⇒ -// val values = l.collect { case cfwv: CustomFieldWithValue if cfwv.value.isDefined ⇒ cfwv.value.get } +// case (name, l) => +// val values = l.collect { case cfwv: CustomFieldWithValue if cfwv.value.isDefined => cfwv.value.get } // val cf = customFieldSrv.getOrFail(name) // val caseCustomField = // if (values.size == 1) cf.`type`.setValue(CaseCustomField(), values.head) @@ -324,12 +324,12 @@ class CaseSrv @Inject() ( // cases // .map(get) // .flatMap(_.tasks.toList -// .foreach(task ⇒ caseTaskSrv.create(CaseTask(), task, mergedCase)) +// .foreach(task => caseTaskSrv.create(CaseTask(), task, mergedCase)) // // cases // .map(get) // .flatMap(_.observables.toList -// .foreach(observable ⇒ observableCaseSrv.create(ObservableCase(), observable, mergedCase)) +// .foreach(observable => observableCaseSrv.create(ObservableCase(), observable, mergedCase)) // // get(mergedCase).richCase.head // } diff --git a/thehive/app/org/thp/thehive/services/package.scala b/thehive/app/org/thp/thehive/services/package.scala deleted file mode 100644 index e0d654e7dd..0000000000 --- a/thehive/app/org/thp/thehive/services/package.scala +++ /dev/null @@ -1,29 +0,0 @@ -//package org.thp.thehive -// -//import org.thp.scalligraph.steps.VertexSteps -// -//package object services { -// -// implicit class EntityStepsOps[E <: Product](steps: Traversal.V[Vertex][E]) { -// def asCase: Traversal.V[Case] = steps match { -// case caseSteps: Traversal.V[Case] => caseSteps -// case _ => new CaseSteps(steps.raw)(steps.db, steps.graph) -// } -// def asTask: Traversal.V[Task] = steps match { -// case taskSteps: Traversal.V[Task] => taskSteps -// case _ => new TaskSteps(steps.raw)(steps.db, steps.graph) -// } -// def asLog: Traversal.V[Log] = steps match { -// case logSteps: Traversal.V[Log] => logSteps -// case _ => new LogSteps(steps.raw)(steps.db, steps.graph) -// } -// def asObservable: Traversal.V[Observable] = steps match { -// case observableSteps: Traversal.V[Observable] => observableSteps -// case _ => new ObservableSteps(steps.raw)(steps.db, steps.graph) -// } -// def asAlert: Traversal.V[Alert] = steps match { -// case alertSteps: Traversal.V[Alert] => alertSteps -// case _ => new AlertSteps(steps.raw)(steps.db, steps.graph) -// } -// } -//} diff --git a/thehive/test/org/thp/thehive/services/CaseSrvTest.scala b/thehive/test/org/thp/thehive/services/CaseSrvTest.scala index 2843c291ac..75a105d0b9 100644 --- a/thehive/test/org/thp/thehive/services/CaseSrvTest.scala +++ b/thehive/test/org/thp/thehive/services/CaseSrvTest.scala @@ -143,7 +143,7 @@ class CaseSrvTest extends PlaySpecification with TestAppBuilder { "merge two cases" in testApp { app => pending // app[Database].transaction { implicit graph => - // Seq("#2", "#3").toTry(app[CaseSrv].getOrFail) must beSuccessfulTry.which { cases: Seq[Case with Entity] ⇒ + // Seq("#2", "#3").toTry(app[CaseSrv].getOrFail) must beSuccessfulTry.which { cases: Seq[Case with Entity] => // val mergedCase = app[CaseSrv].merge(cases)(graph, dummyUserSrv.getSystemAuthContext) // // mergedCase.title must_=== "case#2 / case#3" @@ -159,7 +159,7 @@ class CaseSrvTest extends PlaySpecification with TestAppBuilder { // mergedCase.summary must beNone // mergedCase.impactStatus must beNone // mergedCase.user must beSome("test") - // mergedCase.customFields.map(f ⇒ (f.name, f.typeName, f.value)) must contain( + // mergedCase.customFields.map(f => (f.name, f.typeName, f.value)) must contain( // allOf[(String, String, Option[Any])]( // ("boolean1", "boolean", Some(true)), // ("string1", "string", Some("string1 custom field"))