Skip to content

Commit

Permalink
#110 add operations as result of active response
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Jun 21, 2018
1 parent e6552e1 commit d409944
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/org/thp/cortex/controllers/JobCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ class JobCtrl @Inject() (
"summary" -> Json.parse(report.summary()),
"full" -> Json.parse(report.full()),
"success" -> true,
"artifacts" -> artifacts)
"artifacts" -> artifacts,
"operations" -> Json.parse(report.operations()))
case JobStatus.Failure
val errorMessage = job.errorMessage().getOrElse("")
Future.successful(Json.obj(
Expand Down
1 change: 1 addition & 0 deletions app/org/thp/cortex/models/Report.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.elastic4play.models.{ AttributeDef, EntityDef, AttributeFormat ⇒ F,
trait ReportAttributes { _: AttributeDef
val full = attribute("full", F.textFmt, "Full content of the report", O.readonly)
val summary = attribute("summary", F.textFmt, "Summary of the report", O.readonly)
val operations = attribute("operations", F.textFmt, "Update operations applied at the end of the job", "[]", O.unaudited)
}

@Singleton
Expand Down
2 changes: 2 additions & 0 deletions app/org/thp/cortex/services/JobSrv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,11 @@ class JobSrv(
val fullReport = (report \ "full").as[JsObject].toString
val summaryReport = (report \ "summary").as[JsObject].toString
val artifacts = (report \ "artifacts").asOpt[Seq[JsObject]].getOrElse(Nil)
val operations = (report \ "operations").asOpt[Seq[JsObject]].getOrElse(Nil)
val reportFields = Fields.empty
.set("full", fullReport)
.set("summary", summaryReport)
.set("operations", JsArray(operations).toString)
createSrv[ReportModel, Report, Job](reportModel, job, reportFields)
.flatMap { report
Future.traverse(artifacts) { artifact
Expand Down
6 changes: 5 additions & 1 deletion test/resources/analyzers/echoAnalyzer/echoAnalyzer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ cat << EOF
"dataType": ${DATATYPE}
}
],
"full": ${ARTIFACT}
"full": ${ARTIFACT},
"operations": [
{ "type": "AddTagToCase", "tag": "From Action Operation" },
{ "type": "CreateTask", "title": "task created by action", "description": "yop !" }
]
}
EOF

0 comments on commit d409944

Please sign in to comment.