Skip to content

Commit

Permalink
#1545 Fix permission check in task creation
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Nov 13, 2020
1 parent 13dffe0 commit 6c48c56
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
2 changes: 1 addition & 1 deletion thehive/app/org/thp/thehive/controllers/v0/TaskCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class TaskCtrl @Inject() (
.authTransaction(db) { implicit request => implicit graph =>
val inputTask: InputTask = request.body("task")
for {
case0 <- caseSrv.getOrFail(caseId)
case0 <- caseSrv.get(caseId).can(Permissions.manageTask).getOrFail("Case")
owner <- inputTask.owner.map(userSrv.getOrFail).flip
createdTask <- taskSrv.create(inputTask.toTask, owner)
organisation <- organisationSrv.getOrFail(request.organisation)
Expand Down
3 changes: 2 additions & 1 deletion thehive/app/org/thp/thehive/controllers/v1/TaskCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.thp.thehive.controllers.v1.Conversion._
import org.thp.thehive.dto.v1.InputTask
import org.thp.thehive.models._
import org.thp.thehive.services.OrganisationOps._
import org.thp.thehive.services.CaseOps._
import org.thp.thehive.services.ShareOps._
import org.thp.thehive.services.TaskOps._
import org.thp.thehive.services.{CaseSrv, OrganisationSrv, ShareSrv, TaskSrv}
Expand Down Expand Up @@ -66,7 +67,7 @@ class TaskCtrl @Inject() (
val inputTask: InputTask = request.body("task")
val caseId: String = request.body("caseId")
for {
case0 <- caseSrv.getOrFail(caseId)
case0 <- caseSrv.get(caseId).can(Permissions.manageTask).getOrFail("Case")
createdTask <- taskSrv.create(inputTask.toTask, None)
organisation <- organisationSrv.getOrFail(request.organisation)
_ <- shareSrv.shareTask(createdTask, case0, organisation)
Expand Down
10 changes: 1 addition & 9 deletions thehive/app/org/thp/thehive/services/CaseSrv.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.thp.thehive.services

import java.util.{List => JList, Map => JMap}
import java.util.{Map => JMap}

import akka.actor.ActorRef
import javax.inject.{Inject, Named, Singleton}
Expand Down Expand Up @@ -459,14 +459,6 @@ object CaseOps {
def linkedCases(implicit authContext: AuthContext): Seq[(RichCase, Seq[RichObservable])] = {
val originCaseLabel = StepLabel.v[Case]
val observableLabel = StepLabel.v[Observable]
val linkedCaseLabel = StepLabel.v[Case]

val richCaseLabel = StepLabel[RichCase, JMap[String, Any], Converter[RichCase, JMap[String, Any]]]
val richObservablesLabel =
StepLabel[Seq[RichObservable], JList[JMap[String, Any]], Converter.CList[RichObservable, JMap[String, Any], Converter[
RichObservable,
JMap[String, Any]
]]]
traversal
.as(originCaseLabel)
.observables
Expand Down

0 comments on commit 6c48c56

Please sign in to comment.