From 5ce0e10bffaf758bed7feed461e6a93e6830bf2239c2a228b489c62cce3aa256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=C3=A9ta=20Machov=C3=A1?= Date: Mon, 7 Apr 2025 12:03:22 +0000 Subject: [PATCH] - Update to version 0.10.0 * Add servicePrincipalName to output. * Fix functions descriptions. * Drop future requirement, require Python 3.6+. - Drop patch: * remove-future-requirement.patch - Add patch: * 73.patch OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-ldapdomaindump?expand=0&rev=7 --- .gitattributes | 23 ++++ .gitignore | 1 + 73.patch | 33 ++++++ ldapdomaindump-0.10.0.tar.gz | 3 + ldapdomaindump-0.9.4.tar.gz | 3 + python-ldapdomaindump.changes | 31 +++++ python-ldapdomaindump.spec | 86 ++++++++++++++ remove-future-requirement.patch | 204 ++++++++++++++++++++++++++++++++ 8 files changed, 384 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 73.patch create mode 100644 ldapdomaindump-0.10.0.tar.gz create mode 100644 ldapdomaindump-0.9.4.tar.gz create mode 100644 python-ldapdomaindump.changes create mode 100644 python-ldapdomaindump.spec create mode 100644 remove-future-requirement.patch diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/73.patch b/73.patch new file mode 100644 index 0000000..8a3f2f7 --- /dev/null +++ b/73.patch @@ -0,0 +1,33 @@ +From 07d88abbfc0056bf02321bdbcd503e59143b56e7 Mon Sep 17 00:00:00 2001 +From: Levente Polyak +Date: Fri, 4 Apr 2025 17:49:22 +0200 +Subject: [PATCH] fix(pyproject): declare license file property according to + PEP + +Fixes #72 +--- + pyproject.toml | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/pyproject.toml b/pyproject.toml +index 7657122..c7ab099 100644 +--- a/pyproject.toml ++++ b/pyproject.toml +@@ -11,11 +11,16 @@ authors = [ + ] + urls = { "Homepage" = "https://github.com/dirkjanm/ldapdomaindump/" } + requires-python = ">=3.6" +-license = "MIT" ++license = { file = "LICENSE" } + dependencies = [ + "dnspython", + "ldap3>=2.5,!=2.5.2,!=2.5.0,!=2.6" + ] ++classifiers = [ ++ "License :: OSI Approved :: MIT License", ++ "Programming Language :: Python :: 3", ++ "Programming Language :: Python :: 3.12", ++] + + [tool.setuptools.packages.find] + include = ["ldapdomaindump"] diff --git a/ldapdomaindump-0.10.0.tar.gz b/ldapdomaindump-0.10.0.tar.gz new file mode 100644 index 0000000..b84ff44 --- /dev/null +++ b/ldapdomaindump-0.10.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cbc66b32a7787473ffd169c5319acde46c02fdc9d444556e6448e0def91d3299 +size 19445 diff --git a/ldapdomaindump-0.9.4.tar.gz b/ldapdomaindump-0.9.4.tar.gz new file mode 100644 index 0000000..2453d1f --- /dev/null +++ b/ldapdomaindump-0.9.4.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:99dcda17050a96549966e53bc89e71da670094d53d9542b3b0d0197d035e6f52 +size 18933 diff --git a/python-ldapdomaindump.changes b/python-ldapdomaindump.changes new file mode 100644 index 0000000..2793e44 --- /dev/null +++ b/python-ldapdomaindump.changes @@ -0,0 +1,31 @@ +------------------------------------------------------------------- +Sun Apr 6 09:48:03 UTC 2025 - Martin Hauke + +- Update to version 0.10.0 + * Add servicePrincipalName to output. + * Fix functions descriptions. + * Drop future requirement, require Python 3.6+. +- Drop patch: + * remove-future-requirement.patch +- Add patch: + * 73.patch + +------------------------------------------------------------------- +Wed Sep 6 05:58:09 UTC 2023 - Steve Kowalik + +- Add missing Requires on update-alternatives. +- Switch to autosetup and pyproject macros. +- Add patch remove-future-requirement.patch, dropping requirement on future +- Stop using globs in %files. +- dos2unix the unpacked files. + +------------------------------------------------------------------- +Thu Jan 5 19:57:29 UTC 2023 - Yogalakshmi Arunachalam + +- Update to version 0.9.4 + * version bump for pypi + +------------------------------------------------------------------- +Wed Jul 8 07:27:11 UTC 2020 - Martin Hauke + +- Initial package, version 0.9.3 diff --git a/python-ldapdomaindump.spec b/python-ldapdomaindump.spec new file mode 100644 index 0000000..6a575f5 --- /dev/null +++ b/python-ldapdomaindump.spec @@ -0,0 +1,86 @@ +# +# spec file for package python-ldapdomaindump +# +# Copyright (c) 2025 SUSE LLC +# Copyright (c) 2020-2025, Martin Hauke +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + + +Name: python-ldapdomaindump +Version: 0.10.0 +Release: 0 +Summary: Active Directory information dumper via LDAP +License: MIT +URL: https://github.com/dirkjanm/ldapdomaindump/ +Source: https://files.pythonhosted.org/packages/source/l/ldapdomaindump/ldapdomaindump-%{version}.tar.gz +# PATCH-FIX-UPSTREAM https://github.com/dirkjanm/ldapdomaindump/pull/73 +Patch0: https://patch-diff.githubusercontent.com/raw/dirkjanm/ldapdomaindump/pull/73.patch +BuildRequires: %{python_module pip} +BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module wheel} +BuildRequires: dos2unix +BuildRequires: fdupes +BuildRequires: python-rpm-macros +Requires: python-dnspython +Requires: python-ldap3 >= 2.5 +Requires(post): update-alternatives +Requires(postun): update-alternatives +BuildArch: noarch +# SECTION test requirements +BuildRequires: %{python_module dnspython} +BuildRequires: %{python_module ldap3 >= 2.5} +# /SECTION +%python_subpackages + +%description +Active Directory information dumper via LDAP. + +%prep +%autosetup -p1 -n ldapdomaindump-%{version} +sed -i 's|#!%{_bindir}/env python|#!%{_bindir}/python3|g' \ + bin/ldd2pretty \ + bin/ldapdomaindump \ + bin/ldd2bloodhound +sed -i '/^#!\//, 1d' ldapdomaindump/__main__.py +find . -type f -exec dos2unix {} \; + +%build +%pyproject_wheel + +%install +%pyproject_install +%python_clone -a %{buildroot}%{_bindir}/ldapdomaindump +%python_clone -a %{buildroot}%{_bindir}/ldd2bloodhound +%python_clone -a %{buildroot}%{_bindir}/ldd2pretty +%python_expand %fdupes %{buildroot}%{$python_sitelib} + +%post +%python_install_alternative ldapdomaindump ldd2bloodhound ldd2pretty + +%postun +%python_uninstall_alternative ldapdomaindump ldd2bloodhound ldd2pretty + +#%%check +# Upstream does not provide tests + +%files %{python_files} +%license LICENSE +%doc README.md +%python_alternative %{_bindir}/ldapdomaindump +%python_alternative %{_bindir}/ldd2bloodhound +%python_alternative %{_bindir}/ldd2pretty +%{python_sitelib}/ldapdomaindump +%{python_sitelib}/ldapdomaindump-%{version}.dist-info + +%changelog diff --git a/remove-future-requirement.patch b/remove-future-requirement.patch new file mode 100644 index 0000000..1e4d88f --- /dev/null +++ b/remove-future-requirement.patch @@ -0,0 +1,204 @@ +From 413ceec72fb36832b92b7afdeaa7b164ee1837fc Mon Sep 17 00:00:00 2001 +From: Steve Kowalik +Date: Wed, 6 Sep 2023 15:45:39 +1000 +Subject: [PATCH] Drop future requirement, require Python 3.6+ + +With Python 2 having been unsupported for two and a half years, it's +past time to remove support for it, and by extension, the future module. +I've switched to Python 3.6 code, and forced that requirement in +setup.py + +Closes #53 +--- + Readme.md | 2 +- + ldapdomaindump/__init__.py | 26 ++++++++++---------------- + ldapdomaindump/convert.py | 8 +++----- + ldapdomaindump/pretty.py | 4 +--- + requirements.txt | 1 - + setup.py | 3 ++- + 6 files changed, 17 insertions(+), 27 deletions(-) + +Index: ldapdomaindump-0.9.4/Readme.md +=================================================================== +--- ldapdomaindump-0.9.4.orig/Readme.md ++++ ldapdomaindump-0.9.4/Readme.md +@@ -25,7 +25,7 @@ As well as two grouped files: + - *domain_computers_by_os*: Domain computers sorted by Operating System + + ## Dependencies and installation +-Requires [ldap3](https://github.com/cannatag/ldap3) > 2.0, [dnspython](https://github.com/rthalley/dnspython) and [future](https://python-future.org/). ldapdomaindump runs on both python 2 and 3. ++Requires [ldap3](https://github.com/cannatag/ldap3) > 2.0 and [dnspython](https://github.com/rthalley/dnspython). ldapdomaindump requires Python 3.6 or greater. + + Dependencies can be installed manually with `pip install ldap3 dnspython future`, but should in most cases be handled by pip when you install the main package either from git or pypi. + +Index: ldapdomaindump-0.9.4/ldapdomaindump/__init__.py +=================================================================== +--- ldapdomaindump-0.9.4.orig/ldapdomaindump/__init__.py ++++ ldapdomaindump-0.9.4/ldapdomaindump/__init__.py +@@ -21,22 +21,16 @@ + # SOFTWARE. + # + #################### +-from __future__ import unicode_literals + import sys, os, re, codecs, json, argparse, getpass, base64 + # import class and constants + from datetime import datetime, timedelta +-try: +- from urllib.parse import quote_plus +-except ImportError: +- from urllib import quote_plus ++from urllib.parse import quote_plus + import ldap3 + from ldap3 import Server, Connection, SIMPLE, SYNC, ALL, SASL, NTLM + from ldap3.core.exceptions import LDAPKeyError, LDAPAttributeError, LDAPCursorError, LDAPInvalidDnError + from ldap3.abstract import attribute, attrDef + from ldap3.utils import dn + from ldap3.protocol.formatters.formatters import format_sid +-from builtins import str +-from future.utils import itervalues, iteritems, native_str + + # dnspython, for resolving hostnames + import dns.resolver +@@ -125,7 +119,7 @@ MINIMAL_USERATTRIBUTES = ['cn', 'name', + MINIMAL_GROUPATTRIBUTES = ['cn', 'name', 'sAMAccountName', 'memberOf', 'description', 'whenCreated', 'whenChanged', 'objectSid', 'distinguishedName', 'objectClass'] + + #Class containing the default config +-class domainDumpConfig(object): ++class domainDumpConfig(): + def __init__(self): + #Base path + self.basepath = '.' +@@ -158,7 +152,7 @@ class domainDumpConfig(object): + self.minimal = False #Only query minimal list of attributes + + #Domaindumper main class +-class domainDumper(object): ++class domainDumper(): + def __init__(self, server, connection, config, root=None): + self.server = server + self.connection = connection +@@ -429,7 +423,7 @@ class domainDumper(object): + rw.generateComputersByOsReport(self) + rw.generateUsersByGroupReport(self) + +-class reportWriter(object): ++class reportWriter(): + def __init__(self, config): + self.config = config + self.dd = None +@@ -474,7 +468,7 @@ class reportWriter(object): + outflags = [] + if attr is None or attr.value is None: + return outflags +- for flag, val in iteritems(flags_def): ++ for flag, val in flags_def.items(): + if int(attr.value) & val: + outflags.append(flag) + return outflags +@@ -484,7 +478,7 @@ class reportWriter(object): + outflags = [] + if attr is None: + return outflags +- for flag, val in iteritems(flags_def): ++ for flag, val in flags_def.items(): + if int(attr.value) == val: + outflags.append(flag) + return outflags +@@ -528,7 +522,7 @@ class reportWriter(object): + #Generate several HTML tables for grouped reports + def generateGroupedHtmlTables(self, groups, attributes): + first = True +- for groupname, members in iteritems(groups): ++ for groupname, members in groups.items(): + yield self.generateHtmlTable(members, attributes, groupname, first, specialGroupsFormat=True) + if first: + first = False +@@ -761,7 +755,7 @@ class reportWriter(object): + #Start of the list + yield '[' + firstGroup = True +- for group in iteritems(groups): ++ for group in groups.items(): + if not firstGroup: + #Separate items + yield ',' +@@ -867,8 +861,8 @@ def main(): + #Main parameters + #maingroup = parser.add_argument_group("Main options") + parser.add_argument("host", type=str, metavar='HOSTNAME', help="Hostname/ip or ldap://host:port connection string to connect to (use ldaps:// to use SSL)") +- parser.add_argument("-u", "--user", type=native_str, metavar='USERNAME', help="DOMAIN\\username for authentication, leave empty for anonymous authentication") +- parser.add_argument("-p", "--password", type=native_str, metavar='PASSWORD', help="Password or LM:NTLM hash, will prompt if not specified") ++ parser.add_argument("-u", "--user", type=str, metavar='USERNAME', help="DOMAIN\\username for authentication, leave empty for anonymous authentication") ++ parser.add_argument("-p", "--password", type=str, metavar='PASSWORD', help="Password or LM:NTLM hash, will prompt if not specified") + parser.add_argument("-at", "--authtype", type=str, choices=['NTLM', 'SIMPLE'], default='NTLM', help="Authentication type (NTLM or SIMPLE, default: NTLM)") + + #Output parameters +Index: ldapdomaindump-0.9.4/ldapdomaindump/convert.py +=================================================================== +--- ldapdomaindump-0.9.4.orig/ldapdomaindump/convert.py ++++ ldapdomaindump-0.9.4/ldapdomaindump/convert.py +@@ -6,13 +6,11 @@ import json + import codecs + import re + from ldapdomaindump import trust_flags, trust_directions +-from builtins import str +-from future.utils import itervalues, iteritems + + logging.basicConfig() + logger = logging.getLogger('ldd2bloodhound') + +-class Utils(object): ++class Utils(): + @staticmethod + def ldap_to_domain(ldap): + return re.sub(',DC=', '.', ldap[ldap.find('DC='):], flags=re.I)[3:] +@@ -27,7 +25,7 @@ class Utils(object): + 'memberOf': groupo['attributes']['memberOf'] if 'memberOf' in groupo['attributes'] else [] + } + +-class BloodHoundConverter(object): ++class BloodHoundConverter(): + def __init__(self): + # Input files + self.computers_files = [] +@@ -87,7 +85,7 @@ class BloodHoundConverter(object): + # Read group mapping - write to csv + # file is already created here, we just append + with codecs.open('group_membership.csv', 'a', 'utf-8') as outfile: +- for group in itervalues(self.groups_by_dn): ++ for group in self.groups_by_dn.values(): + for membergroup in group['memberOf']: + try: + outfile.write('%s,%s,%s\n' % (self.groups_by_dn[membergroup]['principal'], group['principal'], 'group')) +Index: ldapdomaindump-0.9.4/ldapdomaindump/pretty.py +=================================================================== +--- ldapdomaindump-0.9.4.orig/ldapdomaindump/pretty.py ++++ ldapdomaindump-0.9.4/ldapdomaindump/pretty.py +@@ -1,12 +1,10 @@ +-from __future__ import print_function +-from builtins import str + import argparse + import json + import os.path + import re + from time import strftime, gmtime + +-class PrettyOuput(object): ++class PrettyOuput(): + + def d2b(self, a): + tbin = [] +Index: ldapdomaindump-0.9.4/setup.py +=================================================================== +--- ldapdomaindump-0.9.4.orig/setup.py ++++ ldapdomaindump-0.9.4/setup.py +@@ -6,7 +6,8 @@ setup(name='ldapdomaindump', + author_email='dirkjan@sanoweb.nl', + url='https://github.com/dirkjanm/ldapdomaindump/', + packages=['ldapdomaindump'], +- install_requires=['dnspython', 'ldap3>=2.5,!=2.5.2,!=2.5.0,!=2.6', 'future'], ++ requires_python=">=3.6", ++ install_requires=['dnspython', 'ldap3>=2.5,!=2.5.2,!=2.5.0,!=2.6'], + package_data={'ldapdomaindump': ['style.css']}, + include_package_data=True, + scripts=['bin/ldapdomaindump', 'bin/ldd2bloodhound', 'bin/ldd2pretty'],