trproof 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
trproof-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 TrProof Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
trproof-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,165 @@
1
+ Metadata-Version: 2.4
2
+ Name: trproof
3
+ Version: 0.1.0
4
+ Summary: Read-only CLI security assessment tool for on-premises AD and Microsoft Entra ID identity attack surfaces.
5
+ License-Expression: MIT
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: click>=8.1
10
+ Requires-Dist: rich>=13.7
11
+ Requires-Dist: ldap3>=2.9.1
12
+ Requires-Dist: msal>=1.28
13
+ Requires-Dist: requests>=2.31
14
+ Requires-Dist: cryptography>=42.0
15
+ Requires-Dist: pydantic>=2.6
16
+ Provides-Extra: dev
17
+ Requires-Dist: pytest>=8.0; extra == "dev"
18
+ Requires-Dist: bandit>=1.7; extra == "dev"
19
+ Requires-Dist: pip-audit>=2.7; extra == "dev"
20
+ Requires-Dist: build>=1.0; extra == "dev"
21
+ Dynamic: license-file
22
+
23
+ ![TrProof Identity Attack Surface Auditor](docs/trproof-banner.png)
24
+
25
+ # TrProof
26
+
27
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
28
+
29
+ **TrProof** is a read-only, command-line security assessment tool for on-premises Active Directory and Microsoft Entra ID identity attack surfaces. It runs in under 10 minutes, requires no agents, and produces a cryptographically signed, self-contained one-page report that auditors and cyber-insurance reviewers can verify offline.
30
+
31
+ ## Elevator pitch
32
+
33
+ - **Zero agents, zero database.** A single lightweight CLI.
34
+ - **Read-only.** Never writes, modifies passwords, or disables accounts.
35
+ - **Offline-capable for AD.** Works against a domain controller you can reach over LDAP/LDAPS.
36
+ - **Hybrid.** Unifies on-prem AD and Entra ID in an in-memory shortest-path attack graph.
37
+ - **Auditor-ready.** Ed25519-signed JSON + self-contained HTML, verifiable with `trproof-verify`.
38
+
39
+ ## Safety & Ethics
40
+
41
+ - **Read-only guarantee.** TrProof only reads directory data. It never writes, modifies passwords, disables accounts, or installs agents.
42
+ - **Authorization required.** You must own or have explicit written authorization to audit the target environment. The CLI prompts for confirmation unless `--yes` is supplied.
43
+ - **Zero telemetry.** No data is sent anywhere. Collection happens in-memory and is written only to the output files you choose.
44
+ - **In-memory credentials only.** Passwords and tokens are held in process memory for the duration of the scan and are never persisted to disk by TrProof.
45
+
46
+ ## Quickstart
47
+
48
+ ### Linux / macOS one-liner
49
+
50
+ ```bash
51
+ curl -sSL https://raw.githubusercontent.com/ebanatrm100/trproof/main/scripts/install.sh | bash
52
+ ```
53
+
54
+ ### Windows PowerShell one-liner
55
+
56
+ ```powershell
57
+ irm https://raw.githubusercontent.com/ebanatrm100/trproof/main/scripts/install.ps1 | iex
58
+ ```
59
+
60
+ ### pip
61
+
62
+ ```bash
63
+ pip install trproof
64
+ ```
65
+
66
+ ### Docker
67
+
68
+ ```bash
69
+ docker run --rm -v "$PWD:/out" trproof scan --mock --yes -o /out
70
+ ```
71
+
72
+ ## CLI Examples
73
+
74
+ Scan on-premises AD:
75
+
76
+ ```bash
77
+ trproof scan --ad --ldap dc01.corp.local -u audit-reader
78
+ ```
79
+
80
+ Scan Microsoft Entra ID:
81
+
82
+ ```bash
83
+ trproof scan --entra --tenant-id <tenant-id>
84
+ ```
85
+
86
+ Hybrid AD + Entra scan:
87
+
88
+ ```bash
89
+ trproof scan --ad --ldap dc01.corp.local -u audit-reader --entra --tenant-id <tenant-id>
90
+ ```
91
+
92
+ Verify a report:
93
+
94
+ ```bash
95
+ trproof-verify report.json
96
+ ```
97
+
98
+ Use a custom signing key:
99
+
100
+ ```bash
101
+ trproof scan --mock --yes --signing-key ./my_ed25519_priv.pem -o ./out
102
+ ```
103
+
104
+ Mock scan (no network):
105
+
106
+ ```bash
107
+ trproof scan --mock --yes
108
+ ```
109
+
110
+ ## Required least-privilege permissions
111
+
112
+ ### Active Directory (read-only)
113
+
114
+ | Role / Account | Permissions |
115
+ |---|---|
116
+ | Standard Domain User or dedicated `audit-reader` | Read access to AD objects (users, groups, computers, OUs, ACLs, SPNs). No write, reset, or admin rights required. |
117
+ | Network | LDAPS (port 636) or LDAP (port 389) read-only connectivity to a domain controller. |
118
+
119
+ ### Microsoft Entra ID (read-only Microsoft Graph scopes)
120
+
121
+ | Scope | Purpose |
122
+ |---|---|
123
+ | `User.Read.All` | Read user profiles and authentication methods |
124
+ | `Group.Read.All` | Read group membership |
125
+ | `Directory.Read.All` | Read directory roles and assignments |
126
+ | `RoleManagement.Read.Directory` | Read privileged role assignments |
127
+ | `Application.Read.All` | Read service principals and app registrations |
128
+
129
+ All scopes are **read-only**. TrProof never requests write scopes.
130
+
131
+ ## Sample report preview
132
+
133
+ Terminal verdict and top-5 paths:
134
+
135
+ ```
136
+ ┌────────────────────────────── TrProof Verdict ──────────────────────────────┐
137
+ │ Your identity attack surface: CRITICAL │
138
+ └─────────────────────────────────────────────────────────────────────────────┘
139
+ Top 5 Ways a Phished Employee Could Reach Domain Admin / Global Admin:
140
+ Path 1 (3 steps): j.smith (no phishing-resistant MFA) → member of 'HelpDesk' →
141
+ HelpDesk can reset passwords of 'svc-backup' → svc-backup is Domain Admin.
142
+ ```
143
+
144
+ Signed one-page report layout:
145
+
146
+ ![TrProof sample signed report](docs/sample-report-preview.svg)
147
+
148
+ ## Prior Art & Acknowledgments
149
+
150
+ TrProof builds on the foundational work of the AD and Entra ID security assessment community. We respectfully credit:
151
+
152
+ - **PingCastle** — pioneering AD security scoring and health checks.
153
+ - **Purple Knight** — comprehensive AD/Entra security assessment benchmarks.
154
+ - **EntraFalcon** — Entra ID-focused security assessment and reporting.
155
+ - **Guerrilla** — identity attack-path research and tooling.
156
+
157
+ What TrProof adds:
158
+
159
+ 1. **Verdict-first plain-language UX** tailored for small-business sysadmins and non-specialists.
160
+ 2. **Cryptographically signed (Ed25519), self-contained one-page HTML/JSON report** verifiable offline via `trproof-verify` for cyber-insurance and compliance audits.
161
+ 3. **Unified hybrid on-premises AD + Entra ID in-memory shortest-path attack graph** in a single lightweight CLI with zero database dependencies.
162
+
163
+ ## License
164
+
165
+ MIT. See [LICENSE](LICENSE).
@@ -0,0 +1,143 @@
1
+ ![TrProof Identity Attack Surface Auditor](docs/trproof-banner.png)
2
+
3
+ # TrProof
4
+
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
6
+
7
+ **TrProof** is a read-only, command-line security assessment tool for on-premises Active Directory and Microsoft Entra ID identity attack surfaces. It runs in under 10 minutes, requires no agents, and produces a cryptographically signed, self-contained one-page report that auditors and cyber-insurance reviewers can verify offline.
8
+
9
+ ## Elevator pitch
10
+
11
+ - **Zero agents, zero database.** A single lightweight CLI.
12
+ - **Read-only.** Never writes, modifies passwords, or disables accounts.
13
+ - **Offline-capable for AD.** Works against a domain controller you can reach over LDAP/LDAPS.
14
+ - **Hybrid.** Unifies on-prem AD and Entra ID in an in-memory shortest-path attack graph.
15
+ - **Auditor-ready.** Ed25519-signed JSON + self-contained HTML, verifiable with `trproof-verify`.
16
+
17
+ ## Safety & Ethics
18
+
19
+ - **Read-only guarantee.** TrProof only reads directory data. It never writes, modifies passwords, disables accounts, or installs agents.
20
+ - **Authorization required.** You must own or have explicit written authorization to audit the target environment. The CLI prompts for confirmation unless `--yes` is supplied.
21
+ - **Zero telemetry.** No data is sent anywhere. Collection happens in-memory and is written only to the output files you choose.
22
+ - **In-memory credentials only.** Passwords and tokens are held in process memory for the duration of the scan and are never persisted to disk by TrProof.
23
+
24
+ ## Quickstart
25
+
26
+ ### Linux / macOS one-liner
27
+
28
+ ```bash
29
+ curl -sSL https://raw.githubusercontent.com/ebanatrm100/trproof/main/scripts/install.sh | bash
30
+ ```
31
+
32
+ ### Windows PowerShell one-liner
33
+
34
+ ```powershell
35
+ irm https://raw.githubusercontent.com/ebanatrm100/trproof/main/scripts/install.ps1 | iex
36
+ ```
37
+
38
+ ### pip
39
+
40
+ ```bash
41
+ pip install trproof
42
+ ```
43
+
44
+ ### Docker
45
+
46
+ ```bash
47
+ docker run --rm -v "$PWD:/out" trproof scan --mock --yes -o /out
48
+ ```
49
+
50
+ ## CLI Examples
51
+
52
+ Scan on-premises AD:
53
+
54
+ ```bash
55
+ trproof scan --ad --ldap dc01.corp.local -u audit-reader
56
+ ```
57
+
58
+ Scan Microsoft Entra ID:
59
+
60
+ ```bash
61
+ trproof scan --entra --tenant-id <tenant-id>
62
+ ```
63
+
64
+ Hybrid AD + Entra scan:
65
+
66
+ ```bash
67
+ trproof scan --ad --ldap dc01.corp.local -u audit-reader --entra --tenant-id <tenant-id>
68
+ ```
69
+
70
+ Verify a report:
71
+
72
+ ```bash
73
+ trproof-verify report.json
74
+ ```
75
+
76
+ Use a custom signing key:
77
+
78
+ ```bash
79
+ trproof scan --mock --yes --signing-key ./my_ed25519_priv.pem -o ./out
80
+ ```
81
+
82
+ Mock scan (no network):
83
+
84
+ ```bash
85
+ trproof scan --mock --yes
86
+ ```
87
+
88
+ ## Required least-privilege permissions
89
+
90
+ ### Active Directory (read-only)
91
+
92
+ | Role / Account | Permissions |
93
+ |---|---|
94
+ | Standard Domain User or dedicated `audit-reader` | Read access to AD objects (users, groups, computers, OUs, ACLs, SPNs). No write, reset, or admin rights required. |
95
+ | Network | LDAPS (port 636) or LDAP (port 389) read-only connectivity to a domain controller. |
96
+
97
+ ### Microsoft Entra ID (read-only Microsoft Graph scopes)
98
+
99
+ | Scope | Purpose |
100
+ |---|---|
101
+ | `User.Read.All` | Read user profiles and authentication methods |
102
+ | `Group.Read.All` | Read group membership |
103
+ | `Directory.Read.All` | Read directory roles and assignments |
104
+ | `RoleManagement.Read.Directory` | Read privileged role assignments |
105
+ | `Application.Read.All` | Read service principals and app registrations |
106
+
107
+ All scopes are **read-only**. TrProof never requests write scopes.
108
+
109
+ ## Sample report preview
110
+
111
+ Terminal verdict and top-5 paths:
112
+
113
+ ```
114
+ ┌────────────────────────────── TrProof Verdict ──────────────────────────────┐
115
+ │ Your identity attack surface: CRITICAL │
116
+ └─────────────────────────────────────────────────────────────────────────────┘
117
+ Top 5 Ways a Phished Employee Could Reach Domain Admin / Global Admin:
118
+ Path 1 (3 steps): j.smith (no phishing-resistant MFA) → member of 'HelpDesk' →
119
+ HelpDesk can reset passwords of 'svc-backup' → svc-backup is Domain Admin.
120
+ ```
121
+
122
+ Signed one-page report layout:
123
+
124
+ ![TrProof sample signed report](docs/sample-report-preview.svg)
125
+
126
+ ## Prior Art & Acknowledgments
127
+
128
+ TrProof builds on the foundational work of the AD and Entra ID security assessment community. We respectfully credit:
129
+
130
+ - **PingCastle** — pioneering AD security scoring and health checks.
131
+ - **Purple Knight** — comprehensive AD/Entra security assessment benchmarks.
132
+ - **EntraFalcon** — Entra ID-focused security assessment and reporting.
133
+ - **Guerrilla** — identity attack-path research and tooling.
134
+
135
+ What TrProof adds:
136
+
137
+ 1. **Verdict-first plain-language UX** tailored for small-business sysadmins and non-specialists.
138
+ 2. **Cryptographically signed (Ed25519), self-contained one-page HTML/JSON report** verifiable offline via `trproof-verify` for cyber-insurance and compliance audits.
139
+ 3. **Unified hybrid on-premises AD + Entra ID in-memory shortest-path attack graph** in a single lightweight CLI with zero database dependencies.
140
+
141
+ ## License
142
+
143
+ MIT. See [LICENSE](LICENSE).
@@ -0,0 +1,43 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "trproof"
7
+ version = "0.1.0"
8
+ description = "Read-only CLI security assessment tool for on-premises AD and Microsoft Entra ID identity attack surfaces."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ dependencies = [
14
+ "click>=8.1",
15
+ "rich>=13.7",
16
+ "ldap3>=2.9.1",
17
+ "msal>=1.28",
18
+ "requests>=2.31",
19
+ "cryptography>=42.0",
20
+ "pydantic>=2.6",
21
+ ]
22
+
23
+ [project.optional-dependencies]
24
+ dev = [
25
+ "pytest>=8.0",
26
+ "bandit>=1.7",
27
+ "pip-audit>=2.7",
28
+ "build>=1.0",
29
+ ]
30
+
31
+ [project.scripts]
32
+ trproof = "trproof.cli:main"
33
+ trproof-verify = "trproof.cli:verify_main"
34
+
35
+ [tool.setuptools.packages.find]
36
+ where = ["."]
37
+ include = ["trproof*"]
38
+
39
+ [tool.setuptools.package-data]
40
+ trproof = ["keys/*.pem"]
41
+
42
+ [tool.pytest.ini_options]
43
+ testpaths = ["tests"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,204 @@
1
+ from __future__ import annotations
2
+
3
+ from types import SimpleNamespace
4
+ from unittest.mock import MagicMock, patch
5
+
6
+ import pytest
7
+ from ldap3.core.exceptions import LDAPInsufficientAccessRightsResult
8
+
9
+ from trproof.collectors.ad import ADCollector
10
+ from trproof.models import ScanBundle
11
+
12
+
13
+ class _Attr:
14
+ def __init__(self, value):
15
+ self.value = value
16
+
17
+
18
+ class LdapEntry:
19
+ def __init__(self, **attrs):
20
+ self._attrs = attrs
21
+ for key, val in attrs.items():
22
+ setattr(self, key, _Attr(val))
23
+ self.entry_dn = attrs.get("dn", attrs.get("distinguishedName", ""))
24
+
25
+ def __getitem__(self, key):
26
+ return getattr(self, key, None)
27
+
28
+
29
+ def _make_conn(entries=None):
30
+ conn = MagicMock()
31
+ conn.entries = list(entries or [])
32
+ conn.server.info.other = {"defaultNamingContext": "DC=corp,DC=local"}
33
+ return conn
34
+
35
+
36
+ def test_connect_uses_read_only_true():
37
+ with patch("trproof.collectors.ad.Server") as mock_server, patch("trproof.collectors.ad.Connection") as mock_conn_cls:
38
+ mock_conn = MagicMock()
39
+ mock_conn_cls.return_value = mock_conn
40
+ mock_conn.server.info.other = {"defaultNamingContext": "DC=corp,DC=local"}
41
+
42
+ collector = ADCollector(
43
+ server="dc01.corp.local",
44
+ username="audit-reader",
45
+ password="secret",
46
+ port=636,
47
+ use_ssl=True,
48
+ base_dn="DC=corp,DC=local",
49
+ )
50
+ conn = collector.connect()
51
+ assert conn is mock_conn
52
+ kwargs = mock_conn_cls.call_args.kwargs
53
+ assert kwargs.get("read_only") is True
54
+ assert kwargs.get("auto_bind") is True
55
+
56
+
57
+ def test_partial_access_resilience():
58
+ with patch("trproof.collectors.ad.Server"), patch("trproof.collectors.ad.Connection") as mock_conn_cls:
59
+ mock_conn = _make_conn([])
60
+ mock_conn_cls.return_value = mock_conn
61
+
62
+ collector = ADCollector(
63
+ server="dc01.corp.local",
64
+ username="u",
65
+ password="p",
66
+ base_dn="DC=corp,DC=local",
67
+ )
68
+
69
+ def boom(conn):
70
+ raise LDAPInsufficientAccessRightsResult("no access")
71
+
72
+ collector._check_kerberos_delegation = boom # type: ignore
73
+
74
+ bundle = collector.collect()
75
+ assert isinstance(bundle, ScanBundle)
76
+ assert len(bundle.warnings) == 1
77
+ assert bundle.warnings[0].source == "ad"
78
+ assert "delegation" in bundle.warnings[0].check_name.lower() or "kerberos" in bundle.warnings[0].check_name.lower()
79
+
80
+
81
+ def test_tier0_check_emits_finding():
82
+ collector = ADCollector(server="dc", username="u", password="p", base_dn="DC=corp,DC=local")
83
+ conn = _make_conn()
84
+
85
+ group_entry = LdapEntry(distinguishedName="CN=Domain Admins,CN=Users,DC=corp,DC=local", member=["CN=alice,DC=corp,DC=local"])
86
+ user_entry = LdapEntry(sAMAccountName="alice", distinguishedName="CN=alice,DC=corp,DC=local")
87
+
88
+ def fake_search(conn_arg, search_filter, attributes, search_base=None):
89
+ if "objectClass=group" in search_filter:
90
+ return [group_entry]
91
+ if "memberOf:1.2.840" in search_filter:
92
+ return [user_entry]
93
+ if search_filter.startswith("(distinguishedName="):
94
+ return [group_entry]
95
+ return []
96
+
97
+ collector._search = fake_search # type: ignore
98
+ collector._check_tier0_admins(conn)
99
+ ids = [f.id for f in collector.findings]
100
+ assert "AD-001" in ids
101
+
102
+
103
+ def test_stale_admincount_check():
104
+ collector = ADCollector(server="dc", username="u", password="p", base_dn="DC=corp,DC=local")
105
+ conn = _make_conn()
106
+ old_ts = (116444736000000000) + (100 * 86400 * 10000000) # ~100 days ago? actually epoch low; ensure stale
107
+ # Use a timestamp far in the past
108
+ old_filetime = 116444736000000000 + int((1700000000 - 90 * 86400) * 10000000)
109
+ entry = LdapEntry(sAMAccountName="svc-old", lastLogonTimestamp=old_filetime, userAccountControl=0x10000, objectClass=["top", "person", "organizationalPerson", "user"], distinguishedName="CN=svc-old,DC=corp,DC=local")
110
+ collector._search = lambda conn, f, attrs, search_base=None: [entry] # type: ignore
111
+ collector._check_stale_or_nonexpiring_admincount(conn)
112
+ ids = [f.id for f in collector.findings]
113
+ assert "AD-002" in ids
114
+
115
+
116
+ def test_kerberoastable_check():
117
+ collector = ADCollector(server="dc", username="u", password="p", base_dn="DC=corp,DC=local")
118
+ conn = _make_conn()
119
+ entry = LdapEntry(sAMAccountName="svc-sql", servicePrincipalName=["MSSQLSvc/db:1433"], adminCount=1, userAccountControl=512, objectClass=["user"], distinguishedName="CN=svc-sql,DC=corp,DC=local")
120
+ collector._search = lambda conn, f, attrs, search_base=None: [entry] # type: ignore
121
+ collector._check_kerberoastable_accounts(conn)
122
+ ids = [f.id for f in collector.findings]
123
+ assert "AD-003" in ids
124
+ assert any(e.relation == "is_kerberoastable_with_admin_equiv" for e in collector.edges)
125
+
126
+
127
+ def test_asrep_roastable_check():
128
+ collector = ADCollector(server="dc", username="u", password="p", base_dn="DC=corp,DC=local")
129
+ conn = _make_conn()
130
+ entry = LdapEntry(sAMAccountName="legacy", userAccountControl=4194304, adminCount=0, objectClass=["user"], distinguishedName="CN=legacy,DC=corp,DC=local")
131
+ collector._search = lambda conn, f, attrs, search_base=None: [entry] # type: ignore
132
+ collector._check_asrep_roastable_accounts(conn)
133
+ ids = [f.id for f in collector.findings]
134
+ assert "AD-004" in ids
135
+
136
+
137
+ def test_kerberos_delegation_check():
138
+ collector = ADCollector(server="dc", username="u", password="p", base_dn="DC=corp,DC=local")
139
+ conn = _make_conn()
140
+ uac_unconstrained = 0x80000
141
+ entry = LdapEntry(sAMAccountName="web01$", userAccountControl=uac_unconstrained, objectClass=["computer"], distinguishedName="CN=web01,DC=corp,DC=local")
142
+ # Only return for unconstrained filter; others empty
143
+ def fake_search(conn_arg, f, attrs, search_base=None):
144
+ if "524288" in f:
145
+ return [entry]
146
+ return []
147
+ collector._search = fake_search # type: ignore
148
+ collector._check_kerberos_delegation(conn)
149
+ ids = [f.id for f in collector.findings]
150
+ assert "AD-005" in ids
151
+
152
+
153
+ def test_local_admin_sprawl_check():
154
+ collector = ADCollector(server="dc", username="u", password="p", base_dn="DC=corp,DC=local")
155
+ conn = _make_conn()
156
+ collector._direct_da_count = 6
157
+ # operator group nested
158
+ group_entry = LdapEntry(cn="HelpDesk", member=["CN=Domain Admins,CN=Users,DC=corp,DC=local"], distinguishedName="CN=HelpDesk,DC=corp,DC=local")
159
+ collector._search = lambda conn, f, attrs, search_base=None: [group_entry] if "objectClass=group" in f else [] # type: ignore
160
+ collector._check_local_admin_sprawl_proxies(conn)
161
+ ids = [f.id for f in collector.findings]
162
+ assert "AD-006" in ids
163
+
164
+
165
+ def test_password_hygiene_checks():
166
+ collector = ADCollector(server="dc", username="u", password="p", base_dn="DC=corp,DC=local")
167
+ conn = _make_conn()
168
+
169
+ # non-expiring
170
+ e1 = LdapEntry(sAMAccountName="user1", userAccountControl=0x10000, objectClass=["user"], distinguishedName="CN=user1,DC=corp,DC=local")
171
+ # disabled privileged
172
+ e2 = LdapEntry(sAMAccountName="disabledadmin", userAccountControl=0x2, adminCount=1, memberOf=[], objectClass=["user"], distinguishedName="CN=disabledadmin,DC=corp,DC=local")
173
+ # pre-win2k group with Everyone
174
+ e3 = LdapEntry(cn="Pre-Windows 2000 Compatible Access", member=["CN=Everyone,CN=WellKnown Security Principals,DC=corp,DC=local"], distinguishedName="CN=Pre-Windows 2000 Compatible Access,CN=Builtin,DC=corp,DC=local")
175
+
176
+ def fake_search(conn_arg, f, attrs, search_base=None):
177
+ if "65536" in f:
178
+ return [e1]
179
+ if "803:=2" in f or "userAccountControl:1.2.840.113556.1.4.803:=2" in f:
180
+ return [e2]
181
+ if "Pre-Windows" in f or "532-554" in f or "554" in f:
182
+ return [e3]
183
+ return []
184
+
185
+ collector._search = fake_search # type: ignore
186
+ collector._check_password_and_compat_hygiene(conn)
187
+ ids = [f.id for f in collector.findings]
188
+ assert "AD-007A" in ids
189
+ assert "AD-007B" in ids
190
+ assert "AD-007C" in ids
191
+
192
+
193
+ def test_collect_returns_scanbundle():
194
+ with patch("trproof.collectors.ad.Server"), patch("trproof.collectors.ad.Connection") as mock_conn_cls:
195
+ mock_conn = _make_conn([])
196
+ mock_conn_cls.return_value = mock_conn
197
+ collector = ADCollector(server="dc", username="u", password="p", base_dn="DC=corp,DC=local")
198
+ # make all checks no-ops
199
+ for m in ["_check_tier0_admins", "_check_stale_or_nonexpiring_admincount", "_check_kerberoastable_accounts",
200
+ "_check_asrep_roastable_accounts", "_check_kerberos_delegation", "_check_local_admin_sprawl_proxies",
201
+ "_check_password_and_compat_hygiene"]:
202
+ setattr(collector, m, lambda conn: None)
203
+ bundle = collector.collect()
204
+ assert isinstance(bundle, ScanBundle)
@@ -0,0 +1,41 @@
1
+ from __future__ import annotations
2
+
3
+ from click.testing import CliRunner
4
+
5
+ from trproof.cli import main, verify
6
+ from trproof.models import ScanBundle
7
+ from tests.fixtures.mock_environment import get_mock_scan_bundle
8
+
9
+
10
+ def test_trproof_help_exits_zero() -> None:
11
+ result = CliRunner().invoke(main, ["--help"])
12
+ assert result.exit_code == 0
13
+
14
+
15
+ def test_trproof_verify_help_exits_zero() -> None:
16
+ result = CliRunner().invoke(verify, ["--help"])
17
+ assert result.exit_code == 0
18
+
19
+
20
+ def test_scan_with_no_flags_exits_nonzero() -> None:
21
+ result = CliRunner().invoke(main, ["scan"])
22
+ assert result.exit_code != 0
23
+
24
+
25
+ def test_scan_mock_yes_creates_output_files(tmp_path) -> None:
26
+ result = CliRunner().invoke(
27
+ main,
28
+ ["scan", "--mock", "--yes", "-o", str(tmp_path)],
29
+ )
30
+ assert result.exit_code == 0, result.output
31
+ assert "AUTHORIZATION REQUIRED" in result.output
32
+
33
+ files = list(tmp_path.iterdir())
34
+ assert any(path.suffix == ".html" for path in files)
35
+ assert any(path.suffix == ".json" for path in files)
36
+
37
+
38
+ def test_mock_scan_bundle_validates() -> None:
39
+ bundle = get_mock_scan_bundle()
40
+ assert isinstance(bundle, ScanBundle)
41
+ assert ScanBundle.model_validate(bundle.model_dump()) == bundle