2019-07-07 19:15:33 +01:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, fetchurl
|
2019-10-16 22:39:24 +01:00
|
|
|
, clang
|
|
|
|
, llvm
|
2021-01-17 02:09:27 +00:00
|
|
|
, pkg-config
|
2019-07-07 19:15:33 +01:00
|
|
|
, makeWrapper
|
|
|
|
, file
|
|
|
|
, hyperscan
|
|
|
|
, jansson
|
2019-10-16 22:39:24 +01:00
|
|
|
, libbpf
|
2019-07-07 19:15:33 +01:00
|
|
|
, libcap_ng
|
2019-10-16 22:39:24 +01:00
|
|
|
, libelf
|
2019-07-07 19:15:33 +01:00
|
|
|
, libevent
|
2019-10-16 22:39:24 +01:00
|
|
|
, libmaxminddb
|
2019-07-07 19:15:33 +01:00
|
|
|
, libnet
|
|
|
|
, libnetfilter_log
|
|
|
|
, libnetfilter_queue
|
|
|
|
, libnfnetlink
|
|
|
|
, libpcap
|
|
|
|
, libyaml
|
|
|
|
, luajit
|
2019-10-15 18:56:31 +01:00
|
|
|
, lz4
|
2019-07-07 19:15:33 +01:00
|
|
|
, nspr
|
|
|
|
, nss
|
|
|
|
, pcre
|
|
|
|
, python
|
|
|
|
, zlib
|
|
|
|
, redisSupport ? true, redis, hiredis
|
|
|
|
, rustSupport ? true, rustc, cargo
|
|
|
|
}: let
|
|
|
|
libmagic = file;
|
|
|
|
hyperscanSupport = stdenv.system == "x86_64-linux" || stdenv.system == "i686-linux";
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "suricata";
|
2020-05-10 17:12:25 +01:00
|
|
|
version = "5.0.3";
|
2019-07-07 19:15:33 +01:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://www.openinfosecfoundation.org/download/${pname}-${version}.tar.gz";
|
2020-05-10 17:12:25 +01:00
|
|
|
sha256 = "1nv5aq5lpkpskkzw05hr2lshkzcs4zqj5kfv4qjlbwigmp6kwh9l";
|
2019-07-07 19:15:33 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
2019-10-16 22:39:24 +01:00
|
|
|
clang
|
|
|
|
llvm
|
2019-07-07 19:15:33 +01:00
|
|
|
makeWrapper
|
2021-01-17 02:09:27 +00:00
|
|
|
pkg-config
|
2019-10-16 22:39:24 +01:00
|
|
|
]
|
|
|
|
++ lib.optionals rustSupport [ rustc cargo ]
|
|
|
|
;
|
2019-07-07 19:15:33 +01:00
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
jansson
|
2019-10-16 22:39:24 +01:00
|
|
|
libbpf
|
2019-07-07 19:15:33 +01:00
|
|
|
libcap_ng
|
2019-10-16 22:39:24 +01:00
|
|
|
libelf
|
2019-07-07 19:15:33 +01:00
|
|
|
libevent
|
|
|
|
libmagic
|
2019-10-16 22:39:24 +01:00
|
|
|
libmaxminddb
|
2019-07-07 19:15:33 +01:00
|
|
|
libnet
|
|
|
|
libnetfilter_log
|
|
|
|
libnetfilter_queue
|
|
|
|
libnfnetlink
|
|
|
|
libpcap
|
|
|
|
libyaml
|
|
|
|
luajit
|
2019-10-15 18:56:31 +01:00
|
|
|
lz4
|
2019-07-07 19:15:33 +01:00
|
|
|
nspr
|
|
|
|
nss
|
|
|
|
pcre
|
|
|
|
python
|
|
|
|
zlib
|
|
|
|
]
|
2019-10-16 22:39:24 +01:00
|
|
|
++ lib.optional hyperscanSupport hyperscan
|
|
|
|
++ lib.optionals redisSupport [ redis hiredis ]
|
2019-07-07 19:15:33 +01:00
|
|
|
;
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2019-10-16 22:39:24 +01:00
|
|
|
patches = lib.optional stdenv.is64bit ./bpf_stubs_workaround.patch;
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace ./configure \
|
|
|
|
--replace "/usr/bin/file" "${file}/bin/file"
|
|
|
|
substituteInPlace ./libhtp/configure \
|
|
|
|
--replace "/usr/bin/file" "${file}/bin/file"
|
|
|
|
|
|
|
|
mkdir -p bpf_stubs_workaround/gnu
|
|
|
|
touch bpf_stubs_workaround/gnu/stubs-32.h
|
|
|
|
'';
|
|
|
|
|
2019-07-07 19:15:33 +01:00
|
|
|
configureFlags = [
|
|
|
|
"--disable-gccmarch-native"
|
|
|
|
"--enable-af-packet"
|
2019-10-16 22:39:24 +01:00
|
|
|
"--enable-ebpf"
|
|
|
|
"--enable-ebpf-build"
|
2019-07-07 19:15:33 +01:00
|
|
|
"--enable-gccprotect"
|
|
|
|
"--enable-geoip"
|
|
|
|
"--enable-luajit"
|
|
|
|
"--enable-nflog"
|
|
|
|
"--enable-nfqueue"
|
|
|
|
"--enable-pie"
|
|
|
|
"--disable-prelude"
|
|
|
|
"--enable-python"
|
|
|
|
"--enable-unix-socket"
|
|
|
|
"--localstatedir=/var"
|
|
|
|
"--sysconfdir=/etc"
|
|
|
|
"--with-libnet-includes=${libnet}/include"
|
|
|
|
"--with-libnet-libraries=${libnet}/lib"
|
|
|
|
]
|
2019-11-20 09:17:54 +00:00
|
|
|
++ lib.optionals hyperscanSupport [
|
2019-10-15 18:56:31 +01:00
|
|
|
"--with-libhs-includes=${hyperscan.dev}/include/hs"
|
2019-07-07 19:15:33 +01:00
|
|
|
"--with-libhs-libraries=${hyperscan}/lib"
|
|
|
|
]
|
2019-11-20 09:17:54 +00:00
|
|
|
++ lib.optional redisSupport "--enable-hiredis"
|
|
|
|
++ lib.optionals rustSupport [
|
2019-07-07 19:15:33 +01:00
|
|
|
"--enable-rust"
|
|
|
|
"--enable-rust-experimental"
|
|
|
|
];
|
|
|
|
|
2019-10-16 22:39:24 +01:00
|
|
|
postConfigure = ''
|
|
|
|
# Avoid unintended clousure growth.
|
|
|
|
sed -i 's|/nix/store/\(.\{8\}\)[^-]*-|/nix/store/\1...-|g' ./src/build-info.h
|
|
|
|
'';
|
|
|
|
|
|
|
|
hardeningDisable = [ "stackprotector" ];
|
|
|
|
|
2019-07-07 19:15:33 +01:00
|
|
|
installFlags = [
|
|
|
|
"e_localstatedir=\${TMPDIR}"
|
|
|
|
"e_logdir=\${TMPDIR}"
|
|
|
|
"e_logcertsdir=\${TMPDIR}"
|
|
|
|
"e_logfilesdir=\${TMPDIR}"
|
|
|
|
"e_rundir=\${TMPDIR}"
|
|
|
|
"e_sysconfdir=\${out}/etc/suricata"
|
|
|
|
"e_sysconfrulesdir=\${out}/etc/suricata/rules"
|
|
|
|
"localstatedir=\${TMPDIR}"
|
|
|
|
"runstatedir=\${TMPDIR}"
|
|
|
|
"sysconfdir=\${out}/etc"
|
|
|
|
];
|
|
|
|
|
2019-11-04 12:33:53 +00:00
|
|
|
installTargets = [ "install" "install-conf" ];
|
2019-07-07 19:15:33 +01:00
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
wrapProgram "$out/bin/suricatasc" \
|
|
|
|
--prefix PYTHONPATH : $PYTHONPATH:$(toPythonPath "$out")
|
2019-10-16 22:39:24 +01:00
|
|
|
substituteInPlace "$out/etc/suricata/suricata.yaml" \
|
|
|
|
--replace "/etc/suricata" "$out/etc/suricata"
|
2019-07-07 19:15:33 +01:00
|
|
|
'';
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2019-07-07 19:15:33 +01:00
|
|
|
description = "A free and open source, mature, fast and robust network threat detection engine";
|
|
|
|
homepage = "https://suricata-ids.org";
|
|
|
|
license = licenses.gpl2;
|
|
|
|
platforms = platforms.linux;
|
|
|
|
maintainers = with maintainers; [ magenbluten ];
|
|
|
|
};
|
|
|
|
}
|