forked from TheHive-Project/TheHive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
356 lines (340 loc) · 11.3 KB
/
build.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
import Dependencies._
import com.typesafe.sbt.packager.Keys.bashScriptDefines
import org.thp.ghcl.Milestone
val thehiveVersion = "4.1.24-1"
val scala212 = "2.12.13"
val scala213 = "2.13.1"
val supportedScalaVersions = List(scala212, scala213)
organization in ThisBuild := "org.thp"
scalaVersion in ThisBuild := scala212
crossScalaVersions in ThisBuild := supportedScalaVersions
resolvers in ThisBuild ++= Seq(
Resolver.mavenLocal,
"Oracle Released Java Packages" at "https://download.oracle.com/maven",
"TheHive project repository" at "https://dl.bintray.com/thehive-project/maven/"
)
scalacOptions in ThisBuild ++= Seq(
"-encoding",
"UTF-8",
"-deprecation", // Emit warning and location for usages of deprecated APIs.
"-feature", // Emit warning and location for usages of features that should be imported explicitly.
"-unchecked", // Enable additional warnings where generated code depends on assumptions.
"-Xlint", // Enable recommended additional warnings.
"-Ywarn-numeric-widen", // Warn when numerics are widened.
"-Ywarn-value-discard", // Warn when non-Unit expression results are unused
//"-Xfatal-warnings", // Fail the compilation if there are any warnings.
//"-Ywarn-adapted-args",// Warn if an argument list is modified to match the receiver.
//"-Ywarn-dead-code", // Warn when dead code is identified.
//"-Ywarn-inaccessible",// Warn about inaccessible types in method signatures.
//"-Ywarn-nullary-override",// Warn when non-nullary overrides nullary, e.g. def foo() over def foo.
//"-Ylog-classpath",
//"-Xlog-implicits",
//"-Yshow-trees-compact",
//"-Yshow-trees-stringified",
//"-Ymacro-debug-lite",
"-Xlog-free-types",
"-Xlog-free-terms",
"-Xprint-types"
)
fork in Test in ThisBuild := true
javaOptions in Test in ThisBuild += s"-Dlogger.file=${file("test/resources/logback-test.xml").getAbsoluteFile}"
javaOptions in ThisBuild ++= Seq(
"-Xms512M",
"-Xmx2048M",
"-Xss1M",
"-XX:+CMSClassUnloadingEnabled",
"-XX:MaxPermSize=256M",
"-XX:MaxMetaspaceSize=512m"
)
scalafmtConfig in ThisBuild := file(".scalafmt.conf")
scalacOptions in ThisBuild ++= {
CrossVersion.partialVersion((Compile / scalaVersion).value) match {
case Some((2, n)) if n >= 13 => "-Ymacro-annotations" :: Nil
case _ => Nil
}
}
libraryDependencies in ThisBuild ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, n)) if n >= 13 => Nil
case _ => compilerPlugin(macroParadise) :: Nil
}
}
dependencyOverrides in ThisBuild ++= Seq(
akkaActor,
logbackClassic
)
val securityUpdates = Seq(
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.12.6",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.12.6.1",
"org.yaml" % "snakeyaml" % "1.30"
)
dependencyOverrides in ThisBuild ++= securityUpdates
PlayKeys.includeDocumentationInBinary := false
milestoneFilter := ((milestone: Milestone) => milestone.title.startsWith("4"))
lazy val scalligraph = (project in file("ScalliGraph"))
.settings(name := "scalligraph")
lazy val thehive = (project in file("."))
.enablePlugins(PlayScala)
.dependsOn(thehiveCore, thehiveCortex, thehiveMisp, thehiveFrontend, thehiveMigration)
.settings(
name := "thehive",
version := thehiveVersion,
crossScalaVersions := Nil,
PlayKeys.playMonitoredFiles ~= (_.filter(f => f.compareTo(file("frontend/app").getAbsoluteFile) != 0)),
PlayKeys.devSettings += "play.server.provider" -> "org.thp.thehive.CustomAkkaHttpServerProvider",
// Universal / mappings ++= (thehiveMigration / Universal / mappings).value,
Compile / run := {
(thehiveFrontend / gruntDev).value
(Compile / run).evaluated
},
discoveredMainClasses in Compile := Seq("play.core.server.ProdServerStart", "org.thp.thehive.migration.Migrate", "org.thp.thehive.cloner.Cloner"),
mainClass in (Compile, bashScriptDefines) := None,
makeBashScripts ~= {
_.map {
case (f, "bin/prod-server-start") => (f, "bin/thehive")
case other => other
}
},
clean := {
(clean in scalligraph).value
(clean in thehiveCore).value
(clean in thehiveDto).value
(clean in thehiveClient).value
(clean in thehiveFrontend).value
(clean in thehiveCortex).value
(clean in thehiveMisp).value
(clean in cortexClient).value
(clean in mispClient).value
(clean in thehiveMigration).value
(clean in clientCommon).value
(clean in cortexDto).value
},
test := {
(test in Test in scalligraph).value
(test in Test in thehiveCore).value
(test in Test in thehiveDto).value
(test in Test in thehiveClient).value
(test in Test in thehiveFrontend).value
(test in Test in thehiveCortex).value
(test in Test in thehiveMisp).value
(test in Test in cortexClient).value
(test in Test in mispClient).value
(test in Test in thehiveMigration).value
(test in Test in clientCommon).value
(test in Test in cortexDto).value
},
testQuick := {
(testQuick in Test in scalligraph).evaluated
(testQuick in Test in thehiveCore).evaluated
(testQuick in Test in thehiveDto).evaluated
(testQuick in Test in thehiveClient).evaluated
(testQuick in Test in thehiveFrontend).evaluated
(testQuick in Test in thehiveCortex).evaluated
(testQuick in Test in thehiveMisp).evaluated
(testQuick in Test in cortexClient).evaluated
(testQuick in Test in mispClient).evaluated
(testQuick in Test in thehiveMigration).evaluated
(testQuick in Test in clientCommon).evaluated
(testQuick in Test in cortexDto).evaluated
}
)
lazy val thehiveCore = (project in file("thehive"))
.enablePlugins(PlayScala)
.dependsOn(scalligraph)
.dependsOn(scalligraph % "test -> test")
.dependsOn(cortexClient % "test -> test")
.dependsOn(thehiveDto)
.dependsOn(clientCommon)
.dependsOn(thehiveClient % Test)
.settings(
name := "thehive-core",
version := thehiveVersion,
libraryDependencies ++= Seq(
chimney,
guice,
akkaCluster,
akkaClusterTyped,
akkaClusterTools,
zip4j,
ws,
specs % Test,
handlebars,
playMailer,
playMailerGuice,
pbkdf2,
commonCodec,
scalaGuice,
reflections,
quartzScheduler
)
)
lazy val thehiveDto = (project in file("dto"))
.dependsOn(scalligraph)
.settings(
name := "thehive-dto",
version := thehiveVersion,
libraryDependencies ++= Seq(
aix
)
)
lazy val thehiveClient = (project in file("client"))
.dependsOn(thehiveDto)
.dependsOn(clientCommon)
.settings(
name := "thehive-client",
version := thehiveVersion,
libraryDependencies ++= Seq(
ws
)
)
lazy val npm = taskKey[Unit]("Install npm dependencies")
lazy val bower = taskKey[Unit]("Install bower dependencies")
lazy val gruntDev = taskKey[Unit]("Inject bower dependencies in index.html")
lazy val gruntBuild = taskKey[Seq[(File, String)]]("Build frontend files")
lazy val thehiveFrontend = (project in file("frontend"))
.settings(
name := "thehive-frontend",
version := thehiveVersion,
npm :=
FileBuilder(
label = "npm",
inputFiles = baseDirectory.value / "package.json",
outputFiles = baseDirectory.value / "node_modules" ** AllPassFilter,
command = baseDirectory.value -> "npm install",
streams = streams.value
),
bower := FileBuilder(
label = "bower",
inputFiles = baseDirectory.value / "bower.json",
outputFiles = baseDirectory.value / "bower_components" ** AllPassFilter,
command = baseDirectory.value -> "bower install",
streams = streams.value
),
gruntDev := {
npm.value
bower.value
FileBuilder(
label = "grunt",
inputFiles = baseDirectory.value / "bower_components" ** AllPassFilter,
outputFiles = baseDirectory.value / "app" / "index.html",
command = baseDirectory.value -> "grunt wiredep",
streams = streams.value
)
},
gruntBuild := {
npm.value
bower.value
val dist = baseDirectory.value / "dist"
val outputFiles = FileBuilder(
label = "grunt",
inputFiles = baseDirectory.value / "bower_components" ** AllPassFilter,
outputFiles = dist ** AllPassFilter,
command = baseDirectory.value -> "grunt build",
streams = streams.value
)
for {
file <- outputFiles.toSeq
rebasedFile <- sbt.Path.rebase(dist, "frontend")(file)
} yield file -> rebasedFile
},
Compile / resourceDirectory := baseDirectory.value / "app",
Compile / packageBin / mappings := gruntBuild.value,
watchSources := Nil,
cleanFiles ++= Seq(
baseDirectory.value / "dist",
baseDirectory.value / "bower_components",
baseDirectory.value / "node_modules"
)
)
lazy val clientCommon = (project in file("client-common"))
.dependsOn(scalligraph)
.settings(
name := "client-common",
version := thehiveVersion,
libraryDependencies ++= Seq(
ws,
specs % Test
)
)
lazy val thehiveCortex = (project in file("cortex/connector"))
.dependsOn(thehiveCore)
.dependsOn(cortexClient)
.dependsOn(cortexClient % "test -> test")
.dependsOn(thehiveCore % "test -> test")
.dependsOn(scalligraph % "test -> test")
.settings(
name := "thehive-cortex",
version := thehiveVersion,
libraryDependencies ++= Seq(
reflections,
specs % Test
)
)
lazy val cortexDto = (project in file("cortex/dto"))
.dependsOn(scalligraph)
.settings(
name := "cortex-dto",
version := thehiveVersion,
libraryDependencies ++= Seq(
chimney
)
)
lazy val cortexClient = (project in file("cortex/client"))
.dependsOn(cortexDto)
.dependsOn(clientCommon)
.dependsOn(scalligraph % "test -> test")
.settings(
name := "cortex-client",
version := thehiveVersion,
libraryDependencies ++= Seq(
ws,
specs % Test,
playFilters % Test,
playMockws % Test,
akkaClusterTyped % Test
)
)
lazy val thehiveMisp = (project in file("misp/connector"))
.dependsOn(thehiveCore)
.dependsOn(mispClient)
.dependsOn(thehiveCore % "test -> test")
.settings(
name := "thehive-misp",
version := thehiveVersion,
libraryDependencies ++= Seq(
specs % Test,
playMockws % Test
)
)
lazy val mispClient = (project in file("misp/client"))
.dependsOn(scalligraph)
.dependsOn(clientCommon)
.settings(
name := "misp-client",
version := thehiveVersion,
libraryDependencies ++= Seq(
ws,
alpakka,
akkaHttp,
specs % Test,
playMockws % Test
)
)
lazy val thehiveMigration = (project in file("migration"))
.enablePlugins(JavaAppPackaging)
.dependsOn(scalligraph)
.dependsOn(thehiveCore)
.dependsOn(thehiveCortex)
.settings(
name := "thehive-migration",
version := thehiveVersion,
resolvers += "elasticsearch-releases" at "https://artifacts.elastic.co/maven",
crossScalaVersions := Seq(scala212),
libraryDependencies ++= Seq(
alpakka,
ehcache,
scopt,
specs % Test
),
normalizedName := "migrate"
)