Skip to content

Commit

Permalink
#609 Rename analyzer by worker
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Jul 11, 2018
1 parent b2c3f7b commit 921af22
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
6 changes: 3 additions & 3 deletions thehive-cortex/app/connectors/cortex/models/Job.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ class Job(model: JobModel, attributes: JsObject) extends EntityDef[JobModel, Job

case class CortexJob(
id: String,
analyzerId: String,
analyzerName: String,
analyzerDefinition: String,
workerId: String,
workerName: String,
workerDefinition: String,
artifact: CortexArtifact,
date: Date,
status: JobStatus.Type)
6 changes: 3 additions & 3 deletions thehive-cortex/app/connectors/cortex/models/JsonFormat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ object JsonFormat {
implicit val cortexJobReads: Reads[CortexJob] = Reads[CortexJob](json
for {
id (json \ "id").validate[String]
analyzerId (json \ "analyzerId").validate[String]
analyzerName = (json \ "analyzerName").validate[String].getOrElse(analyzerId)
analyzerDefinition = (json \ "analyzerDefinitionId").validate[String].getOrElse(analyzerId)
analyzerId (json \ "workerId").validate[String]
analyzerName = (json \ "workerName").validate[String].getOrElse(analyzerId)
analyzerDefinition = (json \ "workerDefinitionId").validate[String].getOrElse(analyzerId)
attributes = filterObject(json.as[JsObject], "tlp", "message", "parameters")
artifact = (json \ "artifact").validate[CortexArtifact]
.getOrElse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,28 +177,31 @@ class CortexActionSrv @Inject() (
objectType fields.getString("objectType").fold[Future[String]](Future.failed(MissingAttributeError("action.objectType")))(Future.successful)
objectId fields.getString("objectId").fold[Future[String]](Future.failed(MissingAttributeError("action.objectId")))(Future.successful)
(cortexClient, responder) getCortexClient
tlp = fields.getLong("tlp").getOrElse(2L)
message = fields.getString("message").getOrElse("")
parameters = fields.getValue("parameters") match {
case Some(o: JsObject) o
case _ JsObject.empty
}
entity getEntity(objectType, objectId)
entityJson auxSrv(entity, 10, withStats = false, removeUnaudited = true)
caze actionOperationSrv.findCaseEntity(entity).map(Some(_)).recover { case _ None }
tlp = fields.getLong("tlp").orElse(caze.map(_.tlp())).getOrElse(2L)
pap = caze.map(_.pap()).getOrElse(2L)
jobJson cortexClient.execute(
responder.id,
s"thehive:$objectType",
entityJson,
tlp,
pap,
message,
parameters)
job = jobJson.as[CortexJob] //(cortexActionJobReads(cortexClient.name))
action createSrv[ActionModel, Action](actionModel, Fields.empty
.set("objectType", entity.model.modelName)
.set("objectId", entity.id)
.set("responderId", job.analyzerId)
.set("responderName", job.analyzerName)
.set("responderDefinition", job.analyzerDefinition)
.set("responderId", job.workerId)
.set("responderName", job.workerName)
.set("responderDefinition", job.workerDefinition)
//.set("status", JobStatus.InProgress)
.set("objectType", objectType)
.set("objectId", objectId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@ class CortexAnalyzerSrv @Inject() (
cortexJobJson cortex.analyze(analyzer.id, cortexArtifact)
cortexJob = cortexJobJson.as[CortexJob]
job create(artifact, Fields.empty
.set("analyzerId", cortexJob.analyzerId)
.set("analyzerName", cortexJob.analyzerName)
.set("analyzerDefinition", cortexJob.analyzerDefinition)
.set("analyzerId", cortexJob.workerId)
.set("analyzerName", cortexJob.workerName)
.set("analyzerDefinition", cortexJob.workerDefinition)
.set("artifactId", artifactId)
.set("cortexId", cortex.name)
.set("cortexJobId", cortexJob.id))
Expand Down

0 comments on commit 921af22

Please sign in to comment.