about summary refs log tree commit diff
path: root/pkgs/tools/security/ossec/server.nix
blob: 2c015617176cb071860d88c6a47e95b0f3c98443 (plain) (blame)
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
{ lib, stdenv, fetchFromGitHub, which, pcre2, zlib, ncurses, openssl }:
let
  version = "unstable-2023-08-09";
in
stdenv.mkDerivation {
  pname = "ossec-server";
  inherit version;

  src = fetchFromGitHub {
    owner = "ossec";
    repo = "ossec-hids";
    rev = "c8a36b0af3d4ee5252855b90236407cbfb996eb2";
    sha256 = "sha256-AZ8iubyhNHXGR/l+hA61ifNDUoan7AQ42l/uRTt5GmE=";
  };

  # clear is used during the build process
  nativeBuildInputs = [ ncurses ];

  buildInputs = [ which pcre2 zlib openssl ];

  # patch to remove root manipulation, install phase which tries to add users to the system, and init phase which tries to modify the system to launch files
  patches = [ ./no-root.patch ];

  # Workaround build failure on -fno-common toolchains like upstream
  # gcc-10. Otherwise build fails as:
  #   ld: src/common/mgmt/pint-worker-external.po:(.data.rel.local+0x0): multiple definition of
  #     `PINT_worker_external_impl'; src/common/mgmt/pint-mgmt.po:(.bss+0x20): first defined here
  env.NIX_CFLAGS_COMPILE = "-fcommon";

  buildPhase = ''
    mkdir -p $out/logs
    export USER_DIR="$out" # just to satisy the script
    ./install.sh <<EOF
en

server
n
n
EOF
  '';

  installPhase = ''
      runHook preInstall

      mkdir -p $out/share
      mv $out/active-response/bin/* $out/bin
      mv $out/etc $out/share
      mv $out/queue $out/share
      mv $out/var $out/share
      mv $out/agentless $out/share
      mv $out/.ssh $out/share
      mv $out/logs $out/share
      mv $out/rules $out/share
      mv $out/stats $out/share
      rm -r $out/active-response
      rm -r $out/tmp
      ls -lah $out

      runHook postInstall
  '';

  meta = with lib; {
    description = "Open source host-based instrusion detection system";
    homepage = "https://www.ossec.net";
    license = licenses.gpl2Only;
    maintainers = with maintainers; [ happysalada ];
    platforms = platforms.all;
  };
}