1{ 2 lib, 3 nix-update-script, 4 buildPythonPackage, 5 crytic-compile, 6 fetchFromGitHub, 7 makeWrapper, 8 packaging, 9 prettytable, 10 pythonOlder, 11 setuptools-scm, 12 solc, 13 web3, 14 withSolc ? false, 15 testers, 16 slither-analyzer, 17}: 18 19buildPythonPackage rec { 20 pname = "slither-analyzer"; 21 version = "0.11.3"; 22 pyproject = true; 23 24 disabled = pythonOlder "3.8"; 25 26 src = fetchFromGitHub { 27 owner = "crytic"; 28 repo = "slither"; 29 tag = version; 30 hash = "sha256-HgPQPyxDvKrmqGiHjiVGxEguYUcaNYwK1gZoMMkQWhM="; 31 }; 32 33 nativeBuildInputs = [ 34 makeWrapper 35 setuptools-scm 36 ]; 37 38 propagatedBuildInputs = [ 39 crytic-compile 40 packaging 41 prettytable 42 web3 43 ]; 44 45 postFixup = lib.optionalString withSolc '' 46 wrapProgram $out/bin/slither \ 47 --prefix PATH : "${lib.makeBinPath [ solc ]}" 48 ''; 49 50 # required for pythonImportsCheck 51 postInstall = '' 52 export HOME="$TEMP" 53 ''; 54 55 pythonImportsCheck = [ 56 "slither" 57 "slither.all_exceptions" 58 "slither.analyses" 59 "slither.core" 60 "slither.detectors" 61 "slither.exceptions" 62 "slither.formatters" 63 "slither.printers" 64 "slither.slither" 65 "slither.slithir" 66 "slither.solc_parsing" 67 "slither.utils" 68 "slither.visitors" 69 "slither.vyper_parsing" 70 ]; 71 72 # Test if the binary works during the build phase. 73 checkPhase = '' 74 runHook preCheck 75 76 HOME="$TEMP" $out/bin/slither --version 77 78 runHook postCheck 79 ''; 80 81 passthru.tests.version = testers.testVersion { 82 package = slither-analyzer; 83 command = "HOME=$TMPDIR slither --version"; 84 version = "${version}"; 85 }; 86 87 passthru.updateScript = nix-update-script { }; 88 89 meta = with lib; { 90 description = "Static Analyzer for Solidity"; 91 longDescription = '' 92 Slither is a Solidity static analysis framework written in Python 3. It 93 runs a suite of vulnerability detectors, prints visual information about 94 contract details, and provides an API to easily write custom analyses. 95 ''; 96 homepage = "https://github.com/trailofbits/slither"; 97 changelog = "https://github.com/crytic/slither/releases/tag/${version}"; 98 license = licenses.agpl3Plus; 99 mainProgram = "slither"; 100 maintainers = with maintainers; [ 101 arturcygan 102 fab 103 hellwolf 104 ]; 105 }; 106}