1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 gibberish-detector,
6 mock,
7 pkgs,
8 pyahocorasick,
9 pytestCheckHook,
10 pythonOlder,
11 pyyaml,
12 requests,
13 responses,
14 setuptools,
15 unidiff,
16}:
17
18buildPythonPackage rec {
19 pname = "bc-detect-secrets";
20 version = "1.5.10";
21 pyproject = true;
22
23 disabled = pythonOlder "3.8";
24
25 src = fetchFromGitHub {
26 owner = "bridgecrewio";
27 repo = "detect-secrets";
28 rev = "refs/tags/${version}";
29 hash = "sha256-b0t5xv4fWiErQsYvDKTJuweiGLqS2WpR9ECGo/cpvQ8=";
30 };
31
32 build-system = [ setuptools ];
33
34 dependencies = [
35 pyyaml
36 requests
37 unidiff
38 ];
39
40 passthru.optional-dependencies = {
41 word_list = [ pyahocorasick ];
42 gibberish = [ gibberish-detector ];
43 };
44
45 nativeCheckInputs = [
46 mock
47 pkgs.gitMinimal
48 pytestCheckHook
49 responses
50 ] ++ lib.flatten (builtins.attrValues passthru.optional-dependencies);
51
52 preCheck = ''
53 export HOME=$(mktemp -d);
54 '';
55
56 disabledTests = [
57 # Tests are failing for various reasons (missing git repo, missing test data, etc.)
58 "test_baseline_filters_out_known_secrets"
59 "test_make_decisions"
60 "test_saves_to_baseline"
61 "test_start_halfway"
62 "TestCreate"
63 "TestDiff"
64 "TestGetFilesToScan"
65 "TestLineNumberChanges"
66 "TestModifiesBaselineFromVersionChange"
67 ];
68
69 pythonImportsCheck = [ "detect_secrets" ];
70
71 meta = with lib; {
72 description = "Tool to detect secrets in the code";
73 homepage = "https://github.com/bridgecrewio/detect-secrets";
74 license = licenses.asl20;
75 maintainers = with maintainers; [ fab ];
76 };
77}