Skip to content

Commit

Permalink
#1649 Fix attachment filters
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Nov 17, 2020
1 parent 6bc19c3 commit a53ce20
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ScalliGraph
6 changes: 5 additions & 1 deletion thehive/app/org/thp/thehive/controllers/v0/LogCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ class PublicLog @Inject() (logSrv: LogSrv, organisationSrv: OrganisationSrv) ext
.property("deleted", UMapping.boolean)(_.field.updatable)
.property("startDate", UMapping.date)(_.rename("date").readonly)
.property("status", UMapping.string)(_.select(_.constant("Ok")).readonly)
.property("attachment", UMapping.string)(_.select(_.attachments.value(_.attachmentId)).readonly)
.property("attachment.name", UMapping.string.optional)(_.select(_.attachments.value(_.name)).readonly)
.property("attachment.hashes", UMapping.hash.sequence)(_.select(_.attachments.value(_.hashes)).readonly)
.property("attachment.size", UMapping.long.optional)(_.select(_.attachments.value(_.size)).readonly)
.property("attachment.contentType", UMapping.string.optional)(_.select(_.attachments.value(_.contentType)).readonly)
.property("attachment.id", UMapping.string.optional)(_.select(_.attachments.value(_.attachmentId)).readonly)
.build
}
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,9 @@ class PublicObservable @Inject() (
.property("dataType", UMapping.string)(_.select(_.observableType.value(_.name)).readonly)
.property("data", UMapping.string.optional)(_.select(_.data.value(_.data)).readonly)
.property("attachment.name", UMapping.string.optional)(_.select(_.attachments.value(_.name)).readonly)
.property("attachment.hashes", UMapping.hash.sequence)(_.select(_.attachments.value(_.hashes)).readonly)
.property("attachment.size", UMapping.long.optional)(_.select(_.attachments.value(_.size)).readonly)
.property("attachment.contentType", UMapping.string.optional)(_.select(_.attachments.value(_.contentType)).readonly)
.property("attachment.hashes", UMapping.hash)(_.select(_.attachments.value(_.hashes)).readonly)
.property("attachment.id", UMapping.string.optional)(_.select(_.attachments.value(_.attachmentId)).readonly)
.build
}
1 change: 0 additions & 1 deletion thehive/app/org/thp/thehive/controllers/v0/UserCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ class UserCtrl @Inject() (
.update(userSrv.get(EntityIdOrName(userId)), propertyUpdaters) // Authorisation is managed in public properties
.flatMap { case (user, _) => user.richUser.getOrFail("User") }
} yield Results.Ok(user.toJson)

}

def setPassword(userId: String): Action[AnyContent] =
Expand Down
12 changes: 10 additions & 2 deletions thehive/app/org/thp/thehive/controllers/v1/Properties.scala
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,11 @@ class Properties @Inject() (
.property("message", UMapping.string)(_.field.updatable)
.property("deleted", UMapping.boolean)(_.field.updatable)
.property("date", UMapping.date)(_.field.readonly)
.property("attachment", UMapping.string)(_.select(_.attachments.value(_.attachmentId)).readonly)
.property("attachment.name", UMapping.string.optional)(_.select(_.attachments.value(_.name)).readonly)
.property("attachment.hashes", UMapping.hash.sequence)(_.select(_.attachments.value(_.hashes)).readonly)
.property("attachment.size", UMapping.long.optional)(_.select(_.attachments.value(_.size)).readonly)
.property("attachment.contentType", UMapping.string.optional)(_.select(_.attachments.value(_.contentType)).readonly)
.property("attachment.id", UMapping.string.optional)(_.select(_.attachments.value(_.attachmentId)).readonly)
.build

lazy val user: PublicProperties =
Expand Down Expand Up @@ -480,6 +484,10 @@ class Properties @Inject() (
.property("tlp", UMapping.int)(_.field.updatable)
.property("dataType", UMapping.string)(_.select(_.observableType.value(_.name)).readonly)
.property("data", UMapping.string.optional)(_.select(_.data.value(_.data)).readonly)
// TODO add attachment ?
.property("attachment.name", UMapping.string.optional)(_.select(_.attachments.value(_.name)).readonly)
.property("attachment.hashes", UMapping.hash.sequence)(_.select(_.attachments.value(_.hashes)).readonly)
.property("attachment.size", UMapping.long.optional)(_.select(_.attachments.value(_.size)).readonly)
.property("attachment.contentType", UMapping.string.optional)(_.select(_.attachments.value(_.contentType)).readonly)
.property("attachment.id", UMapping.string.optional)(_.select(_.attachments.value(_.attachmentId)).readonly)
.build
}
2 changes: 1 addition & 1 deletion thehive/app/org/thp/thehive/services/th3/Aggregation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ case class AggAvg(aggName: Option[String], fieldName: String) extends Aggregatio
traversal: Traversal.Unk,
authContext: AuthContext
): Traversal.Domain[Output[_]] = {
val fieldPath = if (fieldName.startsWith("computed")) FPathElem(fieldName) else FPath(fieldName)
val fieldPath = FPath(fieldName)
val property = publicProperties
.get[Traversal.UnkD, Traversal.UnkDU](fieldPath, traversalType)
.getOrElse(throw BadRequestError(s"Property $fieldName for type $traversalType not found"))
Expand Down

0 comments on commit a53ce20

Please sign in to comment.