Skip to content

Commit

Permalink
#1685 Add observable tags configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Dec 21, 2020
1 parent cfb2f31 commit 089e896
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,13 @@ class MispImportSrv @Inject() (
.runWith(Sink.queue[(Observable, ObservableType with Entity, Set[String], Either[String, (String, String, Source[ByteString, _])])])
QueueIterator(queue).foreach {
case (observable, observableType, tags, Left(data)) =>
updateOrCreateObservable(alert, observable, observableType, data, tags, lastSynchro.isEmpty)
updateOrCreateObservable(alert, observable, observableType, data, tags ++ client.observableTags, lastSynchro.isEmpty)
.recover {
case error =>
logger.error(s"Unable to create observable $observable ${observableType.name}:$data", error)
}
case (observable, observableType, tags, Right((filename, contentType, src))) =>
updateOrCreateObservable(alert, observable, observableType, filename, contentType, src, tags, lastSynchro.isEmpty)
updateOrCreateObservable(alert, observable, observableType, filename, contentType, src, tags ++ client.observableTags, lastSynchro.isEmpty)
.recover {
case error =>
logger.error(s"Unable to create observable $observable ${observableType.name}:$filename", error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ case class TheHiveMispClientConfig(
whitelistTags: Set[String] = Set.empty,
purpose: MispPurpose.Value = MispPurpose.ImportAndExport,
caseTemplate: Option[String],
artifactTags: Seq[String] = Nil,
observableTags: Seq[String] = Nil,
exportCaseTags: Boolean = false,
exportObservableTags: Boolean = false,
includedTheHiveOrganisations: Seq[String] = Seq("*"),
Expand All @@ -50,7 +50,7 @@ object TheHiveMispClientConfig {
whitelistTags <- (JsPath \ "whitelist" \ "tags").readWithDefault[Set[String]](Set.empty)
purpose <- (JsPath \ "purpose").readWithDefault[MispPurpose.Value](MispPurpose.ImportAndExport)
caseTemplate <- (JsPath \ "caseTemplate").readNullable[String]
artifactTags <- (JsPath \ "tags").readWithDefault[Seq[String]](Nil)
observableTags <- (JsPath \ "tags").readWithDefault[Seq[String]](Nil)
exportCaseTags <- (JsPath \ "exportCaseTags").readWithDefault[Boolean](false)
exportObservableTags <- (JsPath \ "exportObservableTags").readWithDefault[Boolean](false)
includedTheHiveOrganisations <- (JsPath \ "includedTheHiveOrganisations").readWithDefault[Seq[String]](Seq("*"))
Expand All @@ -67,7 +67,7 @@ object TheHiveMispClientConfig {
whitelistTags,
purpose,
caseTemplate,
artifactTags,
observableTags,
exportCaseTags,
exportObservableTags,
includedTheHiveOrganisations,
Expand All @@ -85,7 +85,7 @@ object TheHiveMispClientConfig {
"whitelistTags" -> Json.obj("whitelist" -> cfg.whitelistTags),
"purpose" -> cfg.purpose,
"caseTemplate" -> cfg.caseTemplate,
"tags" -> cfg.artifactTags,
"tags" -> cfg.observableTags,
"exportCaseTags" -> cfg.exportCaseTags,
"includedTheHiveOrganisations" -> cfg.includedTheHiveOrganisations,
"excludedTheHiveOrganisations" -> cfg.excludedTheHiveOrganisations
Expand All @@ -106,7 +106,7 @@ class TheHiveMispClient(
whitelistTags: Set[String],
purpose: MispPurpose.Value,
val caseTemplate: Option[String],
artifactTags: Seq[String], // FIXME use artifactTags
val observableTags: Seq[String],
val exportCaseTags: Boolean,
val exportObservableTags: Boolean,
includedTheHiveOrganisations: Seq[String],
Expand Down Expand Up @@ -136,7 +136,7 @@ class TheHiveMispClient(
config.whitelistTags,
config.purpose,
config.caseTemplate,
config.artifactTags,
config.observableTags,
config.exportCaseTags,
config.exportObservableTags,
config.includedTheHiveOrganisations,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class TestMispClientProvider @Inject() (Action: DefaultActionBuilder, implicit v
whitelistTags = Set.empty,
purpose = MispPurpose.ImportAndExport,
caseTemplate = None,
artifactTags = Seq("TEST"),
observableTags = Seq("TEST"),
exportCaseTags = true,
exportObservableTags = true,
includedTheHiveOrganisations = Seq("*"),
Expand Down

0 comments on commit 089e896

Please sign in to comment.