diff --git a/thehive/app/org/thp/thehive/controllers/v0/CaseCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/CaseCtrl.scala index ec72368785..9cd28662a3 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/CaseCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/CaseCtrl.scala @@ -135,17 +135,6 @@ class CaseCtrl @Inject() ( } def delete(caseIdOrNumber: String): Action[AnyContent] = - entrypoint("delete case") - .authTransaction(db) { implicit request => implicit graph => - caseSrv - .get(EntityIdOrName(caseIdOrNumber)) - .can(Permissions.manageCase) - .update(_.status, CaseStatus.Deleted) - .getOrFail("Case") - .map(_ => Results.NoContent) - } - - def realDelete(caseIdOrNumber: String): Action[AnyContent] = entrypoint("delete case") .authTransaction(db) { implicit request => implicit graph => for { diff --git a/thehive/app/org/thp/thehive/controllers/v0/Router.scala b/thehive/app/org/thp/thehive/controllers/v0/Router.scala index 96f8327e37..547c48faf7 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/Router.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/Router.scala @@ -91,10 +91,10 @@ class Router @Inject() ( case PATCH(p"/case/_bulk") => caseCtrl.bulkUpdate // Not used by the frontend case PATCH(p"/case/$caseId") => caseCtrl.update(caseId) // Audit ok case POST(p"/case/_merge/$caseIds") => caseCtrl.merge(caseIds) // Not implemented in backend and not used by frontend - case DELETE(p"/case/$caseId") => caseCtrl.delete(caseId) // Not used by frontend case POST(p"/case/_search") => caseCtrl.search case POST(p"/case/_stats") => caseCtrl.stats - case DELETE(p"/case/$caseId/force") => caseCtrl.realDelete(caseId) // Audit ok + case DELETE(p"/case/$caseId") => caseCtrl.delete(caseId) // Not used by the frontend + case DELETE(p"/case/$caseId/force") => caseCtrl.delete(caseId) // Audit ok case GET(p"/case/$caseId/links") => caseCtrl.linkedCases(caseId) case GET(p"/case/template") => caseTemplateCtrl.search diff --git a/thehive/app/org/thp/thehive/controllers/v1/CaseCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/CaseCtrl.scala index aeb3be90a7..3139f7d6e3 100644 --- a/thehive/app/org/thp/thehive/controllers/v1/CaseCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v1/CaseCtrl.scala @@ -112,12 +112,14 @@ class CaseCtrl @Inject() ( def delete(caseIdOrNumber: String): Action[AnyContent] = entrypoint("delete case") .authTransaction(db) { implicit request => implicit graph => - caseSrv - .get(EntityIdOrName(caseIdOrNumber)) - .can(Permissions.manageCase) - .update(_.status, CaseStatus.Deleted) - .getOrFail("Case") - .map(_ => Results.NoContent) + for { + c <- + caseSrv + .get(EntityIdOrName(caseIdOrNumber)) + .can(Permissions.manageCase) + .getOrFail("Case") + _ <- caseSrv.remove(c) + } yield Results.NoContent } def merge(caseIdsOrNumbers: String): Action[AnyContent] = diff --git a/thehive/app/org/thp/thehive/controllers/v1/Router.scala b/thehive/app/org/thp/thehive/controllers/v1/Router.scala index a04cc7769d..feffe865bb 100644 --- a/thehive/app/org/thp/thehive/controllers/v1/Router.scala +++ b/thehive/app/org/thp/thehive/controllers/v1/Router.scala @@ -38,7 +38,6 @@ class Router @Inject() ( 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 GET(p"/caseTemplate") => caseTemplateCtrl.list diff --git a/thehive/app/org/thp/thehive/models/Case.scala b/thehive/app/org/thp/thehive/models/Case.scala index fa18c888fe..1990523baf 100644 --- a/thehive/app/org/thp/thehive/models/Case.scala +++ b/thehive/app/org/thp/thehive/models/Case.scala @@ -8,7 +8,7 @@ import org.thp.scalligraph.models.{DefineIndex, Entity, IndexType} import play.api.libs.json.{Format, Json} object CaseStatus extends Enumeration { - val Open, Resolved, Deleted, Duplicated = Value + val Open, Resolved, Duplicated = Value implicit val format: Format[CaseStatus.Value] = Json.formatEnum(CaseStatus) } diff --git a/thehive/app/org/thp/thehive/services/notification/notifiers/Webhook.scala b/thehive/app/org/thp/thehive/services/notification/notifiers/Webhook.scala index de4e6d4c6f..20bec8981e 100644 --- a/thehive/app/org/thp/thehive/services/notification/notifiers/Webhook.scala +++ b/thehive/app/org/thp/thehive/services/notification/notifiers/Webhook.scala @@ -13,7 +13,6 @@ import org.thp.scalligraph.traversal.{Converter, IdentityConverter, Traversal} import org.thp.scalligraph.{BadConfigurationError, EntityIdOrName} import org.thp.thehive.controllers.v0.AuditRenderer import org.thp.thehive.controllers.v0.Conversion.fromObjectType -import org.thp.thehive.models.Audit._ import org.thp.thehive.models._ import org.thp.thehive.services.AlertOps._ import org.thp.thehive.services.AuditOps._ diff --git a/thehive/test/org/thp/thehive/controllers/v0/CaseCtrlTest.scala b/thehive/test/org/thp/thehive/controllers/v0/CaseCtrlTest.scala index e36be809b7..a3e623fe55 100644 --- a/thehive/test/org/thp/thehive/controllers/v0/CaseCtrlTest.scala +++ b/thehive/test/org/thp/thehive/controllers/v0/CaseCtrlTest.scala @@ -354,7 +354,7 @@ class CaseCtrlTest extends PlaySpecification with TestAppBuilder { val requestDel = FakeRequest("DELETE", s"/api/v0/case/#1/force") .withHeaders("user" -> "certuser@thehive.local") - val resultDel = app[CaseCtrl].realDelete("1")(requestDel) + val resultDel = app[CaseCtrl].delete("1")(requestDel) status(resultDel) must equalTo(204).updateMessage(s => s"$s\n${contentAsString(resultDel)}") app[Database].roTransaction { implicit graph =>