summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/bloodyad/default.nix
blob: 34149bf73584a2b2831748cbfd104c9751619cfe (plain)
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
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,

  # build-system
  hatchling,

  # dependencies
  asn1crypto,
  badldap,
  cryptography,
  dnspython,
  kerbad,
  winacl,

  # test
  certipy,
  pytestCheckHook,
}:

buildPythonPackage rec {
  pname = "bloodyad";
  version = "2.5.3";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "CravateRouge";
    repo = "bloodyAD";
    tag = "v${version}";
    hash = "sha256-xevh8bPTyroZEiYqG5tbcjhhxjjQWencZTV4Iy/0U28=";
  };

  pythonRelaxDeps = [ "cryptography" ];

  pythonRemoveDeps = [
    "kerbad"
    "badldap"
  ];

  build-system = [ hatchling ];

  # Upstream provides two package scripts: bloodyad and bloodyAD,
  # but this causes a FileAlreadyExists error during installation
  # on Darwin (case-insensitive filesystem).
  # https://github.com/CravateRouge/bloodyAD/issues/99
  postPatch = lib.optionals stdenv.hostPlatform.isDarwin ''
    substituteInPlace pyproject.toml \
      --replace-fail "bloodyAD = \"bloodyAD.main:main\"" ""
  '';

  dependencies = [
    asn1crypto
    badldap
    cryptography
    dnspython
    kerbad
    winacl
  ];

  nativeCheckInputs = [
    certipy
    pytestCheckHook
  ];

  pythonImportsCheck = [ "bloodyAD" ];

  disabledTests = [
    # Tests require network access
    "test_kerberos_authentications"
    "test_01AuthCreateUser"
    "test_02SearchAndGetChildAndGetWritable"
    "test_03UacOwnerGenericShadowGroupPasswordDCSync"
    "test_04ComputerRbcdGetSetAttribute"
    "test_06AddRemoveGetDnsRecord"
    "test_certificate_authentications"
    "test_04ComputerRbcdRestoreGetSetAttribute"
  ];

  disabledTestPaths = [
    # TypeError: applyFormatters() takes 1 positional argument but 2 were given
    # https://github.com/CravateRouge/bloodyAD/issues/98
    "tests/test_formatters.py"
  ];

  meta = {
    description = "Module for Active Directory Privilege Escalations";
    homepage = "https://github.com/CravateRouge/bloodyAD";
    changelog = "https://github.com/CravateRouge/bloodyAD/releases/tag/${src.tag}";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ fab ];
  };
}