summary refs log tree commit diff
path: root/pkgs/development/tools/analysis/checkov/default.nix
blob: 6277b1d4239e43c1d5d221113358ce13edb86045 (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
{ stdenv, pkgs, lib, python3, fetchFromGitHub }:

let
  pname = "checkov";
  version = "1.0.674";
  src = fetchFromGitHub {
    owner = "bridgecrewio";
    repo = pname;
    rev = version;
    sha256 = "/S8ic5ZVxA2vd/rjRPX5gslbmnULL7BSx34vgWIsheQ=";
  };

  disabled = pkgs.python3Packages.pythonOlder "3.7";

  # CheckOV only work with `dpath 1.5.0`
  dpath = pkgs.python3Packages.buildPythonPackage rec {
    pname = "dpath";
    version = "1.5.0";

    src = pkgs.python3Packages.fetchPypi {
      inherit pname version;
      sha256 = "SWYVtOqEI20Y4NKGEi3nSGmmDg+H4sfsZ4f/KGxINhs=";
    };

    doCheck = false;
  };
in
python3.pkgs.buildPythonPackage rec {
  inherit pname version disabled src;

  nativeBuildInputs = with python3.pkgs; [ setuptools_scm ];

  propagatedBuildInputs = with python3.pkgs; [
    pytest
    coverage
    bandit
    bc-python-hcl2
    deep_merge
    tabulate
    colorama
    termcolor
    junit-xml
    dpath
    pyyaml
    boto3
    GitPython
    six
    jmespath
    tqdm
    update_checker
    semantic-version
    packaging
  ];

  # Both of these tests are pulling from external srouces (https://github.com/bridgecrewio/checkov/blob/f03a4204d291cf47e3753a02a9b8c8d805bbd1be/.github/workflows/build.yml)
  preCheck = ''
    rm -rf integration_tests/*
    rm -rf tests/terraform/*
  '';

  # Wrap the executable so that the python packages are available
  # it's just a shebang script which calls `python -m checkov "$@"`
  postFixup = ''
    wrapProgram $out/bin/checkov \
      --set PYTHONPATH $PYTHONPATH
  '';

  meta = with lib; {
    homepage = "https://github.com/bridgecrewio/checkov";
    description = "Static code analysis tool for infrastructure-as-code";
    longDescription = ''
    Prevent cloud misconfigurations during build-time for Terraform, Cloudformation, Kubernetes, Serverless framework and other infrastructure-as-code-languages with Checkov by Bridgecrew.
    '';
    license = licenses.asl20;
    maintainers = with maintainers; [ anhdle14 ];
  };
}