Skip to content

Commit

Permalink
#128 Search analyzer using its name where MISP query a job
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Sep 12, 2018
1 parent dec9853 commit 334feb1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions app/org/thp/cortex/services/MispSrv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import org.apache.commons.codec.binary.Base64
import org.thp.cortex.models._
import org.thp.cortex.services.AuditActor.Register

import org.elastic4play.NotFoundError
import org.elastic4play.services._

@Singleton
Expand Down Expand Up @@ -58,12 +59,15 @@ class MispSrv @Inject() (
}

def query(module: String, mispType: String, data: String)(implicit authContext: AuthContext): Future[JsObject] = {
import org.elastic4play.services.QueryDSL._

val artifact: Either[String, Attachment] = toArtifact(mispType, data)
val duration = 20.minutes // TODO configurable

for {
analyzer workerSrv.get(module)
job jobSrv.create(analyzer, mispType2dataType(mispType), artifact, 0, 0, "", JsObject.empty, None, force = false)
analyzer workerSrv.findAnalyzersForUser(authContext.userId, "name" ~= module, Some("0-1"), Nil)._1.runWith(Sink.headOption)
job analyzer.map(jobSrv.create(_, mispType2dataType(mispType), artifact, 0, 0, "", JsObject.empty, None, force = false))
.getOrElse(Future.failed(NotFoundError(s"Module $module not found")))
_ auditActor.ask(Register(job.id, duration))(Timeout(duration))
updatedJob jobSrv.getForUser(authContext.userId, job.id)
mispOutput toMispOutput(authContext.userId, updatedJob)
Expand Down
2 changes: 1 addition & 1 deletion docker.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dockerCommands ~= { dc =>
ExecCmd("RUN", "bash", "-c",
"apt-get update && " +
"apt-get install -y --no-install-recommends python-pip python2.7-dev python3-pip python3-dev ssdeep libfuzzy-dev libfuzzy2 libimage-exiftool-perl libmagic1 build-essential git libssl-dev && " +
"pip install -U pip setuptools && " +
"pip2 install -U pip setuptools && " +
"pip3 install -U pip setuptools && " +
"cd /opt && " +
"git clone https://github.com/TheHive-Project/Cortex-Analyzers.git && " +
Expand Down

0 comments on commit 334feb1

Please sign in to comment.