Skip to content

Commit

Permalink
#52 remove debug
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Aug 31, 2017
1 parent 1b49540 commit 3d8ad58
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
8 changes: 1 addition & 7 deletions thehive-misp/app/connectors/misp/MispExport.scala
Expand Up @@ -131,14 +131,10 @@ class MispExport @Inject() (

for {
(maybeAlertId, maybeEventId) relatedMispEvent(mispName, caze.id)
_ = println(s"[0] $maybeAlertId $maybeEventId")
attributes mispSrv.getAttributesFromCase(caze)
_ = println(s"[1] $attributes")
uniqueAttributes = removeDuplicateAttributes(attributes)
_ = println(s"[2] $uniqueAttributes")
(eventId, existingAttributes) maybeEventId.fold {
val simpleAttributes = uniqueAttributes.filter(_.value.isLeft)
println(s"[3] $simpleAttributes")
// if no event is associated to this case, create a new one
createEvent(mispConnection, caze.title(), caze.severity(), caze.startDate(), simpleAttributes).map {
case (eventId, exportedAttributes) eventId exportedAttributes.map(_.value.map(_.name))
Expand All @@ -152,11 +148,9 @@ class MispExport @Inject() (
}
}
}
_ = println(s"[4] $existingAttributes")
newAttributes = uniqueAttributes.filterNot(attr existingAttributes.contains(attr.value.map(_.name)))
_ = println(s"[5] $newAttributes")
exportedArtifact Future.traverse(newAttributes)(attr exportAttribute(mispConnection, eventId, attr).toTry)
_ = println(s"[6] $exportedArtifact")
alert maybeAlertId.fold {
alert maybeAlertId.fold {
alertSrv.create(Fields(Json.obj(
"type" "misp",
Expand Down
6 changes: 2 additions & 4 deletions thehive-misp/app/connectors/misp/MispSrv.scala
Expand Up @@ -79,12 +79,10 @@ class MispSrv @Inject() (

def getAttributesFromCase(caze: Case): Future[Seq[ExportedMispAttribute]] = {
import org.elastic4play.services.QueryDSL._
val (artifacts, totalArtifacts) = artifactSrv
artifactSrv
.find(and(withParent(caze), "status" ~= "Ok"), Some("all"), Nil)
totalArtifacts.foreach(t println(s"Case ${caze.id} has $t artifact(s)"))
artifacts
._1
.map { artifact
println(s"[-] $artifact")
val (category, tpe) = fromArtifact(artifact.dataType(), artifact.data())
val value = (artifact.data(), artifact.attachment()) match {
case (Some(data), None) Left(data)
Expand Down

0 comments on commit 3d8ad58

Please sign in to comment.