diff --git a/dto/src/main/scala/org/thp/thehive/dto/v1/Pattern.scala b/dto/src/main/scala/org/thp/thehive/dto/v1/Pattern.scala index e905a9444d..6574766035 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v1/Pattern.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v1/Pattern.scala @@ -16,8 +16,7 @@ case class InputPattern( x_mitre_defense_bypassed: Seq[String], x_mitre_detection: Option[String], x_mitre_is_subtechnique: Boolean, - // TODO x_mitre_tactic_type ? - // TODO x_mitre_permissions_required ? + x_mitre_permissions_required: Seq[String], x_mitre_platforms: Seq[String], x_mitre_remote_support: Boolean, x_mitre_system_requirements: Seq[String], @@ -62,19 +61,20 @@ object InputPattern { for { references <- (json \ "external_references").validate[Seq[InputReference]] mitreReference = references.find(ref => isSourceNameValid(ref.source_name)) - name <- (json \ "name").validate[String] - description <- (json \ "description").validateOpt[String] - kill_chain_phases <- (json \ "kill_chain_phases").validateOpt[Seq[InputKillChainPhase]] - techniqueType <- (json \ "type").validate[String] - revoked <- (json \ "revoked").validateOpt[Boolean] - x_mitre_data_sources <- (json \ "x_mitre_data_sources").validateOpt[Seq[String]] - x_mitre_defense_bypassed <- (json \ "x_mitre_defense_bypassed").validateOpt[Seq[String]] - x_mitre_detection <- (json \ "x_mitre_detection").validateOpt[String] - x_mitre_is_subtechnique <- (json \ "x_mitre_is_subtechnique").validateOpt[Boolean] - x_mitre_platforms <- (json \ "x_mitre_platforms").validateOpt[Seq[String]] - x_mitre_remote_support <- (json \ "x_mitre_remote_support").validateOpt[Boolean] - x_mitre_system_requirements <- (json \ "x_mitre_system_requirements").validateOpt[Seq[String]] - x_mitre_version <- (json \ "x_mitre_version").validateOpt[String] + name <- (json \ "name").validate[String] + description <- (json \ "description").validateOpt[String] + kill_chain_phases <- (json \ "kill_chain_phases").validateOpt[Seq[InputKillChainPhase]] + techniqueType <- (json \ "type").validate[String] + revoked <- (json \ "revoked").validateOpt[Boolean] + x_mitre_data_sources <- (json \ "x_mitre_data_sources").validateOpt[Seq[String]] + x_mitre_defense_bypassed <- (json \ "x_mitre_defense_bypassed").validateOpt[Seq[String]] + x_mitre_detection <- (json \ "x_mitre_detection").validateOpt[String] + x_mitre_is_subtechnique <- (json \ "x_mitre_is_subtechnique").validateOpt[Boolean] + x_mitre_permissions_required <- (json \ "x_mitre_permissions_required").validateOpt[Seq[String]] + x_mitre_platforms <- (json \ "x_mitre_platforms").validateOpt[Seq[String]] + x_mitre_remote_support <- (json \ "x_mitre_remote_support").validateOpt[Boolean] + x_mitre_system_requirements <- (json \ "x_mitre_system_requirements").validateOpt[Seq[String]] + x_mitre_version <- (json \ "x_mitre_version").validateOpt[String] } yield InputPattern( mitreReference.flatMap(_.external_id).getOrElse(""), name, @@ -87,6 +87,7 @@ object InputPattern { x_mitre_defense_bypassed.getOrElse(Seq()), x_mitre_detection, x_mitre_is_subtechnique.getOrElse(false), + x_mitre_permissions_required.getOrElse(Seq()), x_mitre_platforms.getOrElse(Seq()), x_mitre_remote_support.getOrElse(false), x_mitre_system_requirements.getOrElse(Seq()), @@ -117,6 +118,7 @@ case class OutputPattern( dataSources: Seq[String], defenseBypassed: Seq[String], detection: Option[String], + permissionsRequired: Seq[String], platforms: Seq[String], remoteSupport: Boolean, systemRequirements: Seq[String], diff --git a/thehive/app/org/thp/thehive/controllers/v1/Conversion.scala b/thehive/app/org/thp/thehive/controllers/v1/Conversion.scala index e602a49715..e897061fe1 100644 --- a/thehive/app/org/thp/thehive/controllers/v1/Conversion.scala +++ b/thehive/app/org/thp/thehive/controllers/v1/Conversion.scala @@ -504,6 +504,7 @@ object Conversion { .withFieldRenamed(_.x_mitre_data_sources, _.dataSources) .withFieldRenamed(_.x_mitre_defense_bypassed, _.defenseBypassed) .withFieldRenamed(_.x_mitre_detection, _.detection) + .withFieldRenamed(_.x_mitre_permissions_required, _.permissionsRequired) .withFieldRenamed(_.x_mitre_platforms, _.platforms) .withFieldRenamed(_.x_mitre_remote_support, _.remoteSupport) .withFieldRenamed(_.x_mitre_system_requirements, _.systemRequirements) diff --git a/thehive/app/org/thp/thehive/controllers/v1/Properties.scala b/thehive/app/org/thp/thehive/controllers/v1/Properties.scala index 510d780a0e..8c770a85ec 100644 --- a/thehive/app/org/thp/thehive/controllers/v1/Properties.scala +++ b/thehive/app/org/thp/thehive/controllers/v1/Properties.scala @@ -350,6 +350,7 @@ class Properties @Inject() ( .property("dataSources", UMapping.string.sequence)(_.field.readonly) .property("defenseBypassed", UMapping.string.sequence)(_.field.readonly) .property("detection", UMapping.string.optional)(_.field.readonly) + .property("permissionsRequired", UMapping.string.sequence)(_.field.readonly) .property("platforms", UMapping.string.sequence)(_.field.readonly) .property("remoteSupport", UMapping.boolean)(_.field.readonly) .property("systemRequirements", UMapping.string.sequence)(_.field.readonly) diff --git a/thehive/app/org/thp/thehive/models/Pattern.scala b/thehive/app/org/thp/thehive/models/Pattern.scala index c1c0505b21..aa9c9ef5c5 100644 --- a/thehive/app/org/thp/thehive/models/Pattern.scala +++ b/thehive/app/org/thp/thehive/models/Pattern.scala @@ -17,6 +17,7 @@ case class Pattern( dataSources: Seq[String], defenseBypassed: Seq[String], detection: Option[String], + permissionsRequired: Seq[String], platforms: Seq[String], remoteSupport: Boolean, systemRequirements: Seq[String], @@ -27,23 +28,24 @@ case class Pattern( case class PatternPattern() case class RichPattern(pattern: Pattern with Entity, parent: Option[Pattern with Entity]) { - def patternId: String = pattern.patternId - def name: String = pattern.name - def description: Option[String] = pattern.description - def tactics: Set[String] = pattern.tactics - def url: String = pattern.url - def patternType: String = pattern.patternType - def revoked: Boolean = pattern.revoked - def dataSources: Seq[String] = pattern.dataSources - def defenseBypassed: Seq[String] = pattern.defenseBypassed - def detection: Option[String] = pattern.detection - def platforms: Seq[String] = pattern.platforms - def remoteSupport: Boolean = pattern.remoteSupport - def systemRequirements: Seq[String] = pattern.systemRequirements - def version: Option[String] = pattern.revision - def _id: EntityId = pattern._id - def _createdAt: Date = pattern._createdAt - def _createdBy: String = pattern._createdBy - def _updatedAt: Option[Date] = pattern._updatedAt - def _updatedBy: Option[String] = pattern._updatedBy + def patternId: String = pattern.patternId + def name: String = pattern.name + def description: Option[String] = pattern.description + def tactics: Set[String] = pattern.tactics + def url: String = pattern.url + def patternType: String = pattern.patternType + def revoked: Boolean = pattern.revoked + def dataSources: Seq[String] = pattern.dataSources + def defenseBypassed: Seq[String] = pattern.defenseBypassed + def detection: Option[String] = pattern.detection + def permissionsRequired: Seq[String] = pattern.permissionsRequired + def platforms: Seq[String] = pattern.platforms + def remoteSupport: Boolean = pattern.remoteSupport + def systemRequirements: Seq[String] = pattern.systemRequirements + def version: Option[String] = pattern.revision + def _id: EntityId = pattern._id + def _createdAt: Date = pattern._createdAt + def _createdBy: String = pattern._createdBy + def _updatedAt: Option[Date] = pattern._updatedAt + def _updatedBy: Option[String] = pattern._updatedBy } diff --git a/thehive/test/org/thp/thehive/controllers/v1/PatternCtrlTest.scala b/thehive/test/org/thp/thehive/controllers/v1/PatternCtrlTest.scala index c3b331236a..4fd2f61125 100644 --- a/thehive/test/org/thp/thehive/controllers/v1/PatternCtrlTest.scala +++ b/thehive/test/org/thp/thehive/controllers/v1/PatternCtrlTest.scala @@ -20,6 +20,7 @@ case class TestPattern( dataSources: Seq[String], defenseBypassed: Seq[String], detection: Option[String], + permissionsRequired: Seq[String], platforms: Seq[String], remoteSupport: Boolean, systemRequirements: Seq[String], @@ -72,6 +73,7 @@ class PatternCtrlTest extends PlaySpecification with TestAppBuilder { Seq(), None, Seq(), + Seq(), remoteSupport = true, Seq(), Some("1.0")