Skip to content

Commit

Permalink
#1731 Reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Jan 21, 2021
1 parent bfa77ad commit 2607903
Show file tree
Hide file tree
Showing 138 changed files with 367 additions and 395 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package org.thp.cortex.client

import java.util.Date

import org.thp.cortex.dto.v0._
import org.thp.scalligraph.AppBuilder
import play.api.libs.json.{JsObject, JsString, Json}
import play.api.test.PlaySpecification

import java.util.Date
import scala.concurrent.duration._

class CortexClientTest extends PlaySpecification {
Expand Down Expand Up @@ -64,55 +63,61 @@ class CortexClientTest extends PlaySpecification {
OutputReport(
summary = Seq(OutputMinireport("info", "test", "data", JsString("test"))),
success = true,
full = Some(Json.parse("""{
"data": "imageedit_2_3904987689.jpg",
"input": {
"file": "attachment7619802021796183482",
"filename": "imageedit_2_3904987689.jpg",
"dataType": "file",
"tlp": 2,
"message": "179e85c4-4170-45fe-9d2d-3173539554a6",
"contentType": "image/jpeg",
"parameters": {
},
"config": {
"proxy_https": null,
"cacerts": null,
"max_pap": 2,
"jobTimeout": 30,
"check_tlp": true,
"proxy_http": null,
"max_tlp": 2,
"auto_extract_artifacts": false,
"jobCache": 10,
"check_pap": true
},
"pap": 2
}
}""").as[JsObject]),
artifacts = Json.parse("""[
{
"attachment": {
"contentType": "application/octet-stream",
"id": "e64871cf4652cb6e1babc06a376e7c79256dd6b967ca845ae06708cbeb686663",
"name": "passwd",
"size": 2644
},
"dataType": "file",
"message": null,
"tags": ["file", "virus"],
"tlp": 3
},
{
"data": "127.0.0.1",
"dataType": "ip",
"message": null,
"tags": [
"localhost"
],
"tlp": 2
}
]""").as[List[OutputArtifact]],
full = Some(
Json
.parse("""{
"data": "imageedit_2_3904987689.jpg",
"input": {
"file": "attachment7619802021796183482",
"filename": "imageedit_2_3904987689.jpg",
"dataType": "file",
"tlp": 2,
"message": "179e85c4-4170-45fe-9d2d-3173539554a6",
"contentType": "image/jpeg",
"parameters": {
},
"config": {
"proxy_https": null,
"cacerts": null,
"max_pap": 2,
"jobTimeout": 30,
"check_tlp": true,
"proxy_http": null,
"max_tlp": 2,
"auto_extract_artifacts": false,
"jobCache": 10,
"check_pap": true
},
"pap": 2
}
}""")
.as[JsObject]
),
artifacts = Json
.parse("""[
{
"attachment": {
"contentType": "application/octet-stream",
"id": "e64871cf4652cb6e1babc06a376e7c79256dd6b967ca845ae06708cbeb686663",
"name": "passwd",
"size": 2644
},
"dataType": "file",
"message": null,
"tags": ["file", "virus"],
"tlp": 3
},
{
"data": "127.0.0.1",
"dataType": "ip",
"message": null,
"tags": [
"localhost"
],
"tlp": 2
}
]""")
.as[List[OutputArtifact]],
operations = Nil,
errorMessage = None,
input = None
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package org.thp.cortex.client

import java.net.URLEncoder
import java.nio.file.{Path, Paths}

import akka.stream.scaladsl._
import javax.inject.{Inject, Provider}
import mockws.MockWS
import org.thp.client.NoAuthentication
import org.thp.cortex.dto.v0.{OutputJob, OutputWorker}
Expand All @@ -13,6 +9,9 @@ import play.api.libs.json.{JsValue, Json}
import play.api.mvc._
import play.api.test.Helpers._

import java.net.URLEncoder
import java.nio.file.{Path, Paths}
import javax.inject.{Inject, Provider}
import scala.concurrent.ExecutionContext
import scala.io.Source
import scala.util.matching.Regex
Expand Down Expand Up @@ -42,7 +41,8 @@ class TestCortexClientProvider @Inject() (Action: DefaultActionBuilder, implicit
val filename = URLEncoder.encode(s"$id.test.txt", "utf-8")
Action(
Result(
header = ResponseHeader(200, Map("Content-Disposition" -> s"""attachment; filename="$filename"""", "Content-Transfer-Encoding" -> "binary")),
header =
ResponseHeader(200, Map("Content-Disposition" -> s"""attachment; filename="$filename"""", "Content-Transfer-Encoding" -> "binary")),
body = HttpEntity.Streamed(FileIO.fromPath(fileResource(id)), None, None)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.thp.thehive.connector.cortex

import com.google.inject.AbstractModule
import net.codingwell.scalaguice.{ScalaModule, ScalaMultibinder}
import org.thp.scalligraph.models.{Schema, UpdatableSchema}
import org.thp.scalligraph.models.UpdatableSchema
import org.thp.scalligraph.query.QueryExecutor
import org.thp.thehive.connector.cortex.controllers.v0.{CortexQueryExecutor => CortexQueryExecutorV0}
import org.thp.thehive.connector.cortex.models.CortexSchemaDefinition
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package org.thp.thehive.connector.cortex

import javax.inject.{Inject, Provider, Singleton}
import org.thp.thehive.connector.cortex.controllers.v0
import play.api.Logger
import play.api.routing.Router

import javax.inject.{Inject, Provider, Singleton}

@Singleton
class CortexRouter @Inject() (routerV0: v0.Router) extends Provider[Router] {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package org.thp.thehive.connector.cortex.controllers.v0

import akka.actor.ActorSystem
import javax.inject.{Inject, Singleton}
import org.thp.scalligraph.controllers.{Entrypoint, FieldsParser}
import org.thp.thehive.connector.cortex.controllers.v0.Conversion._
import org.thp.thehive.connector.cortex.services.AnalyzerSrv
import org.thp.thehive.controllers.v0.Conversion._
import play.api.mvc.{Action, AnyContent, Results}

import javax.inject.{Inject, Singleton}
import scala.concurrent.ExecutionContext

@Singleton
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package org.thp.thehive.connector.cortex.controllers.v0

import java.util.zip.ZipFile

import com.google.inject.name.Named
import javax.inject.{Inject, Singleton}
import org.thp.scalligraph.EntityIdOrName
import org.thp.scalligraph.controllers.{Entrypoint, FFile, FieldsParser}
import org.thp.scalligraph.models.{Database, Entity, UMapping}
Expand All @@ -21,6 +18,8 @@ import org.thp.thehive.models.Permissions
import play.api.libs.json.{JsFalse, JsObject, JsTrue}
import play.api.mvc.{Action, AnyContent, Results}

import java.util.zip.ZipFile
import javax.inject.{Inject, Singleton}
import scala.util.{Failure, Success}

@Singleton
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.thp.thehive.connector.cortex.controllers.v0

import com.google.inject.name.Named
import javax.inject.{Inject, Singleton}
import org.scalactic.Good
import org.thp.scalligraph.auth.AuthContext
import org.thp.scalligraph.controllers.FieldsParser
Expand All @@ -16,6 +14,7 @@ import org.thp.thehive.controllers.v0._
import org.thp.thehive.models.Observable
import org.thp.thehive.services.ObservableOps._

import javax.inject.{Inject, Singleton}
import scala.reflect.runtime.{universe => ru}

@Singleton
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package org.thp.thehive.connector.cortex.controllers.v0

import com.google.inject.name.Named

import javax.inject.{Inject, Singleton}
import org.thp.scalligraph.controllers.{Entrypoint, FieldsParser}
import org.thp.scalligraph.models.{Database, UMapping}
import org.thp.scalligraph.query._
Expand All @@ -20,6 +18,7 @@ import org.thp.thehive.services.ObservableOps._
import org.thp.thehive.services.ObservableSrv
import play.api.mvc.{Action, AnyContent, Results}

import javax.inject.{Inject, Singleton}
import scala.concurrent.{ExecutionContext, Future}

@Singleton
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.thp.thehive.connector.cortex.controllers.v0

import java.util.{Map => JMap}

import org.thp.scalligraph.auth.AuthContext
import org.thp.scalligraph.traversal.TraversalOps._
import org.thp.scalligraph.traversal.{Converter, Traversal}
Expand All @@ -11,9 +9,11 @@ import org.thp.thehive.models.{RichCase, RichObservable}
import org.thp.thehive.services.CaseOps._
import org.thp.thehive.services.ObservableOps._

import java.util.{Map => JMap}

trait JobRenderer {
def jobParents(traversal: Traversal.V[Job])(
implicit authContext: AuthContext
def jobParents(traversal: Traversal.V[Job])(implicit
authContext: AuthContext
): Traversal[Option[(RichObservable, RichCase)], JMap[String, Any], Converter[Option[(RichObservable, RichCase)], JMap[String, Any]]] =
traversal.observable.project(_.by(_.richObservable).by(_.`case`.richCase)).domainMap(Some(_))
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.thp.thehive.connector.cortex.controllers.v0

import com.google.inject.name.Named
import javax.inject.{Inject, Singleton}
import org.thp.scalligraph.EntityIdOrName
import org.thp.scalligraph.controllers.{Entrypoint, FieldsParser}
import org.thp.scalligraph.models.Database
Expand All @@ -11,6 +9,7 @@ import org.thp.thehive.controllers.v0.Conversion._
import play.api.libs.json.JsObject
import play.api.mvc.{Action, AnyContent, Results}

import javax.inject.{Inject, Singleton}
import scala.concurrent.ExecutionContext

@Singleton
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package org.thp.thehive.connector.cortex.controllers.v0

import javax.inject.{Inject, Singleton}
import play.api.routing.Router.Routes
import play.api.routing.SimpleRouter
import play.api.routing.sird._

import javax.inject.{Inject, Singleton}

@Singleton
class Router @Inject() (
val jobCtrl: JobCtrl,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package org.thp.thehive.connector.cortex.models

import java.util.Date
import org.apache.tinkerpop.gremlin.structure.{Edge, Vertex}
import org.thp.scalligraph.models._
import org.thp.scalligraph.traversal.{Converter, Graph}
import org.thp.scalligraph.{BuildVertexEntity, EntityId}
import play.api.libs.json.JsObject

import java.util.Date

@BuildVertexEntity
case class Action(
workerId: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.thp.thehive.connector.cortex.models

import javax.inject.{Inject, Singleton}
import org.reflections.Reflections
import org.reflections.scanners.SubTypesScanner
import org.reflections.util.ConfigurationBuilder
Expand All @@ -9,6 +8,7 @@ import org.thp.scalligraph.models._
import org.thp.thehive.services.LocalUserSrv
import play.api.Logger

import javax.inject.{Inject, Singleton}
import scala.collection.JavaConverters._
import scala.reflect.runtime.{universe => ru}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package org.thp.thehive.connector.cortex.models

import javax.inject.{Inject, Provider, Singleton}
import org.thp.scalligraph.models.Schema
import org.thp.thehive.models.TheHiveSchemaDefinition

import javax.inject.{Inject, Provider, Singleton}

@Singleton
class TheHiveCortexSchemaProvider @Inject() (thehiveSchema: TheHiveSchemaDefinition, cortexSchema: CortexSchemaDefinition) extends Provider[Schema] {
override lazy val get: Schema = thehiveSchema + cortexSchema
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package org.thp.thehive.connector.cortex.services

import javax.inject.{Inject, Singleton}
import org.thp.cortex.dto.v0.{OutputWorker => CortexWorker}
import org.thp.scalligraph.{EntityIdOrName, NotFoundError}
import org.thp.scalligraph.auth.AuthContext
import org.thp.cortex.dto.v0.OutputWorker
import org.thp.scalligraph.{EntityIdOrName, NotFoundError}
import play.api.Logger
import play.api.libs.json.{JsObject, Json}

import javax.inject.{Inject, Singleton}
import scala.concurrent.{ExecutionContext, Future}
import scala.util.{Failure, Success}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package org.thp.thehive.connector.cortex.services

import java.util.zip.{ZipEntry, ZipFile}
import com.google.inject.name.Named

import javax.inject.{Inject, Singleton}
import org.thp.scalligraph.auth.AuthContext
import org.thp.scalligraph.models.{Database, Entity}
import org.thp.scalligraph.query.PropertyUpdater
import org.thp.scalligraph.services._
import org.thp.scalligraph.traversal.{Graph, Traversal}
import org.thp.scalligraph.traversal.TraversalOps._
import org.thp.scalligraph.traversal.{Graph, Traversal}
import org.thp.scalligraph.{CreateError, EntityIdOrName, EntityName}
import org.thp.thehive.connector.cortex.controllers.v0.Conversion._
import org.thp.thehive.connector.cortex.models.AnalyzerTemplate
Expand All @@ -18,13 +14,14 @@ import org.thp.thehive.controllers.v0.Conversion._
import org.thp.thehive.services.OrganisationSrv
import play.api.libs.json.{JsObject, Json}

import java.util.zip.{ZipEntry, ZipFile}
import javax.inject.{Inject, Singleton}
import scala.collection.JavaConverters._
import scala.io.Source
import scala.util.{Failure, Try}

@Singleton
class AnalyzerTemplateSrv @Inject() (implicit
db: Database,
class AnalyzerTemplateSrv @Inject() (
auditSrv: CortexAuditSrv,
organisationSrv: OrganisationSrv
) extends VertexSrv[AnalyzerTemplate] {
Expand Down
Loading

0 comments on commit 2607903

Please sign in to comment.