1{
2 lib,
3 buildPythonPackage,
4 cmake,
5 fetchFromGitHub,
6 pytestCheckHook,
7 libxcrypt,
8 gtest,
9 pybind11,
10 nlohmann_json,
11 setuptools,
12}:
13
14let
15 pog = fetchFromGitHub {
16 owner = "metthal";
17 repo = "pog";
18 rev = "b09bbf9cea573ee62aab7eccda896e37961d16cd";
19 hash = "sha256-El4WA92t2O/L4wUqH6Xj8w+ANtb6liRwafDhqn8jxjQ=";
20 };
21in
22buildPythonPackage rec {
23 pname = "yaramod";
24 version = "4.3.1";
25 pyproject = true;
26
27 src = fetchFromGitHub {
28 owner = "avast";
29 repo = "yaramod";
30 tag = "v${version}";
31 hash = "sha256-NAKQxKY3FdlSDbDBwiBricvMOwwlhtMNz9RPEaB6NOw=";
32 };
33
34 postPatch = ''
35 rm -r deps/googletest deps/pog/ deps/pybind11/ deps/json/json.hpp
36 cp -r --no-preserve=all ${pog} deps/pog/
37 cp -r --no-preserve=all ${nlohmann_json.src}/single_include/nlohmann/json.hpp deps/json/
38 cp -r --no-preserve=all ${pybind11.src} deps/pybind11/
39 cp -r --no-preserve=all ${gtest.src} deps/googletest/
40 '';
41
42 dontUseCmakeConfigure = true;
43
44 buildInputs = [ libxcrypt ];
45
46 nativeBuildInputs = [
47 cmake
48 pog
49 ];
50
51 build-system = [ setuptools ];
52
53 env.ENV_YARAMOD_BUILD_WITH_UNIT_TESTS = true;
54
55 nativeCheckInputs = [
56 gtest
57 pytestCheckHook
58 ];
59
60 pytestFlagsArray = [ "tests/" ];
61
62 pythonImportsCheck = [ "yaramod" ];
63
64 meta = with lib; {
65 description = "Parsing of YARA rules into AST and building new rulesets in C++";
66 homepage = "https://github.com/avast/yaramod";
67 changelog = "https://github.com/avast/yaramod/blob/v${version}/CHANGELOG.md";
68 license = licenses.mit;
69 maintainers = with maintainers; [ msm ];
70 };
71}