summary refs log tree commit diff
path: root/pkgs/development/python-modules/manticore/default.nix
blob: c645a070e4b1dd5af79bfd262d71f5f8eeaa5758 (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
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
{ lib
, buildPythonPackage
, capstone
, crytic-compile
, fetchFromGitHub
, intervaltree
, ply
, prettytable
, protobuf
, pyelftools
, pyevmasm
, pysha3
, pytestCheckHook
, pythonOlder
, pyyaml
, rlp
, stdenv
, unicorn
, wasm
, yices
, z3
}:

buildPythonPackage rec {
  pname = "manticore";
  version = "0.3.7";
  format = "setuptools";

  disabled = pythonOlder "3.7";

  src = fetchFromGitHub {
    owner = "trailofbits";
    repo = "manticore";
    rev = version;
    hash = "sha256-+17VBfAtkZZIi3SF5Num1Uqg3WjIpgbz3Jx65rD5zkM=";
  };

  propagatedBuildInputs = [
    crytic-compile
    intervaltree
    ply
    prettytable
    protobuf
    pyevmasm
    pysha3
    pyyaml
    rlp
    wasm
  ] ++ lib.optionals (stdenv.isLinux) [
    capstone
    pyelftools
    unicorn
  ];

  postPatch = ''
    # Python API is not used in the code, only z3 from PATH
    substituteInPlace setup.py \
      --replace "z3-solver" "" \
      --replace "crytic-compile==0.2.2" "crytic-compile>=0.2.2"
  '';

  checkInputs = [
    pytestCheckHook
  ];

  preCheck = ''
    export PATH=${yices}/bin:${z3}/bin:$PATH
  '';

  disabledTestPaths = [
    "tests/ethereum" # Enable when solc works again
    "tests/ethereum_bench"
  ] ++ lib.optionals (!stdenv.isLinux) [
    "tests/native"
    "tests/other/test_locking.py"
    "tests/other/test_state_introspection.py"
  ];

  disabledTests = [
    # Failing tests
    "test_chmod"
    "test_timeout"
    "test_wasm_main"
    # Slow tests
    "testmprotectFailSymbReading"
    "test_ConstraintsForking"
    "test_resume"
    "test_symbolic"
    "test_symbolic_syscall_arg"
    "test_state_merging"
    "test_decree"
    "test_register_comparison"
    "test_arguments_assertions_armv7"
    "test_integration_basic_stdout"
    "test_fclose_linux_amd64"
    "test_fileio_linux_amd64"
    "test_arguments_assertions_amd64"
    "test_ioctl_bogus"
    "test_ioctl_socket"
    "test_brk_regression"
    "test_basic_arm"
    "test_logger_verbosity"
    "test_profiling_data"
    "test_integration_basic_stdin"
    "test_getchar"
    "test_ccmp_reg"
    "test_ld1_mlt_structs"
    "test_ccmp_imm"
    "test_try_to_allocate_greater_than_last_space_memory_page_12"
    "test_not_enough_memory_page_12"
    "test_PCMPISTRI_30_symbolic"
    "test_ld1_mlt_structs"
    "test_time"
    "test_implicit_call"
    "test_trace"
    "test_plugin"
    # Tests are failing with latest unicorn
    "Aarch64UnicornInstructions"
    "test_integration_resume"
  ];

  pythonImportsCheck = [
    "manticore"
  ];

  meta = with lib; {
    # m.c.manticore:WARNING: Manticore is only supported on Linux. Proceed at your own risk!
    broken = (stdenv.isLinux && stdenv.isAarch64) || stdenv.isDarwin;
    description = "Symbolic execution tool for analysis of smart contracts and binaries";
    homepage = "https://github.com/trailofbits/manticore";
    changelog = "https://github.com/trailofbits/manticore/releases/tag/${version}";
    license = licenses.agpl3Only;
    platforms = platforms.unix;
    maintainers = with maintainers; [ arturcygan ];
  };
}