forked from TheHive-Project/TheHive
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sbt
194 lines (180 loc) · 7.01 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
name := "TheHive"
lazy val thehiveBackend = (project in file("thehive-backend"))
.enablePlugins(PlayScala)
.settings(publish := {})
lazy val thehiveMetrics = (project in file("thehive-metrics"))
.enablePlugins(PlayScala)
.dependsOn(thehiveBackend)
.settings(publish := {})
lazy val thehiveMisp = (project in file("thehive-misp"))
.enablePlugins(PlayScala)
.dependsOn(thehiveBackend)
.settings(publish := {})
lazy val thehiveCortex = (project in file("thehive-cortex"))
.enablePlugins(PlayScala)
.dependsOn(thehiveBackend)
.settings(publish := {})
lazy val thehive = (project in file("."))
.enablePlugins(PlayScala)
.enablePlugins(PublishToBinTray)
.dependsOn(thehiveBackend, thehiveMetrics, thehiveMisp, thehiveCortex)
.aggregate(thehiveBackend, thehiveMetrics, thehiveMisp, thehiveCortex)
.settings(aggregate in Debian := false)
.settings(aggregate in Rpm := false)
.settings(aggregate in Docker := false)
// Redirect logs from ElasticSearch (which uses log4j2) to slf4j
libraryDependencies += "org.apache.logging.log4j" % "log4j-to-slf4j" % "2.9.1"
excludeDependencies += "org.apache.logging.log4j" % "log4j-core"
lazy val rpmPackageRelease = (project in file("package/rpm-release"))
.enablePlugins(RpmPlugin)
.settings(
name := "thehive-project-release",
maintainer := "TheHive Project <support@thehive-project.org>",
version := "1.0.0",
rpmRelease := "3",
rpmVendor := "TheHive Project",
rpmUrl := Some("http://thehive-project.org/"),
rpmLicense := Some("AGPL"),
maintainerScripts in Rpm := Map.empty,
linuxPackageSymlinks in Rpm := Nil,
packageSummary := "TheHive-Project RPM repository",
packageDescription := """This package contains the TheHive-Project packages repository
|GPG key as well as configuration for yum.""".stripMargin,
logLevel in packageBin in Rpm := Level.Debug,
linuxPackageMappings in Rpm := Seq(packageMapping(
file("PGP-PUBLIC-KEY") -> "etc/pki/rpm-gpg/GPG-TheHive-Project",
file("package/rpm-release/thehive-rpm.repo") -> "/etc/yum.repos.d/thehive-rpm.repo",
file("LICENSE") -> "/usr/share/doc/thehive-project-release/LICENSE"
))
)
// Front-end //
run := {
(run in Compile).evaluated
frontendDev.value
}
mappings in packageBin in Assets ++= frontendFiles.value
// Remove conf files
// Install service files
mappings in Universal ~= {
_.flatMap {
case (_, "conf/application.conf") => Nil
case (file, "conf/application.sample") => Seq(file -> "conf/application.conf")
case (_, "conf/logback.xml") => Nil
case other => Seq(other)
} ++ Seq(
file("package/thehive.service") -> "package/thehive.service",
file("package/thehive.conf") -> "package/thehive.conf",
file("package/thehive") -> "package/thehive",
file("package/logback.xml") -> "conf/logback.xml",
) ++ (file("migration").**(AllPassFilter) pair Path.rebase(file("migration"), "migration"))
}
// Package //
maintainer := "TheHive Project <support@thehive-project.org>"
packageSummary := "Scalable, Open Source and Free Security Incident Response Solutions"
packageDescription :=
"""TheHive is a scalable 3-in-1 open source and free security incident response
| platform designed to make life easier for SOCs, CSIRTs, CERTs and any
| information security practitioner dealing with security incidents that need to
| be investigated and acted upon swiftly.""".stripMargin
defaultLinuxInstallLocation := "/opt"
linuxPackageMappings ~= {
_.map { pm =>
val mappings = pm.mappings.filterNot {
case (_, path) => path.startsWith("/opt/thehive/package") || path.startsWith("/opt/thehive/conf")
}
com.typesafe.sbt.packager.linux.LinuxPackageMapping(mappings, pm.fileData)
}
}
linuxPackageMappings ++= Seq(
packageMapping(
file("package/thehive.service") -> "/usr/lib/systemd/system/thehive.service"
).withPerms("644"),
packageMapping(
file("package/thehive.conf") -> "/etc/init/thehive.conf",
file("conf/application.sample") -> "/etc/thehive/application.conf",
file("package/logback.xml") -> "/etc/thehive/logback.xml"
).withPerms("644").withConfig(),
packageMapping(
file("package/thehive") -> "/etc/init.d/thehive"
).withPerms("755").withConfig())
packageBin := {
(packageBin in Universal).value
(packageBin in Debian).value
(packageBin in Rpm).value
}
// DEB //
linuxPackageMappings in Debian += packageMapping(file("LICENSE") -> "/usr/share/doc/thehive/copyright").withPerms("644")
version in Debian := version.value + "-1"
debianPackageRecommends := Seq("elasticsearch")
debianPackageDependencies += "openjdk-8-jre-headless"
maintainerScripts in Debian := maintainerScriptsFromDirectory(
baseDirectory.value / "package" / "debian",
Seq(DebianConstants.Postinst, DebianConstants.Prerm, DebianConstants.Postrm)
)
linuxEtcDefaultTemplate in Debian := (baseDirectory.value / "package" / "etc_default_thehive").asURL
linuxMakeStartScript in Debian := None
// RPM //
rpmRelease := "1"
rpmVendor := "TheHive Project"
rpmUrl := Some("http://thehive-project.org/")
rpmLicense := Some("AGPL")
rpmRequirements += "java-1.8.0-openjdk-headless"
maintainerScripts in Rpm := maintainerScriptsFromDirectory(
baseDirectory.value / "package" / "rpm",
Seq(RpmConstants.Pre, RpmConstants.Preun, RpmConstants.Postun)
)
linuxPackageSymlinks in Rpm := Nil
rpmPrefix := Some(defaultLinuxInstallLocation.value)
linuxEtcDefaultTemplate in Rpm := (baseDirectory.value / "package" / "etc_default_thehive").asURL
rpmReleaseFile := {
import scala.sys.process._
val rpmFile = (packageBin in Rpm in rpmPackageRelease).value
s"rpm --addsign $rpmFile".!!
rpmFile
}
packageBin in Rpm := {
import scala.sys.process._
val rpmFile = (packageBin in Rpm).value
s"rpm --addsign $rpmFile".!!
rpmFile
}
// DOCKER //
import com.typesafe.sbt.packager.docker.{ Cmd, ExecCmd }
version in Docker := version.value + "-1"
defaultLinuxInstallLocation in Docker := "/opt/thehive"
dockerRepository := Some("certbdf")
dockerUpdateLatest := true
dockerEntrypoint := Seq("/opt/thehive/entrypoint")
dockerExposedPorts := Seq(9000)
mappings in Docker ++= Seq(
file("package/docker/entrypoint") -> "/opt/thehive/entrypoint",
file("package/logback.xml") -> "/etc/thehive/logback.xml",
file("package/empty") -> "/var/log/thehive/application.log")
mappings in Docker ~= (_.filterNot {
case (_, filepath) => filepath == "/opt/thehive/conf/application.conf"
})
dockerCommands ~= { dc =>
val (dockerInitCmds, dockerTailCmds) = dc
.collect {
case ExecCmd("RUN", "chown", _*) => ExecCmd("RUN", "chown", "-R", "daemon:root", ".")
case other => other
}
.splitAt(4)
dockerInitCmds ++
Seq(
Cmd("ADD", "var", "/var"),
Cmd("ADD", "etc", "/etc"),
ExecCmd("RUN", "chown", "-R", "daemon:root", "/var/log/thehive"),
ExecCmd("RUN", "chmod", "+x", "/opt/thehive/bin/thehive", "/opt/thehive/entrypoint")) ++
dockerTailCmds
}
// Bintray //
bintrayOrganization := Some("cert-bdf")
bintrayRepository := "thehive"
publish := {
(publish in Docker).value
publishRelease.value
publishLatest.value
publishRpm.value
publishDebian.value
}