base16-schemes: unstable-2024-06-21 -> unstable-2024-11-12 (#356361)
[NixPkgs.git] / pkgs / tools / security / libmodsecurity / default.nix
blob83dc2bff29daa3ce443c8984f4586f5a6454998a
1 { lib, stdenv, fetchFromGitHub
2 , autoreconfHook, bison, flex, pkg-config
3 , curl, geoip, libmaxminddb, libxml2, lmdb, lua, pcre, pcre2, ssdeep, yajl
4 , nixosTests
5 }:
7 stdenv.mkDerivation rec {
8   pname = "libmodsecurity";
9   version = "3.0.13";
11   src = fetchFromGitHub {
12     owner = "owasp-modsecurity";
13     repo = "ModSecurity";
14     rev = "v${version}";
15     hash = "sha256-+z31t007NLCAFG/Lsj5j/AbBDPkI2wjbH5yM5vipH04=";
16     fetchSubmodules = true;
17   };
19   nativeBuildInputs = [ autoreconfHook bison flex pkg-config ];
20   buildInputs = [ curl geoip libmaxminddb libxml2 lmdb lua pcre pcre2 ssdeep yajl ];
22   outputs = [ "out" "dev" ];
24   configureFlags = [
25     "--enable-parser-generation"
26     "--disable-doxygen-doc"
27     "--with-curl=${curl.dev}"
28     "--with-libxml=${libxml2.dev}"
29     "--with-lmdb=${lmdb.out}"
30     "--with-maxmind=${libmaxminddb}"
31     "--with-pcre=${pcre.dev}"
32     "--with-pcre2=${pcre2.out}"
33     "--with-ssdeep=${ssdeep}"
34   ];
36   postPatch = ''
37     substituteInPlace build/lmdb.m4 \
38       --replace "\''${path}/include/lmdb.h" "${lmdb.dev}/include/lmdb.h" \
39       --replace "lmdb_inc_path=\"\''${path}/include\"" "lmdb_inc_path=\"${lmdb.dev}/include\""
40     substituteInPlace build/pcre2.m4 \
41       --replace "/usr/local/pcre2" "${pcre2.out}/lib" \
42       --replace "\''${path}/include/pcre2.h" "${pcre2.dev}/include/pcre2.h" \
43       --replace "pcre2_inc_path=\"\''${path}/include\"" "pcre2_inc_path=\"${pcre2.dev}/include\""
44     substituteInPlace build/ssdeep.m4 \
45       --replace "/usr/local/libfuzzy" "${ssdeep}/lib" \
46       --replace "\''${path}/include/fuzzy.h" "${ssdeep}/include/fuzzy.h" \
47       --replace "ssdeep_inc_path=\"\''${path}/include\"" "ssdeep_inc_path=\"${ssdeep}/include\""
48     substituteInPlace modsecurity.conf-recommended \
49       --replace "SecUnicodeMapFile unicode.mapping 20127" "SecUnicodeMapFile $out/share/modsecurity/unicode.mapping 20127"
50   '';
52   postInstall = ''
53     mkdir -p $out/share/modsecurity
54     cp ${src}/{AUTHORS,CHANGES,LICENSE,README.md,modsecurity.conf-recommended,unicode.mapping} $out/share/modsecurity
55   '';
57   enableParallelBuilding = true;
59   passthru.tests = {
60     nginx-modsecurity = nixosTests.nginx-modsecurity;
61   };
63   meta = with lib; {
64     homepage = "https://github.com/owasp-modsecurity/ModSecurity";
65     description = ''
66       ModSecurity v3 library component.
67     '';
68     longDescription = ''
69       Libmodsecurity is one component of the ModSecurity v3 project. The
70       library codebase serves as an interface to ModSecurity Connectors taking
71       in web traffic and applying traditional ModSecurity processing. In
72       general, it provides the capability to load/interpret rules written in
73       the ModSecurity SecRules format and apply them to HTTP content provided
74       by your application via Connectors.
75     '';
76     license = licenses.asl20;
77     platforms = platforms.all;
78     maintainers = with maintainers; [ izorkin ];
79     mainProgram = "modsec-rules-check";
80   };